Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace 2ch
- {
- public class Shiet
- {
- public string[] PrintAllT();
- public T Get<T>();
- }
- public class ShietService
- {
- public static Dictionary<Type, Func<object>> DoShit(Shiet shiet)
- {
- var dict = new Dictionary<Type, Func<object>>();
- var method = typeof(Shiet).GetMethod("Get");
- foreach (var t in shiet.PrintAllT())
- {
- //not 'int' or 'Int32', but 'System.Int32, mscorlib'
- var type = Type.GetType(t);
- var generic = method.MakeGenericMethod(type);
- Func<object> func = () => generic.Invoke(shiet, null);
- dict.Add(type, func);
- }
- return dict;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement