本文整理汇总了C#中Behaviac.Design.Nodes.Node.AddChildNotModified方法的典型用法代码示例。如果您正苦于以下问题:C# Node.AddChildNotModified方法的具体用法?C# Node.AddChildNotModified怎么用?C# Node.AddChildNotModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behaviac.Design.Nodes.Node
的用法示例。
在下文中一共展示了Node.AddChildNotModified方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNodeAndAdd
/// <summary>
/// Loads a node from a given XML node.
/// </summary>
/// <param name="getBehaviorNode">The callback used to return the behavior.</param>
/// <param name="xml">The XML node we want to create the node from.</param>
/// <param name="parent">The parent this node will be added to.</param>
/// <param name="connector">The connector used to add this node to the parent.</param>
/// <returns>Returns the created node.</returns>
protected Node CreateNodeAndAdd(List<Nodes.Node.ErrorCheck> result, GetBehaviorNode getBehaviorNode, XmlNode xml, Node parent, Node.Connector connector)
{
try {
// get the type of the node and create it
string clss = GetAttribute(xml, "Class");
Type t = Plugin.GetType(clss);
if (t == null) {
string msg = string.Format(Resources.ExceptionUnknownNodeType, clss);
string msgError = string.Format("{0}:\n{1}", this.Filename, msg);
//throw new Exception(msg);
MessageBox.Show(msgError, Resources.LoadError, MessageBoxButtons.OK);
parent.Behavior.TriggerWasModified(parent);
return null;
}
Node node = Nodes.Node.Create(t);
if (parent == null) {
//if this._version == 0, it means there is no Version attribute in the file
node.Behavior.Version = this._version;
}
// update the loaded behaviour member
if (node is BehaviorNode)
{ ((BehaviorNode)node).FileManager = this; }
// add the node to the parent
if (parent != null) {
if (connector != null)
{ parent.AddChildNotModified(connector, node); }
else
{ parent.AddFSMNode(node); }
}
int version = 0;
if (node.Behavior != null) {
version = node.Behavior.Version;
} else {
Debug.Check(true);
}
SetEnterExitSlot(result, xml, node, version);
// initialise the properties
IList<DesignerPropertyInfo> properties = node.GetDesignerProperties();
foreach(DesignerPropertyInfo property in properties) {
if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) {
InitProperty(result, xml, node, property);
}
}
// return the created behaviour node
if (node is BehaviorNode)
{ getBehaviorNode((BehaviorNode)node); }
// maintain compatibility with version 1
if (node is ReferencedBehaviorNode) {
ReferencedBehaviorNode refbehavior = (ReferencedBehaviorNode)node;
if (refbehavior.ReferenceFilename == null)
{ refbehavior.ReferenceFilename = GetAttribute(xml, "Reference"); }
}
// update node with properties
node.OnPropertyValueChanged(false);
// load child objects
foreach(XmlNode xnode in xml.ChildNodes) {
if (xnode.NodeType == XmlNodeType.Element) {
switch (xnode.Name) {
// load parameters
case ("Parameters"):
if (node is Behavior || node is ReferencedBehavior) {
LoadParameters(result, xnode, node, node.LocalVars);
node.Behavior.PostLoadPars();
}
break;
case ("DescriptorRefs"):
#if QUERY_EANBLED
LoadDescriptorRefs(result, xnode, node.Behavior as Behavior);
#endif//#if QUERY_EANBLED
break;
//.........这里部分代码省略.........
示例2: CreateNodeAndAdd
/// <summary>
/// Loads a node from a given XML node.
/// </summary>
/// <param name="getBehaviorNode">The callback used to return the behavior.</param>
/// <param name="xml">The XML node we want to create the node from.</param>
/// <param name="parent">The parent this node will be added to.</param>
/// <param name="connector">The connector used to add this node to the parent.</param>
/// <returns>Returns the created node.</returns>
protected Node CreateNodeAndAdd(GetBehaviorNode getBehaviorNode, XmlNode xml, Node parent, Node.Connector connector)
{
try
{
// get the type of the node and create it
string clss = GetAttribute(xml, "Class");
Type t = Plugin.GetType(clss);
if (t == null)
{
string msg = string.Format(Resources.ExceptionUnknownNodeType, clss);
string msgError = string.Format("{0}:\n{1}", this.Filename, msg);
//throw new Exception(msg);
MessageBox.Show(msgError, Resources.LoadError, MessageBoxButtons.OK);
parent.Behavior.IsModified = true;
return null;
}
Node node = Nodes.Node.Create(t);
// update the loaded behaviour member
if (node is BehaviorNode)
((BehaviorNode)node).FileManager = this;
// add the node to the parent
if (parent != null)
{
Debug.Check(connector != null);
parent.AddChildNotModified(connector, node);
}
// initialise the properties
IList<DesignerPropertyInfo> properties = node.GetDesignerProperties();
foreach (DesignerPropertyInfo property in properties)
{
if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
{
InitProperty(xml, node, property);
node.PostPropertyInit(property);
}
}
// return the created behaviour node
if (node is BehaviorNode)
getBehaviorNode((BehaviorNode)node);
// maintain compatibility with version 1
if (node is ReferencedBehaviorNode)
{
ReferencedBehaviorNode refbehavior = (ReferencedBehaviorNode)node;
if (refbehavior.ReferenceFilename == null)
refbehavior.ReferenceFilename = GetAttribute(xml, "Reference");
}
// update node with properties
node.OnPropertyValueChanged(false);
// load child objects
foreach (XmlNode xnode in xml.ChildNodes)
{
if (xnode.NodeType == XmlNodeType.Element)
{
switch (xnode.Name.ToLowerInvariant())
{
// load parameters
case ("parameters"):
LoadParameters(xnode, node, node.Pars);
break;
case ("descriptorrefs"):
#if QUERY_EANBLED
LoadDescriptorRefs(xnode, node.Behavior as Behavior);
#endif//#if QUERY_EANBLED
break;
// maintain compatibility with version 1
case ("node"):
CreateNodeAndAdd(getBehaviorNode, xnode, node, node.GetConnector("GenericChildren"));
break;
// maintain compatibility with version 2.1
case ("event"):
case ("attachment"):
{
Attachments.Attachment a = CreateAttachment(node, xnode);
if (a != null)
//.........这里部分代码省略.........