은 내가 ASP.NET MVC 5 ID 공급자의 기능을 시도 할 수있는이 샘플을 다운로드 , 서비스, 작업 단위 및 문제없이 다른 것들.ID 공급자와 유니티 의존성 주입
하지만 이제 Unity DI를 설치할 때 ID 공급자를 사용하는 인터페이스 및 DI에 많은 문제가 있습니다.
방금 예제의 코드를 다운로드하고 Unity DI를 구성했지만 Identity Membership에 Unity를 사용하고 싶지 않습니다. Unity DI를 사용하고 싶습니다. (IRepository, IService,
나는 그들이 내가 이런 일을 포함해야했다있는 일부 게시물을 읽고,하지만 난현재 유형, Microsoft.AspNet.Identity.IUserStore`1 [Ecoavantis.Interactive.GCI.Models : 나는 사용자를 등록 할 때 등 IUnitOfWork)
는이 오류가 있습니다. ApplicationUser], 은 인터페이스이며 구성 할 수 없습니다. 매핑이 누락 되었습니까?
container.RegisterType<UserManager<ApplicationUser>>(new HierarchicalLifetimeManager());
container.RegisterType<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>(new HierarchicalLifetimeManager());
는 사람이 제발 도와 드릴까요 ... ID 공급자의 의존성을 주입 할 필요가 없습니다?
코드 예 :
/// <summary>Registers the type mappings with the Unity container.</summary>
/// <param name="container">The unity container to configure.</param>
/// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
/// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
public static void RegisterTypes(IUnityContainer container)
{
// NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
// container.LoadConfiguration();
// TODO: Register your types here
//container.RegisterType<DbContext, ApplicationDbContext>(new ContainerControlledLifetimeManager());
container.RegisterType<IUnitOfWorkAsync, UnitOfWork>(new PerRequestLifetimeManager());
container.RegisterType<IMainPanelService, MainPanelService>();
container.RegisterType(typeof (IRepositoryAsync<>), typeof (Repository<>));
container.RegisterType<IDataContextAsync, ecoavantisinteractivegciContext>(new PerRequestLifetimeManager());
}
ApplicationUser 클래스는 어떤 모양입니까? 그것은 그것이 인터페이스 일 때 클래스로서 사용되고 있다고 말하는 것입니다. 애플리케이션 사용자 인터페이스를 사용하는 경우 해당 인터페이스와 구현을위한 DI를 구성하려고 했습니까? – grimurd
예, 시도했지만 작동하지 않습니다 ... 비슷한 질문이 있습니다. http://stackoverflow.com/questions/24731426/register-iauthenticationmanager-with-unity – chemitaxis