public void StartPythonCompilation(object sender, EventArgs eventArgs) { if (TopComment.Visibility == Visibility.Visible) { TopComment.Visibility = Visibility.Hidden; TopComment.HostNode_PropertyChanged(null, null); } var file = new PythonScriptFile { ScriptContent = scriptingControl.TextEditor.Text }; try { var compiler = new PythonScriptCompiler(); var obj = compiler.CompileSourceAndExecute(file.ScriptContent, InputPorts[0].Data); if (obj != null) { OutputPorts[0].Data = obj; } } catch (Exception e) { TopComment.Text = e.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); } }
public void StartCSharpCompilation(object sender, EventArgs eventArgs) { if (TopComment.Visibility == Visibility.Visible) { TopComment.Visibility = Visibility.Hidden; TopComment.HostNode_PropertyChanged(null, null); } scriptingControl.CurrentFile.ScriptContent = scriptingControl.TextEditor.Text; // Define the Input for the Script if (InputPorts[0].Data != null) { // Define the Input for the Script } try { var mScriptCompiler = new Lazy <CSharpScriptCompiler>(); //Compile and execute current script var result = mScriptCompiler.Value.Compile(scriptingControl.CurrentFile as CSharpScriptFile); if (result.GetType() == typeof(CompilerErrorCollection)) { var compilerErrors = new StringBuilder(); var compilerErrorCollection = result as CompilerErrorCollection; if (compilerErrorCollection == null) { throw new InvalidOperationException( "Unable to compile scripts: " + compilerErrors); } foreach (var actError in compilerErrorCollection) { compilerErrors.Append("" + actError + Environment.NewLine); } TopComment.Text = compilerErrors.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); throw new InvalidOperationException( "Unable to compile scripts: " + compilerErrors); } OutputPorts[0].Data = result; } catch (Exception e) { } }
private void conn_DataChanged(object sender, EventArgs e) { try { if (AutoCheckBox.IsChecked != null && (bool)AutoCheckBox.IsChecked) { Calculate(); } HasError = false; TopComment.Visibility = Visibility.Hidden; } catch (Exception ex) { HasError = true; TopComment.Text = ex.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); PropertyChanged += TopComment.HostNode_PropertyChanged; } }
public void StartCSharpCompilation(object sender, EventArgs eventArgs) { if (TopComment.Visibility == Visibility.Visible) { TopComment.Visibility = Visibility.Hidden; TopComment.HostNode_PropertyChanged(null, null); } scriptingControl.CurrentFile.ScriptContent = scriptingControl.TextEditor.Text; // Define the Input for the Script try { mScriptCompiler = new Lazy <CSharpScriptCompiler>(); //Compile and execute current script var result = mScriptCompiler.Value.Compile(scriptingControl.CurrentFile as CSharpScriptFile); if (result.GetType() == typeof(CompilerErrorCollection)) { var compilerErrors = new StringBuilder(); var compilerErrorCollection = result as CompilerErrorCollection; if (compilerErrorCollection == null) { throw new InvalidOperationException( "Unable to compile scripts: " + compilerErrors); } foreach (var actError in compilerErrorCollection) { compilerErrors.Append("" + actError + Environment.NewLine); } TopComment.Text = compilerErrors.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); throw new InvalidOperationException( "Unable to compile scripts: " + compilerErrors); } var parameter = mScriptCompiler.Value.ScriptMethod.GetParameters(); var counter = 0; foreach (var para in parameter) { if (counter < InputPorts.Count) { if (para.ParameterType.IsGenericType) { InputPorts[counter].MultipleConnectionsAllowed = true; InputPorts[counter].DataType = para.ParameterType.GetGenericArguments()[0]; } else { InputPorts[counter].DataType = para.ParameterType; } InputPorts[counter].Name = para.Name; } else { if (para.ParameterType.IsGenericType) { AddInputPortToNode(para.Name, para.ParameterType.GetGenericArguments()[0], true); } else { AddInputPortToNode(para.Name, para.ParameterType); } } counter++; } while (counter < InputPorts.Count()) { RemoveInputPortFromNode(InputPorts.Last()); } Calculate(); TopComment.Text = ""; TopComment.Visibility = Visibility.Collapsed; } catch (Exception e) { TopComment.Text = e.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); Console.WriteLine(e.Message); } }