public void AddTheme(Theme theme) { lock (this) { if (!_themes.ContainsKey(theme)) { _themes.Add(theme, new LinkedList<User>()); } else { throw new InvalidOperationException("Theme already exists!"); } } }
public void AddUser(Theme theme, User user) { lock (this) { if (_themes.ContainsKey(theme)) { var themeUserContainer = _themes[theme]; if (!themeUserContainer.Contains(user)) { themeUserContainer.AddLast(user); } else { throw new InvalidOperationException("User already exists!"); } } else { throw new InvalidOperationException("Theme doesn't exist!"); } } }
public void RemoveUser(Theme theme, User user) { lock (this) { _themes[theme].Remove(user); } }
public IEnumerable<User> GetUsers(Theme theme) { lock (this) { if (_themes.ContainsKey(theme)) { return _themes[theme]; } throw new InvalidOperationException("Theme doesn't exist!"); } }