예제 #1
0
        public static void StartScript(ScriptingInterface.IServiceProvider serviceProvider)
        {
            string path = @"TestScript1.cs";
            // Open the file to read from.
            string   readText       = File.ReadAllText(path);
            Assembly compiledScript = CompileCode(readText);

            if (compiledScript != null)
            {
                RunScript(serviceProvider, compiledScript);
            }
        }
예제 #2
0
 static void RunScript(ScriptingInterface.IServiceProvider serviceProvider, Assembly script)
 {
     foreach (Type type in script.GetExportedTypes())
     {
         foreach (Type iface in type.GetInterfaces())
         {
             if (iface == typeof(ScriptingInterface.IScriptType1))
             {
                 ConstructorInfo constructor = type.GetConstructor(System.Type.EmptyTypes);
                 if (constructor != null && constructor.IsPublic)
                 {
                     ScriptingInterface.IScriptType1 scriptObject = constructor.Invoke(null) as ScriptingInterface.IScriptType1;
                     if (scriptObject != null)
                     {
                         //Lets run our script and display its results
                         MessageBox.Show(scriptObject.RunScript(50));
                     }
                 }
             }
         }
     }
 }
예제 #3
0
 public string RunScript(ScriptingInterface.IServiceProvider serviceProvider, int value)
 {
     System.Console.WriteLine("Hello World! This works!");
     serviceProvider.Messenger.SendMessage("Test");
 }