本文整理汇总了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;
//.........这里部分代码省略.........