示例#1
0
 public override void Add(MemoComponent mc)
 {
     // We might want to prevent looping here ...
     // since we can add any MemoComponent, we can
     // add a composite A to composite B, and then
     // composite B to A, making a loop between them
     // printing them out, results in a infintie loop
     // Maybe, a deep copy of the objects ???
     try {
         if (!Contains(mc) && !mc.Contains(this)) {
             // This container does not have mc
             // and mc does not contain this
             // OK to add
             this.items.Add(mc);
         }
     } catch (InvalidOperationException ex) {
         // mc does not have the operation Contains
         // so it must be a Memo, not a MemoList. OK to add
         // Might want to log this ...
         this.items.Add(mc);
     }
 }
示例#2
0
 public virtual void Remove(MemoComponent mc)
 {
     throw new System.NotSupportedException(
             "Remove() not implemented for this class");
 }
示例#3
0
 public virtual bool Contains(MemoComponent mc)
 {
     throw new System.NotSupportedException(
             "Contains() not implemented for this class");
 }
示例#4
0
 public override void Remove(MemoComponent mc)
 {
     this.items.Remove(mc);
 }
示例#5
0
 public override bool Contains(MemoComponent m)
 {
     return this.items.Contains(m);
 }