internal void AddFriends(string userId, JSONObject[] friendsDict) { foreach (var subFriend in friendsDict) { graphStorage.AddEdge(userId, subFriend.String); Debug.WriteLine("Mutual: " + subFriend.ToDisplayableString()); } }
internal void AddAreFriends(JSONObject[] friendsDict) { foreach (var friend in friendsDict) if (friend.Dictionary["are_friends"].Boolean) { graphStorage.AddEdge(friend.Dictionary["uid1"].String, friend.Dictionary["uid2"].String); Debug.WriteLine(friend.Dictionary["uid1"].String + " AreFriends: " + friend.Dictionary["uid2"].String); } }
private void onLoadUserInfo(JSONObject ego) { userInfoTextBox.Clear(); userInfoTextBox.AppendText(ego.Dictionary["name"].String + "\n"); userInfoTextBox.AppendText(ego.Dictionary["age"].String + "лет; "); userInfoTextBox.AppendText("д.р.: " + ego.Dictionary["birthday"].String + "\n"); userInfoTextBox.AppendText(ego.Dictionary["gender"].String + "\n"); userInfoTextBox.AppendText(ego.Dictionary["location"].Dictionary["country"].String + ": "); userInfoTextBox.AppendText(ego.Dictionary["location"].Dictionary["city"].String + "\n"); userInfoTextBox.AppendText(ego.Dictionary["pic_1"].String + "\n"); if (ego.Dictionary.ContainsKey("current_status")) userInfoTextBox.AppendText("Статус: " + ego.Dictionary["current_status"].String); pictureBox.ImageLocation = ego.Dictionary["pic_2"].String; userIdTextBox.Clear(); userIdTextBox.Text = analyzer.EgoId = ego.Dictionary["uid"].String; LoginDialog.Close(); ActivateAuthControls(true); }
private string calcLocation(JSONObject obj, string name) { return name == "location" ? obj.Dictionary[name].Dictionary["city"].String + ", " + obj.Dictionary[name].Dictionary["country"].String : obj.Dictionary[name].Dictionary["latitude"].String + ", " + obj.Dictionary[name].Dictionary["longitude"].String; }
internal AttributesDictionary<string> CreateVertexAttributes(JSONObject obj) { AttributesDictionary<string> attributes = new AttributesDictionary<string>(); List<AttributeUtils.Attribute> keys = new List<AttributeUtils.Attribute>(attributes.Keys); foreach (AttributeUtils.Attribute key in keys) { if (!isNeeded(key.value)) { attributes.Remove(key); continue; } string name = convertKey(key.value); if (obj.Dictionary.ContainsKey(name)) { string value = name.Contains("location") ? calcLocation(obj, name) : obj.Dictionary[name].String; attributes[key] = value; } } return attributes; }
private Vertex<String> makeVertex(JSONObject token, AttributesDictionary<String> attributes, string type) { return new Vertex<String>(token.Dictionary["uid"].String, token.Dictionary["name"].String, type, attributes); }
internal void AddFriendVertex(JSONObject friend, AttributesDictionary<String> attributes) { vertices.Add(makeVertex(friend, attributes, "Friend")); }
internal void MakeEgoVertex(JSONObject ego, AttributesDictionary<String> attributes) { egoVertex = makeVertex(ego, attributes, "Ego"); includeEgo = true; }
public GraphEventArgs(Types type, JSONObject data = null) { Type = type; JData = data; }
private static void RecursiveDictionaryToString(JSONObject obj, StringBuilder sb, int level) { foreach (KeyValuePair<string, JSONObject> kvp in obj.Dictionary) { sb.Append(' ', level * 2); sb.Append(kvp.Key); sb.Append(" => "); RecursiveObjectToString(kvp.Value, sb, level); sb.AppendLine(); } }
private static void RecursiveObjectToString(JSONObject obj, StringBuilder sb, int level) { if (obj.IsDictionary) { sb.AppendLine(); RecursiveDictionaryToString(obj, sb, level + 1); } else if (obj.IsArray) { foreach (JSONObject o in obj.Array) { RecursiveObjectToString(o, sb, level); sb.AppendLine(); } } else // some sort of scalar value { sb.Append(obj.String); } }
/// <summary> /// Recursively constructs this JSONObject /// </summary> private static JSONObject Create(object o) { JSONObject obj = new JSONObject(); if (o is object[]) { object[] objArray = o as object[]; obj._arrayData = new JSONObject[objArray.Length]; for (int i = 0; i < obj._arrayData.Length; ++i) { obj._arrayData[i] = Create(objArray[i]); } } else if (o is Dictionary<string, object>) { obj._dictData = new Dictionary<string, JSONObject>(); Dictionary<string, object> dict = o as Dictionary<string, object>; foreach (string key in dict.Keys) { obj._dictData[key] = Create(dict[key]); } } else if (o != null) // o is a scalar { obj._stringData = o.ToString(); } return obj; }
internal void AddFriends(JSONObject[] friends) { foreach (var friend in friends) graphStorage.AddFriendVertex(friend, attributeStorage.CreateVertexAttributes(friend)); }
internal void MakeEgo(JSONObject ego) { graphStorage.MakeEgoVertex(ego, attributeStorage.CreateVertexAttributes(ego)); }
internal void SendEgo(JSONObject ego) { GraphEventArgs evnt = new GraphEventArgs(GraphEventArgs.Types.UserInfoLoaded, ego); DispatchEvent(evnt); }