RegistrationHandler<T> Class

public sealed class RegistrationHandler<T> where T : class

Handles the registration of multiple users of any reference type.

Properties

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.

Constructors

RegistrationHandler()

public RegistrationHandler()

Initializes a new instance of the RegistrationHandler class, with a default capacity of 4.


RegistrationHandler(int)

public RegistrationHandler(int intitialCapacity)

Initializes a new instance of the RegistrationHandler class, with a capacity of intitialCapacity.

Parameters

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.

Methods

AddRegistrant(T, out int)

public void AddRegistrant(T newRegistrant, out int registrationID)

Add a new registrant.

Parameters

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.


GetAllRegistrants(List<T>)

public void GetAllRegistrants(List<T> registrants)

Gets all the users Currently registered.

Parameters

Name Type Description
registrants List<T>

The list the registrants will be added to.


GetAllRegistrantsOfType<U>(List<U>)

public void GetAllRegistrantsOfType<U>(List<U> registrants) where U : T

Gets all the users Currently registered of the type U specified.

Type Parameters

Name Description
U The specific type of the registrant to get. Must be or derive from T

Parameters

Name Type Description
registrants List<U>

The list to add the registrants to.


RegistrantEntries()

public IEnumerable<T> RegistrantEntries()

Gets an enumerable collection of registered users. This can be used in a foreach and does not generate garbage.

Returns

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();
                }
            }
            

RemoveAllRegistrants()

public void RemoveAllRegistrants()

Removes all registrants.


RemoveRegistrant(int)

public void RemoveRegistrant(int registrationID)

Remove the registrant registered under registrationID.

Parameters

Name Type Description
registrationID int

The ID of the registrant to remove.