本文整理汇总了C#中JsonSerializer.Select方法的典型用法代码示例。如果您正苦于以下问题:C# JsonSerializer.Select方法的具体用法?C# JsonSerializer.Select怎么用?C# JsonSerializer.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonSerializer
的用法示例。
在下文中一共展示了JsonSerializer.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProjects
public List<Project> GetProjects()
{
var issueTypes = new List<Type>();
var projects = new List<Project>();
try
{
"Getting a list of issue types from JIRA".Debug();
//https://yoursite.atlassian.net/rest/api/2/issuetype
var issueTypeRequest = new RestRequest("/rest/api/2/issuetype", Method.GET);
var issueTypeResponse = _restClient.Execute(issueTypeRequest);
if (issueTypeResponse.StatusCode == HttpStatusCode.OK)
{
"JIRA issue types retrieved. Deserializing results.".Debug();
var jiraIssueTypes =
new JsonSerializer<List<IssueType>>().DeserializeFromString(issueTypeResponse.Content);
if (jiraIssueTypes != null && jiraIssueTypes.Any())
{
issueTypes.AddRange(jiraIssueTypes.Select(jiraIssueType => new Type(jiraIssueType.Name)));
}
}
"Getting projects from JIRA".Debug();
//https://yoursite.atlassian.net/rest/api/2/project
var request = new RestRequest("/rest/api/2/project", Method.GET);
var jiraResp = _restClient.Execute(request);
if (jiraResp.StatusCode != HttpStatusCode.OK)
{
string.Format("Failed to get projects from JIRA. {0}: {1}", jiraResp.StatusCode, jiraResp.ErrorMessage ?? string.Empty).Warn();
//var serializer = new JsonSerializer<ErrorMessage>();
//var errorMessage = serializer.DeserializeFromString(jiraResp.Content);
return projects;
}
"JIRA projects retrieved. Deserializing results.".Debug();
var resp = new JsonSerializer<List<JiraProject>>().DeserializeFromString(jiraResp.Content);
if (resp != null && resp.Any())
{
projects.AddRange(
resp.Select(
jiraProject =>
new Project(jiraProject.Key, jiraProject.Name, issueTypes,
GetProjectStates(jiraProject.Key))));
}
}
catch (Exception ex)
{
"Error getting JIRA projects.".Error(ex);
}
return projects;
}
示例2: Confirm
public async Task<IEnumerable<SynchronizationConfirmation>> Confirm()
{
var contentStream = await Request.Content.ReadAsStreamAsync();
var confirmingFiles =
new JsonSerializer().Deserialize<IEnumerable<Tuple<string, Guid>>>(
new JsonTextReader(new StreamReader(contentStream)));
return confirmingFiles.Select(file => new SynchronizationConfirmation
{
FileName = file.Item1,
Status = CheckSynchronizedFileStatus(file)
});
}
示例3: Confirm
public async Task<HttpResponseMessage> Confirm()
{
var contentStream = await Request.Content.ReadAsStreamAsync();
var confirmingFiles =
new JsonSerializer().Deserialize<IEnumerable<Tuple<string, Guid>>>(
new JsonTextReader(new StreamReader(contentStream)));
var result = confirmingFiles.Select(file => new SynchronizationConfirmation
{
FileName = file.Item1,
Status = CheckSynchronizedFileStatus(file)
});
return this.GetMessageWithObject(result)
.WithNoCache();
}