Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
删除冗余代码
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed May 12, 2020
1 parent 69b6e65 commit 6a4aad4
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 159 deletions.
15 changes: 0 additions & 15 deletions PixivFSUWP/Data/CurrentUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ public class CurrentUser
public string Avatar50 { get; set; }
public string Avatar170 { get; set; }

public static CurrentUser FromJsonValue(JsonObject Source)
{
CurrentUser toret = new CurrentUser();
toret.ID = Convert.ToInt32(Source["id"].TryGetString());
toret.Username = Source["name"].TryGetString();
toret.UserAccount = Source["account"].TryGetString();
toret.Email = Source["mail_address"].TryGetString();
toret.IsMailAuthorized = Source["is_mail_authorized"].GetBoolean();
toret.IsPremium = Source["is_premium"].GetBoolean();
toret.Avatar16 = Source["profile_image_urls"].GetObject()["px_16x16"].TryGetString();
toret.Avatar50 = Source["profile_image_urls"].GetObject()["px_50x50"].TryGetString();
toret.Avatar170 = Source["profile_image_urls"].GetObject()["px_170x170"].TryGetString();
return toret;
}

public static CurrentUser FromObject(PixivCS.Objects.ResponseUser Source)
{
CurrentUser toret = new CurrentUser();
Expand Down
29 changes: 0 additions & 29 deletions PixivFSUWP/Data/IllustCommentItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,6 @@ public class IllustCommentItem
public string AvatarUrl { get; set; }
public int ParentCommentID { get; set; }

public static IllustCommentItem FromJsonValue(JsonObject Source)
{
IllustCommentItem toret = new IllustCommentItem();
toret.ID = (int)Source["id"].GetNumber();
toret.Comment = Source["comment"].TryGetString();
toret.DateTime = Source["date"].TryGetString();
toret.UserName = Source["user"].GetObject()["name"].TryGetString();
toret.UserAccount = Source["user"].GetObject()["account"].TryGetString();
toret.AvatarUrl = Source["user"].GetObject()["profile_image_urls"].GetObject()["medium"].TryGetString();
string parent;
try
{
parent = Source["parent_comment"].ToString();
}
catch
{
parent = "{}";
}
if (parent != "{}")
{
//有父级评论
toret.ParentCommentID = (int)Source["parent_comment"].GetObject()["id"].GetNumber();
}
else
{
toret.ParentCommentID = -1;
}
return toret;
}
public static IllustCommentItem FromObject(PixivCS.Objects.Comment Source)
{
IllustCommentItem toret = new IllustCommentItem();
Expand Down
41 changes: 0 additions & 41 deletions PixivFSUWP/Data/IllustDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,6 @@ public class IllustDetail
public int TotalComments { get; set; }
public bool IsBookmarked { get; set; }

public static IllustDetail FromJsonValue(JsonObject Source)
{
IllustDetail toret = new IllustDetail();
toret.IllustID = (int)Source["illust"].GetObject()["id"].GetNumber();
toret.Title = Source["illust"].GetObject()["title"].TryGetString();
toret.Type = Source["illust"].GetObject()["type"].TryGetString();
toret.Caption = Source["illust"].GetObject()["caption"].TryGetString();
toret.AuthorID = (int)Source["illust"].GetObject()["user"].GetObject()["id"].GetNumber();
toret.Author = Source["illust"].GetObject()["user"].GetObject()["name"].TryGetString();
toret.AuthorAccount = Source["illust"].GetObject()["user"].GetObject()["account"].TryGetString();
toret.AuthorAvatarUrl = Source["illust"].GetObject()["user"].GetObject()["profile_image_urls"].GetObject()["medium"].TryGetString();
toret.IsUserFollowed = Source["illust"].GetObject()["user"].GetObject()["is_followed"].GetBoolean();
var tags = Source["illust"].GetObject()["tags"].GetArray();
toret.Tags = new List<string>();
foreach (var tag in tags)
toret.Tags.Add(tag.GetObject()["name"].TryGetString());
var tools = Source["illust"].GetObject()["tools"].GetArray();
toret.Tools = new List<string>();
foreach (var tool in tools)
toret.Tools.Add(tool.TryGetString());
toret.CreateDate = Source["illust"].GetObject()["create_date"].TryGetString();
toret.MediumUrl = Source["illust"].GetObject()["image_urls"].GetObject()["square_medium"].TryGetString();
var pgCount = (int)Source["illust"].GetObject()["page_count"].GetNumber();
toret.OriginalUrls = new List<string>();
if (pgCount == 1) toret.OriginalUrls.Add(Source["illust"].GetObject()["meta_single_page"].GetObject()["original_image_url"].TryGetString());
else
{
var pages = Source["illust"].GetObject()["meta_pages"].GetArray();
foreach (var page in pages)
toret.OriginalUrls.Add(page.GetObject()["image_urls"].GetObject()["original"].TryGetString());
}
toret.Width = (int)Source["illust"].GetObject()["width"].GetNumber();
toret.Height = (int)Source["illust"].GetObject()["height"].GetNumber();
toret.SanityLevel = (int)Source["illust"].GetObject()["sanity_level"].GetNumber();
toret.TotalView = (int)Source["illust"].GetObject()["total_view"].GetNumber();
toret.TotalBookmarks = (int)Source["illust"].GetObject()["total_bookmarks"].GetNumber();
toret.IsBookmarked = Source["illust"].GetObject()["is_bookmarked"].GetBoolean();
toret.TotalComments = (int)Source["illust"].GetObject()["total_comments"].GetNumber();
return toret;
}

public static IllustDetail FromObject(PixivCS.Objects.IllustDetail Source)
{
IllustDetail toret = new IllustDetail();
Expand Down
59 changes: 0 additions & 59 deletions PixivFSUWP/Data/UserDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,65 +60,6 @@ public class UserDetail
public string WorkspaceComment { get; set; }
public string WorkspaceImageUrl { get; set; }

public static UserDetail FromJsomValue(JsonObject Source)
{
UserDetail toret = new UserDetail();
var user = Source["user"].GetObject();
toret.ID = (int)user["id"].GetNumber();
toret.Name = user["name"].TryGetString();
toret.Account = user["account"].TryGetString();
toret.AvatarUrl = user["profile_image_urls"].GetObject()["medium"].TryGetString();
toret.Comment = user["comment"].TryGetString();
toret.IsFollowed = user["is_followed"].GetBoolean();
var profile = Source["profile"].GetObject();
toret.WebPage = profile["webpage"].TryGetString();
toret.Gender = profile["gender"].TryGetString();
toret.Birth = profile["birth"].TryGetString();
toret.BirthDay = profile["birth_day"].TryGetString();
toret.BirthYear = (int)profile["birth_year"].GetNumber();
toret.Region = profile["region"].TryGetString();
toret.AddressID = (int)profile["address_id"].GetNumber();
toret.CountryCode = profile["country_code"].TryGetString();
toret.Job = profile["job"].TryGetString();
toret.JobID = (int)profile["job_id"].GetNumber();
toret.TotalFollowUsers = (int)profile["total_follow_users"].GetNumber();
toret.TotalMyPixivUsers = (int)profile["total_mypixiv_users"].GetNumber();
toret.TotalIllusts = (int)profile["total_illusts"].GetNumber();
toret.TotalManga = (int)profile["total_manga"].GetNumber();
toret.TotalNovels = (int)profile["total_novels"].GetNumber();
toret.TotalIllustBookmarksPublic = (int)profile["total_illust_bookmarks_public"].GetNumber();
toret.TotalIllustSeries = (int)profile["total_illust_series"].GetNumber();
toret.TotalNovelSeries = (int)profile["total_novel_series"].GetNumber();
toret.BackgroundImage = profile["background_image_url"].TryGetString();
toret.TwitterAccount = profile["twitter_account"].TryGetString();
toret.TwitterUrl = profile["twitter_url"].TryGetString();
toret.PawooUrl = profile["pawoo_url"].TryGetString();
toret.IsPremium = profile["is_premium"].GetBoolean();
toret.IsUsingCustomProfileImage = profile["is_using_custom_profile_image"].GetBoolean();
var profile_publicity = Source["profile_publicity"].GetObject();
toret.GenderPublicity = profile_publicity["gender"].TryGetString();
toret.RegionPublicity = profile_publicity["region"].TryGetString();
toret.BirthDayPublicity = profile_publicity["birth_day"].TryGetString();
toret.BirthYearPublicity = profile_publicity["birth_year"].TryGetString();
toret.JobPublicity = profile_publicity["job"].TryGetString();
toret.Pawoo = profile_publicity["pawoo"].GetBoolean();
var workspace = Source["workspace"].GetObject();
toret.PC = workspace["pc"].TryGetString();
toret.Monitor = workspace["monitor"].TryGetString();
toret.Tool = workspace["tool"].TryGetString();
toret.Scanner = workspace["scanner"].TryGetString();
toret.Tablet = workspace["tablet"].TryGetString();
toret.Mouse = workspace["mouse"].TryGetString();
toret.Printer = workspace["printer"].TryGetString();
toret.Desktop = workspace["desktop"].TryGetString();
toret.Music = workspace["music"].TryGetString();
toret.Desk = workspace["desk"].TryGetString();
toret.Chair = workspace["chair"].TryGetString();
toret.WorkspaceComment = workspace["comment"].TryGetString();
toret.WorkspaceImageUrl = workspace["workspace_image_url"].TryGetString();
return toret;
}

public static UserDetail FromObject(PixivCS.Objects.UserDetail Source)
{
UserDetail toret = new UserDetail();
Expand Down
15 changes: 0 additions & 15 deletions PixivFSUWP/Data/WaterfallItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ public class WaterfallItem
public int Width { get; set; }
public int Height { get; set; }

public static WaterfallItem FromJsonValue(JsonObject Source)
{
var toret = new WaterfallItem();
toret.Id = (int)Source["id"].GetNumber();
toret.Title = Source["title"].TryGetString();
toret.Author = Source["user"].GetObject()["name"].TryGetString();
toret.ImageUri = Source["image_urls"].GetObject()["medium"].TryGetString();
toret.Stars = (int)Source["total_bookmarks"].GetNumber();
toret.Pages = (int)Source["page_count"].GetNumber();
toret.IsBookmarked = Source["is_bookmarked"].GetBoolean();
toret.Width = (int)Source["width"].GetNumber();
toret.Height = (int)Source["height"].GetNumber();
return toret;
}

public static WaterfallItem FromObject(PixivCS.Objects.UserPreviewIllust Source)
{
var toret = new WaterfallItem();
Expand Down

0 comments on commit 6a4aad4

Please sign in to comment.