Table of Contents

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
object
ApplicationRoleStore<TRole>
Extension Methods

Constructors

ApplicationRoleStore(IServiceProvider)

Initializes a new instance of the ApplicationRoleStore<TRole>.

public ApplicationRoleStore(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

Methods

CreateAsync(TRole, CancellationToken)

Creates a new role in a store as an asynchronous operation.

public Task<IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken)

Parameters

role TRole

The role to create in the store.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

role TRole

The role to delete from the store.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

disposing bool

Describes 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

roleId int

The role ID to look for.

cancellationToken CancellationToken

The 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 cancellationToken is 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

roleId string

The role ID to look for.

cancellationToken CancellationToken

The 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 roleId is empty or non integer.

OperationCanceledException

Thrown when cancellationToken is 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

normalizedRoleName string

The role name to look for.

cancellationToken CancellationToken

The 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 cancellationToken is 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

role TRole

The role whose normalized name should be retrieved.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

role TRole

The role whose ID should be returned.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

role TRole

The role whose name should be returned.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

role TRole

The role whose normalized name should be set.

normalizedName string

The normalized name to set.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

role TRole

The role whose name should be set.

roleName string

The name of the role.

cancellationToken CancellationToken

The 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 role is null.

OperationCanceledException

Thrown when cancellationToken is 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

role TRole

The role to update in the store.

cancellationToken CancellationToken

The 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 role is null.

InvalidOperationException

Thrown when role is not found.

OperationCanceledException

Thrown when cancellationToken is canceled.

ObjectDisposedException

Thrown when the store object has been disposed.