public override void ParseParentKey(ParentKey parent) { base.keyValues = parent.GetKeyValues(); foreach(ParentKey child in parent.GetChildren()) { switch (child.GetKey()) { case "group_source_bindings": GroupSourceBinding g = new GroupSourceBinding(); g.ParseParentKey(child); groupSourceBindings.Add(g); break; case "switch_bindings": SwitchBinding sb = new SwitchBinding(); sb.ParseParentKey(child); switchBindings.Add(sb); break; case "settings": Setting s = new Setting(); s.ParseParentKey(child); settings.Add(s); break; } } }
public override void ParseParentKey(ParentKey parent) { foreach(ParentKey child in parent.GetChildren()) { Binding b = new Binding(); b.ParseParentKey(child); bindings.Add(b); } }
public override void ParseParentKey(ParentKey parent) { base.keyValues = parent.GetKeyValues(); foreach (ParentKey child in parent.GetChildren()) { switch (child.GetKey()) { case "group": Group group = new Group(); group.ParseParentKey(child); groups.Add(group); break; case "preset": Preset preset = new Preset(); preset.ParseParentKey(child); presets.Add(preset); break; } } }
public override void ParseParentKey(ParentKey parent) { base.keyValues = parent.GetKeyValues(); foreach (ParentKey child in parent.GetChildren()) { switch (child.GetKey()) { case "bindings": Binding b = new Binding(); b.ParseParentKey(child); bindings.Add(b); break; case "settings": Setting s = new Setting(); s.ParseParentKey(child); settings.Add(s); break; } } }
public override void ParseParentKey(ParentKey parent) { setting = parent.GetKeyValues(); }
public ParentKey Parse(StreamReader reader) { try { using (StreamReader sr = reader) { StringBuilder sb = new StringBuilder(); char ch; while (!sr.EndOfStream) { ch = (char)sr.Read(); switch (ch) { case '"': if (keyStarted || valueStarted) { if (valueStarted) { value = sb.ToString(); sb.Clear(); KeyValue kv = new KeyValue(key, value); currentParent.AddKeyValue(kv); keyStarted = false; valueStarted = false; previousKey = false; stringOverride = false; } else { key = sb.ToString(); sb.Clear(); keyStarted = false; previousKey = true; stringOverride = false; } } else { if (previousKey) { valueStarted = true; stringOverride = true; } else { keyStarted = true; stringOverride = true; } } break; case '{': if (!previousKey) { throw new FormatException("Cannot start ParentKey without Key, '{' without Key"); } if (currentParent != null) { parentKeys.Push(currentParent); //Push currentParent to close/append later } currentParent = new ParentKey(key); previousKey = false; sb.Clear(); break; case '}': completedParents.Push(currentParent); //If there are no more on the stack we are on outer most parent if (parentKeys.Count != 0) { ParentKey child = currentParent; currentParent = parentKeys.Pop(); //"Done" with current parent; get previous one to continue appending keys currentParent.AddParentKey(child); } break; default: if (!stringOverride && (ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t')) { if (keyStarted) { key = sb.ToString(); sb.Clear(); keyStarted = false; } if (valueStarted) { value = sb.ToString(); sb.Clear(); KeyValue kv = new KeyValue(key, value); currentParent.AddKeyValue(kv); valueStarted = false; previousKey = false; } continue; } if (!keyStarted && !previousKey) { keyStarted = true; } if (!keyStarted && previousKey && !valueStarted) { valueStarted = true; } sb.Append(ch); break; } } } } catch (Exception ex) { //Throw it up for now throw ex; } return(currentParent); }
public void AddParentKey(ParentKey childKey) { childrenKeys.Add(childKey); }
public abstract void ParseParentKey(ParentKey parent);
public override void ParseParentKey(ParentKey parent) { base.keyValues = parent.GetKeyValues(); }
public ParentKey Parse(StreamReader reader) { try { using (StreamReader sr = reader) { StringBuilder sb = new StringBuilder(); char ch; while (!sr.EndOfStream) { ch = (char)sr.Read(); switch (ch) { case '"': if (keyStarted || valueStarted) { if (valueStarted) { value = sb.ToString(); sb.Clear(); KeyValue kv = new KeyValue(key, value); currentParent.AddKeyValue(kv); keyStarted = false; valueStarted = false; previousKey = false; stringOverride = false; } else { key = sb.ToString(); sb.Clear(); keyStarted = false; previousKey = true; stringOverride = false; } } else { if (previousKey) { valueStarted = true; stringOverride = true; } else { keyStarted = true; stringOverride = true; } } break; case '{': if (!previousKey) throw new FormatException("Cannot start ParentKey without Key, '{' without Key"); if (currentParent != null) parentKeys.Push(currentParent); //Push currentParent to close/append later currentParent = new ParentKey(key); previousKey = false; sb.Clear(); break; case '}': completedParents.Push(currentParent); //If there are no more on the stack we are on outer most parent if (parentKeys.Count != 0) { ParentKey child = currentParent; currentParent = parentKeys.Pop(); //"Done" with current parent; get previous one to continue appending keys currentParent.AddParentKey(child); } break; default: if (!stringOverride && (ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t')) { if (keyStarted) { key = sb.ToString(); sb.Clear(); keyStarted = false; } if (valueStarted) { value = sb.ToString(); sb.Clear(); KeyValue kv = new KeyValue(key, value); currentParent.AddKeyValue(kv); valueStarted = false; previousKey = false; } continue; } if (!keyStarted && !previousKey) keyStarted = true; if (!keyStarted && previousKey && !valueStarted) valueStarted = true; sb.Append(ch); break; } } } } catch (Exception ex) { //Throw it up for now throw ex; } return currentParent; }