当前位置: 首页>>代码示例>>C#>>正文


C# JsonSerializer.Select方法代码示例

本文整理汇总了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;
        }
开发者ID:JanKinable,项目名称:LeanKit.IntegrationService,代码行数:55,代码来源:JiraConnection.cs

示例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)
			});
		}
开发者ID:randacc,项目名称:ravendb,代码行数:14,代码来源:SynchronizationController.cs

示例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();
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:17,代码来源:SynchronizationController.cs


注:本文中的JsonSerializer.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。