예제 #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!");
     }
 }