Ejemplo n.º 1
0
        private void ParseElement(SymbolDef current, XmlNode node)
        {
            int tagNumber = reader.ReadInt32() - 1;

            if (tagNumber == -1)
            {
                return;                         // shit happens
            }
            if (tagNumber < 0 || tagNumber > ntags)
            {
                throw new SPBException("Invalid tag index " + tagNumber);
            }

            DefinitionElement tagType = tags[tagNumber];

            if (tagType is SetDef)
            {
                SetDef set = (SetDef)tagType;
                ParseSet(current, set, node);
            }
            else if (tagType is PropertyDef)
            {
                PropertyDef pd = (PropertyDef)tagType;
                ParseProperty(current, pd, node);
            }
            else
            {
                throw new SPBException("Unexpected tag type : " + tagType.GetType().Name);
            }
        }
Ejemplo n.º 2
0
        private void ParseSet(SymbolDef current, SetDef set, XmlNode node)
        {
            int  setSize     = reader.ReadInt32();
            long endPosition = reader.BaseStream.Position + setSize;

            XmlNode setNode;

            // compare SetDefs
            if (current == null || set.Parent != current)
            {
                // switch symbols
                setNode = doc.CreateElement("", set.Parent.Name + "." + set.Name, "");
                current = set.Parent;
            }
            else
            {
                setNode = doc.CreateElement("", set.Name, "");
            }


            node.AppendChild(setNode);
            while (reader.BaseStream.Position < endPosition)
            {
                ParseElement(current, setNode);
            }
        }
Ejemplo n.º 3
0
        public SymbolDef(string dirName, XmlNode node)
            : base(node)
        {
            SymbolBank bank = SymbolBank.Instance;

            foreach (XmlNode son in node.ChildNodes)
            {
                string sonName = son.Name;

                if (sonName.Equals("SymbolInclude"))
                {
                    string symbolFile = son.Attributes["filename"].Value;
                    bank.AddSymbolDefinitionFile(dirName + "\\" + symbolFile);
                }


                if (sonName.Equals("TypeDefs"))
                {
                    // parse types
                    foreach (XmlNode typeNode in son.ChildNodes)
                    {
                        if (typeNode.Name.Equals("TypeDef"))
                        {
                            TypeDef type = new TypeDef(typeNode);
                            bank.AddType(type);
                        }
                    }
                }

                if (sonName.Equals("PropertyDefs"))
                {
                    // parse properties
                    foreach (XmlNode propNode in son.ChildNodes)
                    {
                        if (propNode.Name.Equals("PropertyDef"))
                        {
                            PropertyDef prop = new PropertyDef(propNode);
                            prop.SymbolContext = this;
                            bank.AddProperty(prop);
                        }
                    }
                }

                if (sonName.Equals("SetDefs"))
                {
                    // parse types
                    foreach (XmlNode setNode in son.ChildNodes)
                    {
                        if (setNode.Name.Equals("SetDef"))
                        {
                            SetDef set = new SetDef(setNode);
                            set.Parent = this;
                            bank.AddSet(set);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void AddSet(SetDef set)
 {
     AddAndCheck(set);
 }