本文整理汇总了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;
}
示例2: Clone
internal static JToken Clone(JToken value)
{
return value.DeepClone();
}
示例3: RedactSensitiveInformaton
public static JToken RedactSensitiveInformaton(JToken check, List<string> keys = null)
{
var clonedCheck = check.DeepClone();
return RedactInformationRecursive(clonedCheck, keys);
}
示例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;
}