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)); } }
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) { 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)); }
protected override void InMemoryLogic(EntityCollectionBase target) { bool contains = target.IndexOf(target.ForeignItem(this) !).Length != 0; if (!contains) { target.Add(target.NewCollectionItem(target.Parent, target.ForeignItem(this) !, null, null)); } }
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)); } } } } }
protected override void InMemoryLogic(EntityCollectionBase target) { bool wasAdded = false; 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, null)); wasAdded = true; } } }); if (!wasAdded) { target.Add(target.NewCollectionItem(target.Parent, target.ForeignItem(this), Moment, null)); } }
protected override void InMemoryLogic(EntityCollectionBase target) { bool contains = false; target.ForEach(delegate(int index, CollectionItem item) { if (item.Item.Equals(target.ForeignItem(this))) { contains = true; } }); if (!contains) { target.Add(target.NewCollectionItem(target.Parent, target.ForeignItem(this), null, null)); } }
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)); } } }); }