Unity Dependency Injection of WCF Service via web.config

I have a project in which I am experimenting with DI. I use Unity and everything looks good for regular builds and injections.

I am trying to continue dependency breaks with WCF services. The WCF service that I want to deploy is created at runtime without using DI, and I do not use proxies created using .NET.

MyService = new ChannelFactory<IMyService>("BasicHttpBinding_IMyService").CreateChannel();

The endpoint for the above is in the web.config file:

<endpoint address="http://localhost:35806/MyService.svc"
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
       contract="Interfaces.IMyService" name="BasicHttpBinding_IMyService" />

I am trying to figure out how to map this WCF service to an interface via web.config so that I can use the constructor installation

In web.config, normal mapping occurs using "mapTo", where you must specify an interface alias and an alias for a previously defined class.

<type type="IMyService" mapTo="MyService">
 <lifetime type="singleton"/>
</type>

- WCF , "MyService", "BasicHttpBinding_IMyService" .

, ?

+3
2

, , , - MyService, IMyService, - ( ChannelFactory) .

,

RegisterInstance<IMyService>(myServiceChannelInstance)

MyService?

+2

Unity, . http://neovolve.codeplex.com/releases/view/19004, .

chm . Neovolve.Toolkit.Unity.ProxyParameterValueElement , , .

+1

Source: https://habr.com/ru/post/1728499/


All Articles