示例#1
0
        public Entry GenerateDefault()
        {
            if (m_default == null)
            {
                m_default = new SectionEntry();
                m_default.InternalName = "";
                m_default.FriendlyName = "[!/birth_name:[VALUE]!]";
                ValueEntry bname = new ValueEntry();
                bname.InternalName = "birth_name";
                bname.FriendlyName = "Birth Name";
                bname.Parent = m_default;
                m_default.Entries.Add(bname);
            }

            return m_default.Clone();
        }
示例#2
0
        public SectionEntry ReadSection(string file, XmlNode formatNode, SectionEntry root = null)
        {
            SectionEntry re;
            if (root == null)
            {
                re = new EntryGrouper();
                root = re; //if no root was provided, the current editor is the root
            }
            else
                re = new SectionEntry();
            re.Root = root;

            Dictionary<string, EntryGrouper> multiples = null;
            foreach (var pair in FormatUtil.ListEntriesWithIndexes(file))
            {
                SectionEntry parent = re;

                XmlNode childNode = FindNode(formatNode, pair.Value);//look for a format node that can describe this entry
                if (childNode != null)
                {
                    parent = HandleMultiples(childNode, ref multiples, re);

                    if (!childNode.HasChildNodes)
                    {//the node is a value
                        ValueEntry ent = new ValueEntry();
                        ent.InternalName = pair.Value;
                        ent.FriendlyName = childNode.Attributes["name"].Value;
                        ent.Type = childNode.Attributes["type"] != null ? childNode.Attributes["type"].Value : "misc";
                        ent.Value = FormatUtil.ReadValue(file, ent.InternalName, ent.Type, pair.Key);
                        ent.Link = childNode.Attributes["link"] != null ? childNode.Attributes["link"].Value : null;
                        ent.Parent = parent;
                        ent.Root = root;
                        parent.Entries.Add(ent);
                    }
                    else
                    {//the node is a section
                        SectionEntry ent = ReadSection(FormatUtil.ExtractDelimited(file, pair.Value, pair.Key), childNode, re.Root);
                        ent.InternalName = pair.Value;
                        ent.FriendlyName = childNode.Attributes["name"].Value;
                        ent.Link = childNode.Attributes["link"] != null ? childNode.Attributes["link"].Value : null;
                        ent.Parent = parent;
                        parent.Entries.Add(ent);
                    }
                }
                else //if no format node was found, try to supplement information
                {
                    string type = DetectType(file, pair);
                    if (type != "section")
                    {//the node is a value
                        ValueEntry ent = new ValueEntry();
                        ent.InternalName = pair.Value;
                        ent.Type = type;
                        ent.Value = FormatUtil.ReadValue(file, ent.InternalName, ent.Type, pair.Key);
                        ent.Parent = re;
                        ent.Root = root;
                        parent.Entries.Add(ent);
                    }
                    else
                    {//the node is a section
                        SectionEntry ent = new SectionEntry();
                        ent.InternalName = pair.Value;
                        ent = ReadSection(FormatUtil.ExtractDelimited(file, pair.Value, pair.Key), childNode, re.Root);
                        ent.Parent = parent;
                        parent.Entries.Add(ent);
                    }
                }
            }
            return re;
        }
示例#3
0
        public override bool Equals(Entry other)
        {
            ValueEntry otherv = other as ValueEntry;

            return(otherv != null && base.Equals(other) && otherv.Type == this.Type && otherv.Value == this.Value);
        }
示例#4
0
 protected override Entry CreateClone()
 {
     ValueEntry ret = new ValueEntry();
     ret.Type = this.Type;
     ret.Value = this.Value;
     return ret;
 }
示例#5
0
        public SectionEntry ReadSection(string file, XmlNode formatNode, SectionEntry root = null)
        {
            SectionEntry re;

            if (root == null)
            {
                re   = new EntryGrouper();
                root = re; //if no root was provided, the current editor is the root
            }
            else
            {
                re = new SectionEntry();
            }
            re.Root = root;

            Dictionary <string, EntryGrouper> multiples = null;

            foreach (var pair in FormatUtil.ListEntriesWithIndexes(file))
            {
                SectionEntry parent = re;

                XmlNode childNode = FindNode(formatNode, pair.Value);//look for a format node that can describe this entry
                if (childNode != null)
                {
                    parent = HandleMultiples(childNode, ref multiples, re);

                    if (!childNode.HasChildNodes)
                    {//the node is a value
                        ValueEntry ent = new ValueEntry();
                        ent.InternalName = pair.Value;
                        ent.FriendlyName = childNode.Attributes["name"].Value;
                        ent.Type         = childNode.Attributes["type"] != null ? childNode.Attributes["type"].Value : "misc";
                        ent.Value        = FormatUtil.ReadValue(file, ent.InternalName, ent.Type, pair.Key);
                        ent.Link         = childNode.Attributes["link"] != null ? childNode.Attributes["link"].Value : null;
                        ent.Parent       = parent;
                        ent.Root         = root;
                        parent.Entries.Add(ent);
                    }
                    else
                    {//the node is a section
                        SectionEntry ent = ReadSection(FormatUtil.ExtractDelimited(file, pair.Value, pair.Key), childNode, re.Root);
                        ent.InternalName = pair.Value;
                        ent.FriendlyName = childNode.Attributes["name"].Value;
                        ent.Link         = childNode.Attributes["link"] != null ? childNode.Attributes["link"].Value : null;
                        ent.Parent       = parent;
                        parent.Entries.Add(ent);
                    }
                }
                else //if no format node was found, try to supplement information
                {
                    string type = DetectType(file, pair);
                    if (type != "section")
                    {//the node is a value
                        ValueEntry ent = new ValueEntry();
                        ent.InternalName = pair.Value;
                        ent.Type         = type;
                        ent.Value        = FormatUtil.ReadValue(file, ent.InternalName, ent.Type, pair.Key);
                        ent.Parent       = re;
                        ent.Root         = root;
                        parent.Entries.Add(ent);
                    }
                    else
                    {//the node is a section
                        SectionEntry ent = new SectionEntry();
                        ent.InternalName = pair.Value;
                        ent        = ReadSection(FormatUtil.ExtractDelimited(file, pair.Value, pair.Key), childNode, re.Root);
                        ent.Parent = parent;
                        parent.Entries.Add(ent);
                    }
                }
            }
            return(re);
        }