public sealed class RegistrationHandler<T> where T : class
Handles the registration of multiple users of any reference type.
Name | Type | Description |
---|---|---|
Item(System.Int32) | T |
Gets the user T associated with the specified registrationID. |
LastValidID | int |
Gets a value reflecting the last valid ID in the Current registrar. Valid ID's range from 0 to LastValidID. Note that this is a reflection of the Current possible registrants, not the max allowed registrants. The main use of this is for validating ID's you are not sure are valid, since trying to access a registrant with an invalid ID will cause all sorts of trouble. |
RegistrantsExists | bool |
Gets a value indicating whether any users are registered. |
RegistrantsRegistered | int |
Gets a value indicating how many users are registered. |
public RegistrationHandler()
Initializes a new instance of the RegistrationHandler class, with a default capacity of 4.
public RegistrationHandler(int intitialCapacity)
Initializes a new instance of the RegistrationHandler class, with a capacity of intitialCapacity.
Name | Type | Description |
---|---|---|
intitialCapacity | int |
The initial capacity of the registration handler. If a user is registered when there is no more room, the capacity will be doubled. |
public void AddRegistrant(T newRegistrant, out int registrationID)
Add a new registrant.
Name | Type | Description |
---|---|---|
newRegistrant | T |
The registrant to add. |
registrationID | int |
The ID assigned to the new registrant. Use this value when you wish to retrieve the registrant. |
public void GetAllRegistrants(List<T> registrants)
Gets all the users Currently registered.
Name | Type | Description |
---|---|---|
registrants | List<T> |
The list the registrants will be added to. |
public void GetAllRegistrantsOfType<U>(List<U> registrants) where U : T
Gets all the users Currently registered of the type U specified.
Name | Description |
---|---|
U | The specific type of the registrant to get. Must be or derive from T |
Name | Type | Description |
---|---|---|
registrants | List<U> |
The list to add the registrants to. |
public IEnumerable<T> RegistrantEntries()
Gets an enumerable collection of registered users. This can be used in a foreach and does not generate garbage.
IEnumerable<T>
An enumerable collection of the registered users.
Example:
class IterateOverRegistrantsExample { RegistrationHandler<ActiveGrid> activeGridUsers; public void Iterate() { foreach(ActiveGrid activeGrid in activeGridUsers.RegistrantEntries()) activeGrid.DoSomething(); } }
public void RemoveAllRegistrants()
Removes all registrants.
public void RemoveRegistrant(int registrationID)
Remove the registrant registered under registrationID.
Name | Type | Description |
---|---|---|
registrationID | int |
The ID of the registrant to remove. |