This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tobiichiamane
committed
Oct 29, 2019
1 parent
ae0f4e8
commit 0015080
Showing
7 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Data.Json; | ||
|
||
namespace PixivFSUWP.Data | ||
{ | ||
public enum Contribution | ||
{ | ||
doc, translation, code, bug, idea, unknown | ||
} | ||
|
||
public class Contributor | ||
{ | ||
public string AvatarUrl { get; set; } | ||
public string DisplayName { get; set; } | ||
public string Account { get; set; } | ||
public string ProfileUrl { get; set; } | ||
public List<Contribution> Contributions { get; set; } | ||
|
||
//由字符串返回Contribution枚举 | ||
private static Contribution stringToContribution(string source) | ||
{ | ||
switch (source) | ||
{ | ||
case "doc": | ||
return Contribution.doc; | ||
case "translation": | ||
return Contribution.translation; | ||
case "code": | ||
return Contribution.code; | ||
case "bug": | ||
return Contribution.bug; | ||
case "ideas": | ||
return Contribution.idea; | ||
default: | ||
return Contribution.unknown; | ||
} | ||
} | ||
|
||
public static Contributor FromJsonValue(JsonObject Source) | ||
{ | ||
Contributor toret = new Contributor(); | ||
toret.Account = Source["login"].TryGetString(); | ||
toret.DisplayName = Source["name"].TryGetString(); | ||
toret.AvatarUrl = Source["avatar_url"].TryGetString(); | ||
toret.ProfileUrl = Source["profile"].TryGetString(); | ||
toret.Contributions = new List<Contribution>(); | ||
var contributions = Source["contributions"].GetArray(); | ||
foreach (var contribution in contributions) | ||
toret.Contributions.Add(stringToContribution(contribution.TryGetString())); | ||
return toret; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters