コード例 #1
0
        private Dictionary <Guid, NetworkComponent> ProcessNodes(XmlNodeList cells)
        {
            Dictionary <Guid, NetworkComponent> nodesList = new Dictionary <Guid, NetworkComponent>();

            foreach (var c in cells)
            {
                var cell = (XmlElement)c;
                if (cell.HasAttribute("ComponentGuid"))
                {
                    //this seems problematic in that a component could be missing a type
                    NetworkComponent cn = new NetworkComponent();
                    foreach (XmlAttribute a in cell.Attributes)
                    {
                        cn.setValue(a.Name, a.Value);
                    }

                    cn.Parent_id = GetParentId(cell);

                    // determine the component type
                    int ctype = GetComponentType(cell);
                    if (ctype != 0)
                    {
                        cn.Component_Symbol_Id = ctype;
                    }
                    else
                    {
                        throw new Exception("Unrecognized component: " + cell.OuterXml);
                    }
                    NetworkComponent tmp;
                    if (nodesList.TryGetValue(cn.ComponentGuid, out tmp))
                    {
                        if (cn.Equals(tmp))
                        {
                            Trace.WriteLine("cn == temp");
                        }
                    }
                    else
                    {
                        nodesList.Add(cn.ComponentGuid, cn);
                    }
                }
            }
            return(nodesList);
        }