Example #1
0
 public void PopulateFromDatabaseObject(DatabaseObject databaseObject)
 {
     m_databaseObject = databaseObject;
     foreach (DatabaseObject effectiveNestingChild in databaseObject.GetEffectiveNestingChildren(null, directChildrenOnly: true))
     {
         if (effectiveNestingChild.Type.SupportsValue)
         {
             if (effectiveNestingChild.Value is ProceduralValue)
             {
                 object value = ((ProceduralValue)effectiveNestingChild.Value).Parse(databaseObject);
                 SetValue(effectiveNestingChild.Name, value);
             }
             else
             {
                 SetValue(effectiveNestingChild.Name, effectiveNestingChild.Value);
             }
         }
         else
         {
             ValuesDictionary valuesDictionary = new ValuesDictionary();
             valuesDictionary.PopulateFromDatabaseObject(effectiveNestingChild);
             SetValue(effectiveNestingChild.Name, valuesDictionary);
         }
     }
 }
Example #2
0
 public void ApplyOverrides(XElement overridesNode)
 {
     foreach (XElement item in overridesNode.Elements())
     {
         if (item.Name == "Value")
         {
             string attributeValue  = XmlUtils.GetAttributeValue <string>(item, "Name");
             string attributeValue2 = XmlUtils.GetAttributeValue <string>(item, "Type", null);
             Type   type;
             if (attributeValue2 == null)
             {
                 object value = GetValue <object>(attributeValue, null);
                 if (value == null)
                 {
                     throw new InvalidOperationException($"Type of override \"{attributeValue}\" cannot be determined.");
                 }
                 type = value.GetType();
             }
             else
             {
                 type = TypeCache.FindType(attributeValue2, skipSystemAssemblies: false, throwIfNotFound: true);
             }
             object attributeValue3 = XmlUtils.GetAttributeValue(item, "Value", type);
             SetValue(attributeValue, attributeValue3);
         }
         else
         {
             if (!(item.Name == "Values"))
             {
                 throw new InvalidOperationException($"Unrecognized element \"{item.Name}\" in values dictionary overrides XML.");
             }
             string           attributeValue4  = XmlUtils.GetAttributeValue <string>(item, "Name");
             ValuesDictionary valuesDictionary = GetValue <object>(attributeValue4, null) as ValuesDictionary;
             if (valuesDictionary == null)
             {
                 valuesDictionary = new ValuesDictionary();
                 SetValue(attributeValue4, valuesDictionary);
             }
             valuesDictionary.ApplyOverrides(item);
         }
     }
 }
Example #3
0
 public void Save(XElement node)
 {
     foreach (KeyValuePair <string, object> item in m_dictionary)
     {
         ValuesDictionary valuesDictionary = item.Value as ValuesDictionary;
         if (valuesDictionary != null)
         {
             XElement node2 = XmlUtils.AddElement(node, "Values");
             XmlUtils.SetAttributeValue(node2, "Name", item.Key);
             valuesDictionary.Save(node2);
         }
         else
         {
             XElement node3 = XmlUtils.AddElement(node, "Value");
             XmlUtils.SetAttributeValue(node3, "Name", item.Key);
             XmlUtils.SetAttributeValue(node3, "Type", TypeCache.GetShortTypeName(item.Value.GetType().FullName));
             XmlUtils.SetAttributeValue(node3, "Value", item.Value);
         }
     }
 }
Example #4
0
 public void ApplyOverrides(ValuesDictionary overridesValuesDictionary)
 {
     foreach (KeyValuePair <string, object> item in overridesValuesDictionary)
     {
         ValuesDictionary valuesDictionary = item.Value as ValuesDictionary;
         if (valuesDictionary != null)
         {
             ValuesDictionary valuesDictionary2 = GetValue <object>(item.Key, null) as ValuesDictionary;
             if (valuesDictionary2 == null)
             {
                 valuesDictionary2 = new ValuesDictionary();
                 SetValue(item.Key, valuesDictionary2);
             }
             valuesDictionary2.ApplyOverrides(valuesDictionary);
         }
         else
         {
             SetValue(item.Key, item.Value);
         }
     }
 }