Exemplo n.º 1
0
        public bool RunCommand(CommandReceiver runner)
        {
            if (runner.Loaded == false)
            {
                throw new Exception("CommandReceiver not loaded yet");
            }

            SharedData.CurrentProject = runner.CurrentProject;

            Assembly assembly = Assembly.LoadFrom(AssemblyFilename);

            log.DebugFormat("Loading Type {0}.{1}", Namespace, Classname);
            Type generatedObjectType = assembly.GetType(Namespace + "." + Classname);

            if (generatedObjectType == null)
            {
                throw new Exception("Could not find test class");
            }

            log.DebugFormat("Loader State: {0}", runner.CurrentProject.TemplateLoader != null ? "Loaded" : "Not Loaded");

            runner.CurrentProject.LoadTemplate(AssemblyFilename);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(AaprojXml);

            runner.CurrentProject.InitFromDesignerProjectXml(doc);

            log.DebugFormat("Loader State: {0}", runner.CurrentProject.TemplateLoader != null ? "Loaded" : "Not Loaded");

            runner.CurrentProject.FillProviders();

            SetUserOptions(assembly);
            runner.CurrentProject.FillVirtualProperties();

            log.DebugFormat("Loading Function {0}", FunctionName);
            MethodInfo  method = generatedObjectType.GetMethod(FunctionName);
            ThreadStart start
                = delegate
                {
                Thread.Sleep(1000);

                object instance = IsStaticMethod ? null : assembly.CreateInstance(Namespace + "." + Classname);

                string obj = method.Invoke(instance, Arguments.ToArray(runner.CurrentProject.Providers)).ToString();
#line 16707564
                Console.WriteLine(obj);
#line default
                };
            Thread thread = new Thread(start);

            thread.Start();

            return(true);
        }