2using System.Collections;
3using System.Collections.Generic;
25 public object this[
string key] {
26 get => GetValue<object>(key);
27 set => SetValue(key, value);
42 throw new InvalidOperationException($
"Required value \"{key}\" not found in values dictionary");
56 public void Add<T>(
string key, T value) {
68 public void Remove(
string key, out
object value) {
91 public void Save(XElement node) {
92 foreach (KeyValuePair<string, object> item
in m_dictionary) {
96 valuesDictionary.Save(node2);
98 else if (item.Value !=
null) {
109 foreach (
DatabaseObject effectiveNestingChild
in databaseObject.GetEffectiveNestingChildren(
null,
true)) {
112 object value = proceduralValue.Parse(databaseObject);
113 SetValue(effectiveNestingChild.
Name, value);
116 SetValue(effectiveNestingChild.
Name, effectiveNestingChild.
Value);
122 SetValue(effectiveNestingChild.
Name, valuesDictionary);
128 foreach (KeyValuePair<string, object> item
in overridesValuesDictionary) {
130 if (GetValue<object>(item.Key,
null) is not
ValuesDictionary valuesDictionary2) {
131 valuesDictionary2 = [];
132 SetValue(item.Key, valuesDictionary2);
134 valuesDictionary2.ApplyOverrides(valuesDictionary);
137 SetValue(item.Key, item.Value);
147 foreach (XElement item
in overridesNode.Elements()) {
148 if (item.Name ==
"Value") {
150 if (overrideExistOnly && !
m_dictionary.ContainsKey(key))
154 if (typeName ==
null) {
155 object value = GetValue<object>(key,
null);
157 throw new InvalidOperationException($
"Type of override \"{key}\" cannot be determined.");
158 type = value.GetType();
164 SetValue(key, valueObj);
166 else if (item.Name ==
"Values") {
168 if (overrideExistOnly && !
m_dictionary.ContainsKey(key))
172 valuesDictionary = vd;
176 SetValue(key, valuesDictionary);
181 throw new InvalidOperationException($
"Unrecognized element \"{item.Name}\" in values dictionary overrides XML.");
187 IEnumerator IEnumerable.GetEnumerator() =>
m_dictionary.GetEnumerator();
static Type FindType(string typeName, bool skipSystemAssemblies, bool throwIfNotFound)
static string GetShortTypeName(string longTypeName)
bool TryAdd< T >(string key, T value)
Dictionary< string, object > m_dictionary
void Add< T >(string key, T value)
IEnumerable< object > Values
void ApplyOverrides(XElement overridesNode, bool overrideExistOnly)
void EnsureCapacity(int capacity)
bool ContainsKey(string key)
IEnumerable< string > Keys
T GetValue< T >(string key)
void ApplyOverrides(XElement overridesNode)
DatabaseObject m_databaseObject
bool TryGetValue< T >(string key, out T value)
void TrimExcess(int capacity)
void Remove(string key, out object value)
bool ContainsValue(object value)
void SetValue< T >(string key, T value)
IEnumerator< KeyValuePair< string, object > > GetEnumerator()
void PopulateFromDatabaseObject(DatabaseObject databaseObject)
DatabaseObject DatabaseObject
void ApplyOverrides(ValuesDictionary overridesValuesDictionary)
static void SetAttributeValue(XElement node, string attributeName, object value)
static object GetAttributeValue(XElement node, string attributeName, Type type)
static XElement AddElement(XElement parentNode, string name)