Class VirtualRoleRepository<T>
A repository for keeping a set of role names and their implementation
Implements
Namespace: EPiServer.Security
Assembly: EPiServer.Framework.dll
Version: 12.0.3Syntax
public class VirtualRoleRepository<T> : Object, IDisposable where T : VirtualRoleProviderBase
Type Parameters
Name | Description |
---|---|
T |
Remarks
The purpose of this class is to act as a baseclass for implementations. Dependencies should not be taken to this class but instead to abstractions exposed by implementations, such as IVirtualRoleRepository or IVisitorGroupRoleRepository.
All operations on this class is thread-safe.
Constructors
VirtualRoleRepository(IVirtualRoleReplication)
Initializes a new instance of the VirtualRoleRepository<T> class.
Declaration
public VirtualRoleRepository(IVirtualRoleReplication replication)
Parameters
Type | Name | Description |
---|---|---|
IVirtualRoleReplication | replication | Class that will handle replication of changes |
Methods
AfterUnregister(T)
Called after an instance has been unregistered.
Declaration
protected virtual void AfterUnregister(T virtualRoleProvider)
Parameters
Type | Name | Description |
---|---|---|
T | virtualRoleProvider | The virtual role provider. |
Remarks
The base implementation does nothing, subclasses can override this method if any processing is needed after unregistration.
BeforeRegister(T)
Called before an instance is registered.
Declaration
protected virtual void BeforeRegister(T virtualRoleProvider)
Parameters
Type | Name | Description |
---|---|---|
T | virtualRoleProvider | The virtual role provider. |
Remarks
The base implementation does nothing, subclasses can override this method if any processing is needed before registration.
ClearCache(Boolean)
Clears the internal repository cache.
Declaration
public virtual void ClearCache(bool broadcast)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | broadcast | if set to |
Dispose()
Implements IDisposable
Declaration
public void Dispose()
Dispose(Boolean)
Implements IDisposable
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
GetAllRoles()
Get a list of all registered virtual roles in this repository.
Declaration
public virtual IEnumerable<string> GetAllRoles()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A list of virtual role names. |
GetRoleNamesByType(Type)
Gets the virtual role names for a specified type.
Declaration
public virtual IEnumerable<string> GetRoleNamesByType(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | Type of the class. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | The role names. |
Register(String, T)
Register a new virtual role
Declaration
public virtual void Register(string name, T virtualRoleProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the role |
T | virtualRoleProvider | The implementation |
Remarks
This method will overwrite any existing registered virtual roles with the same name. No events will be raised with this overload.
Register(String, Type, Boolean)
Register a new virtual role and return the instance T.
Declaration
public virtual void Register(string name, Type virtualRoleProviderType, bool replicateChanges)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the role |
System.Type | virtualRoleProviderType | The type of the implementation |
System.Boolean | replicateChanges | True if changes should be replicated to other instances or machines |
Remarks
This method will overwrite any existing registered virtual roles with the same name
RegisterInstance(String, T, Boolean)
Registers an instance of VirtualRoleProviderBase.
Declaration
protected virtual void RegisterInstance(string name, T instance, bool replicateChanges)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
T | instance | The instance. |
System.Boolean | replicateChanges | if set to |
SearchRoles(String)
Find virtual roles registered in this repository
Declaration
public virtual IEnumerable<string> SearchRoles(string query)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | Query to find roles from. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A list of roles that match the roleName |
Remarks
Matching of role names is simply a substring check - if the role contains the string passed in roleName anywhere in the string, it is considered a match.
TryGetRole(String, out T)
Get a role based on name
Declaration
public virtual bool TryGetRole(string name, out T virtualRoleProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the role |
T | virtualRoleProvider | The virtual role provider registered for this name |
Returns
Type | Description |
---|---|
System.Boolean | True if the role was found |
Unregister(String, Boolean)
Unregister a virtual role
Declaration
public virtual void Unregister(string name, bool replicateChanges)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the role |
System.Boolean | replicateChanges | Replicate changes to all instences of this class |
Events
ClearedCache
Occurs when the instance has cleared it cached data
Declaration
public event EventHandler ClearedCache
Event Type
Type | Description |
---|---|
System.EventHandler |