public IList <TResult> ToList(CanCreateInstance canCreateInstance, CreateInstancePre createInstancePre, CanCreateInstancePre canCreateInstancePre) { List <TResult> list = new List <TResult>(_cutCount); if (_headDot.Next == null) { return(list); } Dot currentDot = _headDot.Next; Dot beginDot = _headDot; T previousT = default(T); var m1 = new Action <DateTime, DateTime, T, T>((t1, t2, previous, target) => { var newInstance = createInstancePre != null?createInstancePre(t1, t2, previous, target): _instanceFunc(t1, t2, target); if (!ReferenceEquals(newInstance, default(TResult))) { list.Add(newInstance); } }); while (currentDot != null) { if (currentDot.Next == null) { m1(beginDot.Time, currentDot.Time, previousT, beginDot.GetActualTarget()); break; } if (currentDot.Time != currentDot.Next.Time) { if (beginDot == _headDot) { beginDot = currentDot; continue; } var target = beginDot.GetActualTarget(); bool canAdd = canCreateInstancePre != null ? canCreateInstancePre(target, previousT, currentDot.GetActualTarget()) : canCreateInstance(target, currentDot.GetActualTarget()); if (canAdd) { m1(beginDot.Time, currentDot.Time, previousT, target); beginDot = currentDot; } previousT = target; } currentDot = currentDot.Next; } return(list); }
public IList <TResult> ToList(CreateInstancePre createInstancePre, CanCreateInstancePre canCreateInstancePre) { return(ToList(null, createInstancePre, canCreateInstancePre)); }