Exemplo n.º 1
0
		public static RootInfo ParseJson (string jsonString)
		{
			Hyena.Json.Deserializer deserializer =
				new Hyena.Json.Deserializer (jsonString);
			object obj = deserializer.Deserialize ();

			Hyena.Json.JsonObject jsonObj =
				obj as Hyena.Json.JsonObject;
			if (jsonObj == null)
				throw new ArgumentException ("jsonString does not contain a valid RootInfo representation");

			// TODO: Checks
			RootInfo root = new RootInfo ();
			root.ApiVersion = (string) jsonObj ["api-version"];

			object val;
			if (jsonObj.TryGetValue ("user-ref", out val)) {
				Hyena.Json.JsonObject userRefJsonObj = (Hyena.Json.JsonObject) val;

				root.User =
					ResourceReference.ParseJson (userRefJsonObj);
			}

			root.AuthorizeUrl =  (string) jsonObj ["oauth_authorize_url"];
			root.AccessTokenUrl = (string) jsonObj ["oauth_access_token_url"];
			root.RequestTokenUrl = (string) jsonObj ["oauth_request_token_url"];

			return root;
		}
Exemplo n.º 2
0
        public static RootInfo ParseJson(string jsonString)
        {
            Hyena.Json.Deserializer deserializer =
                new Hyena.Json.Deserializer(jsonString);
            object obj = deserializer.Deserialize();

            Hyena.Json.JsonObject jsonObj =
                obj as Hyena.Json.JsonObject;
            if (jsonObj == null)
            {
                throw new ArgumentException("jsonString does not contain a valid RootInfo representation");
            }

            // TODO: Checks
            RootInfo root = new RootInfo();

            root.ApiVersion = (string)jsonObj ["api-version"];

            object val;

            if (jsonObj.TryGetValue("user-ref", out val))
            {
                Hyena.Json.JsonObject userRefJsonObj = (Hyena.Json.JsonObject)val;

                root.User =
                    ResourceReference.ParseJson(userRefJsonObj);
            }

            root.AuthorizeUrl    = (string)jsonObj ["oauth_authorize_url"];
            root.AccessTokenUrl  = (string)jsonObj ["oauth_access_token_url"];
            root.RequestTokenUrl = (string)jsonObj ["oauth_request_token_url"];

            return(root);
        }
Exemplo n.º 3
0
        public static NoteInfo ParseJson(string jsonString)
        {
            Hyena.Json.Deserializer deserializer =
                new Hyena.Json.Deserializer(jsonString);
            object obj = deserializer.Deserialize();

            Hyena.Json.JsonObject jsonObj =
                obj as Hyena.Json.JsonObject;
            return(ParseJson(jsonObj));
        }
Exemplo n.º 4
0
		public static NoteInfo ParseJson (string jsonString)
		{
			Hyena.Json.Deserializer deserializer =
				new Hyena.Json.Deserializer (jsonString);
			object obj = deserializer.Deserialize ();

			Hyena.Json.JsonObject jsonObj =
				obj as Hyena.Json.JsonObject;
			return ParseJson (jsonObj);
		}
Exemplo n.º 5
0
        public static UserInfo ParseJson(string jsonString)
        {
            Hyena.Json.Deserializer deserializer =
                new Hyena.Json.Deserializer(jsonString);
            object obj = deserializer.Deserialize();

            Hyena.Json.JsonObject jsonObj =
                obj as Hyena.Json.JsonObject;
            if (jsonObj == null)
            {
                throw new ArgumentException("jsonString does not contain a valid UserInfo representation");
            }

            // TODO: Checks
            UserInfo user = new UserInfo();

            user.UserName  = (string)jsonObj ["user-name"];
            user.FirstName = (string)jsonObj ["first-name"];
            user.LastName  = (string)jsonObj ["last-name"];

            object val;

            if (jsonObj.TryGetValue("latest-sync-revision", out val))
            {
                user.LatestSyncRevision = (int)val;
            }
            else
            {
                user.LatestSyncRevision = -1;
            }

            if (jsonObj.TryGetValue("current-sync-guid", out val))
            {
                user.CurrentSyncGuid = (string)val;
            }

            Hyena.Json.JsonObject notesRefJsonObj =
                (Hyena.Json.JsonObject)jsonObj ["notes-ref"];
            user.Notes =
                ResourceReference.ParseJson(notesRefJsonObj);

            if (jsonObj.TryGetValue("friends-ref", out val))
            {
                user.Notes =
                    ResourceReference.ParseJson((Hyena.Json.JsonObject)val);
            }

            return(user);
        }
Exemplo n.º 6
0
		public static UserInfo ParseJson (string jsonString)
		{
			Hyena.Json.Deserializer deserializer =
				new Hyena.Json.Deserializer (jsonString);
			object obj = deserializer.Deserialize ();

			Hyena.Json.JsonObject jsonObj =
				obj as Hyena.Json.JsonObject;
			if (jsonObj == null)
				throw new ArgumentException ("jsonString does not contain a valid UserInfo representation");

			// TODO: Checks
			UserInfo user = new UserInfo ();
			user.UserName = (string) jsonObj ["user-name"];
			user.FirstName = (string) jsonObj ["first-name"];
			user.LastName = (string) jsonObj ["last-name"];
			
			object val;
			if (jsonObj.TryGetValue ("latest-sync-revision", out val))
				user.LatestSyncRevision = (int) val;
			else
				user.LatestSyncRevision = -1;
			
			if (jsonObj.TryGetValue ("current-sync-guid", out val))
				user.CurrentSyncGuid = (string) val;

			Hyena.Json.JsonObject notesRefJsonObj =
				(Hyena.Json.JsonObject) jsonObj ["notes-ref"];
			user.Notes =
				ResourceReference.ParseJson (notesRefJsonObj);

			if (jsonObj.TryGetValue ("friends-ref", out val)) {
				user.Notes =
					ResourceReference.ParseJson ((Hyena.Json.JsonObject) val);
			}

			return user;
		}
Exemplo n.º 7
0
        private IList <NoteInfo> ParseJsonNotes(string jsonString, out int?latestSyncRevision)
        {
            Hyena.Json.Deserializer deserializer =
                new Hyena.Json.Deserializer(jsonString);
            object obj = deserializer.Deserialize();

            Hyena.Json.JsonObject jsonObj =
                obj as Hyena.Json.JsonObject;
            Hyena.Json.JsonArray noteArray =
                (Hyena.Json.JsonArray)jsonObj [NotesElementName];

            object val;

            if (jsonObj.TryGetValue(LatestSyncRevisionElementName, out val))
            {
                latestSyncRevision = (int)val;
            }
            else
            {
                latestSyncRevision = null;
            }

            return(ParseJsonNoteArray(noteArray));
        }
Exemplo n.º 8
0
		private IList<NoteInfo> ParseJsonNotes (string jsonString, out int? latestSyncRevision)
		{
			Hyena.Json.Deserializer deserializer =
				new Hyena.Json.Deserializer (jsonString);
			object obj = deserializer.Deserialize ();
			Hyena.Json.JsonObject jsonObj =
				obj as Hyena.Json.JsonObject;
			Hyena.Json.JsonArray noteArray =
				(Hyena.Json.JsonArray) jsonObj [NotesElementName];

			object val;
			if (jsonObj.TryGetValue (LatestSyncRevisionElementName, out val))
				latestSyncRevision = (int) val;
			else
				latestSyncRevision = null;
				
			return ParseJsonNoteArray (noteArray);
		}