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


C# DateRange.IsInTheRange方法代码示例

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


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

示例1: SetTime

        public virtual void SetTime(ITerm term, DateTime unCheckedstart, DateTime uncheckedEnd, Action<ITerm, bool> callback, bool withRplaceDayOff)
        {
            var start = unCheckedstart.TurnToMultiplesOf5();
            var end = uncheckedEnd.TurnToMultiplesOf5();

            var result = false;
            var source = (Term)term;

            var value = new DateRange(start, end);

            if (start >= end)
            {
                source.Exception = new TermException(source, "InvalidTimeValue");
                callback(source, false);
                return;
            }


            bool? childIsInsideOfParent = null;
            source.Bottom.SaftyInvoke(o => childIsInsideOfParent = value.IsInTheRange(o));

            //var assignmentIsOutOfBoundary = source.GetLowestTerm().IsOutOfBoundary(start, this);
            //if(assignmentIsOutOfBoundary)
            //    source.Exception = new TermException(source, "IsOutOfBoundary");
            if (childIsInsideOfParent == false)
                source.Exception = new TermException(source, "BreakAwayFromParent");

            if ((!source.Locked) && childIsInsideOfParent != false) // ((!source.Locked) && !assignmentIsOutOfBoundary && childIsInsideOfParent != false)
            {
                var coverage = source.MeasureCoverage(value.Start, value.End);
                var coverdTerms = TermSet.Retrieve<Term>(coverage.Start, coverage.End, o => !ReferenceEquals(o, source) && o.IsNot<IImmutableTerm>()).ToList();//range filter
                var overlappedTerm = coverdTerms.FirstOrDefault(o => o.Level == source.Level && o.IsCoverd(value));//same level have any covered term
                var relatedTerms = coverdTerms.WhereFamilyTerms(source).ToList(); //relation filter, the real child in the parent

                if (overlappedTerm == null || (withRplaceDayOff && overlappedTerm is DayOff))
                {
                    if (source.IsNot<AbsentEvent>())
                    {
                        overlappedTerm.SaftyInvoke<DayOff>(o =>
                        {
                            _termSet.Remove(o);
                            overlappedTerm = null;
                        });

                        var notMoving = !source.CanCauseMoved(start, end);
                        var offset = new { L = value.Start.Subtract(source.Start), R = value.End.Subtract(source.End) };

                        var verifiedTerms = relatedTerms.Where(o => o.IsInTheRange(source.Start, source.End)).OrderByDescending(o => o.Level);
                        var lockedTerms = relatedTerms.Where(o => o.Locked && o.IsInTheRange(source.Start, source.End));
                        Action applyDelegate = () => { };

                        foreach (var o in verifiedTerms)
                        {
                            var newTime = new DateRange(o.Is<AbsentEvent>() || o.Locked || notMoving ? o.Start : o.Start.Add(offset.L), o.Is<AbsentEvent>() || o.Locked || notMoving ? o.End : o.End.Add(offset.R));
                            if (o.Level < source.Level ? !value.IsInTheRange(newTime) : !newTime.IsInTheRange(value) && o.IsNot<AbsentEvent>())
                            {
                                overlappedTerm = o;
                                break;
                            }

                            if (o.Is<AbsentEvent>() && !o.IsInTheRange(o.ParentTerm == term ? start : o.ParentTerm.Start, o.ParentTerm == term ? end : o.ParentTerm.End))
                            {
                                overlappedTerm = o;
                                break;
                            }

                            if (notMoving || o.Is<AbsentEvent>()) continue;
                            var current = o;
                            var verifyLockedTermIsNotInTheRange = new Func<Term, bool>(lockedTerm =>
                            {
                                if (lockedTerm.Bottom != current) return false;
                                if (!lockedTerm.IsInTheRange(newTime.Start, newTime.End))
                                    overlappedTerm = lockedTerm;
                                return true;
                            });

                            if (lockedTerms.Any(verifyLockedTermIsNotInTheRange)) continue;

                            overlappedTerm = lockedTerms.FirstOrDefault(locked => !ReferenceEquals(current, locked) && ((locked.Level == current.Level && locked.IsCoverd(newTime))));
                            if (overlappedTerm == null && !o.Locked && !o.BottomIsLocked())
                            {
                                applyDelegate += () =>
                                {
                                    current.Snapshot();
                                    current.Start = newTime.Start;
                                    current.End = newTime.End;
                                };
                                current.ForceAssignSeat(coverdTerms, false);
                            }
                            if (overlappedTerm != null) break;
                        }
                        if (overlappedTerm == null) applyDelegate();
                    }

                    if (overlappedTerm == null)
                    {
                        source.Snapshot();
                        source.RectifyAttribution(Boundary, value.Start);
                        source.Start = value.Start;
                        source.End = value.End;
//.........这里部分代码省略.........
开发者ID:Mrding,项目名称:Ribbon,代码行数:101,代码来源:TimeBox.Edit.cs


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