예제 #1
0
        public static void Initialize(ModuleBuilder moduleBuilder)
        {
            if (initialized)
            {
                return;
            }

            var actions = new[]
            {
                typeof(Action), typeof(Action <>), typeof(Action <,>), typeof(Action <, ,>), typeof(Action <, , ,>),
                typeof(Action <, , , ,>)
            };

            var funcs = new[]
            {
                typeof(Func <>), typeof(Func <,>), typeof(Func <, ,>), typeof(Func <, , ,>), typeof(Func <, , , ,>),
                typeof(Func <, , , , ,>)
            };

            foreach (var action in actions)
            {
                proxyMap[action] = ProxyBuilder.Build(moduleBuilder, action, false);
            }

            foreach (var func in funcs)
            {
                proxyMap[func] = ProxyBuilder.Build(moduleBuilder, func, true);
            }

            initialized = true;
        }
        internal static Type Build(ModuleBuilder moduleBuilder, Type delegateType, bool @return)
        {
            var builder = new ProxyBuilder(moduleBuilder, delegateType, @return);

            return(builder.typeBuilder.CreateType());
        }