C# Class Dynamo.Graph.Nodes.CodeBlockNodeModel

Inheritance: NodeModel
显示文件 Open project: DynamoDS/Dynamo Class Usage Examples

Private Properties

Property Type Description
BuildAst IEnumerable
CreateInputOutputPorts void
GetAstIdentifierForOutputIndexInternal ProtoCore.AST.AssociativeAST.IdentifierNode
GetDefinedVariableNames List
GetInportIndex int
GetOutportIndex int
GetStatementForOutput Statement
LoadAndCreateConnectors void
LocalizeIdentifier string
ProcessCode void
ProcessCodeDirect void
ProcessError void
SaveAndDeleteConnectors void
SetInputPorts void
SetOutputPorts void
SetPreviewVariable void
ShouldBeRenamed bool

Public Methods

Method Description
CodeBlockNodeModel ( LibraryServices libraryServices ) : System

Initilizes a new instance of the CodeBlockNodeModel class

CodeBlockNodeModel ( string userCode, System.Guid guid, double xPos, double yPos, LibraryServices libraryServices, ProtoCore.Namespace.ElementResolver resolver ) : System

Initilizes a new instance of the CodeBlockNodeModel class

CodeBlockNodeModel ( string code, double x, double y, LibraryServices libraryServices, ProtoCore.Namespace.ElementResolver resolver ) : System

Initilizes a new instance of the CodeBlockNodeModel class

GetAstIdentifierForOutputIndex ( int outputIndex ) : ProtoCore.AST.AssociativeAST.IdentifierNode

Fetches the ProtoAST Identifier for a given output index.

GetRawAstIdentifierForOutputIndex ( int portIndex ) : ProtoCore.AST.AssociativeAST.IdentifierNode

Fetches the raw ProtoAST Identifier for a given index.

GetTypeHintForOutput ( int index ) : ProtoCore.Type

Returns possible type of the output at specified output port.

SetCodeContent ( string newCode, ProtoCore.Namespace.ElementResolver workspaceElementResolver ) : void

Sets string content of CodeBlock node.

Protected Methods

Method Description
DeserializeCore ( XmlElement nodeElement, SaveContext context ) : void
SerializeCore ( XmlElement element, SaveContext context ) : void
SetNodeStateBasedOnConnectionAndDefaults ( ) : void

If a CBN is in Error state, it will have no code but will have output ports from the last successful compilation if any. In this case it should continue to be in Error state.

UpdateValueCore ( UpdateValueParams updateValueParams ) : bool

Private Methods

Method Description
BuildAst ( List inputAstNodes, CompilationContext context ) : IEnumerable
CreateInputOutputPorts ( ) : void

Creates the inport and outport data based on the statements generated from the user code.

GetAstIdentifierForOutputIndexInternal ( int portIndex, bool forRawName ) : ProtoCore.AST.AssociativeAST.IdentifierNode

For code block nodes, each output identifier of an output port is mapped. For an example, "p = 1" would have its internal identifier renamed to "pXXXX", where "XXXX" is the GUID of the code block node. This mapping is done to ensure the uniqueness of the output variable name.

GetDefinedVariableNames ( ) : List

Returns the names of all the variables defined in this code block.

GetInportIndex ( CodeBlockNodeModel cbn, string variableName ) : int

Returns the index of the port corresponding to the variable name given

GetOutportIndex ( string variableName ) : int

Returns the corresponding output port index for a given defined variable

GetStatementForOutput ( int portIndex ) : Statement
LoadAndCreateConnectors ( OrderedDictionary inportConnections, OrderedDictionary outportConnections ) : void

Now that the portData has been set for the new ports, we recreate the connections we so mercilessly destroyed, restoring peace and balance to the world once again.

LocalizeIdentifier ( string identifierName ) : string
ProcessCode ( string &errorMessage, string &warningMessage, ProtoCore.Namespace.ElementResolver workspaceElementResolver = null ) : void
ProcessCodeDirect ( ) : void
ProcessError ( ) : void

It removes all the in ports and out ports so that the user knows there is an error.

SaveAndDeleteConnectors ( IDictionary inportConnections, IDictionary outportConnections ) : void

Deletes all the connections and saves their data (the start and end port) so that they can be recreated if needed.

SetInputPorts ( ) : void
SetOutputPorts ( ) : void
SetPreviewVariable ( IEnumerable parsedNodes ) : void
ShouldBeRenamed ( string ident ) : bool

Method Details

CodeBlockNodeModel() public method

Initilizes a new instance of the CodeBlockNodeModel class
public CodeBlockNodeModel ( LibraryServices libraryServices ) : System
libraryServices LibraryServices object to manage /// builtin libraries as well as imported libraries
return System

CodeBlockNodeModel() public method

Initilizes a new instance of the CodeBlockNodeModel class
public CodeBlockNodeModel ( string userCode, System.Guid guid, double xPos, double yPos, LibraryServices libraryServices, ProtoCore.Namespace.ElementResolver resolver ) : System
userCode string Code block content
guid System.Guid Identifier of the code block
xPos double X coordinate of the code block
yPos double Y coordinate of the code block
libraryServices LibraryServices object to manage /// builtin libraries as well as imported libraries
resolver ProtoCore.Namespace.ElementResolver Responsible for resolving /// a partial class name to its fully resolved name
return System

CodeBlockNodeModel() public method

Initilizes a new instance of the CodeBlockNodeModel class
public CodeBlockNodeModel ( string code, double x, double y, LibraryServices libraryServices, ProtoCore.Namespace.ElementResolver resolver ) : System
code string Code block content
x double X coordinate of the code block
y double Y coordinate of the code block
libraryServices LibraryServices object to manage /// builtin libraries as well as imported libraries
resolver ProtoCore.Namespace.ElementResolver Responsible for resolving /// a partial class name to its fully resolved name
return System

DeserializeCore() protected method

protected DeserializeCore ( XmlElement nodeElement, SaveContext context ) : void
nodeElement System.Xml.XmlElement
context SaveContext
return void

GetAstIdentifierForOutputIndex() public method

Fetches the ProtoAST Identifier for a given output index.
public GetAstIdentifierForOutputIndex ( int outputIndex ) : ProtoCore.AST.AssociativeAST.IdentifierNode
outputIndex int Index of the output port.
return ProtoCore.AST.AssociativeAST.IdentifierNode

GetRawAstIdentifierForOutputIndex() public method

Fetches the raw ProtoAST Identifier for a given index.
public GetRawAstIdentifierForOutputIndex ( int portIndex ) : ProtoCore.AST.AssociativeAST.IdentifierNode
portIndex int Index of the port.
return ProtoCore.AST.AssociativeAST.IdentifierNode

GetTypeHintForOutput() public method

Returns possible type of the output at specified output port.
public GetTypeHintForOutput ( int index ) : ProtoCore.Type
index int Index of the port
return ProtoCore.Type

SerializeCore() protected method

protected SerializeCore ( XmlElement element, SaveContext context ) : void
element System.Xml.XmlElement
context SaveContext
return void

SetCodeContent() public method

Sets string content of CodeBlock node.
public SetCodeContent ( string newCode, ProtoCore.Namespace.ElementResolver workspaceElementResolver ) : void
newCode string New content of the code block
workspaceElementResolver ProtoCore.Namespace.ElementResolver object
return void

SetNodeStateBasedOnConnectionAndDefaults() protected method

If a CBN is in Error state, it will have no code but will have output ports from the last successful compilation if any. In this case it should continue to be in Error state.
protected SetNodeStateBasedOnConnectionAndDefaults ( ) : void
return void

UpdateValueCore() protected method

protected UpdateValueCore ( UpdateValueParams updateValueParams ) : bool
updateValueParams UpdateValueParams
return bool