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


C# ITimePeriod.AsString方法代码示例

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


在下文中一共展示了ITimePeriod.AsString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReleation

        /// <summary>
        /// <paramref name="period"/>가 <paramref name="target"/>과의 시간 축으로 선 후행 관계를 판단합니다.
        /// </summary>
        /// <param name="period"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static PeriodRelation GetReleation(this ITimePeriod period, ITimePeriod target) {
            period.ShouldNotBeNull("period");
            target.ShouldNotBeNull("target");

            var relation = PeriodRelation.NoRelation;

            if(period.Start > target.End) {
                relation = PeriodRelation.After;
            }
            else if(period.End < target.Start) {
                relation = PeriodRelation.Before;
            }
            else if(period.Start == target.Start && period.End == target.End) {
                relation = PeriodRelation.ExactMatch;
            }
            else if(period.Start == target.End) {
                relation = PeriodRelation.StartTouching;
            }
            else if(period.End == target.Start) {
                relation = PeriodRelation.EndTouching;
            }
            else if(HasInside(period, target)) {
                if(period.Start == target.Start)
                    relation = PeriodRelation.EnclosingStartTouching;
                else
                    relation = (period.End == target.End) ? PeriodRelation.EnclosingEndTouching : PeriodRelation.Enclosing;
            }
                // 기간이 대상 기간 내부에 속할 때
            else {
                var insideStart = HasInside(target, period.Start);
                var insideEnd = HasInside(target, period.End);

                if(insideStart && insideEnd) {
                    relation = Equals(period.Start, target.Start)
                                   ? PeriodRelation.InsideStartTouching
                                   : period.End == target.End
                                         ? PeriodRelation.InsideEndTouching
                                         : PeriodRelation.Inside;
                }
                else if(insideStart)
                    relation = PeriodRelation.StartInside;

                else if(insideEnd)
                    relation = PeriodRelation.EndInside;
            }

            if(IsDebugEnabled)
                log.Debug("period[{0}]와 target[{1}] 간의 Relation은 [{2}] 입니다.", period.AsString(), target.AsString(), relation);

            return relation;
        }
开发者ID:debop,项目名称:NFramework,代码行数:57,代码来源:TimeTool.Relation.cs

示例2: GetUnionRange

        /// <summary>
        /// 두 기간의 합집합 기간을 반환한다.
        /// </summary>
        /// <param name="period"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static TimeRange GetUnionRange(this ITimePeriod period, ITimePeriod target) {
            target.ShouldNotBeNull("target");

            TimeRange unionPeriod = null;

            if(period.HasPeriod && target.HasPeriod) {
                unionPeriod = new TimeRange(period.StartAsNullable < target.StartAsNullable
                                                ? period.StartAsNullable
                                                : target.StartAsNullable,
                                            period.EndAsNullable > target.EndAsNullable
                                                ? period.EndAsNullable
                                                : target.EndAsNullable,
                                            period.IsReadOnly);
            }
            else {
                var start = (period.StartAsNullable.HasValue && target.StartAsNullable.HasValue)
                                ? Min(period.Start, target.Start)
                                : (period.StartAsNullable ?? target.StartAsNullable);
                var end = (period.EndAsNullable.HasValue && target.EndAsNullable.HasValue)
                              ? Max(period.End, target.End)
                              : (period.EndAsNullable ?? target.EndAsNullable);

                unionPeriod = new TimeRange(start, end, period.IsReadOnly);
            }

            if(IsDebugEnabled)
                log.Debug("period[{0}]와 target[{1}] 의 합집합 TimeRange [{2}]를 구했습니다!!!", period.AsString(), target.AsString(),
                          unionPeriod.AsString());

            return unionPeriod;
        }
开发者ID:debop,项目名称:NFramework,代码行数:37,代码来源:TimeTool.Relation.cs

示例3: OverlapsWith

        /// <summary>
        /// 두 기간이 겹치는 구간이 있는지 파악합니다.
        /// </summary>
        /// <param name="period"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool OverlapsWith(this ITimePeriod period, ITimePeriod target) {
            target.ShouldNotBeNull("target");


            var relation = GetReleation(period, target); //period.GetRelation(target);

            var isOverlaps = relation != PeriodRelation.After &&
                             relation != PeriodRelation.StartTouching &&
                             relation != PeriodRelation.EndTouching &&
                             relation != PeriodRelation.Before;

            if(IsDebugEnabled)
                log.Debug("period[{0}]와 target[{1}]이 Overlap되는지 있는지 확인합니다. isOverlaps=[{2}]", period.AsString(), target.AsString(),
                          isOverlaps);

            return isOverlaps;
        }
开发者ID:debop,项目名称:NFramework,代码行数:23,代码来源:TimeTool.Relation.cs

示例4: GetIntersectionRange

        /// <summary>
        /// 두 기간의 공통되는 기간을 반환한다. (교집합)
        /// </summary>
        /// <param name="period"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static TimeRange GetIntersectionRange(this ITimePeriod period, ITimePeriod target) {
            target.ShouldNotBeNull("target");

            TimeRange intersectionPeriod = null;

            if(IntersectsWith(period, target)) {
                var start = Max(period.Start, target.Start);
                var end = Min(period.End, target.End);

                intersectionPeriod = new TimeRange(start, end, period.IsReadOnly);
            }

            if(IsDebugEnabled)
                log.Debug("period[{0}]와 target[{1}] 의 교집합 TimeRange [{2}]를 구했습니다!!!", period.AsString(), target.AsString(),
                          intersectionPeriod.AsString());

            return intersectionPeriod;
        }
开发者ID:debop,项目名称:NFramework,代码行数:24,代码来源:TimeTool.Relation.cs

示例5: IntersectsWith

        /// <summary>
        /// 두 기간 교차하거나, <paramref name="period"/>가 <paramref name="target"/> 의 내부 구간이면 true를 반환합니다.
        /// </summary>
        /// <param name="period"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool IntersectsWith(this ITimePeriod period, ITimePeriod target) {
            target.ShouldNotBeNull("target");

            var isIntersected = period.HasInside(target.Start) ||
                                period.HasInside(target.End) ||
                                (target.Start < period.Start && target.End > period.End);

            if(IsDebugEnabled)
                log.Debug("period[{0}]와 target[{1}]이 교차 구간이 있는지 확인합니다. isIntersected=[{2}]", period.AsString(), target.AsString(),
                          isIntersected);

            return isIntersected;
        }
开发者ID:debop,项目名称:NFramework,代码行数:19,代码来源:TimeTool.Relation.cs


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