public static void executeInAppDomain(string appDomainName, string scriptToExecute)
        {
            O2Thread.mtaThread(
                () => {
                var o2AppDomain = new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);
                try
                {
                    o2AppDomain.load("O2_XRules_Database");
                    o2AppDomain.load("O2_Kernel");
                    o2AppDomain.load("O2_DotNetWrappers");

                    var o2Proxy = (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");

                    o2Proxy.InvokeInStaThread = true;
                    o2Proxy.staticInvocation("O2_External_SharpDevelop", "FastCompiler_ExtensionMethods", "executeSourceCode", new object[] { scriptToExecute });
                }
                catch (Exception ex)
                {
                    ex.log("inside new AppDomain");
                }

                PublicDI.log.showMessageBox("Click OK to close the '{0}' AppDomain (and close all open windows)".format(appDomainName));
                o2AppDomain.unLoadAppDomain();
            });
        }
        public static string executeEngineOnSeparateAppDomain(string sourceFolder, string resultsFolder, string methodFilter, bool useCachedData, List <string> references, int numberOfItemsToProcess)
        {
            //var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
            var script = "MethodMappings_Engine.cs".local();

            "Creating new AppDomain".info();
            var appDomainName = 4.randomString();
            var o2AppDomain   = new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);

            o2AppDomain.load("O2_XRules_Database");
            o2AppDomain.load("O2_Kernel");
            o2AppDomain.load("O2_DotNetWrappers");
            var o2Proxy    = (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
            var parameters = new object[]
            {
                sourceFolder,
                resultsFolder,
                methodFilter,
                useCachedData,
                references,
                numberOfItemsToProcess
            };

            var result = (string)o2Proxy.staticInvocation("O2_External_SharpDevelop", "FastCompiler_ExtensionMethods", "executeFirstMethod", new object[] { script, parameters });

            o2AppDomain.unLoadAppDomain();
            "AppDomain execution completed, Runing GCCollect".info();
            PublicDI.config.gcCollect();
            "GCCollect completed, returning result data: {0}".info(result);
            return(result);
        }
Esempio n. 3
0
        public static string codeStreams_CreateInAppDomain(this Saved_MethodStream savedMethodStream)
        {
            //var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
            var script = "Saved_MethodStream.cs".local();

            "Creating new AppDomain".info();
            var appDomainName = 4.randomString();
            var o2AppDomain   = new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);

            o2AppDomain.load("O2_XRules_Database");
            o2AppDomain.load("O2_Kernel");
            o2AppDomain.load("O2_DotNetWrappers");
            var o2Proxy    = (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
            var parameters = new object[]
            {
                savedMethodStream.Serialized_Saved_MethodStream_FileCache
//						sourceFolder,
//						resultsFolder,
//						methodFilter,
//						useCachedData,
//						references,
//						numberOfItemsToProcess
            };

            var result = (string)o2Proxy.staticInvocation("O2_External_SharpDevelop", "FastCompiler_ExtensionMethods", "executeFirstMethod", new object[] { script, parameters });

            "Result: {0}".info(result);
            o2AppDomain.sleep(2000);
            o2AppDomain.unLoadAppDomain();
            "AppDomain execution completed, Runing GCCollect".info();
            PublicDI.config.gcCollect();
            "GCCollect completed, returning result data: {0}".info(result);
            return(result);
        }
		public static string executeScriptInSeparateAppDomain(this string scriptToExecute, bool showLogViewer, bool openScriptGui)
		{
			var appDomainName = 12.randomLetters();
			var o2AppDomain =  new O2AppDomainFactory(appDomainName);
			o2AppDomain.load("O2_XRules_Database"); 	
			o2AppDomain.load("O2_Kernel");
			o2AppDomain.load("O2_DotNetWrappers");
			
			var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
			if (o2Proxy.isNull())
			{
				"in executeScriptInSeparateAppDomain, could not create O2Proxy object".error();
				return null;
			}
			o2Proxy.InvokeInStaThread = true;
			if (showLogViewer)
				o2Proxy.executeScript( "O2Gui.open<Panel>(\"Util - LogViewer\", 400,140).add_LogViewer();");
			if (openScriptGui)
				o2Proxy.executeScript("O2Gui.open<Panel>(\"Script editor\", 700, 300)".line() + 
 	  								  "		.add_Script(false)".line() + 
									  " 	.onCompileExecuteOnce()".line() + 
									  " 	.Code = \"hello\";".line() + 
									  "//O2File:Scripts_ExtensionMethods.cs");
			o2Proxy.executeScript(scriptToExecute);
			
			//PublicDI.log.showMessageBox
			MessageBox.Show("Click OK to close the '{0}' AppDomain (and close all open windows)".format(appDomainName));
			o2AppDomain.unLoadAppDomain();
			return scriptToExecute;
		}
Esempio n. 5
0
        public static string executeEngineOnSeparateAppDomain(string sourceFolder, string resultsFolder, string methodFilter, bool useCachedData, List<string> references, int numberOfItemsToProcess)
        {
        	//var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
        	var script = "MethodMappings_Engine.cs".local();
        	"Creating new AppDomain".info();
 			var appDomainName = 4.randomString();
			var o2AppDomain =  new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);			
			o2AppDomain.load("O2_XRules_Database"); 	
			o2AppDomain.load("O2_Kernel");
			o2AppDomain.load("O2_DotNetWrappers");
			var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
			var parameters = new object[]
					{ 
						sourceFolder,
						resultsFolder,
						methodFilter,
						useCachedData,
						references,
						numberOfItemsToProcess                        
					};					

    	    var result =(string)o2Proxy.staticInvocation("O2_External_SharpDevelop","FastCompiler_ExtensionMethods","executeFirstMethod",new object[]{script, parameters});	
    	    o2AppDomain.unLoadAppDomain(); 
    	    "AppDomain execution completed, Runing GCCollect".info();
    	    PublicDI.config.gcCollect();
        	"GCCollect completed, returning result data: {0}".info(result);
        	return result;
        }
		public static string codeStreams_CreateInAppDomain(this Saved_MethodStream savedMethodStream)
	    {
	    	//var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
	    	var script = "Saved_MethodStream.cs".local();
	    	"Creating new AppDomain".info();
			var appDomainName = 4.randomString();
			var o2AppDomain =  new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);			
			o2AppDomain.load("FluentSharp.CoreLib.dll"); 						
			var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
			var parameters = new object[]
					{ 
						savedMethodStream.Serialized_Saved_MethodStream_FileCache
//						sourceFolder,
//						resultsFolder,
//						methodFilter,
//						useCachedData,
//						references,
//						numberOfItemsToProcess                        
					};					
	
		    var result =(string)o2Proxy.staticInvocation("O2_External_SharpDevelop","FastCompiler_ExtensionMethods","executeFirstMethod",new object[]{script, parameters});	
		    "Result: {0}".info(result);
		    o2AppDomain.sleep(2000);
		    o2AppDomain.unLoadAppDomain(); 
		    "AppDomain execution completed, Runing GCCollect".info();
		    PublicDI.config.gcCollect();
	    	"GCCollect completed, returning result data: {0}".info(result);
	    	return result;
	    }				
		public static void executeInAppDomain(string appDomainName,string scriptToExecute)
		{
				O2Thread.mtaThread(
					()=>{
							var o2AppDomain =  new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);
							try
							{
								o2AppDomain.load("O2_XRules_Database"); 	
								o2AppDomain.load("O2_Kernel");
								o2AppDomain.load("O2_DotNetWrappers");
							
								var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
								 
								o2Proxy.InvokeInStaThread = true;
								o2Proxy.staticInvocation("O2_External_SharpDevelop","FastCompiler_ExtensionMethods","executeSourceCode",new object[]{ scriptToExecute });								
							}
							catch(Exception ex)
							{
								ex.log("inside new AppDomain"); 
							}
							
							DebugMsg.showMessageBox("Click OK to close the '{0}' AppDomain (and close all open windows)".format(appDomainName));							
							o2AppDomain.unLoadAppDomain();
						});
		  }