2016-08-12 1 views
0

ISecureDataFormatをMicrosoft Unityに登録しようとしています。私はクラスに到達しようとすると、私は次のエラーが発生しかしUnityでISecureDataFormat <AuthenticationTicket>を登録します。

container.RegisterType<ISecureDataFormat<AuthenticationTicket>>(); 

:私はこのようにそれを登録しようとした

現在のタイプ、Microsoft.Owin.Security.ISecureDataFormat`1 [マイクロソフトを.Owin.Security.AuthenticationTicket]の場合、 はインタフェースであり、構築できません。あなたはこのように動作しますDIないMicrosoftからタイプ マッピング

オリジナルコード不足している:

public AccountController(ApplicationUserManager userManager, 
    ISecureDataFormat<AuthenticationTicket> accessTokenFormat) 
{ 
    UserManager = userManager; 
    AccessTokenFormat = accessTokenFormat; 
} 

public ApplicationUserManager UserManager 
{ 
    get 
    { 
     return _userManager ?? Request.GetOwinContext().GetUserManager<ApplicationUserManager>(); 
    } 
    private set 
    { 
     _userManager = value; 
    } 
} 

public ISecureDataFormat<AuthenticationTicket> AccessTokenFormat { get; private set; } 

を多分私がInjectionFactoryか何かを使用する必要があるが、現時点では、私はこだわっています。

答えて

0

は、最後にそれが動作するようになった:

container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>)); 
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>(); 
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>(); 
container.RegisterType<IDataSerializer<AuthenticationTicket>, TicketSerializer>(); 
container.RegisterType<IDataProtector>(
    new InjectionFactory(c => new DpapiDataProtectionProvider().Create("ASP.NET Identity"))); 
+0

私はこの答えをupvoteしたいと思いますが、あなたは、このコードのドキュメントを助言することができます。 –

+0

https://msdn.microsoft.com/en-us/library/microsoft.owin.security(v=vs.113).aspx – Ogglas

関連する問題