本文整理汇总了C#中JToken.LastName方法的典型用法代码示例。如果您正苦于以下问题:C# JToken.LastName方法的具体用法?C# JToken.LastName怎么用?C# JToken.LastName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JToken
的用法示例。
在下文中一共展示了JToken.LastName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DescribeReservationAsync
public static async Task<string> DescribeReservationAsync(
this UserState userState,
JToken reservation,
int index,
bool showOwner,
bool showDate,
bool showIndex,
bool useMarkdown)
{
var startDate = userState.ConvertToLocalTime(reservation.StartDate());
var duration = reservation.Value<string>("duration");
var boatName = await BookedSchedulerCache
.Instance[userState.ClubId]
.GetResourceNameFromIdAsync(reservation.ResourceId());
string owner = string.Empty;
if (showOwner)
{
owner = $" {reservation.FirstName()} {reservation.LastName()}";
}
string partnerName = string.Empty;
//
// Getting the participant list is messy. When it's empty, it looks like an empty
// array. When there are participants, it looks like an object with each key/value
// pair consisting of the user id and the full user name. This is probably a bug so
// we also try to handle the case that we expected (array of integer user id's).
//
if (reservation["participants"] is JArray)
{
var participants = (JArray)reservation["participants"];
if (participants.Count > 0)
{
var partnerRef = participants[0];
var partnerUser = await BookedSchedulerCache.Instance[userState.ClubId].GetUserAsync(partnerRef.UserId());
partnerName = $" w/ {partnerUser.FullName()}";
}
}
else if (reservation["participants"] is JObject)
{
var participants = (JObject)reservation["participants"];
foreach (var kv in participants)
{
var partnerId = long.Parse(kv.Key);
var partnerUser = await BookedSchedulerCache.Instance[userState.ClubId].GetUserAsync(partnerId);
partnerName = $" w/ {partnerUser.FullName()}";
break;
}
}
if (useMarkdown)
{
return string.Format(
"{0}**{1} {2}** {3}{4} *({5})*{6}",
showIndex ? $"**{index}**: " : string.Empty,
showDate ? startDate.ToLocalTime().ToString("d") : string.Empty,
startDate.ToLocalTime().ToString("t"),
boatName,
partnerName,
duration,
owner);
}
else
{
return string.Format(
"{0}{1} {2} {3}{4} ({5}) {6}",
showIndex ? $"{index}: " : string.Empty,
showDate ? startDate.ToLocalTime().ToString("d") : string.Empty,
startDate.ToLocalTime().ToString("t"),
boatName,
partnerName,
duration,
owner);
}
}
示例2: GetUserNames
private static IEnumerable<string> GetUserNames(JToken user)
{
// NOTE: The username should never be any user's first or last name!
yield return $"{user.FirstName()} {user.LastName()}";
yield return user.UserName();
}