Beispiel #1
0
 static void RecursiveDictionaryToString(FacebookObject obj, StringBuilder sb, int level)
 {
     foreach (var kvp in obj.Dictionary)
     {
         sb.Append(' ', level * 2);
         sb.Append(kvp.Key);
         sb.Append(" => ");
         RecursiveObjectToString(kvp.Value, sb, level);
         sb.AppendLine();
     }
 }
Beispiel #2
0
 static void RecursiveObjectToString(FacebookObject obj, StringBuilder sb, int level)
 {
     if (obj.IsDictionary)
     {
         sb.AppendLine();
         RecursiveDictionaryToString(obj, sb, level + 1);
     }
     else if (obj.IsArray)
     {
         foreach (FacebookObject o in obj.Array)
         {
             RecursiveObjectToString(o, sb, level);
             sb.AppendLine();
         }
     }
     else // some sort of scalar value
     {
         sb.Append(obj.String);
     }
 }
Beispiel #3
0
        static FacebookObject Create(object o)
        {
            FacebookObject obj = new FacebookObject();
            if (o is object[])
            {
                var objArray = o as object[];
                obj._arrayData = new FacebookObject[objArray.Length];
                for (var 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, FacebookObject>();
                var dict = o as Dictionary<string, object>;
                foreach (var key in dict.Keys)
                {
                    obj._dictData[key] = Create(dict[key]);
                }
            }
            else if (o != null) // o is a scalar
            {
                obj._stringData = o.ToString();
            }

            return obj;
        }