protected override void LoadNode(XmlNode nodeElement) { foreach (XmlNode subNode in nodeElement.ChildNodes) { if (subNode.Name.Equals("Name")) { NickName = subNode.Attributes[0].Value; } } foreach (XmlNode subNode in nodeElement.ChildNodes) { if (subNode.Name.Equals("ID")) { Symbol = subNode.Attributes[0].Value; Guid funcId; if (!VerifySymbol(out funcId)) { LoadProxyCustomNode(funcId); return; } } } foreach (XmlNode subNode in nodeElement.ChildNodes) { if (subNode.Name.Equals("Outputs")) { int i = 0; foreach (XmlNode outputNode in subNode.ChildNodes) { var data = new PortData( outputNode.Attributes[0].Value, "Output #" + (i + 1), typeof(object)); if (OutPortData.Count > i) { OutPortData[i] = data; } else { OutPortData.Add(data); } i++; } } else if (subNode.Name.Equals("Inputs")) { int i = 0; foreach (XmlNode inputNode in subNode.ChildNodes) { var data = new PortData( inputNode.Attributes[0].Value, "Input #" + (i + 1), typeof(object)); if (InPortData.Count > i) { InPortData[i] = data; } else { InPortData.Add(data); } i++; } } #region Legacy output support else if (subNode.Name.Equals("Output")) { var data = new PortData( subNode.Attributes[0].Value, "function output", typeof(object)); if (OutPortData.Any()) { OutPortData[0] = data; } else { OutPortData.Add(data); } } #endregion } RegisterAllPorts(); //argument lacing on functions should be set to disabled //by default in the constructor, but for any workflow saved //before this was the case, we need to ensure it here. ArgumentLacing = LacingStrategy.Disabled; // we've found a custom node, we need to attempt to load its guid. // if it doesn't exist (i.e. its a legacy node), we need to assign it one // deterministically Guid funId; try { funId = Guid.Parse(Symbol); } catch (FormatException) { funId = GuidUtility.Create( GuidUtility.UrlNamespace, nodeElement.Attributes["nickname"].Value); Symbol = funId.ToString(); } Definition = dynSettings.Controller.CustomNodeManager.GetFunctionDefinition(funId); }
protected override void DeserializeCore(XmlElement nodeElement, SaveContext context) { List <XmlNode> childNodes = nodeElement.ChildNodes.Cast <XmlNode>().ToList(); if (!Controller.IsInSyncWithNode(this)) { Controller.SyncNodeWithDefinition(this); OnNodeModified(); } else if (Controller.Definition == null || Controller.Definition.IsProxy) { foreach (XmlNode subNode in childNodes) { if (subNode.Name.Equals("Outputs")) { var data = subNode.ChildNodes.Cast <XmlNode>() .Select( (outputNode, i) => new { data = new PortData(outputNode.Attributes[0].Value, Properties.Resources.ToolTipOutput + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (OutPortData.Count > dataAndIdx.idx) { OutPortData[dataAndIdx.idx] = dataAndIdx.data; } else { OutPortData.Add(dataAndIdx.data); } } } else if (subNode.Name.Equals("Inputs")) { var data = subNode.ChildNodes.Cast <XmlNode>() .Select( (inputNode, i) => new { data = new PortData(inputNode.Attributes[0].Value, Properties.Resources.ToolTipInput + (i + 1)), idx = i }); foreach (var dataAndIdx in data) { if (InPortData.Count > dataAndIdx.idx) { InPortData[dataAndIdx.idx] = dataAndIdx.data; } else { InPortData.Add(dataAndIdx.data); } } } #region Legacy output support else if (subNode.Name.Equals("Output")) { var data = new PortData(subNode.Attributes[0].Value, Properties.Resources.ToolTipFunctionOutput); if (OutPortData.Any()) { OutPortData[0] = data; } else { OutPortData.Add(data); } } #endregion } RegisterAllPorts(); } base.DeserializeCore(nodeElement, context); //Base implementation must be called XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name")); if (nameNode != null && nameNode.Attributes != null) { NickName = nameNode.Attributes["value"].Value; } XmlNode descNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Description")); if (descNode != null && descNode.Attributes != null) { Description = descNode.Attributes["value"].Value; } }