Esempio n. 1
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);
                    }
                }
            }
        }
Esempio n. 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));
        }
        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));
            }
        }
Esempio n. 4
0
        protected override void InMemoryLogic(EntityCollectionBase target)
        {
            DateTime minStartDate = Moment;
            DateTime maxEndDate   = EndDate;

            target.ForEach(delegate(int index, CollectionItem item)
            {
                if (item.Item.Equals(target.ForeignItem(this)))
                {
                    if (item.Overlaps(Moment))
                    {
                        if (minStartDate > item.StartDate)
                        {
                            minStartDate = item.StartDate ?? DateTime.MinValue;
                        }

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

                        target.RemoveAt(index);
                    }
                }
            });

            target.Add(target.NewCollectionItem(target.Parent, target.ForeignItem(this), minStartDate, maxEndDate));
        }
Esempio n. 5
0
 protected override void InMemoryLogic(EntityCollectionBase target)
 {
     target.ForEach(delegate(int index, CollectionItem item)
     {
         if (item.Item.Equals(target.ForeignItem(this)))
         {
             target.RemoveAt(index);
         }
     });
 }
Esempio n. 6
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));
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 protected override void InMemoryLogic(EntityCollectionBase target)
 {
     target.ForEach(delegate(int index, CollectionItem item)
     {
         if (target.Direction == DirectionEnum.Out)
         {
             if ((OutItem is not null && item.Parent.Equals(OutItem)) || (InItem is not null && item.Item.Equals(InItem)))
             {
                 target.RemoveAt(index);
             }
         }
         else if (target.Direction == DirectionEnum.In)
         {
             if ((InItem is not null && item.Parent.Equals(InItem)) || (OutItem is not null && item.Item.Equals(OutItem)))
             {
                 target.RemoveAt(index);
             }
         }
         else
         {
             throw new NotSupportedException("Please contact developer.");
         }
     });
 }
Esempio n. 8
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);
             }
         }
     }
 }
 protected override void InMemoryLogic(EntityCollectionBase target)
 {
     target.ForEach(delegate(int index, CollectionItem item)
     {
         if (item.Item.Equals(target.ForeignItem(this)))
         {
             if (item.IsAfter(Moment))
             {
                 target.RemoveAt(index);
             }
             else if (item.Overlaps(Moment))
             {
                 target.SetItem(index, target.NewCollectionItem(target.Parent, item.Item, item.StartDate, Moment));
             }
         }
     });
 }
        protected override void InMemoryLogic(EntityCollectionBase target)
        {
            target.ForEach(delegate(int index, CollectionItem item)
            {
                if (target.Direction == DirectionEnum.Out)
                {
                    if ((OutItem is not null && item.Parent.Equals(OutItem)) || (InItem is not null && item.Item.Equals(InItem)))
                    {
                        Remove();
                    }
                }
                else if (target.Direction == DirectionEnum.In)
                {
                    if ((InItem is not null && item.Parent.Equals(InItem)) || (OutItem is not null && item.Item.Equals(OutItem)))
                    {
                        Remove();
                    }
                }
                else
                {
                    throw new NotSupportedException("Please contact developer.");
                }

                void Remove()
                {
                    if (item.IsAfter(Moment))
                    {
                        target.RemoveAt(index);
                    }
                    else if (item.Overlaps(Moment))
                    {
                        target.SetItem(index, target.NewCollectionItem(target.Parent, item.Item, item.StartDate, Moment));
                    }
                }
            });
        }