private void ApplyScript_Click(ScriptDocument script) { try { ApplyStringConverter(ScriptUtils.GetInstance <IStringConverter>(script.Container) ?? new ScriptStringConverter(script)); } catch (Exception ex) { MessageBox.Show(this, ex.Message, CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <returns></returns> protected override BasePipelineNode OnCreate(Logger logger, NetGraph graph, Dictionary <string, object> stateDictionary) { BasePipelineNode node = null; if (Container != null) { try { if (String.IsNullOrWhiteSpace(ClassName)) { throw new ArgumentException(String.Format(CANAPE.Scripting.Properties.Resources.DynamicNodeFactory_MustSpecifyClassName, Label)); } // Determine what type of object we create, if it is an BasePipelineNode then return as is, // if it is a parser then create the parsing pipeline node to contain it object o = ScriptUtils.GetInstance(Container, ClassName); if (o is BasePipelineNode) { node = o as BasePipelineNode; if (State != null) { IPersistNode persist = node as IPersistNode; if (persist != null) { persist.SetState(State, logger); } } } else if (o is IDataStreamParser) { // If we are selecting the whole packet, then we convert a binary stream if (SelectionPath == "/") { DynamicBinaryStreamPipelineNode stmNode = new DynamicBinaryStreamPipelineNode(); stmNode.Container = DynamicScriptContainer.Create(Container, ClassName); stmNode.State = State; node = stmNode; } else { DynamicStreamPipelineNode dynNode = new DynamicStreamPipelineNode(); dynNode.Container = DynamicScriptContainer.Create(Container, ClassName); dynNode.State = State; node = dynNode; } } else if (o is IDataArrayParser) { DynamicArrayPipelineNode dynNode = new DynamicArrayPipelineNode(); dynNode.Container = DynamicScriptContainer.Create(Container, ClassName); dynNode.State = State; node = dynNode; } else if (o is IDataStringParser) { DynamicStringPipelineNode dynNode = new DynamicStringPipelineNode(); dynNode.Container = DynamicScriptContainer.Create(Container, ClassName); dynNode.State = State; node = dynNode; } else if (o == null) { throw new InvalidOperationException(String.Format(CANAPE.Scripting.Properties.Resources.DynamicNodeFactory_CannotCreateType, ClassName, Label)); } else { throw new InvalidOperationException(String.Format(CANAPE.Scripting.Properties.Resources.DynamicNodeFactory_InvalidNodeType, o.GetType().Name, Label)); } node.Enabled = Enabled; } catch (EndOfStreamException) { // End of stream } catch (ThreadAbortException) { } } else { throw new ArgumentException(String.Format(CANAPE.Scripting.Properties.Resources.DynamicNodeFactory_NoScriptSpecified, Label)); } return(node); }