8using System.Collections.Generic;
102 if (foundUser ==
null)
104 string message = String.Format(
"User '{0}' does not exist. Cannot add to group '{1}'!", userName, groupName);
105 throw new ArgumentException(message);
109 if (foundGroup ==
null)
111 string message = String.Format(
"Cannot add user '{0}' to group '{1}' as that group does not exist!", userName, groupName);
112 throw new ArgumentException(message);
131 if (foundUser ==
null)
133 string message = String.Format(
"User '{0}' does not exist. Cannot remove from group '{1}'!", userName, groupName);
134 throw new ArgumentException(message);
138 if (foundGroup ==
null)
140 string message = String.Format(
"Cannot remove user '{0}' from group '{1}' as that group does not exist!", userName, groupName);
141 throw new ArgumentException(message);
159 if (foundUser ==
null)
161 string message = String.Format(
"User '{0}' does not exist. Cannot remove from all groups'!", userName);
162 throw new ArgumentException(message);
188 bool userInGroup =
false;
191 if (foundUser ==
null)
193 string message = String.Format(
"User '{0}' does not exist. Cannot determine if user is in group '{1}'!", userName, groupName);
194 throw new ArgumentException(message);
198 if (foundGroup ==
null)
200 string message = String.Format(
"Cannot determine if user '{0}' is in group '{1}' as that group does not exist!", userName, groupName);
201 throw new ArgumentException(message);
220 if (foundUser ==
null)
222 string message = String.Format(
"User '{0}' does not exist. Cannot get groups container user!", userName);
223 throw new ArgumentException(message);
226 List<string> groupNames =
new List<string>();
234 groupNames.Add(groupName);
238 return groupNames.ToArray();
252 if (foundGroup ==
null)
254 string message = String.Format(
"Cannot determine get users in group '{0}' as that group does not exist!", groupName);
255 throw new ArgumentException(message);
257 return (
string[])foundGroup.
Users.Clone();
Represents a single group. A group has a name and zero or more users. Users are tracked by name.
bool ContainsUser(string name)
Determine if the specified user is in this group. This is a case- sensitive search.
void AddUser(string name)
Add the specified user to this group. If the user is already in the group, the operation is ignored.
void RemoveUser(string name)
Remove a user from this group. If the user is not in the group then the operation is ignored.
string[] Users
The names of users in this group (read-only).
Represents a list of Groups.
Group? FindGroup(string name)
Retrieve the Group instance for the specified group name.
void RemoveGroup(string name)
Remove the specified group from the list. Operation ignored if the group is not in the list.
void AddGroup(string name)
Add a group to the list using the given group name. Operation ignored if the group is already in the ...
string[] GroupNames
The names of all groups contained in this list (read-only). The list is always sorted.
A simple container for the user and group lists. This represents some entity external to the mediator...
Represents a user with a name.
Represents a list of users.
User? FindUser(string name)
Retrieve the User instance for the specified user name.
void AddUser(string name)
Add the specified user name as a user. Operation ignored if user is already in the list.
void RemoveUser(string name)
Remove the specified user name as a user. Operation ignored if user is not in the list.
string[] UserNames
The user names contained in this list (read-only). The list is always sorted.
The namespace containing all Design Pattern Examples implemented in C#.