Esempio n. 1
0
 public Maybe <FocusData> Combine(FocusData data) =>
 CanCombine(data) ?
 new FocusData(
     new DateTime(Math.Min(data.StartTime.Ticks, StartTime.Ticks)),
     new DateTime(Math.Max(data.EndTime.Ticks, EndTime.Ticks)),
     ItemId)
         : null;
Esempio n. 2
0
        public void AddAndCombineItem(FocusData data)
        {
            var gotCombined = new List <FocusData>();

            var combined = data;

            foreach (var item in Data)
            {
                if (item.CanCombine(combined))
                {
                    combined = item.Combine(combined).Value;
                    gotCombined.Add(item);
                }
            }

            Data = Data.Except(gotCombined)
                   .Concat(new List <FocusData>()
            {
                combined
            })
                   .OrderBy(x => x.StartTime);
        }
Esempio n. 3
0
 public bool CanCombine(FocusData data) =>
 data.ItemId == ItemId &&
 (data.EndTime == StartTime || data.StartTime == EndTime);