Beispiel #1
0
        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 (OutPorts.Count > dataAndIdx.idx)
                            {
                                OutPorts[dataAndIdx.idx] = new PortModel(PortType.Output, this, dataAndIdx.data);
                            }
                            else
                            {
                                OutPorts.Add(new PortModel(PortType.Output, this, 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 (InPorts.Count > dataAndIdx.idx)
                            {
                                InPorts[dataAndIdx.idx] = new PortModel(PortType.Input, this, dataAndIdx.data);
                            }
                            else
                            {
                                InPorts.Add(new PortModel(PortType.Input, this, dataAndIdx.data));
                            }
                        }
                    }

                    #region Legacy output support

                    else if (subNode.Name.Equals("Output"))
                    {
                        var data = new PortData(subNode.Attributes[0].Value, Properties.Resources.ToolTipFunctionOutput);

                        if (OutPorts.Any())
                        {
                            OutPorts[0] = new PortModel(PortType.Output, this, data);
                        }
                        else
                        {
                            OutPorts.Add(new PortModel(PortType.Output, this, 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;
            }
        }