UserStore を実装しようとしていますが、UserEmailStore と UserLockoutStore なども実装したいと思います。すべての User*Store が UserStore に基づいていることに気付いたので、問題ありません。しかし、UserManager を調べたところ、奇妙なことがわかりました。複数のタイプのストアを UserManager に注入できますが、常に 1 つだけです。ただし、UserManager は、注入したタイプに基づいてそれらすべてを操作できます。
UserManager からの Fox サンプル メソッド GetLockoutEndDateAsync
public virtual async Task<DateTimeOffset?> GetLockoutEndDateAsync(TUser user)
{
this.ThrowIfDisposed();
IUserLockoutStore<TUser> userLockoutStore = this.GetUserLockoutStore();
if ((object) user == null)
throw new ArgumentNullException("user");
TUser user1 = user;
CancellationToken cancellationToken = this.CancellationToken;
return await userLockoutStore.GetLockoutEndDateAsync(user1, cancellationToken);
}
メソッドthis.GetUserLockoutStoreは次のようになります
internal IUserLockoutStore<TUser> GetUserLockoutStore()
{
IUserLockoutStore<TUser> userLockoutStore = this.Store as IUserLockoutStore<TUser>;
if (userLockoutStore != null)
return userLockoutStore;
throw new NotSupportedException(Resources.StoreNotIUserLockoutStore);
}
などの方法もあります
- GetEmailStore
- GetPhoneNumberStore
- GetClaimStore
- GetLoginStore
- ...
したがって、ストアは使用する正しいインターフェイスに基づいている必要があります。
私の質問は、これにどう対処するかです。考えられるすべての User*Store インターフェイスに基づいて 1 つのストアを実装する必要がありますか? または、別の解決策を提案できますか?
前もって感謝します