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


C# JToken.StartDate方法代码示例

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


在下文中一共展示了JToken.StartDate方法的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);
            }
        }
开发者ID:CrewNerd,项目名称:BoatTracker,代码行数:80,代码来源:UserStateExtensions.cs

示例2: SummarizeReservationAsync

        public static async Task<string> SummarizeReservationAsync(this UserState userState, JToken reservation)
        {
            var startDate = userState.ConvertToLocalTime(reservation.StartDate());

            var boatName = await BookedSchedulerCache
                .Instance[userState.ClubId]
                .GetResourceNameFromIdAsync(reservation.ResourceId());

            return string.Format(
                "{0} {1} {2}",
                startDate.ToLocalTime().ToString("d"),
                startDate.ToLocalTime().ToString("t"),
                boatName);
        }
开发者ID:CrewNerd,项目名称:BoatTracker,代码行数:14,代码来源:UserStateExtensions.cs


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