Esempio n. 1
0
            public XmlType GetMember(string name)
            {
                if (arrayElement != null)
                {
                    return(arrayElement.GetMember(name));
                }
                XmlType value = null;

                if (dicMembers.TryGetValue(name, out value))
                {
                    return(value);
                }
                return(null);
            }
Esempio n. 2
0
            public string Check(XmlType xmlType, IgnoreNode ignoreNodeRoot, bool checkExtraField = false)
            {
                if (xmlType == null || ignoreNodeRoot == null)
                {
                    return(string.Empty);
                }
                string error = string.Empty;

                if (xmlType.name != name)
                {
                    if (checkExtraField && !ignoreNodeRoot.IsIgnored(xmlType))
                    {
                        error += "<color=yellow>  XML多填了:  " + GetPathName() + GetPosition() + "</color>\n";
                    }
                }
                else
                {
                    Dictionary <string, XmlType> dicChildren = new Dictionary <string, XmlType>();
                    xmlType.GetAllMembers(dicChildren);
                    for (int i = 0; i < listChildren.Count; ++i)
                    {
                        Node    child        = listChildren[i];
                        XmlType childXmlType = xmlType.GetMember(child.name);
                        if (childXmlType == null)
                        {
                            if (checkExtraField && !ignoreNodeRoot.IsIgnored(xmlType, child.name))
                            {
                                error += "<color=yellow>  XML多填了:   " + child.GetPathName() + child.GetPosition() + "</color>\n";
                            }
                            continue;
                        }
                        dicChildren.Remove(child.name);
                        error += child.Check(childXmlType, ignoreNodeRoot, checkExtraField);
                    }
                    foreach (KeyValuePair <string, XmlType> temp in dicChildren)
                    {
                        if (!temp.Value.IsArray() && !ignoreNodeRoot.IsIgnored(temp.Value))
                        {
                            error += "<color=red>  XML少填了:   " + GetPathName() + "/" + temp.Value.name + GetPosition() + "</color>\n";
                        }
                    }
                }
                return(error);
            }