Пример #1
0
        public static Panel packageCurrentScriptAsStandAloneExe(this ascx_Simple_Script_Editor simpleScriptEditor)
        {
            if ("FluentSharp.MsBuild".assembly().isNull())
            {
                "[packageCurrentScriptAsStandAloneExe] could not invoke because FluentSharp.MsBuild assembly is not avaiable".error();
                return(null);
            }
            var h2File = simpleScriptEditor.currentSourceCodeFilePath();

            if (h2File.valid())
            {
                simpleScriptEditor.saveScript();
            }
            else
            {
                h2File = simpleScriptEditor.Code.h2_File();
            }


            var assembly = "FluentSharp.MsBuild".assembly();
            var type     = assembly.type("Package_O2_Script_into_separate_Folder");

            var topPanel = type.invokeStatic("Main", /*startHidden*/ false, /*targetScript*/ h2File);

            return(topPanel.cast <Panel>());


            //var packageScript = (Action<string>)"Util - Package O2 Script into separate Folder.h2".executeFirstMethod();
            //packageScript(h2File);
        }
Пример #2
0
        public static ascx_Simple_Script_Editor waitFor_ExecutionComplete(this ascx_Simple_Script_Editor simpleScriptEditor, int maxWaitSeconds = 20)
        {
            var executionThread = simpleScriptEditor.ExecutionThread;

            if (executionThread.isNull())                                   // if the execution thread is not alive
            {
                for (int i = 0; i < maxWaitSeconds; i++)
                {
                    500.sleep();                                            // wait 500ms for a maximum of maxWaitSeconds times (default is 10sec)
                    executionThread = simpleScriptEditor.ExecutionThread;   // try again
                    if (executionThread.notNull())
                    {
                        break;
                    }
                }
            }

            if (executionThread.notNull() && executionThread.IsAlive)
            {
                if (executionThread.Join(20 * 1000).isFalse())
                {
                    "[ascx_Simple_Script_Editor][waitFor_ExecutionComplete] the execution lasted more than {0} seconds".error(maxWaitSeconds);
                }
            }
            return(simpleScriptEditor);
        }
Пример #3
0
 public static ascx_Simple_Script_Editor csharpCompiler(this ascx_Simple_Script_Editor simpleScriptEditor, CSharp_FastCompiler value)
 {
     if (simpleScriptEditor.notNull())
     {
         simpleScriptEditor.CSharpCompiler = value;
     }
     return(simpleScriptEditor);
 }
 public static ascx_Simple_Script_Editor set_Command(this ascx_Simple_Script_Editor scriptEditor, string commandText)
 {
     return((ascx_Simple_Script_Editor)scriptEditor.invokeOnThread(
                () =>
     {
         scriptEditor.commandsToExecute.set_Text(commandText);
         return scriptEditor;
     }));
 }
Пример #5
0
 public static ascx_Simple_Script_Editor set_Command(this ascx_Simple_Script_Editor scriptEditor, string commandText)
 {
     return((ascx_Simple_Script_Editor)scriptEditor.invokeOnThread(
                () =>
     {
         scriptEditor.Code = commandText;
         return scriptEditor;
     }));
 }
Пример #6
0
 public static T executionResult <T>(this ascx_Simple_Script_Editor simpleScriptEditor)
 {
     if (simpleScriptEditor.notNull() && simpleScriptEditor.LastExecutionResult.notNull())
     {
         if (simpleScriptEditor.LastExecutionResult is T)
         {
             return((T)simpleScriptEditor.LastExecutionResult);
         }
     }
     return(default(T));
 }
Пример #7
0
 public static T invocationParameter <T>(this ascx_Simple_Script_Editor simpleScriptEditor)
 {
     foreach (var invocationParameter in simpleScriptEditor.invocationParameters())
     {
         if (invocationParameter.Value is T)
         {
             return((T)invocationParameter.Value);
         }
     }
     return(default(T));
 }
 public static ascx_Simple_Script_Editor add_Script(this Control hostControl, bool codeCompleteSupport)
 {
     return((ascx_Simple_Script_Editor)hostControl.invokeOnThread(
                () =>
     {
         var scriptControl = new ascx_Simple_Script_Editor(codeCompleteSupport);
         scriptControl.fill();
         hostControl.add(scriptControl);
         return scriptControl;
     }));
 }
 public static ascx_Simple_Script_Editor onCompileExecuteOnce(this ascx_Simple_Script_Editor scriptEditor)
 {
     return((ascx_Simple_Script_Editor)scriptEditor.invokeOnThread(
                () =>
     {
         scriptEditor.onCompilationOk =
             () =>
         {
             scriptEditor.execute();
             scriptEditor.onCompilationOk = null;
         };
         return scriptEditor;
     }));
 }
        public static ascx_Simple_Script_Editor execute(this ascx_Simple_Script_Editor scriptEditor, params string[] codesToExecute)
        {
            var codeToExecute = "";

            foreach (var code in codesToExecute)
            {
                codeToExecute += code.line();
            }
            return((ascx_Simple_Script_Editor)scriptEditor.invokeOnThread(
                       () =>
            {
                scriptEditor.commandsToExecute.set_Text(codeToExecute);
                scriptEditor.onCompileExecuteOnce();
                return scriptEditor;
            }));
        }
 public static ascx_Simple_Script_Editor executeOnCompile(this ascx_Simple_Script_Editor simpleEditor)
 {
     simpleEditor.ExecuteOnCompile = true;
     return(simpleEditor);
 }
Пример #12
0
 public void SetUp()
 {
     TestValue  = "a test Value";
     CodeEditor = TestValue.script_Me("testValue");
 }
Пример #13
0
 public static Dictionary <string, object> invocationParameters(this ascx_Simple_Script_Editor simpleScriptEditor)
 {
     return(simpleScriptEditor.notNull() ? simpleScriptEditor.InvocationParameters : null);
 }
Пример #14
0
        //the one below seems to aggresive and not optiomal

        /*public static ascx_Simple_Script_Editor wait_For_OnExecute_Once(this ascx_Simple_Script_Editor simpleScriptEditor)
         * {
         *  var previousOnExecute = simpleScriptEditor.onExecute;
         *  var sync = false.autoResetEvent();
         *  simpleScriptEditor.onExecute = result =>
         *      {
         *          sync.set();
         *      };
         *  sync.waitOne();
         *  simpleScriptEditor.onExecute = previousOnExecute;
         *  return simpleScriptEditor;
         * }*/
        public static object executionResult(this ascx_Simple_Script_Editor simpleScriptEditor)
        {
            return(simpleScriptEditor.executionResult <object>());
        }
Пример #15
0
 public static ascx_Simple_Script_Editor code_Insert(this ascx_Simple_Script_Editor scriptEditor, string textToInsert)
 {
     scriptEditor.Code = textToInsert.line() + scriptEditor.Code;
     return(scriptEditor);
 }
Пример #16
0
 public static ascx_Simple_Script_Editor set_Code(this ascx_Simple_Script_Editor scriptEditor, string code)
 {
     return(scriptEditor.set_Command(code));
 }
Пример #17
0
 public static ascx_Simple_Script_Editor add_InvocationParameter(this ascx_Simple_Script_Editor scriptEditor, string parameterName, object parameterObject)
 {
     scriptEditor.InvocationParameters.add(parameterName, parameterObject);
     return(scriptEditor);
 }
Пример #18
0
 public static ascx_Simple_Script_Editor code_Append(this ascx_Simple_Script_Editor scriptEditor, string textToInsert)
 {
     scriptEditor.Code = scriptEditor.Code.line() + textToInsert;
     return(scriptEditor);
 }
Пример #19
0
 public static CSharp_FastCompiler csharpCompiler(this ascx_Simple_Script_Editor simpleScriptEditor)
 {
     return(simpleScriptEditor.notNull() ? simpleScriptEditor.CSharpCompiler : null);
 }
Пример #20
0
 public static ascx_Simple_Script_Editor execute_WaitFor_ExecutionComplete(this ascx_Simple_Script_Editor simpleScriptEditor, int maxWaitSeconds = 20)
 {
     simpleScriptEditor.execute();
     return(simpleScriptEditor.waitFor_ExecutionComplete(maxWaitSeconds));
 }
Пример #21
0
 public static ascx_Simple_Script_Editor makeInvocationParametersTypeGeneric(this ascx_Simple_Script_Editor simpleEditor)
 {
     simpleEditor.csharpCompiler.ResolveInvocationParametersType = false;
     return(simpleEditor);
 }
Пример #22
0
 public static ascx_Simple_Script_Editor compile_WaitFor_CompilationComplete(this ascx_Simple_Script_Editor simpleScriptEditor)
 {
     simpleScriptEditor.compile();
     simpleScriptEditor.csharpCompiler().waitForCompilationComplete();
     return(simpleScriptEditor);
 }
Пример #23
0
 public static ascx_Simple_Script_Editor append_Code(this ascx_Simple_Script_Editor scriptEditor, string textToInsert)
 {
     return(scriptEditor.code_Append(textToInsert));
 }