Identity 如何知道使用我对其核心接口的自定义实现?
How will Identity know to use my custom implementations of its core interfaces?
我找到了两篇相当全面的文章,详细介绍了如何实现像 IUserStore<,>
这样的身份服务,并且快完成它们了,例如我有一个:
public class QsaasUserStore<TLogin> : IUserStore<QsaasUser<TLogin>, int> where TLogin : QsaasUserLogin<int>
现在困扰我的是,我如何告诉 Identity 在需要用户存储时使用 QsaasUserStore<TLogin>
?我是否需要实现方法覆盖,或者我是否可以在 Identity 需要 IUserStore
时使用 Unity 来提供我的用户存储?
查看 UserManager
和 RoleManager
的 constructors。
UserManager
在构造函数中依赖于 IUserStore
。因此,无论您以何种方式创建 UserManager
,请在构造函数中提供 IUserStore
的实现。
同样适用于 RoleManager
- 在构造函数中提供 IRoleStore
的实现,您就完成了。
我找到了两篇相当全面的文章,详细介绍了如何实现像 IUserStore<,>
这样的身份服务,并且快完成它们了,例如我有一个:
public class QsaasUserStore<TLogin> : IUserStore<QsaasUser<TLogin>, int> where TLogin : QsaasUserLogin<int>
现在困扰我的是,我如何告诉 Identity 在需要用户存储时使用 QsaasUserStore<TLogin>
?我是否需要实现方法覆盖,或者我是否可以在 Identity 需要 IUserStore
时使用 Unity 来提供我的用户存储?
查看 UserManager
和 RoleManager
的 constructors。
UserManager
在构造函数中依赖于 IUserStore
。因此,无论您以何种方式创建 UserManager
,请在构造函数中提供 IUserStore
的实现。
同样适用于 RoleManager
- 在构造函数中提供 IRoleStore
的实现,您就完成了。