Example #1
0
 internal void AddFriends(string userId, JSONObject[] friendsDict)
 {
     foreach (var subFriend in friendsDict) {
         graphStorage.AddEdge(userId, subFriend.String);
         Debug.WriteLine("Mutual: " + subFriend.ToDisplayableString());
     }
 }
Example #2
0
 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);
        }
Example #4
0
 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;
 }
Example #5
0
 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;
 }
Example #6
0
 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);
 }
Example #7
0
 internal void AddFriendVertex(JSONObject friend, AttributesDictionary<String> attributes)
 {
     vertices.Add(makeVertex(friend, attributes, "Friend"));
 }
Example #8
0
 internal void MakeEgoVertex(JSONObject ego, AttributesDictionary<String> attributes)
 {
     egoVertex = makeVertex(ego, attributes, "Ego");
     includeEgo = true;
 }
Example #9
0
 public GraphEventArgs(Types type, JSONObject data = null)
 {
     Type = type;
     JData = data;
 }
Example #10
0
 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();
     }
 }
Example #11
0
 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);
     }
 }
Example #12
0
        /// <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;
        }
Example #13
0
 internal void AddFriends(JSONObject[] friends)
 {
     foreach (var friend in friends)
         graphStorage.AddFriendVertex(friend, attributeStorage.CreateVertexAttributes(friend));
 }
Example #14
0
 internal void MakeEgo(JSONObject ego)
 {
     graphStorage.MakeEgoVertex(ego, attributeStorage.CreateVertexAttributes(ego));
 }
Example #15
0
 internal void SendEgo(JSONObject ego)
 {
     GraphEventArgs evnt = new GraphEventArgs(GraphEventArgs.Types.UserInfoLoaded, ego);
     DispatchEvent(evnt);
 }