Class ApplicationRoleStore<TRole>
- Namespace
- Kentico.Membership
- Assembly
- Kentico.Membership.dll
Implements basic application role management operations.
public class ApplicationRoleStore<TRole> where TRole : ApplicationRole, new()
Type Parameters
TRole
- Inheritance
-
objectApplicationRoleStore<TRole>
- Extension Methods
Constructors
ApplicationRoleStore(IServiceProvider)
Initializes a new instance of the ApplicationRoleStore<TRole>.
public ApplicationRoleStore(IServiceProvider serviceProvider)
Parameters
serviceProviderIServiceProvider
Methods
CreateAsync(TRole, CancellationToken)
Creates a new role in a store as an asynchronous operation.
public Task<IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken)
Parameters
roleTRoleThe role to create in the store.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A System.Threading.Tasks.Task<TResult> that contains the Microsoft.AspNetCore.Identity.IdentityResult of the asynchronous query.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
DeleteAsync(TRole, CancellationToken)
Deletes a role from the store as an asynchronous operation.
public Task<IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken)
Parameters
roleTRoleThe role to delete from the store.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A System.Threading.Tasks.Task<TResult> that contains the Microsoft.AspNetCore.Identity.IdentityResult of the asynchronous query.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
Dispose()
Performs tasks to dispose the role store.
public void Dispose()
Dispose(bool)
Disposes the role store.
protected virtual void Dispose(bool disposing)
Parameters
disposingboolDescribes whether or not should the managed resources be disposed.
FindByIdAsync(int, CancellationToken)
Finds the role with the specified ID as an asynchronous operation.
public Task<TRole> FindByIdAsync(int roleId, CancellationToken cancellationToken)
Parameters
roleIdintThe role ID to look for.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A System.Threading.Tasks.Task<TResult> that contains the result of the lookup.
Exceptions
- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
FindByIdAsync(string, CancellationToken)
Finds the role with the specified ID as an asynchronous operation.
public Task<TRole> FindByIdAsync(string roleId, CancellationToken cancellationToken)
Parameters
roleIdstringThe role ID to look for.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A System.Threading.Tasks.Task<TResult> that contains the result of the lookup.
Exceptions
- ArgumentException
Thrown when
roleIdis empty or non integer.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
FindByNameAsync(string, CancellationToken)
Finds the role with the specified name as an asynchronous operation.
public Task<TRole> FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken)
Parameters
normalizedRoleNamestringThe role name to look for.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A System.Threading.Tasks.Task<TResult> that contains the result of the lookup.
Exceptions
- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
GetNormalizedRoleNameAsync(TRole, CancellationToken)
Gets a role's normalized name as an asynchronous operation.
public Task<string> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken)
Parameters
roleTRoleThe role whose normalized name should be retrieved.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A System.Threading.Tasks.Task<TResult> that contains
null.
Remarks
Normalized role names are not used in Xperience membership. Use the name instead. This method returns null.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
GetRoleIdAsync(TRole, CancellationToken)
Gets the ID for a role from the store as an asynchronous operation.
public Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken)
Parameters
roleTRoleThe role whose ID should be returned.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A System.Threading.Tasks.Task<TResult> that contains the ID of the role.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
GetRoleNameAsync(TRole, CancellationToken)
Gets the name of a role from the store as an asynchronous operation.
public Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken)
Parameters
roleTRoleThe role whose name should be returned.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A System.Threading.Tasks.Task<TResult> that contains the name of the role.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
SetNormalizedRoleNameAsync(TRole, string, CancellationToken)
Sets a role's normalized name as an asynchronous operation.
public Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken)
Parameters
roleTRoleThe role whose normalized name should be set.
normalizedNamestringThe normalized name to set.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
A System.Threading.Tasks.Task that represents the asynchronous operation.
Remarks
Normalized role names are not used in Xperience membership. Use the name instead. This method performs no operation.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
SetRoleNameAsync(TRole, string, CancellationToken)
Sets the name of a role in the store as an asynchronous operation.
public Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken)
Parameters
roleTRoleThe role whose name should be set.
roleNamestringThe name of the role.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
A System.Threading.Tasks.Task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.
ThrowIfDisposed()
Throws if this store has already been disposed.
protected void ThrowIfDisposed()
UpdateAsync(TRole, CancellationToken)
Updates a role in a store as an asynchronous operation.
public Task<IdentityResult> UpdateAsync(TRole role, CancellationToken cancellationToken)
Parameters
roleTRoleThe role to update in the store.
cancellationTokenCancellationTokenThe System.Threading.CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A System.Threading.Tasks.Task<TResult> that contains the Microsoft.AspNetCore.Identity.IdentityResult of the asynchronous query.
Exceptions
- ArgumentNullException
Thrown when
roleis null.- InvalidOperationException
Thrown when role is not found.
- OperationCanceledException
Thrown when
cancellationTokenis canceled.- ObjectDisposedException
Thrown when the store object has been disposed.