Beispiel #1
0
        public new void Load(Control murpleControl, string filename)
        {
            StreamReader streamReader = new StreamReader (filename);
            XmlReader xmlReader = XmlReader.Create (streamReader);
            XmlDocument document = new XmlDocument ();

            document.Load (xmlReader);

            XmlNodeList allDefinitions = document.GetElementsByTagName ("Definition");

            foreach(XmlNode thisDefinition in allDefinitions)
            {
                XmlNode nameNode = thisDefinition.Attributes.GetNamedItem("name");
                XmlNode extendsOption = thisDefinition.Attributes.GetNamedItem("extends");
                string definitionName = nameNode.Value;

                if (murpleControl.HasMurpleDefinition(definitionName) == true)
                    System.Diagnostics.Debug.Assert(false, string.Format("We already have a murple definition called {0}", definitionName));

                Definition newDefinition = new Definition(definitionName, murpleControl);

                if (extendsOption != null && extendsOption.Value == "true")
                    newDefinition.ExtendedDefinition = true;

                XmlNode childNode = thisDefinition.FirstChild;

                while(childNode != null)
                {
                    XmlNode statTypeNode = childNode.Attributes.GetNamedItem("statType");

                    if(statTypeNode != null)
                    {
                        string statName = childNode.Name;
                        string statType = statTypeNode.Value;

                        newDefinition.AddDefinitionNode(statName, statType);//MURPLE.Types.GetTypeOfString(statType));
                    }

                    childNode = childNode.NextSibling;
                }

                murpleControl.AddMurpleDefinition(definitionName, newDefinition);

            }
            streamReader.Close();
        }
Beispiel #2
0
 public void AddMurpleDefinition(string definitionName, Definition definition)
 {
     definition.Name = definitionName;
     mDefinitions.Add(definitionName, definition);
 }