protected override void InMemoryLogic(EntityCollectionBase target)
        {
            bool wasUpdated = false;

            int[] indexes = target.IndexOf(target.ForeignItem(this) !);
            foreach (int index in indexes)
            {
                CollectionItem?item = target.GetItem(index);
                if (item is not null)
                {
                    if (item.IsAfter(Moment))
                    {
                        target.RemoveAt(index);
                    }
                    else if (item.OverlapsOrIsAttached(Moment))
                    {
                        target.SetItem(index, target.NewCollectionItem(target.Parent, item.Item, item.StartDate, null));
                        wasUpdated = true;
                    }
                }
            }
            if (!wasUpdated)
            {
                target.Add(target.NewCollectionItem(target.Parent, target.ForeignItem(this) !, Moment, null));
            }
        }
示例#2
0
        protected override void InMemoryLogic(EntityCollectionBase target)
        {
            DateTime minStartDate = Moment;
            DateTime maxEndDate   = EndDate;

            int[] indexes = target.IndexOf(target.ForeignItem(this) !);
            foreach (int index in indexes)
            {
                CollectionItem?item = target.GetItem(index);
                if (item is not null)
                {
                    if (item.Overlaps(Moment))
                    {
                        if (minStartDate > item.StartDate)
                        {
                            minStartDate = item.StartDate;
                        }

                        if (maxEndDate < item.EndDate)
                        {
                            maxEndDate = item.EndDate;
                        }

                        target.RemoveAt(index);
                    }
                }
            }

            target.Add(target.NewCollectionItem(target.Parent, target.ForeignItem(this) !, minStartDate, maxEndDate));
        }
示例#3
0
        protected override void InMemoryLogic(EntityCollectionBase target)
        {
            OGM?foreignItem = target.ForeignItem(this);

            if (foreignItem is null)
            {
                target.ForEach((index, item) =>
                {
                    if (item is not null)
                    {
                        target.RemoveAt(index);
                    }
                });
            }
            else
            {
                int[] indexes = target.IndexOf(foreignItem);
                foreach (int index in indexes)
                {
                    CollectionItem?item = target.GetItem(index);
                    if (item is not null)
                    {
                        target.RemoveAt(index);
                    }
                }
            }
        }
示例#4
0
 protected override void InMemoryLogic(EntityCollectionBase target)
 {
     int[] indexes = target.IndexOf(target.ForeignItem(this) !);
     foreach (int index in indexes)
     {
         CollectionItem?item = target.GetItem(index);
         if (item is not null)
         {
             if (item.StartDate == Moment)
             {
                 target.RemoveAt(index);
             }
         }
     }
 }
示例#5
0
        protected override void InMemoryLogic(EntityCollectionBase target)
        {
            OGM?foreignItem = target.ForeignItem(this);

            if (foreignItem is null)
            {
                target.ForEach((index, item) =>
                {
                    if (item is not null)
                    {
                        if (item.IsAfter(Moment))
                        {
                            target.RemoveAt(index);
                        }
                        else if (item.Overlaps(Moment))
                        {
                            target.SetItem(index, target.NewCollectionItem(target.Parent, item.Item, item.StartDate, Moment));
                        }
                    }
                });
            }
            else
            {
                int[] indexes = target.IndexOf(foreignItem);
                foreach (int index in indexes)
                {
                    CollectionItem?item = target.GetItem(index);
                    if (item is not null)
                    {
                        if (item.IsAfter(Moment))
                        {
                            target.RemoveAt(index);
                        }
                        else if (item.Overlaps(Moment))
                        {
                            target.SetItem(index, target.NewCollectionItem(target.Parent, item.Item, item.StartDate, Moment));
                        }
                    }
                }
            }
        }