Example #1
0
            public static IEnumerable <Items> Do(
                IEnumerable <T> items, Func <T, TimeRange> getTimeRange,
                DateTime dtMin, DateTime dtMax)
            {
                var lst           = new Lst();
                var lstMaxEndTime = dtMin;

                foreach (var item in items)
                {
                    var tr = getTimeRange(item);

                    if (tr.endTime == DateTime.MinValue)
                    {
                        continue;
                    }

                    if (lstMaxEndTime <= tr.time && lst.Count > 0)
                    {
                        if (lst.Count == 1)
                        {
                            yield return(lst[0].ToItems(dtMin, tr.time));
                        }
                        else
                        {
                            foreach (var tuple in EnumerateLst(lst, dtMin, tr.time))
                            {
                                yield return(tuple);
                            }
                        }
                        lst.Clear();
                        dtMin = tr.time;
                    }
                    if (lstMaxEndTime < tr.endTime)
                    {
                        lstMaxEndTime = tr.endTime;
                    }
                    lst.Add(new Item()
                    {
                        timeRng = tr, item = item
                    });
                }
                if (lst.Count > 0)
                {
                    if (lst.Count == 1)
                    {
                        yield return(lst[0].ToItems(dtMin, dtMax));
                    }
                    else
                    {
                        foreach (var tuple in EnumerateLst(lst, dtMin, dtMax))
                        {
                            yield return(tuple);
                        }
                    }
                }
            }
Example #2
0
        public void Clear()
        {
            _nodes = _nodes.Clear();

            _dirty = false;
        }