Ejemplo n.º 1
0
 public override void IntersectWith(IEnumerable <E> other)
 {
     if (this.IsManaged)
     {
         var txn = Transaction.Current;
         txn.VerifyRecordAccessed(this);
         var oldv = txn.GetLog(LogKey) is LogV log ? log.Value : set;
         var newv = oldv.Intersect(other);
         if (newv != oldv)
         {
             txn.PutLog(NewLog(newv));
             ChangeNoteSet <E> note = (ChangeNoteSet <E>)txn.GetOrAddChangeNote(this.ObjectId, () => new ChangeNoteSet <E>(this));
             foreach (var old in oldv)
             {
                 if (false == other.Contains(old))
                 {
                     note.LogRemove(old);
                 }
             }
         }
     }
     else
     {
         set = set.Intersect(other);
     }
 }
Ejemplo n.º 2
0
 public override void SymmetricExceptWith(IEnumerable <E> other)
 {
     if (this.IsManaged)
     {
         var txn = Transaction.Current;
         txn.VerifyRecordAccessed(this);
         var oldv = txn.GetLog(LogKey) is LogV log ? log.Value : set;
         var newv = oldv.SymmetricExcept(other);
         if (newv != oldv)
         {
             txn.PutLog(NewLog(newv));
             ChangeNoteSet <E> note = (ChangeNoteSet <E>)txn.GetOrAddChangeNote(this.ObjectId, () => new ChangeNoteSet <E>(this));
             // this: 1,2 other: 2,3 result: 1,3
             foreach (var item in other)
             {
                 if (oldv.Contains(item))
                 {
                     note.LogRemove(item);
                 }
                 else
                 {
                     note.LogAdd(item);
                 }
             }
         }
     }
     else
     {
         set = set.SymmetricExcept(other);
     }
 }
Ejemplo n.º 3
0
        public override void UnionWith(IEnumerable <E> other)
        {
            foreach (E v in other)
            {
                if (null == v)
                {
                    throw new ArgumentNullException();
                }
            }

            if (this.IsManaged)
            {
                var txn = Transaction.Current;
                txn.VerifyRecordAccessed(this);
                var oldv = txn.GetLog(LogKey) is LogV log ? log.Value : set;
                var newv = oldv.Union(other);
                if (newv != oldv)
                {
                    txn.PutLog(NewLog(newv));
                    ChangeNoteSet <E> note = (ChangeNoteSet <E>)txn.GetOrAddChangeNote(this.ObjectId, () => new ChangeNoteSet <E>(this));
                    foreach (var item in other)
                    {
                        if (false == oldv.Contains(item))
                        {
                            note.LogAdd(item);
                        }
                    }
                }
            }
            else
            {
                set = set.Union(other);
            }
        }
Ejemplo n.º 4
0
            void ChangeListener.OnChanged(object key, Bean value, ChangeNote note)
            {
                ChangeNoteSet <int> noteset = (ChangeNoteSet <int>)note;

                foreach (var a in noteset.Added)
                {
                    newValue.Add(a);
                }
                foreach (var r in noteset.Removed)
                {
                    newValue.Remove(r);
                }
            }
Ejemplo n.º 5
0
 public override void Clear()
 {
     if (this.IsManaged)
     {
         var txn = Transaction.Current;
         txn.VerifyRecordAccessed(this);
         var oldv = txn.GetLog(LogKey) is LogV log ? log.Value : set;
         if (!oldv.IsEmpty)
         {
             txn.PutLog(NewLog(ImmutableHashSet <E> .Empty));
             ChangeNoteSet <E> note = (ChangeNoteSet <E>)txn.GetOrAddChangeNote(this.ObjectId, () => new ChangeNoteSet <E>(this));
             foreach (var item in oldv)
             {
                 note.LogRemove(item);
             }
         }
     }
     else
     {
         set = ImmutableHashSet <E> .Empty;
     }
 }