public bool Has(ConfigTag key) { for (var i = 0; i < rows.Length; i++) { if (rows[i].key == key) { return(true); } } return(false); }
public void AddConfig() { foreach (string child in Body_ConfigTag) { ConfigTag config = new ConfigTag(); config.Addself(child, ConfigBody); } foreach (TaskMessage child in AllTaskData) { TaskMessageBody.Add(child.id, child); } }
public void Save <T>(ConfigTag key, T value) { // see if key already exists int index = 0; bool found = false; for (; index < rows.Length; index++) { if (rows[index].key == key) { found = true; } } // resize to add room if not found if (!found) { Array.Resize(ref rows, rows.Length + 1); index = rows.Length - 1; rows[index] = new PartConfigRow(key); } // set value based on type if (typeof(T) == typeof(bool)) { rows[index].valueType = 0; rows[index].boolValue = (bool)(object)value; } else if (typeof(T) == typeof(string)) { rows[index].valueType = 1; rows[index].stringValue = (string)(object)value; } else if (typeof(T) == typeof(float)) { rows[index].valueType = 2; rows[index].floatValue = (float)(object)value; } }
public T Get <T>(ConfigTag key) { for (var i = 0; i < rows.Length; i++) { if (rows[i].key == key) { if (typeof(T) == typeof(bool)) { return((T)(object)(rows[i].boolValue)); } else if (typeof(T) == typeof(string)) { return((T)(object)(rows[i].stringValue)); } else if (typeof(T) == typeof(float)) { return((T)(object)(rows[i].floatValue)); } } } return(default(T)); }
public PartConfigRow(ConfigTag key) { this.key = key; }