Beispiel #1
0
        public void ConvertToList()
        {
            if (Type == CK2TokenTypes.List)
            {
                return;
            }

            var list = new List <CK2Token>();

            switch (Type)
            {
            case CK2TokenTypes.Object:

                var fields = GetObject();

                foreach (var field in fields)
                {
                    field.Value.Parent = this;
                    list.Add(field.Value);
                }

                break;

            case CK2TokenTypes.Value:
                var newToken = new CK2Token(Value.ToString(), CK2TokenTypes.Value, Value);
                newToken.Parent = this;
                list.Add(newToken);
                break;
            }

            Value = list;
            Type  = CK2TokenTypes.List;
        }
Beispiel #2
0
        public void Add(CK2Object obj)
        {
            var token = new CK2Token("", CK2TokenTypes.Object, obj);

            token.Parent = this;

            GetList().Add(token);
        }
Beispiel #3
0
 private void SetRoot(string key, CK2Token value)
 {
     if (Root.ContainsKey(key))
     {
         Root[key] = value;
     }
     else
     {
         Root.Add(key, value);
     }
 }
Beispiel #4
0
 private void EnterContext(string key)
 {
     if (Context == null)
     {
         Context = new CK2Token(key);
         SetRoot(Context.Key, Context);
     }
     else
     {
         Context = Context.AddField(key);
     }
 }
Beispiel #5
0
        public CK2Token Add(string key)
        {
            var list = GetList();
            var item = list.FirstOrDefault();
            var type = CK2TokenTypes.Undefined;

            if (item != null)
            {
                type = item.Type;
            }

            var token = new CK2Token(key, type, key);

            token.Parent = this;

            GetList().Add(token);
            return(token);
        }