Esempio n. 1
0
 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;
         }
     }
 }
Esempio n. 2
0
 public override void ParseParentKey(ParentKey parent)
 {
     foreach(ParentKey child in parent.GetChildren())
     {
         Binding b = new Binding();
         b.ParseParentKey(child);
         bindings.Add(b);
     }
 }
Esempio n. 3
0
 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;
         }
     }
 }
Esempio n. 4
0
 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;
         }
     }
 }
Esempio n. 5
0
 public override void ParseParentKey(ParentKey parent)
 {
     setting = parent.GetKeyValues();
 }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public void AddParentKey(ParentKey childKey)
 {
     childrenKeys.Add(childKey);
 }
 public abstract void ParseParentKey(ParentKey parent);
Esempio n. 9
0
 public override void ParseParentKey(ParentKey parent)
 {
     base.keyValues = parent.GetKeyValues();
 }
Esempio n. 10
0
 public void AddParentKey(ParentKey childKey)
 {
     childrenKeys.Add(childKey);
 }
Esempio n. 11
0
        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;
        }