Пример #1
0
 public void AddTheme(Theme theme)
 {
     lock (this)
     {
         if (!_themes.ContainsKey(theme))
         {
             _themes.Add(theme, new LinkedList<User>());
         }
         else
         {
             throw new InvalidOperationException("Theme already exists!");
         }
     }
 }
Пример #2
0
 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!");
         }
     }
 }
Пример #3
0
 public void RemoveUser(Theme theme, User user)
 {
     lock (this)
     {
         _themes[theme].Remove(user);
     }
 }
Пример #4
0
 public IEnumerable<User> GetUsers(Theme theme)
 {
     lock (this)
     {
         if (_themes.ContainsKey(theme))
         {
             return _themes[theme];
         }
         throw new InvalidOperationException("Theme doesn't exist!");
     }
 }