Beispiel #1
0
        public static void Execute(InvokeOptions invokeOptions, CompilerOptions compilerOptions)
        {
            CompilerResult result = null;
            if (TryCompile(compilerOptions, out result))
                result.CompiledAssembly = LoadAssembly(result.PathToAssembly);

            Invoke(result.CompiledAssembly, invokeOptions);
        }
Beispiel #2
0
        private static void Invoke(Assembly asm, InvokeOptions invokeOptions)
        {
            var type = asm.GetTypes().FirstOrDefault(x => x.FullName == invokeOptions.ClassName);
            var method = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)
                .FirstOrDefault(x => x.Name == invokeOptions.MethodName && x.GetParameters().Count() == 0);

            if (method != null)
            {
                if (invokeOptions.Async)
                {
                    ThreadPool.QueueUserWorkItem(InvokeMethod, method);
                }
                else
                {
                    MethodInvoker.InvokeMethod(method);
                }

            }
            else throw new ArgumentOutOfRangeException("No parameterless method (static or instance) found that matches the provided name.");
        }