コード例 #1
0
        public static T Delegate(string content,
                                 AssemblyCSharpBuilder builder,
                                 Action <AssemblyCSharpBuilder> option = default,
                                 Func <FakeMethodOperator, FakeMethodOperator> methodAction = null,
                                 Func <OopBuilder, OopBuilder> oopAction = null,
                                 params NamespaceConverter[] usings)
        {
#if DEBUG
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            var method    = typeof(T).GetMethod("Invoke");
            var @operator = FakeMethodOperator.UseDomain(builder.Compiler.Domain, option);
            @operator.AssemblyBuilder = builder;
            @operator
            .UseMethod(method)
            .Using(usings)
            .StaticMethodBody(content);
            methodAction?.Invoke(@operator);
            oopAction?.Invoke(@operator.OopHandler);
#if DEBUG
            stopwatch.StopAndShowCategoreInfo("[Operator]", "模板构建耗时", 1);
#endif
            return(@operator.Compile <T>());
        }
コード例 #2
0
        public static T Delegate(string content, DomainBase domain = default, Action <AssemblyCSharpBuilder> option = default, Func <FakeMethodOperator, FakeMethodOperator> methodAction = null, params NamespaceConverter[] usings)
        {
            var method    = typeof(T).GetMethod("Invoke");
            var @operator = FakeMethodOperator.UseDomain(domain, option);

            @operator
            .UseMethod(method)
            .Using(usings)
            .StaticMethodBody(content);
            methodAction?.Invoke(@operator);
            return(@operator.Compile <T>());
        }
コード例 #3
0
        public static T UnsafeDelegate(string content,
                                       AssemblyCSharpBuilder builder,
                                       Action <AssemblyCSharpBuilder> option = default,
                                       Func <FakeMethodOperator, FakeMethodOperator> methodAction = null,
                                       Func <OopBuilder, OopBuilder> oopAction = null,
                                       params NamespaceConverter[] usings)
        {
            var method    = typeof(T).GetMethod("Invoke");
            var @operator = FakeMethodOperator.UseDomain(builder.Compiler.Domain, option);

            @operator.AssemblyBuilder = builder;
            @operator
            .UseMethod(method)
            .Unsafe()
            .Using(usings)
            .StaticMethodBody(content);
            methodAction?.Invoke(@operator);
            oopAction?.Invoke(@operator.OopHandler);
            return(@operator.Compile <T>());
        }