Instance Provider in WCF ?

InfoPath alternatives for form designing SharePoint
Instance providers can be applied to services.
Service: Here are the steps for applying an instance provider to a service.
Declare: Implement the System.ServiceModel.Dispatcher.IInstanceProvider interface:
public class RajInstanceProvider :
IInstanceProvider
{
public object GetInstance(
InstanceContext instanceContext,
Message message)
{
//create the service instance here.
}
public object GetInstance(
InstanceContext instanceContext)
{
//create the service instance here.
}
public void ReleaseInstance(
InstanceContext instanceContext,
object instance)
{
//dispose of the service instance.
}
}
Attach: Implement the ApplyDispatchBehavior() method of the System.ServiceModel.
Description.IEndpointBehavior interface:
public class RajInstanceProvider :
IInstanceProvider,
IEndpointBehavior
{
public void ApplyDispatchBehavior(
ServiceEndpoint serviceEndpoint,
EndpointDispatcher endpointDispatcher)
{
endpointDispatcher.DispatchRuntime.InstanceProvider = this;
}
……..
}
Inform In the code for a Windows Communication Foundation service host, add the instance context provider to the Behaviors collection of a System.ServiceModel.Description.EndpointDescription object:
ServiceHost host = new ServiceHost(typeof(Service));
host.Description.Endpoints[0].Behaviors.Add(
new RajInstanceProvider());

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply