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


C# JToken.DeepClone方法代码示例

本文整理汇总了C#中JToken.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# JToken.DeepClone方法的具体用法?C# JToken.DeepClone怎么用?C# JToken.DeepClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JToken的用法示例。


在下文中一共展示了JToken.DeepClone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Merge

        /// <summary>
        /// <para>Creates a new token which is the merge of the passed tokens</para>
        /// </summary>
        /// <param name="left">Token</param>
        /// <param name="right">Token to merge, overwriting the left</param>
        /// <param name="options">Options for merge</param>
        /// <returns>A new merged token</returns>
        public static JToken Merge(
            this JToken left, JToken right, MergeOptions options)
        {
            if (left.Type != JTokenType.Object)
                return right.DeepClone();

            var leftClone = (JContainer) left.DeepClone();
            MergeInto(leftClone, right, options);

            return leftClone;
        }
开发者ID:dogeincomm,项目名称:Newtonsoft.Json,代码行数:18,代码来源:MergeExtensions.cs

示例2: Clone

 internal static JToken Clone(JToken value)
 {
     return value.DeepClone();
 }
开发者ID:NuGet,项目名称:json-ld.net,代码行数:4,代码来源:JsonLdUtils.cs

示例3: RedactSensitiveInformaton

        public static JToken RedactSensitiveInformaton(JToken check, List<string> keys = null)
        {
            var clonedCheck = check.DeepClone();

            return RedactInformationRecursive(clonedCheck, keys);
        }
开发者ID:fhoek,项目名称:sensu-client,代码行数:6,代码来源:SensuClientHelper.cs

示例4: ExecuteRequestAsync

        public async Task<HttpProgressInfo> ExecuteRequestAsync(string url, Dictionary<string,string> headers = null, string method = "GET", JToken body = null)
        {
            var pi = new HttpProgressInfo();
            pi.Url = new Uri(url);
            pi.Method = method;
            pi.RequestHeaders = new WebHeaderCollection();

            var req = WebRequest.CreateHttp(url);
            req.Method = method;

            if (headers != null)
            {
                foreach (var i in headers)
                {
                    req.Headers.Add(i.Key, i.Value);
                    pi.RequestHeaders.Add(i.Key, i.Value);
                }
            }

            pi.RequestBody = body == null ? null : body.DeepClone();
            pi.RequestStarted = DateTime.UtcNow;
            pi.State = HttpTransactionState.Started;
            OnProgress(pi);

            if (body != null)
            {
                using (var rs = await req.GetRequestStreamAsync())
                using (var sw = new System.IO.StreamWriter(rs))
                {
                    await sw.WriteAsync(body.ToString(Formatting.None));
                }
            }
            
            pi.RequestCompleted = DateTime.UtcNow;
            pi.State = HttpTransactionState.RequestSent;
            OnProgress(pi);

            var res = (HttpWebResponse)await req.GetResponseAsync();

            pi.State = HttpTransactionState.HeadersReceived;
            pi.ResponseStarted = DateTime.UtcNow;
            pi.ResponseStatus = res.StatusCode;
            pi.ResponseStatusDescription = res.StatusDescription;
            pi.ResponseHeaders = res.Headers;
            OnProgress(pi);

            using (var rs = res.GetResponseStream())
            using (var sr = new System.IO.StreamReader(rs, Encoding.UTF8))
            {
                var dataText = await sr.ReadToEndAsync();

                pi.State = HttpTransactionState.Complete;
                pi.ResponseCompleted = DateTime.UtcNow;

                if (!string.IsNullOrWhiteSpace(dataText))
                {
                    var tok = JToken.Parse(dataText);
                    pi.ResponseBody = tok;
                }
            }

            OnProgress(pi);

            return pi;
        }
开发者ID:kythyria,项目名称:gallus,代码行数:65,代码来源:Http.cs


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