本文整理汇总了C#中JToken.SelectToken方法的典型用法代码示例。如果您正苦于以下问题:C# JToken.SelectToken方法的具体用法?C# JToken.SelectToken怎么用?C# JToken.SelectToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JToken
的用法示例。
在下文中一共展示了JToken.SelectToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseJToken
internal static LastTag ParseJToken(JToken token, string relatedTag = null)
{
var name = token.Value<string>("name");
var url = token.Value<string>("url");
int? count = null;
var countToken = token.SelectToken("count");
if (countToken != null)
{
count = countToken.ToObject<int?>();
}
bool? streamable = null;
var streamableToken = token.SelectToken("streamable");
if (streamableToken != null)
{
streamable = Convert.ToBoolean(streamableToken.Value<int>());
}
return new LastTag(name, url, count)
{
Streamable = streamable,
RelatedTo = relatedTag
};
}
示例2: TwitchFollower
public TwitchFollower(JToken followerData)
{
_createdAt = followerData.SelectToken("created_at").ToString();
if (followerData.SelectToken("notifications").ToString() == "true")
_notifications = true;
_user = new UserObj(followerData.SelectToken("user"));
}
示例3: Function
public Function(JToken JSON, bool magicMethod = false)
: this(magicMethod)
{
this.StartLine = Int32.MinValue;
this.EndLine = Int32.MinValue;
this.Formats = new List<string>();
this.Name = (string)JSON.SelectToken(Keys.PHPDefinitionJSONKeys.GeneralKeys.Name);
this.ParameterCount = (int)JSON.SelectToken(Keys.PHPDefinitionJSONKeys.GeneralKeys.ParameterCount);
this.ReturnType = (string)JSON.SelectToken(Keys.PHPDefinitionJSONKeys.GeneralKeys.ReturnType);
var formats = (JArray)JSON.SelectToken(Keys.PHPDefinitionJSONKeys.GeneralKeys.Formats);
if (formats != null)
{
foreach (string format in formats)
{
this.Formats.Add(format);
}
}
var aliasArray = (JArray)JSON.SelectToken(Keys.PHPDefinitionJSONKeys.GeneralKeys.Aliases);
if(aliasArray != null)
{
foreach (string alias in aliasArray)
{
Aliases.Add(alias);
}
}
}
示例4: parseContactFromJToken
public void parseContactFromJToken(JToken token)
{
try
{
JToken data = token.SelectToken("gd$name");
if (data != null)
{
parseName(data);
}
data = token.SelectToken("gd$email");
if (data != null)
{
parseEmail(data);
}
data = token.SelectToken("gd$phoneNumber");
if (data != null)
{
parsePhone(data);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
示例5: Block
/// <summary>
/// Block object constructor.
/// </summary>
/// <param name="json"></param>
public Block(JToken json)
{
UpdatedAt = Common.DateTimeStringToObject(json.SelectToken("updated_at")?.ToString());
TimeSinceUpdate = DateTime.UtcNow - UpdatedAt;
if (json.SelectToken("user") != null)
User = new User(json.SelectToken("user").ToString());
}
示例6: PreviewObj
public PreviewObj(JToken previewData)
{
_small = previewData.SelectToken("small").ToString();
_medium = previewData.SelectToken("medium").ToString();
_large = previewData.SelectToken("large").ToString();
_template = previewData.SelectToken("template").ToString();
}
示例7: BoxUrls
/// <summary>Constructor for BoxUrls.</summary>
public BoxUrls(JToken j)
{
Large = j.SelectToken("large")?.ToString();
Medium = j.SelectToken("medium")?.ToString();
Small = j.SelectToken("small")?.ToString();
Template = j.SelectToken("template")?.ToString();
}
示例8: YoutubeStats
public YoutubeStats(JToken youtubeData)
{
viewCount = int.Parse(youtubeData.SelectToken("viewCount").ToString());
commentCount = int.Parse(youtubeData.SelectToken("commentCount").ToString());
subscriberCount = int.Parse(youtubeData.SelectToken("subscriberCount").ToString());
videoCount = int.Parse(youtubeData.SelectToken("videoCount").ToString());
}
示例9: RecentDonation
public RecentDonation(JToken donationData)
{
username = donationData.SelectToken("username").ToString();
message = donationData.SelectToken("message").ToString();
date = Convert.ToDateTime(donationData.SelectToken("date").ToString());
amount = Double.Parse(donationData.SelectToken("amount").ToString());
}
示例10: TokenResponse
/// <summary>
/// Construct a new token by parsing activeConfigJson and get the credential.
/// </summary>
public TokenResponse(JToken userCredentialJson)
{
JToken accessTokenJson = userCredentialJson.SelectToken("access_token");
JToken tokenExpiryJson = userCredentialJson.SelectToken("token_expiry");
if (accessTokenJson == null || accessTokenJson.Type != JTokenType.String)
{
throw new InvalidDataException("Credential JSON should contain access token key.");
}
AccessToken = accessTokenJson.Value<string>();
// Service account credentials do not expire.
if (tokenExpiryJson == null || tokenExpiryJson.Type == JTokenType.Null)
{
ExpiredTime = DateTime.MaxValue;
}
else
{
if (tokenExpiryJson.Type != JTokenType.Date)
{
throw new InvalidDataException("Credential JSON contains an invalid token_expiry.");
}
ExpiredTime = DateTime.SpecifyKind(tokenExpiryJson.Value<DateTime>(), DateTimeKind.Utc);
}
}
示例11: ChannelHasUserSubscribedResponse
/// <summary>Constructor for ChannelHasUserSubscribedResponse object.</summary>
/// <param name="json"></param>
public ChannelHasUserSubscribedResponse(JToken json)
{
Id = json.SelectToken("_id")?.ToString();
if (json.SelectToken("user") != null)
User = new User(json.SelectToken("user").ToString());
if (json.SelectToken("created_at") != null)
CreatedAt = Common.DateTimeStringToObject(json.SelectToken("created_at").ToString());
}
示例12: Follower
/// <summary>Follower object constructor.</summary>
public Follower(JToken followerData)
{
CreatedAt = Common.DateTimeStringToObject(followerData.SelectToken("created_at").ToString());
TimeSinceCreated = DateTime.UtcNow - CreatedAt;
if (followerData.SelectToken("notifications").ToString() == "true")
Notifications = true;
User = new User(followerData.SelectToken("user").ToString());
}
示例13: PlatformUser
public PlatformUser(IPlatformSession session, JToken token)
: base(session)
{
Id = token.SelectToken("id").Value<string>();
Email = token.SelectToken("email").Value<string>();
Name = token.SelectToken("name").Value<string>();
Uuid = token.SelectToken("uuid").Value<string>();
}
示例14: KnowledgeBase
/// <summary>
/// Creates a new Knowledge Base
/// </summary>
/// <param name="t">JSON Token for the Object that represents the Service</param>
internal KnowledgeBase(JToken t)
{
this._name = (String)t.SelectToken("name");
foreach (JToken svc in t.SelectToken("kb-services").Children())
{
PelletService s = PelletService.CreateService(svc);
if (s != null) this._services.Add(s);
}
}
示例15: RaffleWin
public RaffleWin(JToken raffleWinProperties)
{
raffleJsonData = raffleWinProperties.ToString();
winner = raffleWinProperties.SelectToken("winner").ToString();
winCount = int.Parse(raffleWinProperties.SelectToken("win_count").ToString());
enterCount = int.Parse(raffleWinProperties.SelectToken("enter_count").ToString());
claimTime = double.Parse(raffleWinProperties.SelectToken("claim_time").ToString());
claimTimeAvg = double.Parse(raffleWinProperties.SelectToken("claim_time_avg").ToString());
}