本文整理汇总了C#中Newtonsoft.Json.Linq.JValue.Value方法的典型用法代码示例。如果您正苦于以下问题:C# JValue.Value方法的具体用法?C# JValue.Value怎么用?C# JValue.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JValue
的用法示例。
在下文中一共展示了JValue.Value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FirebasePriority
internal FirebasePriority(JValue priority)
{
if (priority == null || priority.Type == JTokenType.Null)
{
Type = PriorityType.None;
return;
}
switch (priority.Type)
{
case JTokenType.None:
Type = PriorityType.None;
return;
case JTokenType.Integer:
case JTokenType.Float:
Type = PriorityType.Numeric;
_fp = priority.Value<float>();
return;
case JTokenType.String:
int value;
if (int.TryParse(priority.Value<string>(), out value))
{
Type = PriorityType.Numeric;
_fp = value;
}
else
{
Type = PriorityType.String;
_sp = priority.Value<string>();
}
return;
default:
throw new Exception(string.Format("Unable to load priority of type: {0}", priority.Type));
}
}
示例2: RefreshAccessToken
public void RefreshAccessToken()
{
var p = new Dictionary<string, string> ();
p.Add ("client_id", chromeSettings.ClientId);
p.Add ("client_secret", chromeSettings.ClientSecret);
p.Add ("refresh_token", chromeSettings.RefreshToken);
p.Add("grant_type", "refresh_token");
var response = http.PostAsync (chromeSettings.AuthUrl, new FormUrlEncodedContent (p)).Result;
var result = response.Content.ReadAsStringAsync ().Result;
var json = JObject.Parse(result);
this.AccessToken = json["access_token"].ToString();
JToken expiresJson = new JValue(3400);
json.TryGetValue("expires_in", out expiresJson);
this.Expires = DateTime.UtcNow.AddSeconds(expiresJson.Value<int>());
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", this.AccessToken);
}
示例3: EncryptJsonValue
private static void EncryptJsonValue(JsonPasswordCrypto cryptoHandler, JValue valueToEncrypt)
{
var value = valueToEncrypt.Value<string>();
var encryptedValue = cryptoHandler.Encrypt(value);
valueToEncrypt.Replace(JObject.FromObject(encryptedValue));
}