Exemplo n.º 1
0
        public static void LoadObjectDefaults(IDefaultsHolder defaultsHolder)
        {
            Type t = defaultsHolder.GetType();

            if (BusinessObject.ClassXmlSerializationCache.ContainsKey(t))
            {
                XmlSerializationCache classCache = BusinessObject.ClassXmlSerializationCache[t];

                XElement defaultSettings = defaultsHolder.DefaultsXml.Root.Element(classCache.Attribute.XmlField);

                XmlSerializationCache[] cache = BusinessObject.PropertiesXmlSerializationCache[t];

                for (int i = 0; i < cache.Length; i++)
                {
                    XmlSerializationCache c = cache[i];

                    XmlSerializableAttribute propAttr = c.Attribute;
                    if (!propAttr.UseAttribute && defaultSettings.Element(propAttr.XmlField) != null ||
                        propAttr.UseAttribute && defaultSettings.Attribute(propAttr.XmlField) != null) //zeby nie nullowal juz ustawionych ustawien
                    {
                        BusinessObjectHelper.DeserializeSingleValue(defaultsHolder, c.Property, propAttr, defaultSettings);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Recursively creates new children (BusinessObjects) and loads settings from provided xml.
        /// </summary>
        /// <param name="element">Xml element to attach.</param>
        public virtual void Deserialize(XElement element)
        {
            Type t = this.GetType();

            if (!BusinessObject.PropertiesXmlSerializationCache.ContainsKey(t))
            {
                BusinessObject.CacheClass(t);
            }

            XmlSerializationCache[] cache = BusinessObject.PropertiesXmlSerializationCache[t];

            for (int i = 0; i < cache.Length; i++)
            {
                XmlSerializationCache c = cache[i];

                if (c.Attribute.AutoDeserialization)
                {
                    BusinessObjectHelper.DeserializeSingleValue(this, c.Property, c.Attribute, element);
                }
            }
        }