private void HandleServerErrors(HttpStatusCode statusCode, string errorDetails)
 {
     if (statusCode == HttpStatusCode.InternalServerError)
     {
         JsonValue errorValue = null;
         JsonValue.TryParse(errorDetails, out errorValue);
         if (errorValue != null && !errorValue.IsNull && errorValue.ContainsName("error"))
         {
             // 04/14/2012 Paul.  The text is in a message property.
             JsonValue errorValue2 = errorValue.GetValue("error");
             string    errorText   = errorValue2.GetValue <string>("message");
             throw new FacebookApiException(errorText, FacebookApiError.Server);
         }
         else if (errorValue != null && !errorValue.IsNull && errorValue.ContainsName("error_msg"))
         {
             string errorText = errorValue.GetValue <string>("error_msg");
             throw new FacebookApiException(errorText, FacebookApiError.Server);
         }
         else
         {
             //throw new FacebookApiException("Something is broken at Facebook. Please see http://developer.facebook.com/ to report the issue.", FacebookApiError.Server);
         }
     }
     else if (statusCode == HttpStatusCode.BadGateway)
     {
         throw new FacebookApiException("Facebook is down or is being upgraded.", FacebookApiError.ServerDown);
     }
     else if (statusCode == HttpStatusCode.ServiceUnavailable)
     {
         throw new FacebookApiException("Facebook is overloaded with requests. Try again later.", FacebookApiError.ServerOverloaded);
     }
 }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Comment comment = null;
			if ( json != null && !json.IsNull )
			{
				comment = new Comment();
				comment.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"     ) : String.Empty;
				comment.Message     = json.ContainsName("message"     ) ? json.GetValue<string>("message") : String.Empty;
				comment.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				comment.From        = mapper.Deserialize<Reference      >(json.GetValue("from" ));
				// 04/12/2012 Paul.  Likes is a connection object, so make sure that this is not the same likes property value. 
				// 04/15/2012 Paul.  Likes can be a number or an array. 
				JsonValue jsonLikes = json.GetValue("likes");
				if ( jsonLikes != null && !jsonLikes.IsNull )
				{
					if ( jsonLikes.IsArray )
					{
						comment.Likes       = mapper.Deserialize<List<Reference>>(jsonLikes);
						comment.LikesCount  = (comment.Likes != null) ? comment.Likes.Count : 0;
					}
					else if ( jsonLikes.IsNumber )
					{
						comment.LikesCount = jsonLikes.GetValue<int>();
					}
				}
			}
			return comment;
		}
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Comment comment = null;

            if (json != null && !json.IsNull)
            {
                comment             = new Comment();
                comment.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                comment.Message     = json.ContainsName("message") ? json.GetValue <string>("message") : String.Empty;
                comment.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                comment.From = mapper.Deserialize <Reference>(json.GetValue("from"));
                // 04/12/2012 Paul.  Likes is a connection object, so make sure that this is not the same likes property value.
                // 04/15/2012 Paul.  Likes can be a number or an array.
                JsonValue jsonLikes = json.GetValue("likes");
                if (jsonLikes != null && !jsonLikes.IsNull)
                {
                    if (jsonLikes.IsArray)
                    {
                        comment.Likes      = mapper.Deserialize <List <Reference> >(jsonLikes);
                        comment.LikesCount = (comment.Likes != null) ? comment.Likes.Count : 0;
                    }
                    else if (jsonLikes.IsNumber)
                    {
                        comment.LikesCount = jsonLikes.GetValue <int>();
                    }
                }
            }
            return(comment);
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            PaginatedResult paginatedResult = this.CreatePaginatedResult();

            paginatedResult.Total = json.GetValue<int>("_total");
            paginatedResult.Start = json.ContainsName("_start") ? json.GetValue<int>("_start") : 0;
            paginatedResult.Count = json.ContainsName("_count") ? json.GetValue<int>("_count") : paginatedResult.Total;            

            return paginatedResult;
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Reference reference = null;
			if ( json != null && !json.IsNull )
			{
				reference = new Reference();
				reference.ID   = json.ContainsName("id"  ) ? json.GetValue<string>("id"  ) : String.Empty;
				reference.Name = json.ContainsName("name") ? json.GetValue<string>("name") : String.Empty;
			}
			return reference;
		}
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Reference reference = null;

            if (json != null && !json.IsNull)
            {
                reference      = new Reference();
                reference.ID   = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                reference.Name = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
            }
            return(reference);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			FamilyMember family = null;
			if ( json != null && !json.IsNull )
			{
				family = new FamilyMember();
				family.ID           = json.ContainsName("id"          ) ? json.GetValue<string>("id"          ) : String.Empty;
				family.Name         = json.ContainsName("name"        ) ? json.GetValue<string>("name"        ) : String.Empty;
				family.Relationship = json.ContainsName("relationship") ? json.GetValue<string>("relationship") : String.Empty;
			}
			return family;
		}
Пример #8
0
 public object Deserialize(JsonValue json, JsonMapper mapper)
 {
     Photo.Image image = null;
     if (json != null && !json.IsNull)
     {
         image        = new Photo.Image();
         image.Source = json.ContainsName("source") ? json.GetValue <string>("source") : String.Empty;
         image.Width  = json.ContainsName("width") ? json.GetValue <int>("width") : 0;
         image.Height = json.ContainsName("height") ? json.GetValue <int>("height") : 0;
     }
     return(image);
 }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			GroupMemberReference group = null;
			if ( json != null && !json.IsNull )
			{
				group = new GroupMemberReference();
				group.ID            = json.ContainsName("id"           ) ? json.GetValue<string>("id"           ) : String.Empty;
				group.Name          = json.ContainsName("name"         ) ? json.GetValue<string>("name"         ) : String.Empty;
				group.Administrator = json.ContainsName("administrator") ? json.GetValue<bool  >("administrator") : false;
			}
			return group;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Photo.Image image = null;
			if ( json != null && !json.IsNull )
			{
				image = new Photo.Image();
				image.Source = json.ContainsName("source") ? json.GetValue<string>("source") : String.Empty;
				image.Width  = json.ContainsName("width" ) ? json.GetValue<int   >("width" ) : 0;
				image.Height = json.ContainsName("height") ? json.GetValue<int   >("height") : 0;
			}
			return image;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			EventInvitee album = null;
			if ( json != null && !json.IsNull )
			{
				album = new EventInvitee();
				album.ID         = json.ContainsName("id"  ) ? json.GetValue<string>("id"  ) : String.Empty;
				album.Name       = json.ContainsName("name") ? json.GetValue<string>("name") : String.Empty;
				album.RsvpStatus = RsvpStatusDeserializer(json.GetValue("rsvp_status"));
			}
			return album;
		}
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            EventInvitee album = null;

            if (json != null && !json.IsNull)
            {
                album            = new EventInvitee();
                album.ID         = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                album.Name       = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                album.RsvpStatus = RsvpStatusDeserializer(json.GetValue("rsvp_status"));
            }
            return(album);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			WorkEntry entry = null;
			if ( json != null && !json.IsNull )
			{
				entry = new WorkEntry();
				entry.StartDate = json.ContainsName("start_date") ? json.GetValue<string>("start_date") : String.Empty;
				entry.EndDate   = json.ContainsName("end_date"  ) ? json.GetValue<string>("end_date"  ) : String.Empty;
				
				entry.Employer  = mapper.Deserialize<Reference>(json.GetValue("employer"));
			}
			return entry;
		}
Пример #14
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            GroupMemberReference group = null;

            if (json != null && !json.IsNull)
            {
                group               = new GroupMemberReference();
                group.ID            = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                group.Name          = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                group.Administrator = json.ContainsName("administrator") ? json.GetValue <bool>("administrator") : false;
            }
            return(group);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			StoryTag video = null;
			if ( json != null && !json.IsNull )
			{
				video = new StoryTag();
				video.ID     = json.ContainsName("id"    ) ? json.GetValue<string>("id"    ) : String.Empty;
				video.Name   = json.ContainsName("name"  ) ? json.GetValue<string>("name"  ) : String.Empty;
				video.Offset = json.ContainsName("offset") ? json.GetValue<int   >("offset") : 0;
				video.Length = json.ContainsName("length") ? json.GetValue<int   >("length") : 0;
			}
			return video;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Account account = null;
			if ( json != null && !json.IsNull )
			{
				account = new Account();
				account.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"          ) : String.Empty;
				account.Name        = json.ContainsName("name"        ) ? json.GetValue<string>("name"        ) : String.Empty;
				account.Category    = json.ContainsName("category"    ) ? json.GetValue<string>("category"    ) : String.Empty;
				account.AccessToken = json.ContainsName("access_token") ? json.GetValue<string>("access_token") : String.Empty;
			}
			return account;
		}
Пример #17
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            FamilyMember family = null;

            if (json != null && !json.IsNull)
            {
                family              = new FamilyMember();
                family.ID           = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                family.Name         = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                family.Relationship = json.ContainsName("relationship") ? json.GetValue <string>("relationship") : String.Empty;
            }
            return(family);
        }
 private static LinkedInDate DeserializeLinkedInDate(JsonValue json)
 {
     if (json != null)
     {
         return new LinkedInDate()
         {
             Year = json.ContainsName("year") ? json.GetValue<int?>("year") : null,
             Month = json.ContainsName("month") ? json.GetValue<int?>("month") : null,
             Day = json.ContainsName("day") ? json.GetValue<int?>("day") : null
         };
     }
     return null;
 }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			StatusPost post = null;
			if ( json != null && !json.IsNull )
			{
				post = new StatusPost();
				post.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id") : String.Empty;
				post.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				post.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				
				post.From        = mapper.Deserialize<Reference>(json.GetValue("from"));
			}
			return post;
		}
Пример #20
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Account account = null;

            if (json != null && !json.IsNull)
            {
                account             = new Account();
                account.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                account.Name        = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                account.Category    = json.ContainsName("category") ? json.GetValue <string>("category") : String.Empty;
                account.AccessToken = json.ContainsName("access_token") ? json.GetValue <string>("access_token") : String.Empty;
            }
            return(account);
        }
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            StoryTag video = null;

            if (json != null && !json.IsNull)
            {
                video        = new StoryTag();
                video.ID     = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                video.Name   = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                video.Offset = json.ContainsName("offset") ? json.GetValue <int>("offset") : 0;
                video.Length = json.ContainsName("length") ? json.GetValue <int>("length") : 0;
            }
            return(video);
        }
        private void HandleClientErrors(HttpResponseMessage <byte[]> response)
        {
            JsonValue errorValue = this.ExtractErrorDetailsFromResponse(response);

            if (errorValue == null)
            {
                return;             // unexpected error body, can't be handled here
            }

            string errorText = null;

            if (errorValue.ContainsName("error"))
            {
                errorText = errorValue.GetValue <string>("error");
            }
            else if (errorValue.ContainsName("errors"))
            {
                JsonValue errorsValue = errorValue.GetValue("errors");
                if (errorsValue.IsArray)
                {
                    errorText = errorsValue.GetValue(0).GetValue <string>("message");
                }
                else if (errorsValue.IsString)
                {
                    errorText = errorsValue.GetValue <string>();
                }
            }
            errorText = errorText ?? response.StatusDescription;

            if (response.StatusCode == HttpStatusCode.Unauthorized)
            {
                throw new TwitterApiException(errorText, TwitterApiError.NotAuthorized);
            }
            else if (response.StatusCode == HttpStatusCode.Forbidden)
            {
                throw new TwitterApiException(errorText, TwitterApiError.OperationNotPermitted);
            }
            else if (response.StatusCode == HttpStatusCode.NotFound)
            {
                throw new TwitterApiException(errorText, TwitterApiError.ResourceNotFound);
            }
            else if (response.StatusCode == HttpStatusCode.NotAcceptable)
            {
                throw new TwitterApiException(errorText, TwitterApiError.InvalidFormat);
            }
            else if (response.StatusCode == (HttpStatusCode)429) // Too Many Requests
            {
                throw new TwitterApiException("The rate limit has been exceeded.", TwitterApiError.RateLimitExceeded);
            }
        }
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            WorkEntry entry = null;

            if (json != null && !json.IsNull)
            {
                entry           = new WorkEntry();
                entry.StartDate = json.ContainsName("start_date") ? json.GetValue <string>("start_date") : String.Empty;
                entry.EndDate   = json.ContainsName("end_date") ? json.GetValue <string>("end_date") : String.Empty;

                entry.Employer = mapper.Deserialize <Reference>(json.GetValue("employer"));
            }
            return(entry);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Invitation invite = null;
			if ( json != null && !json.IsNull )
			{
				invite = new Invitation();
				invite.EventId    = json.ContainsName("id"        ) ? json.GetValue<string>("id"  ) : String.Empty;
				invite.Name       = json.ContainsName("name"      ) ? json.GetValue<string>("name") : String.Empty;
				invite.StartTime  = json.ContainsName("start_time") ? JsonUtils.ToDateTime(json.GetValue<string>("start_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				invite.EndTime    = json.ContainsName("end_time"  ) ? JsonUtils.ToDateTime(json.GetValue<string>("end_time"  ), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				invite.RsvpStatus = RsvpStatusDeserializer(json.GetValue("rsvp_status"));
			}
			return invite;
		}
Пример #25
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Invitation invite = null;

            if (json != null && !json.IsNull)
            {
                invite            = new Invitation();
                invite.EventId    = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                invite.Name       = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                invite.StartTime  = json.ContainsName("start_time") ? JsonUtils.ToDateTime(json.GetValue <string>("start_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                invite.EndTime    = json.ContainsName("end_time") ? JsonUtils.ToDateTime(json.GetValue <string>("end_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                invite.RsvpStatus = RsvpStatusDeserializer(json.GetValue("rsvp_status"));
            }
            return(invite);
        }
Пример #26
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            StatusPost post = null;

            if (json != null && !json.IsNull)
            {
                post             = new StatusPost();
                post.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                post.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                post.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue <string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                post.From = mapper.Deserialize <Reference>(json.GetValue("from"));
            }
            return(post);
        }
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Tag video = null;

            if (json != null && !json.IsNull)
            {
                video             = new Tag();
                video.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                video.Name        = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                video.X           = json.ContainsName("x") ? json.GetValue <int>("x") : 0;
                video.Y           = json.ContainsName("y") ? json.GetValue <int>("y") : 0;
                video.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
            }
            return(video);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Question question = null;
			if ( json != null && !json.IsNull )
			{
				question = new Question();
				question.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"      ) : String.Empty;
				question.Text        = json.ContainsName("question"    ) ? json.GetValue<string>("question") : String.Empty;
				question.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				question.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				question.From        = mapper.Deserialize<Reference           >(json.GetValue("from"   ));
				question.Options     = mapper.Deserialize<List<QuestionOption>>(json.GetValue("options"));
			}
			return question;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			QuestionOption option = null;
			if ( json != null && !json.IsNull )
			{
				option = new QuestionOption();
				option.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"   ) : String.Empty;
				option.Name        = json.ContainsName("name"        ) ? json.GetValue<string>("name" ) : String.Empty;
				option.Votes       = json.ContainsName("votes"       ) ? json.GetValue<int   >("votes") : 0;
				option.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				
				option.From        = mapper.Deserialize<Reference>(json.GetValue("from"  ));
				option.Object      = mapper.Deserialize<Page     >(json.GetValue("object"));
			}
			return option;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			CheckinPost post = null;
			if ( json != null && !json.IsNull )
			{
				post = new CheckinPost();
				post.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id") : String.Empty;
				post.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				post.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				post.From        = mapper.Deserialize<Reference>(json.GetValue("from" ));
				post.Place       = mapper.Deserialize<Page     >(json.GetValue("place"));
				post.Tags        = mapper.Deserialize<List<Tag>>(json.GetValue("tags" ));
			}
			return post;
		}
 public override object Deserialize(JsonValue json, JsonMapper mapper)
 {
     JsonValue peopleJson = json.ContainsName("people") ? json.GetValue("people") : json;
     LinkedInProfiles profiles = (LinkedInProfiles)base.Deserialize(peopleJson, mapper);
     profiles.Profiles = mapper.Deserialize<IList<LinkedInProfile>>(peopleJson);
     return profiles;
 }
Пример #32
0
 private static void handleResponse(String response, YebobHandler handler, ErrorHandler onError)
 {
     if (response == null)
     {
         String msg = "sorry, I can't get the data from server.";
         onError(ERROR.RESPONSE_IS_NONE, msg);
         return;
     }
     try
     {
         JsonValue json = JsonValue.Parse(response);
         if (json.ContainsName("ret"))
         {
             String msg = json.GetValue <String>("msg");
             onError(ERROR.RESPONSE_HAS_ERROR, msg);
         }
         else
         {
             if (handler != null)
             {
                 handler(json);
             }
         }
     }
     catch (Exception e)
     {
         onError(ERROR.RESPONSE_HAS_EXCEPTION, response);
     }
 }
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Question question = null;

            if (json != null && !json.IsNull)
            {
                question             = new Question();
                question.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                question.Text        = json.ContainsName("question") ? json.GetValue <string>("question") : String.Empty;
                question.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                question.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue <string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                question.From    = mapper.Deserialize <Reference>(json.GetValue("from"));
                question.Options = mapper.Deserialize <List <QuestionOption> >(json.GetValue("options"));
            }
            return(question);
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInProfile profile = CreateLinkedInProfile();

            profile.ID = json.GetValue<string>("id");
            profile.FirstName = json.GetValue<string>("firstName");
            profile.LastName = json.GetValue<string>("lastName");
            profile.Headline = json.ContainsName("headline") ? json.GetValue<string>("headline") : "";
            profile.Industry = json.ContainsName("industry") ? json.GetValue<string>("industry") : "";
            profile.PictureUrl = json.ContainsName("pictureUrl") ? json.GetValue<string>("pictureUrl") : null;
            profile.Summary = json.ContainsName("summary") ? json.GetValue<string>("summary") : "";
            profile.PublicProfileUrl = json.ContainsName("publicProfileUrl") ? json.GetValue<string>("publicProfileUrl") : null;
            profile.StandardProfileUrl = GetSiteStandardProfileUrl(json);
            profile.AuthToken = GetAuthToken(json);

            return profile;
        }
        public override object Deserialize(JsonValue json, JsonMapper mapper)
        {
            JsonValue        peopleJson = json.ContainsName("people") ? json.GetValue("people") : json;
            LinkedInProfiles profiles   = (LinkedInProfiles)base.Deserialize(peopleJson, mapper);

            profiles.Profiles = mapper.Deserialize <IList <LinkedInProfile> >(peopleJson);
            return(profiles);
        }
Пример #36
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            QuestionOption option = null;

            if (json != null && !json.IsNull)
            {
                option             = new QuestionOption();
                option.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                option.Name        = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                option.Votes       = json.ContainsName("votes") ? json.GetValue <int>("votes") : 0;
                option.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                option.From   = mapper.Deserialize <Reference>(json.GetValue("from"));
                option.Object = mapper.Deserialize <Page>(json.GetValue("object"));
            }
            return(option);
        }
        public override object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInFullProfile profile = (LinkedInFullProfile)base.Deserialize(json, mapper);

            profile.Associations = json.ContainsName("associations") ? json.GetValue<string>("associations") : "";
            profile.BirthDate = DeserializeLinkedInDate(json.GetValue("dateOfBirth"));
            profile.ConnectionsCount = json.GetValue<int>("numConnections");
            profile.Distance = json.GetValue<int>("distance");
            profile.Educations = DeserializeEducations(json.GetValue("educations"));
            profile.Honors = json.ContainsName("honors") ? json.GetValue<string>("honors") : "";
            profile.ImAccounts = DeserializeImAccounts(json.GetValue("imAccounts"));
            profile.Interests = json.ContainsName("interests") ? json.GetValue<string>("interests") : "";
            profile.IsConnectionsCountCapped = json.GetValue<bool>("numConnectionsCapped");
            JsonValue locationJson = json.GetValue("location");
            profile.CountryCode = locationJson.GetValue("country").GetValue<string>("code");
            profile.Location = locationJson.GetValue<string>("name");
            profile.MainAddress = json.ContainsName("mainAddress") ? json.GetValue<string>("mainAddress") : "";
            profile.PhoneNumbers = DeserializePhoneNumbers(json.GetValue("phoneNumbers"));
            profile.Positions = DeserializePositions(json.GetValue("positions"));
            profile.ProposalComments = json.ContainsName("proposalComments") ? json.GetValue<string>("proposalComments") : "";
            profile.Recommendations = DeserializeRecommendations(json.GetValue("recommendationsReceived"), mapper);
            profile.RecommendersCount = json.ContainsName("numRecommenders") ? json.GetValue<int?>("numRecommenders") : null;
            profile.Skills = DeserializeSkills(json.GetValue("skills"));
            profile.Specialties = json.ContainsName("specialties") ? json.GetValue<string>("specialties") : "";
            profile.TwitterAccounts = DeserializeTwitterAccounts(json.GetValue("twitterAccounts"));
            profile.UrlResources = DeserializeUrlResources(json.GetValue("memberUrlResources"));

            return profile;
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Checkin checkin = null;
			if ( json != null && !json.IsNull )
			{
				checkin = new Checkin();
				checkin.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"     ) : String.Empty;
				checkin.Message     = json.ContainsName("message"     ) ? json.GetValue<string>("message") : String.Empty;
				checkin.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				checkin.From        = mapper.Deserialize<Reference>(json.GetValue("category"   ));
				checkin.Place       = mapper.Deserialize<Page     >(json.GetValue("place"      ));
				checkin.Application = mapper.Deserialize<Reference>(json.GetValue("application"));

				checkin.Likes       = mapper.Deserialize<List<Reference>>(json.GetValue("likes"   ));
				checkin.Comments    = mapper.Deserialize<List<Comment  >>(json.GetValue("comments"));
				checkin.Tags        = mapper.Deserialize<List<Reference>>(json.GetValue("tags"    ));
			}
			return checkin;
		}
Пример #39
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Checkin checkin = null;

            if (json != null && !json.IsNull)
            {
                checkin             = new Checkin();
                checkin.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                checkin.Message     = json.ContainsName("message") ? json.GetValue <string>("message") : String.Empty;
                checkin.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                checkin.From        = mapper.Deserialize <Reference>(json.GetValue("category"));
                checkin.Place       = mapper.Deserialize <Page>(json.GetValue("place"));
                checkin.Application = mapper.Deserialize <Reference>(json.GetValue("application"));

                checkin.Likes    = mapper.Deserialize <List <Reference> >(json.GetValue("likes"));
                checkin.Comments = mapper.Deserialize <List <Comment> >(json.GetValue("comments"));
                checkin.Tags     = mapper.Deserialize <List <Reference> >(json.GetValue("tags"));
            }
            return(checkin);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Album album = null;
			if ( json != null && !json.IsNull )
			{
				album = new Album();
				album.ID           = json.ContainsName("id"          ) ? json.GetValue<string>("id"         ) : String.Empty;
				album.Name         = json.ContainsName("name"        ) ? json.GetValue<string>("name"       ) : String.Empty;
				album.Description  = json.ContainsName("description" ) ? json.GetValue<string>("description") : String.Empty;
				album.Location     = json.ContainsName("location"    ) ? json.GetValue<string>("location"   ) : String.Empty;
				album.Link         = json.ContainsName("link"        ) ? json.GetValue<string>("link"       ) : String.Empty;
				album.CoverPhotoId = json.ContainsName("cover_photo" ) ? json.GetValue<string>("cover_photo") : String.Empty;
				album.Count        = json.ContainsName("count"       ) ? json.GetValue<int   >("count"      ) : 0;
				album.CanUpload    = json.ContainsName("can_upload"  ) ? json.GetValue<bool  >("can_upload" ) : false;
				album.CreatedTime  = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				album.UpdatedTime  = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				album.From         = mapper.Deserialize<Reference>(json.GetValue("from"));
				album.Type         = TypeDeserializer   (json.GetValue("type"   ));
				album.Privacy      = PrivacyDeserializer(json.GetValue("privacy"));
			}
			return album;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			EducationEntry entry = null;
			if ( json != null && !json.IsNull )
			{
				entry = new EducationEntry();
				entry.Type          = json.ContainsName("type"  ) ? json.GetValue<string>("type") : String.Empty;

				entry.School        = mapper.Deserialize<Reference      >(json.GetValue("school"       ));
				entry.Year          = mapper.Deserialize<Reference      >(json.GetValue("year"         ));
				entry.Concentration = mapper.Deserialize<List<Reference>>(json.GetValue("concentration"));
			}
			return entry;
		}
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Album album = null;

            if (json != null && !json.IsNull)
            {
                album              = new Album();
                album.ID           = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                album.Name         = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                album.Description  = json.ContainsName("description") ? json.GetValue <string>("description") : String.Empty;
                album.Location     = json.ContainsName("location") ? json.GetValue <string>("location") : String.Empty;
                album.Link         = json.ContainsName("link") ? json.GetValue <string>("link") : String.Empty;
                album.CoverPhotoId = json.ContainsName("cover_photo") ? json.GetValue <string>("cover_photo") : String.Empty;
                album.Count        = json.ContainsName("count") ? json.GetValue <int>("count") : 0;
                album.CanUpload    = json.ContainsName("can_upload") ? json.GetValue <bool>("can_upload") : false;
                album.CreatedTime  = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                album.UpdatedTime  = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue <string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                album.From    = mapper.Deserialize <Reference>(json.GetValue("from"));
                album.Type    = TypeDeserializer(json.GetValue("type"));
                album.Privacy = PrivacyDeserializer(json.GetValue("privacy"));
            }
            return(album);
        }
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            EducationEntry entry = null;

            if (json != null && !json.IsNull)
            {
                entry      = new EducationEntry();
                entry.Type = json.ContainsName("type") ? json.GetValue <string>("type") : String.Empty;

                entry.School        = mapper.Deserialize <Reference>(json.GetValue("school"));
                entry.Year          = mapper.Deserialize <Reference>(json.GetValue("year"));
                entry.Concentration = mapper.Deserialize <List <Reference> >(json.GetValue("concentration"));
            }
            return(entry);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Video video = null;
			if ( json != null && !json.IsNull )
			{
				video = new Video();
				video.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"         ) : String.Empty;
				video.Name        = json.ContainsName("name"        ) ? json.GetValue<string>("name"       ) : String.Empty;
				video.Description = json.ContainsName("description" ) ? json.GetValue<string>("description") : String.Empty;
				video.Picture     = json.ContainsName("picture"     ) ? json.GetValue<string>("picture"    ) : String.Empty;
				video.EmbedHtml   = json.ContainsName("embed_html"  ) ? json.GetValue<string>("embed_html" ) : String.Empty;
				video.Icon        = json.ContainsName("icon"        ) ? json.GetValue<string>("icon"       ) : String.Empty;
				video.Source      = json.ContainsName("source"      ) ? json.GetValue<string>("source"     ) : String.Empty;
				video.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				video.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				
				video.From        = mapper.Deserialize<Reference    >(json.GetValue("from"    ));
				video.Tags        = mapper.Deserialize<List<Tag    >>(json.GetValue("tags"    ));
				video.Comments    = mapper.Deserialize<List<Comment>>(json.GetValue("comments"));
			}
			return video;
		}
Пример #45
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Video video = null;

            if (json != null && !json.IsNull)
            {
                video             = new Video();
                video.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                video.Name        = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                video.Description = json.ContainsName("description") ? json.GetValue <string>("description") : String.Empty;
                video.Picture     = json.ContainsName("picture") ? json.GetValue <string>("picture") : String.Empty;
                video.EmbedHtml   = json.ContainsName("embed_html") ? json.GetValue <string>("embed_html") : String.Empty;
                video.Icon        = json.ContainsName("icon") ? json.GetValue <string>("icon") : String.Empty;
                video.Source      = json.ContainsName("source") ? json.GetValue <string>("source") : String.Empty;
                video.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                video.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue <string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                video.From     = mapper.Deserialize <Reference>(json.GetValue("from"));
                video.Tags     = mapper.Deserialize <List <Tag> >(json.GetValue("tags"));
                video.Comments = mapper.Deserialize <List <Comment> >(json.GetValue("comments"));
            }
            return(video);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Location location  = null;
			if ( json != null && !json.IsNull )
			{
				location = new Location();
				location.Latitude  = json.ContainsName("latitude" ) ? json.GetValue<double>("latitude" ) : 0.0;
				location.Longitude = json.ContainsName("longitude") ? json.GetValue<double>("longitude") : 0.0;
				location.Street    = json.ContainsName("street"   ) ? json.GetValue<string>("street"   ) : String.Empty;
				location.City      = json.ContainsName("city"     ) ? json.GetValue<string>("city"     ) : String.Empty;
				location.State     = json.ContainsName("state"    ) ? json.GetValue<string>("state"    ) : String.Empty;
				location.Country   = json.ContainsName("country"  ) ? json.GetValue<string>("country"  ) : String.Empty;
				location.Zip       = json.ContainsName("zip"      ) ? json.GetValue<string>("zip"      ) : String.Empty;
			}
			return location;
		}
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Location location = null;

            if (json != null && !json.IsNull)
            {
                location           = new Location();
                location.Latitude  = json.ContainsName("latitude") ? json.GetValue <double>("latitude") : 0.0;
                location.Longitude = json.ContainsName("longitude") ? json.GetValue <double>("longitude") : 0.0;
                location.Street    = json.ContainsName("street") ? json.GetValue <string>("street") : String.Empty;
                location.City      = json.ContainsName("city") ? json.GetValue <string>("city") : String.Empty;
                location.State     = json.ContainsName("state") ? json.GetValue <string>("state") : String.Empty;
                location.Country   = json.ContainsName("country") ? json.GetValue <string>("country") : String.Empty;
                location.Zip       = json.ContainsName("zip") ? json.GetValue <string>("zip") : String.Empty;
            }
            return(location);
        }
        private string GetAuthToken(JsonValue json)
        {
            JsonValue apiStandardProfileJson = json.GetValue("apiStandardProfileRequest");

            if (apiStandardProfileJson != null)
            {
                JsonValue headerValues = apiStandardProfileJson.ContainsName("headers") ? apiStandardProfileJson.GetValue("headers").GetValue("values") : null;
                if (headerValues != null)
                {
                    foreach (JsonValue headerJson in headerValues.GetValues())
                    {
                        if (headerJson.GetValue <string>("name").Equals(AuthTokenHeaderName))
                        {
                            return(headerJson.GetValue <string>("value"));
                        }
                    }
                }
            }
            return(null);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			GroupMembership group = null;
			if ( json != null && !json.IsNull )
			{
				group = new GroupMembership();
				group.ID            = json.ContainsName("id"            ) ? json.GetValue<string>("id"            ) : String.Empty;
				group.Name          = json.ContainsName("name"          ) ? json.GetValue<string>("name"          ) : String.Empty;
				group.Version       = json.ContainsName("version"       ) ? json.GetValue<int   >("version"       ) : 0;
				group.BookmarkOrder = json.ContainsName("bookmark_order") ? json.GetValue<int   >("bookmark_order") : 0;
				group.Administrator = json.ContainsName("administrator" ) ? json.GetValue<bool  >("administrator" ) : false;
				group.Unread        = json.ContainsName("unread"        ) ? json.GetValue<int   >("unread"        ) : 0;
			}
			return group;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Group group = null;
			if ( json != null && !json.IsNull )
			{
				group = new Group();
				group.ID           = json.ContainsName("id"          ) ? json.GetValue<string>("id"         ) : String.Empty;
				group.Version      = json.ContainsName("version"     ) ? json.GetValue<int   >("version"    ) : 0;
				group.Icon         = json.ContainsName("icon"        ) ? json.GetValue<string>("icon"       ) : String.Empty;
				group.Name         = json.ContainsName("name"        ) ? json.GetValue<string>("name"       ) : String.Empty;
				group.Description  = json.ContainsName("description" ) ? json.GetValue<string>("description") : String.Empty;
				group.Link         = json.ContainsName("link"        ) ? json.GetValue<string>("link"       ) : String.Empty;
				group.UpdatedTime  = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				group.Owner        = mapper.Deserialize<Reference>(json.GetValue("owner"  ));
				group.Privacy      = PrivacyDeserializer(json.GetValue("privacy"));
			}
			return group;
		}
        public override object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInFullProfile profile = (LinkedInFullProfile)base.Deserialize(json, mapper);

            profile.Associations = json.ContainsName("associations") ? json.GetValue<string>("associations") : "";
            profile.BirthDate = DeserializeLinkedInDate(json.GetValue("dateOfBirth"));
            profile.ConnectionsCount = json.GetValue<int>("numConnections");
            profile.Distance = json.GetValue<int>("distance");
            profile.Educations = DeserializeEducations(json.GetValue("educations"));
            profile.Honors = json.ContainsName("honors") ? json.GetValue<string>("honors") : "";
            profile.ImAccounts = DeserializeImAccounts(json.GetValue("imAccounts"));
            profile.Interests = json.ContainsName("interests") ? json.GetValue<string>("interests") : "";
            profile.IsConnectionsCountCapped = json.GetValue<bool>("numConnectionsCapped");
            JsonValue locationJson = json.GetValue("location");
            profile.CountryCode = locationJson.GetValue("country").GetValue<string>("code");
            profile.Location = locationJson.GetValue<string>("name");
            profile.MainAddress = json.ContainsName("mainAddress") ? json.GetValue<string>("mainAddress") : "";
            profile.PhoneNumbers = DeserializePhoneNumbers(json.GetValue("phoneNumbers"));
            profile.Positions = DeserializePositions(json.GetValue("positions"));
            profile.ProposalComments = json.ContainsName("proposalComments") ? json.GetValue<string>("proposalComments") : "";
            profile.Recommendations = DeserializeRecommendations(json.GetValue("recommendationsReceived"), mapper);
            profile.RecommendersCount = json.ContainsName("numRecommenders") ? json.GetValue<int?>("numRecommenders") : null;
            
            profile.Specialties = json.ContainsName("specialties") ? json.GetValue<string>("specialties") : "";
            profile.TwitterAccounts = DeserializeTwitterAccounts(json.GetValue("twitterAccounts"));
            profile.UrlResources = DeserializeUrlResources(json.GetValue("memberUrlResources"));
            // ***********
            // added or updated 9/15/2012 James Fleming
            // publications,patents,courses,languages,volunteer
            profile.Certifications = DeserializeCertifications(json.GetValue("certifications"));
            profile.Skills = DeserializeSkills(json.GetValue("skills"));
            profile.Publications = DeserializePublications(json.GetValue("publications"));
           
            profile.Courses = DeserializeCourses(json.GetValue("courses"));
            profile.Languages = DeserializeLanguages(json.GetValue("languages"));
            // todo: add method for deserializing the attributes below.
            // profile.Patents = DeserializePatents(json.GetValue("patents"));
            // profile.VolunteerExperiences = DeserializeVolunteerExperiencess(json.GetValue("volunteer"));


            // ***********
            return profile;
        }
Пример #52
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            GroupMembership group = null;

            if (json != null && !json.IsNull)
            {
                group               = new GroupMembership();
                group.ID            = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                group.Name          = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                group.Version       = json.ContainsName("version") ? json.GetValue <int>("version") : 0;
                group.BookmarkOrder = json.ContainsName("bookmark_order") ? json.GetValue <int>("bookmark_order") : 0;
                group.Administrator = json.ContainsName("administrator") ? json.GetValue <bool>("administrator") : false;
                group.Unread        = json.ContainsName("unread") ? json.GetValue <int>("unread") : 0;
            }
            return(group);
        }
Пример #53
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Group group = null;

            if (json != null && !json.IsNull)
            {
                group             = new Group();
                group.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                group.Version     = json.ContainsName("version") ? json.GetValue <int>("version") : 0;
                group.Icon        = json.ContainsName("icon") ? json.GetValue <string>("icon") : String.Empty;
                group.Name        = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                group.Description = json.ContainsName("description") ? json.GetValue <string>("description") : String.Empty;
                group.Link        = json.ContainsName("link") ? json.GetValue <string>("link") : String.Empty;
                group.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue <string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                group.Owner   = mapper.Deserialize <Reference>(json.GetValue("owner"));
                group.Privacy = PrivacyDeserializer(json.GetValue("privacy"));
            }
            return(group);
        }
Пример #54
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Post post = null;

            if (json != null && !json.IsNull)
            {
                post             = new Post();
                post.ID          = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty;
                post.Message     = json.ContainsName("message") ? json.GetValue <string>("message") : String.Empty;
                post.Caption     = json.ContainsName("caption") ? json.GetValue <string>("caption") : String.Empty;
                post.Picture     = json.ContainsName("picture") ? json.GetValue <string>("picture") : String.Empty;
                post.Link        = json.ContainsName("link") ? json.GetValue <string>("link") : String.Empty;
                post.Name        = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty;
                post.Description = json.ContainsName("description") ? json.GetValue <string>("description") : String.Empty;
                post.Icon        = json.ContainsName("icon") ? json.GetValue <string>("icon") : String.Empty;
                post.Story       = json.ContainsName("story") ? json.GetValue <string>("story") : String.Empty;
                post.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue <string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
                post.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue <string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

                // 04/15/2012 Paul.  Shares is not a simple integer.  It contains a count node.
                if (json.ContainsName("shares"))
                {
                    JsonValue jsonShares = json.GetValue("shares");
                    post.SharesCount = jsonShares.ContainsName("count") ? jsonShares.GetValue <int>("count") : 0;
                }

                post.Type        = TypeDeserializer(json.GetValue("type"));
                post.From        = mapper.Deserialize <Reference>(json.GetValue("from"));
                post.Application = mapper.Deserialize <Reference>(json.GetValue("application"));
                post.To          = mapper.Deserialize <List <Reference>                >(json.GetValue("to"));
                post.Likes       = mapper.Deserialize <List <Reference>                >(json.GetValue("likes"));
                post.Comments    = mapper.Deserialize <List <Comment>                >(json.GetValue("comments"));
                post.StoryTags   = mapper.Deserialize <Dictionary <int, List <StoryTag> > >(json.GetValue("story_tags"));

                post.LikeCount    = (post.Likes != null) ? post.Likes.Count    : 0;
                post.CommentCount = (post.Comments != null) ? post.Comments.Count : 0;
            }
            return(post);
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Event evt = null;
			if ( json != null && !json.IsNull )
			{
				evt = new Event();
				evt.ID           = json.ContainsName("id"          ) ? json.GetValue<string>("id"         ) : String.Empty;
				evt.Name         = json.ContainsName("name"        ) ? json.GetValue<string>("name"       ) : String.Empty;
				evt.Description  = json.ContainsName("description" ) ? json.GetValue<string>("description") : String.Empty;
				evt.Location     = json.ContainsName("location"    ) ? json.GetValue<string>("location"   ) : String.Empty;
				// 04/15/2012 Paul.  Facebook uses ISO-8601 formatted date/time "yyyy-MM-ddTHH:mm:ss". 
				evt.StartTime    = json.ContainsName("start_time"  ) ? JsonUtils.ToDateTime(json.GetValue<string>("start_time"  ), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				evt.EndTime      = json.ContainsName("end_time"    ) ? JsonUtils.ToDateTime(json.GetValue<string>("end_time"    ), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				evt.UpdatedTime  = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				evt.Owner        = mapper.Deserialize<Reference>(json.GetValue("owner"));
				evt.Venue        = mapper.Deserialize<Location >(json.GetValue("venue"));
				evt.Privacy      = PrivacyDeserializer(json.GetValue("privacy"));
			}
			return evt;
		}
        private void HandleClientErrors(HttpResponseMessage <byte[]> response)
        {
            JsonValue errorValue = this.ExtractErrorDetailsFromResponse(response);

            if (errorValue == null)
            {
                return;             // unexpected error body, can't be handled here
            }
            string errorText = errorValue.ContainsName("error")
                ? errorValue.GetValue <string>("error")
                : response.StatusDescription;

            switch (response.StatusCode)
            {
            case HttpStatusCode.BadRequest:
                throw new DropboxApiException(errorText, DropboxApiError.BadParameter);

            case HttpStatusCode.Unauthorized:
                throw new DropboxApiException(errorText, DropboxApiError.NotAuthorized);

            case HttpStatusCode.Forbidden:
                throw new DropboxApiException(errorText, DropboxApiError.OperationNotPermitted);

            case HttpStatusCode.NotFound:
                throw new DropboxApiException(errorText, DropboxApiError.PathNotFound);

            case HttpStatusCode.NotAcceptable:
                throw new DropboxApiException(errorText, DropboxApiError.TooManyEntries);

            case HttpStatusCode.LengthRequired:
                throw new DropboxApiException(errorText, DropboxApiError.ChunkedEncodingNotSupported);

            case HttpStatusCode.UnsupportedMediaType:
                throw new DropboxApiException(errorText, DropboxApiError.ThumbnailNotSupported);
            }
        }
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			FacebookProfile profile = null;
			if ( json != null && !json.IsNull )
			{
				profile = new FacebookProfile();
				// 04/14/2012 Paul.  Should not have both id and uid. 
				profile.ID                 = json.ContainsName("id"                 ) ? json.GetValue<string>("id"                 ) : String.Empty;
				profile.ID                 = json.ContainsName("uid"                ) ? json.GetValue<string>("uid"                ) : profile.ID;
				profile.Username           = json.ContainsName("username"           ) ? json.GetValue<string>("username"           ) : String.Empty;
				profile.Name               = json.ContainsName("name"               ) ? json.GetValue<string>("name"               ) : String.Empty;
				profile.FirstName          = json.ContainsName("first_name"         ) ? json.GetValue<string>("first_name"         ) : String.Empty;
				profile.LastName           = json.ContainsName("last_name"          ) ? json.GetValue<string>("last_name"          ) : String.Empty;
				profile.Gender             = json.ContainsName("gender"             ) ? json.GetValue<string>("gender"             ) : String.Empty;
				profile.Locale             = json.ContainsName("locate"             ) ? json.GetValue<string>("locate"             ) : String.Empty;
				profile.MiddleName         = json.ContainsName("middle_name"        ) ? json.GetValue<string>("middle_name"        ) : String.Empty;
				// 04/14/2012 Paul.  Should not have both email and contact_email. 
				profile.Email              = json.ContainsName("email"              ) ? json.GetValue<string>("email"              ) : String.Empty;
				profile.Email              = json.ContainsName("contact_email"      ) ? json.GetValue<string>("contact_email"      ) : profile.Email;
				profile.Link               = json.ContainsName("link"               ) ? json.GetValue<string>("link"               ) : String.Empty;
				profile.ThirdPartyId       = json.ContainsName("third_party_id"     ) ? json.GetValue<string>("third_party_id"     ) : String.Empty;
				profile.Timezone           = json.ContainsName("timezone"           ) ? json.GetValue<int   >("timezone"           ) : 0;
				profile.Verified           = json.ContainsName("verified"           ) ? json.GetValue<bool  >("verified"           ) : false;
				profile.About              = json.ContainsName("about"              ) ? json.GetValue<string>("about"              ) : String.Empty;
				profile.About              = json.ContainsName("about_me"           ) ? json.GetValue<string>("about_me"           ) : profile.About;
				profile.Bio                = json.ContainsName("bio"                ) ? json.GetValue<string>("bio"                ) : String.Empty;
				profile.Religion           = json.ContainsName("religion"           ) ? json.GetValue<string>("religion"           ) : String.Empty;
				profile.Political          = json.ContainsName("political"          ) ? json.GetValue<string>("political"          ) : String.Empty;
				profile.Quotes             = json.ContainsName("quotes"             ) ? json.GetValue<string>("quotes"             ) : String.Empty;
				profile.RelationshipStatus = json.ContainsName("relationship_status") ? json.GetValue<string>("relationship_status") : String.Empty;
				profile.Website            = json.ContainsName("website"            ) ? json.GetValue<string>("website"            ) : String.Empty;
				// http://developers.facebook.com/docs/reference/fql/user/
				// The birthday of the user being queried. The format of this date varies based on the user's locale.
				profile.Birthday           = json.ContainsName("birthday"           ) ? JsonUtils.ToDateTime(json.GetValue<string>("birthday"     ), "MM/dd/yyyy"                  ) : DateTime.MinValue;
				// The birthday of the user being queried in MM/DD/YYYY format.
				profile.Birthday           = json.ContainsName("birthday_date"      ) ? JsonUtils.ToDateTime(json.GetValue<string>("birthday_date"), "MM/dd/yyyy"                  ) : profile.Birthday;
				profile.UpdatedTime        = json.ContainsName("updated_time"       ) ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time" ), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				
				profile.Location            = mapper.Deserialize<Reference           >(json.GetValue("location"            ));
				profile.Hometown            = mapper.Deserialize<Reference           >(json.GetValue("hometown"            ));
				if ( json.ContainsName("hometown_location") )
					profile.Hometown = mapper.Deserialize<Reference>(json.GetValue("hometown_location"));
				profile.SignificantOther    = mapper.Deserialize<Reference           >(json.GetValue("significant_other"   ));
				profile.Work                = mapper.Deserialize<List<WorkEntry     >>(json.GetValue("work"                ));
				profile.Education           = mapper.Deserialize<List<EducationEntry>>(json.GetValue("education"           ));
				profile.InterestedIn        = mapper.Deserialize<List<String        >>(json.GetValue("interested_in"       ));
				profile.InspirationalPeople = mapper.Deserialize<List<Reference     >>(json.GetValue("inspirational_people"));
				profile.Languages           = mapper.Deserialize<List<Reference     >>(json.GetValue("languages"           ));
				profile.Sports              = mapper.Deserialize<List<Reference     >>(json.GetValue("sports"              ));
				profile.FavoriteTeams       = mapper.Deserialize<List<Reference     >>(json.GetValue("favorite_teams"      ));
				profile.FavoriteAtheletes   = mapper.Deserialize<List<Reference     >>(json.GetValue("favorite_athletes"   ));
			}
			return profile;
		}
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Post post = null;
			if ( json != null && !json.IsNull )
			{
				post = new Post();
				post.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"         ) : String.Empty;
				post.Message     = json.ContainsName("message"     ) ? json.GetValue<string>("message"    ) : String.Empty;
				post.Caption     = json.ContainsName("caption"     ) ? json.GetValue<string>("caption"    ) : String.Empty;
				post.Picture     = json.ContainsName("picture"     ) ? json.GetValue<string>("picture"    ) : String.Empty;
				post.Link        = json.ContainsName("link"        ) ? json.GetValue<string>("link"       ) : String.Empty;
				post.Name        = json.ContainsName("name"        ) ? json.GetValue<string>("name"       ) : String.Empty;
				post.Description = json.ContainsName("description" ) ? json.GetValue<string>("description") : String.Empty;
				post.Icon        = json.ContainsName("icon"        ) ? json.GetValue<string>("icon"       ) : String.Empty;
				post.Story       = json.ContainsName("story"       ) ? json.GetValue<string>("story"      ) : String.Empty;
				post.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				post.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				
				// 04/15/2012 Paul.  Shares is not a simple integer.  It contains a count node. 
				if ( json.ContainsName("shares") )
				{
					JsonValue jsonShares = json.GetValue("shares");
					post.SharesCount = jsonShares.ContainsName("count") ? jsonShares.GetValue<int>("count") : 0;
				}
				
				post.Type        = TypeDeserializer(json.GetValue("type"));
				post.From        = mapper.Deserialize<Reference                      >(json.GetValue("from"       ));
				post.Application = mapper.Deserialize<Reference                      >(json.GetValue("application"));
				post.To          = mapper.Deserialize<List<Reference>                >(json.GetValue("to"         ));
				post.Likes       = mapper.Deserialize<List<Reference>                >(json.GetValue("likes"      ));
				post.Comments    = mapper.Deserialize<List<Comment  >                >(json.GetValue("comments"   ));
				post.StoryTags   = mapper.Deserialize<Dictionary<int, List<StoryTag>>>(json.GetValue("story_tags" ));
				
				post.LikeCount    = (post.Likes    != null ) ? post.Likes.Count    : 0;
				post.CommentCount = (post.Comments != null ) ? post.Comments.Count : 0;
			}
			return post;
		}
Пример #59
0
 private AccessGrant ExtractAccessGrant(JsonValue response)
 {
     string accessToken = response.GetValue<string>("access_token");
     string scope = response.ContainsName("scope") ? response.GetValue<string>("scope") : null;
     string refreshToken = response.ContainsName("refresh_token") ? response.GetValue<string>("refresh_token") : null;
     int? expiresIn = null;
     if (response.ContainsName("expires_in"))
     {
         try { expiresIn = response.GetValue<int?>("expires_in"); } catch (JsonException) { }
     }
     return this.CreateAccessGrant(accessToken, scope, refreshToken, expiresIn, response);
 }