void LoadConfigInternalHashTags(JsonArray array) { for (int i = 0; i < array.Length; i ++) _hashTags.Add ((array[i] as JsonString).Value); }
public JsonValue Read() { JsonValue cur = null; string lastPropName = null; Stack<JsonValue> stack = new Stack<JsonValue> (); Stack<string> propNameStack = new Stack<string> (); JsonReader reader = _reader; while (reader.Read ()) { switch (reader.Token) { case JsonToken.ArrayStart: case JsonToken.ObjectStart: if (cur != null) { stack.Push (cur); if (cur is JsonObject) { propNameStack.Push (lastPropName); lastPropName = null; } } if (reader.Token == JsonToken.ArrayStart) cur = new JsonArray (new List<JsonValue> ()); else cur = new JsonObject (new Dictionary<string,JsonValue> ()); break; case JsonToken.ObjectEnd: case JsonToken.ArrayEnd: if (stack.Count == 0) return cur; JsonValue parent = stack.Pop (); if (parent is JsonArray) { (parent as JsonArray).Value.Add (cur); } else if (parent is JsonObject) { lastPropName = propNameStack.Pop (); if (lastPropName == null) throw new JsonException (); (parent as JsonObject).Value.Add (lastPropName, cur); lastPropName = null; } cur = parent; break; case JsonToken.PropertyName: if (lastPropName != null) throw new JsonException (); lastPropName = (string)reader.Value; break; case JsonToken.Boolean: case JsonToken.Null: case JsonToken.Number: case JsonToken.String: JsonValue value; switch (reader.Token) { case JsonToken.Boolean: value = new JsonBoolean ((bool)reader.Value); break; case JsonToken.Null: value = new JsonNull (); break; case JsonToken.Number: value = new JsonNumber (Convert (reader.NumberType), (double)reader.Value, reader.ValueSignedInteger, reader.ValueUnsignedInteger); break; case JsonToken.String: value = new JsonString ((string)reader.Value); break; default: throw new JsonException (); } if (cur == null) return value; if (cur is JsonArray) { (cur as JsonArray).Value.Add (value); } else if (cur is JsonObject) { if (lastPropName == null) throw new JsonException (); (cur as JsonObject).Value.Add (lastPropName, value); lastPropName = null; } break; } } if (cur == null) return null; throw new JsonException (); }
void LoadConfigInternal(JsonArray array, TimelineBase timelines) { for (int i = 0; i < array.Length; i ++) { JsonObject obj = array[i] as JsonObject; if (obj != null) { TimelineBase info = null; switch ((obj.Value["type"] as JsonString).Value) { case "account": string subtype = (obj.Value["subtype"] as JsonString).Value; string name = (obj.Value["name"] as JsonString).Value; TwitterAccount account = null; foreach (TwitterAccount item in _mgr.Accounts) if (name.Equals (item.ScreenName)) { account = item; break; } if (account == null) continue; switch (subtype) { case "home": info = new TimelineInfo (_mgr, timelines, account, account.HomeTimeline); break; case "mentions": info = new TimelineInfo (_mgr, timelines, account, account.Mentions); break; case "directmessages": info = new TimelineInfo (_mgr, timelines, account, account.DirectMessages); break; } break; case "search": string keywords = (obj.Value["keywords"] as JsonString).Value; foreach (SearchStatuses search in _mgr.Searches) if (keywords.Equals (search.Keyword)) { info = new TimelineInfo (timelines, search); break; } break; case "tab": string title = (obj.Value["title"] as JsonString).Value; TabInfo tb = new TabInfo (timelines, title); LoadConfigInternal ((JsonArray)obj.Value["windows"], tb); info = tb; break; case "list": ulong id = (ulong)(obj.Value["id"] as JsonNumber).Value; foreach (ListStatuses list in _mgr.Lists) if (id == list.List.ID) { info = new TimelineInfo (timelines, list); break; } break; } if (info != null) timelines.TimeLines.Add (info); } } }