Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We are using a build policy extension in unity to add behaviors on the service host. On the client we have a ServiceFactory.</p> <pre><code>/// &lt;summary&gt; /// Factory for creating application service proxies used on the workstation /// &lt;/summary&gt; /// &lt;typeparam name="TInterface"&gt;Interface for the service contract&lt;/typeparam&gt; public class ServiceFactory&lt;TInterface&gt; where TInterface : class { private readonly List&lt;IEndpointBehavior&gt; m_Behaviors = new List&lt;IEndpointBehavior&gt;(); /// &lt;summary&gt; /// Add a behavior that is added to the proxy endpoint when the channel is created. /// &lt;/summary&gt; /// &lt;param name="behavior"&gt;An &lt;see cref="IEndpointBehavior"/&gt; that should be added&lt;/param&gt;. public void AddBehavior(IEndpointBehavior behavior) { m_Behaviors.Add(behavior); } /// &lt;summary&gt; /// Creates a channel of type &lt;see cref="CommunicationObjectInterceptor{TInterface}"/&gt; given the endpoint address which /// will recreate its "inner channel" if it becomes in a faulted state. /// &lt;/summary&gt; /// &lt;param name="url"&gt;The endpoint address for the given channel to connect to&lt;/param&gt;. public TInterface CreateChannel(string url) { // create the channel using channelfactory adding the behaviors in m_Behaviors } } </code></pre> <p>Then we configure unity with an <code>InjectionFactory</code></p> <pre><code>new InjectionFactory(c =&gt; { var factory = new ServiceFactory&lt;TInterface&gt;(); factory.AddBehavior(c.Resolve&lt;IClientTokenBehavior&gt;()); return factory.CreateChannel(url); }); </code></pre> <p>By doing it this way you can also resolve your behavior through unity if you have some dependencies.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload