Example #1
0
        public override void NotifyVariableChanged(object key, Bean value)
        {
            if (null == note && null == changedValue)
            {
                return;
            }

            if (null == note)
            {
                note = NoteFactory();                 // 动态创建的 note 是没有所属容器的引用,也就丢失了所在 Bean 的引用。
            }
            note.SetChangedValue(changedValue);

            foreach (var l in listeners)
            {
                try
                {
                    l.OnChanged(key, value, note);
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "NotifyVariableChanged");
                }
            }
        }
Example #2
0
        } = new Dictionary <long, ChangeNote>();                                                         // 所有Collection的ChangeNote。

        /*
         * public void PutChangeNote(long key, ChangeNote note)
         * {
         *  notes[key] = note;
         * }
         */

        public ChangeNote GetOrAddChangeNote(long key, Func <ChangeNote> factory)
        {
            if (ChangeNotes.TryGetValue(key, out var exist))
            {
                return(exist);
            }
            ChangeNote newNote = factory();

            ChangeNotes.Add(key, newNote);
            return(newNote);
        }
Example #3
0
        internal override void Merge(ChangeNote note)
        {
            ChangeNoteMap1 <K, V> another = (ChangeNoteMap1 <K, V>)note;

            // Put,Remove 需要确认有没有顺序问题
            // this: replace 1,3 remove 2,4 nest: repalce 2 remove 1
            foreach (var e in another.Replaced)
            {
                LogPut(e.Key, e.Value);                                 // replace 1,2,3 remove 4
            }
            foreach (var e in another.Removed)
            {
                LogRemove(e);                                // replace 2,3 remove 1,4
            }
        }
Example #4
0
        internal override void Merge(ChangeNote other)
        {
            ChangeNoteSet <K> another = (ChangeNoteSet <K>)other;

            // Put,Remove 需要确认有没有顺序问题
            // this: add 1,3 remove 2,4 nest: add 2 remove 1
            foreach (var e in another.Added)
            {
                LogAdd(e);                              // replace 1,2,3 remove 4
            }
            foreach (var e in another.Removed)
            {
                LogRemove(e);                                // replace 2,3 remove 1,4
            }
        }
Example #5
0
 public override void CollectChanged(List <Util.KV <Bean, int> > path, ChangeNote note)
 {
     if (path.Count == 0)
     {
         this.note = note;                 // 肯定只有一个。这里就不检查了。
     }
     else
     {
         if (null == changedValue)
         {
             changedValue = new Util.IdentityHashMap <Bean, Bean>();
         }
         // Value 不是 Bean 的 Map 不会走到这里。
         Bean value = path[path.Count - 1].Key;
         if (!changedValue.ContainsKey(value))
         {
             changedValue.TryAdd(value, value);
         }
     }
 }
Example #6
0
 internal abstract void Merge(ChangeNote other);
Example #7
0
 public override void CollectChanged(List <Util.KV <Bean, int> > path, ChangeNote note)
 {
     // 忽略错误检查
     this.note = note;
 }
Example #8
0
 public override void CollectChanged(List <Util.KV <Bean, int> > path, ChangeNote note)
 {
     changed = true;
 }
Example #9
0
 public abstract void CollectChanged(List <Util.KV <Bean, int> > path, ChangeNote note);