public void ReadXml(XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;

            reader.Read();

            if (wasEmpty)
            {
                return;
            }
            m_Name = reader.ReadElementString("Name");
            string propTypeStr = reader.ReadElementString("PropertyType");

            Type propType = null;

            try
            {
                propType = Type.GetType(propTypeStr);
            }
            catch { }

            if (propType != null)
            {
                Property = XMLHelpers.Deserialise(reader, propType);
            }
        }
        public void ReadXml(XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;

            reader.Read();
            if (wasEmpty)
            {
                return;
            }

            m_BaseValue = reader.ReadElementContentAsInt("BaseValue", string.Empty);

            reader.ReadStartElement("Modifiers");
            if (!reader.IsEmptyElement)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    reader.ReadStartElement("Modifier");
                    string typeString = reader.ReadElementString("Type");

                    Type modifierType = null;
                    try
                    {
                        modifierType = Type.GetType(typeString);
                    }
                    catch { }

                    if (modifierType != null)
                    {
                        var newMod = XMLHelpers.Deserialise(reader, modifierType) as INumericalPropertyModifier <int, KDMNumericalPropertyContext, KDMNumericalPropertyModifierReader>;
                        if (newMod != null)
                        {
                            m_Modifiers.Add(newMod);
                        }
                    }
                    else
                    {
                        reader.Skip();
                    }

                    reader.ReadEndElement();
                    reader.MoveToContent();
                }
            }

            Update();
        }
Exemple #3
0
        public void ReadXml(XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;

            reader.Read();
            if (wasEmpty)
            {
                return;
            }

            reader.ReadStartElement("AllowedTypes");
            if (!reader.IsEmptyElement)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    reader.ReadStartElement("PropertyType");
                    PropertyType propType = new PropertyType();
                    try
                    {
                        propType.Type = Type.GetType(reader.ReadElementString("Type"));
                    }
                    catch
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            reader.Read();
                        }
                        continue;
                    }

                    if (reader.Name == "FilterData")
                    {
                        propType.FilterData = reader.ReadElementString("FilterData");
                    }

                    reader.ReadEndElement();
                    reader.MoveToContent();

                    m_AllowedTypes.Add(propType);
                }
            }

            reader.ReadStartElement("Items");
            if (!reader.IsEmptyElement)
            {
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    reader.ReadStartElement("Item");
                    Type propType = null;
                    try
                    {
                        propType = Type.GetType(reader.ReadElementString("Type"));
                    }
                    catch
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            reader.Read();
                        }
                        continue;
                    }

                    reader.ReadEndElement();
                    reader.MoveToContent();

                    object item = XMLHelpers.Deserialise(reader, propType);
                    if (item != null)
                    {
                        Items.Add(item);
                    }
                }
            }
        }