public T this[Type type] { get { for (var i = _head; i != null; i = i.Next) { if (type == i.Type || type.IsSubclassOf(i.Type)) { return(i.Value); } } return(default(T)); } set { var prev = default(NEntry); for (var i = _head; i != null; i = i.Next) { if (type == i.Type) { Debug.WriteLine($"Warning: Setter for type ({type.Name}) has been already registered"); i.Value = value; return; } if (type.IsSubclassOf(i.Type)) { var e = new NEntry(type, value, i); if (prev == null) { _head = e; } else { prev.Next = e; } return; } prev = i; } { var e = new NEntry(type, value); if (prev == null) { _head = e; } else { prev.Next = e; } } } }
protected internal NEntry AddNotify_unlocked(NEntry ne) { #if DEBUG if (0 != ne.ID) { throw new Exception("DEBUG: NEntry.AddNotify_unlocked: (0 != ne.ID) might already be added to notify list"); } #endif ne.ID = ++this.LastNotifyID; ne.TimeAdded = DateTime.Now; Notify.Add(ne); return(ne); }
public NEntry(Type type, T value, NEntry next) : this(type, value) { Next = next; }
protected internal NEntry AddNotify_unlocked(NEntry ne) { #if DEBUG if (0 != ne.ID) { throw new Exception("DEBUG: NEntry.AddNotify_unlocked: (0 != ne.ID) might already be added to notify list"); } #endif ne.ID = ++this.LastNotifyID; ne.TimeAdded = DateTime.Now; Notify.Add(ne); return ne; }