void NamedItemList_BeforeInsert(object sender, InsertEventArgs <T> e) { if (_NameDict.ContainsKey(e.Item.Name)) { throw new ArgumentException("Cant insert the INamedItem named {0}. The name does already exist in the collection.".Build(e.Item.Name)); } }
void NamedItemList_AfterInsert(object sender, InsertEventArgs <T> e) { _NameDict.Add(e.Item.Name, e.Item); e.Item.BeforeNameChange += new EventHandler <NameChangeEventArgs>(Item_BeforeNameChange); e.Item.AfterNameChanged += new EventHandler <NameChangeEventArgs>(Item_AfterNameChanged); }