<?xml version="1.0" encoding="utf-8"?>
<Type Name="IInstanceProvider" FullName="System.ServiceModel.Dispatcher.IInstanceProvider">
  <TypeSignature Language="C#" Value="public interface IInstanceProvider" />
  <TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IInstanceProvider" />
  <AssemblyInfo>
    <AssemblyName>System.ServiceModel</AssemblyName>
    <AssemblyVersion>4.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Interfaces />
  <Docs>
    <remarks>
      <attribution license="cc4" from="Microsoft" modified="false" />
      <para>Implement the <see cref="T:System.ServiceModel.Dispatcher.IInstanceProvider" /> interface to control the creation and recycling of service objects when one is requested or disposed by an <see cref="T:System.ServiceModel.InstanceContext" /> object. </para>
      <para>Once the <see cref="T:System.ServiceModel.Dispatcher.IInstanceProvider" /> interface is implemented, you must assign your custom instance provider object to the <see cref="P:System.ServiceModel.Dispatcher.DispatchRuntime.InstanceProvider" /> property using either an endpoint behavior (a <see cref="T:System.ServiceModel.Description.IEndpointBehavior" /> object) or a contract behavior (a <see cref="T:System.ServiceModel.Description.IContractBehavior" /> object). </para>
      <para>If the insertion mechanism is an endpoint behavior you can also implement a <see cref="T:System.ServiceModel.Configuration.BehaviorExtensionElement" /> object that can insert your custom behavior using a configuration file. If the insertion mechanism is a contract behavior, you can insert the behavior programmatically prior to the opening of the service host or you can implement a custom attribute. (For an example of the contract behavior approach, see the Example section.)</para>
      <para>
        <see cref="T:System.ServiceModel.Dispatcher.IInstanceProvider" /> has two methods, <see cref="Overload:System.ServiceModel.Dispatcher.IInstanceProvider.GetInstance" /> and <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.ReleaseInstance(System.ServiceModel.InstanceContext,System.Object)" />. These methods are typically implemented to create service objects using a non-default constructor or to initialize or dispose of some state related to the lifetime of the object. Service object pooling is one example of custom <see cref="T:System.ServiceModel.Dispatcher.IInstanceProvider" /> functionality.</para>
      <para>Typically, the <see cref="T:System.ServiceModel.InstanceContext" /> invokes the <see cref="Overload:System.ServiceModel.Dispatcher.IInstanceProvider.GetInstance" /> when the <see cref="T:System.ServiceModel.InstanceContext" /> is first created and invokes the <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.ReleaseInstance(System.ServiceModel.InstanceContext,System.Object)" /> method when the <see cref="T:System.ServiceModel.InstanceContext" /> is closed.</para>
      <para>There are two ways to cause an <see cref="T:System.ServiceModel.InstanceContext" /> object to release a service object before the <see cref="T:System.ServiceModel.InstanceContext" /> is closed. The first method is to set the <see cref="P:System.ServiceModel.OperationBehaviorAttribute.ReleaseInstanceMode" /> to <see cref="F:System.ServiceModel.ReleaseInstanceMode.AfterCall" /> or <see cref="F:System.ServiceModel.ReleaseInstanceMode.BeforeAndAfterCall" />. The second method is to call the <see cref="M:System.ServiceModel.InstanceContext.ReleaseServiceInstance" /> method. If this is done, the <see cref="T:System.ServiceModel.InstanceContext" /> calls the <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.ReleaseInstance(System.ServiceModel.InstanceContext,System.Object)" /> method on the dispatcher's instance provider. If a new message arrives after the instance has been released, indigo2 creates a new instance using the <see cref="Overload:System.ServiceModel.Dispatcher.IInstanceProvider.GetInstance" /> method.</para>
      <block subset="none" type="note">
        <para>If the <see cref="T:System.ServiceModel.InstanceContextMode" /> of the service is <see cref="F:System.ServiceModel.InstanceContextMode.Single" />, the system does not call the <see cref="Overload:System.ServiceModel.Dispatcher.IInstanceProvider.GetInstance" /> or <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.ReleaseInstance(System.ServiceModel.InstanceContext,System.Object)" /> methods even when the user did not provide a well-known service object unless the user directly calls <see cref="M:System.ServiceModel.InstanceContext.ReleaseServiceInstance" /> and then calls <see cref="M:System.ServiceModel.InstanceContext.GetServiceInstance" />.</para>
      </block>
    </remarks>
    <summary>
      <attribution license="cc4" from="Microsoft" modified="false" />
      <para>Declares methods that provide a service object or recycle a service object for a indigo1 service.</para>
    </summary>
  </Docs>
  <Members>
    <Member MemberName="GetInstance">
      <MemberSignature Language="C#" Value="public object GetInstance (System.ServiceModel.InstanceContext context);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance object GetInstance(class System.ServiceModel.InstanceContext context) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>4.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="context" Type="System.ServiceModel.InstanceContext" />
      </Parameters>
      <Docs>
        <param name="context">To be added.</param>
        <remarks>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Use the <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.GetInstance(System.ServiceModel.InstanceContext)" /> method to control the exact service object that a indigo2 service receives when it attempts to create a new one.</para>
        </remarks>
        <summary>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Returns a service object given the specified <see cref="T:System.ServiceModel.InstanceContext" /> object.</para>
        </summary>
        <returns>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>A user-defined service object.</para>
        </returns>
      </Docs>
    </Member>
    <Member MemberName="GetInstance">
      <MemberSignature Language="C#" Value="public object GetInstance (System.ServiceModel.InstanceContext context, System.ServiceModel.Channels.Message message);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance object GetInstance(class System.ServiceModel.InstanceContext context, class System.ServiceModel.Channels.Message message) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>4.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="context" Type="System.ServiceModel.InstanceContext" />
        <Parameter Name="message" Type="System.ServiceModel.Channels.Message" />
      </Parameters>
      <Docs>
        <param name="context">To be added.</param>
        <remarks>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Use the <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.GetInstance(System.ServiceModel.InstanceContext,System.ServiceModel.Channels.Message)" /> method to control the exact service object that a indigo2 service receives when it attempts to create a new one.</para>
        </remarks>
        <summary>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Returns a service object given the specified <see cref="T:System.ServiceModel.InstanceContext" /> object.</para>
        </summary>
        <returns>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>The service object.</para>
        </returns>
        <param name="message">
          <attribution license="cc4" from="Microsoft" modified="false" />The message that triggered the creation of a service object.</param>
      </Docs>
    </Member>
    <Member MemberName="ReleaseInstance">
      <MemberSignature Language="C#" Value="public void ReleaseInstance (System.ServiceModel.InstanceContext context, object instance);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void ReleaseInstance(class System.ServiceModel.InstanceContext context, object instance) cil managed" />
      <MemberType>Method</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>4.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="context" Type="System.ServiceModel.InstanceContext" />
        <Parameter Name="instance" Type="System.Object" />
      </Parameters>
      <Docs>
        <param name="context">To be added.</param>
        <remarks>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Use the <see cref="M:System.ServiceModel.Dispatcher.IInstanceProvider.ReleaseInstance(System.ServiceModel.InstanceContext,System.Object)" /> method to perform some custom resource disposal or other recycling customization when a service recycles a service object.</para>
        </remarks>
        <summary>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Called when an <see cref="T:System.ServiceModel.InstanceContext" /> object recycles a service object.</para>
        </summary>
        <param name="instance">
          <attribution license="cc4" from="Microsoft" modified="false" />The service object to be recycled.</param>
      </Docs>
    </Member>
  </Members>
</Type>