public void Attach(ICharacterObserver observer) { if (observer == null) { throw new ArgumentNullException(); } if (ObserversList.Contains(observer)) { throw new InvalidOperationException("Cannot have duplicate observers."); } ObserversList.Add(observer); }
public void Detach(ICharacterObserver observer) { if (observer == null) { throw new ArgumentNullException(); } if (!ObserversList.Contains(observer)) { throw new InvalidOperationException("Cannot remove observer when observer not in the list."); } if (ObserversList.Count == 0) { throw new InvalidOperationException("The observer list is empty. Cannot detach."); } ObserversList.Remove(observer); }
/// <summary> /// Unsubscribe to remove notifications of the Characterchanged events /// </summary> /// <param name="iCO"></param> public void UnSubscribe(ICharacterObserver iCO) { charHandler -= new CharacterHandler <CharacterSheet>(iCO.CharacterChangedEvent); }
public void Detach(ICharacterObserver observer) { if (observer == null) throw new ArgumentNullException(); if (!ObserversList.Contains(observer)) throw new InvalidOperationException("Cannot remove observer when observer not in the list."); if (ObserversList.Count == 0) throw new InvalidOperationException("The observer list is empty. Cannot detach."); ObserversList.Remove(observer); }
public void Attach(ICharacterObserver observer) { if (observer == null) throw new ArgumentNullException(); if (ObserversList.Contains(observer)) throw new InvalidOperationException("Cannot have duplicate observers."); ObserversList.Add(observer); }
public void Subscribe(ICharacterObserver observer) { observers.Add(observer); }