InstanceContext InstanceContext InstanceContext InstanceContext Constructors

Definition

Overloads

InstanceContext(Object) InstanceContext(Object) InstanceContext(Object) InstanceContext(Object)

Initializes a new instance of the InstanceContext class for a specified object that implements the service instance.

InstanceContext(ServiceHostBase) InstanceContext(ServiceHostBase) InstanceContext(ServiceHostBase) InstanceContext(ServiceHostBase)

Initializes a new instance of the InstanceContext class for a service hosted by a specified host.

InstanceContext(ServiceHostBase, Object) InstanceContext(ServiceHostBase, Object) InstanceContext(ServiceHostBase, Object) InstanceContext(ServiceHostBase, Object)

Initializes a new instance of the InstanceContext class for a specified object that implements the service instance and is hosted by a specified host.

InstanceContext(Object) InstanceContext(Object) InstanceContext(Object) InstanceContext(Object)

Initializes a new instance of the InstanceContext class for a specified object that implements the service instance.

public:
 InstanceContext(System::Object ^ implementation);
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public InstanceContext (object implementation);
new System.ServiceModel.InstanceContext : obj -> System.ServiceModel.InstanceContext
Public Sub New (implementation As Object)
Parameters
implementation
Object Object Object Object

The object that implements the service instance.

Examples

The following code shows how to construct an InstanceContext object by passing in a ServiceHost instance:

string info = "";

InstanceContext instanceContext = new InstanceContext(serviceHost);
info += "    " + "State: " + instanceContext.State.ToString() + "\n";
info += "    " + "ManualFlowControlLimit: " + instanceContext.ManualFlowControlLimit.ToString() + "\n";
info += "    " + "HashCode: " + instanceContext.GetHashCode().ToString() + "\n";

Console.WriteLine(info);

Remarks

This sets the service host associated with the instance context to null.

InstanceContext(ServiceHostBase) InstanceContext(ServiceHostBase) InstanceContext(ServiceHostBase) InstanceContext(ServiceHostBase)

Initializes a new instance of the InstanceContext class for a service hosted by a specified host.

public:
 InstanceContext(System::ServiceModel::ServiceHostBase ^ host);
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public InstanceContext (System.ServiceModel.ServiceHostBase host);
new System.ServiceModel.InstanceContext : System.ServiceModel.ServiceHostBase -> System.ServiceModel.InstanceContext
Public Sub New (host As ServiceHostBase)
Parameters
Exceptions

Examples

The following code shows how to construct an InstanceContext object by passing in a ServiceHost instance:

string info = "";

InstanceContext instanceContext = new InstanceContext(serviceHost);
info += "    " + "State: " + instanceContext.State.ToString() + "\n";
info += "    " + "ManualFlowControlLimit: " + instanceContext.ManualFlowControlLimit.ToString() + "\n";
info += "    " + "HashCode: " + instanceContext.GetHashCode().ToString() + "\n";

Console.WriteLine(info);

InstanceContext(ServiceHostBase, Object) InstanceContext(ServiceHostBase, Object) InstanceContext(ServiceHostBase, Object) InstanceContext(ServiceHostBase, Object)

Initializes a new instance of the InstanceContext class for a specified object that implements the service instance and is hosted by a specified host.

public:
 InstanceContext(System::ServiceModel::ServiceHostBase ^ host, System::Object ^ implementation);
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public InstanceContext (System.ServiceModel.ServiceHostBase host, object implementation);
new System.ServiceModel.InstanceContext : System.ServiceModel.ServiceHostBase * obj -> System.ServiceModel.InstanceContext
Public Sub New (host As ServiceHostBase, implementation As Object)
Parameters
implementation
Object Object Object Object

The object that implements the service instance.

Examples

The following code illustrates how to create an InstanceContext object by first creating the service object and ServiceHost object:

Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");
CalculatorService service = new CalculatorService();
ServiceHost serviceHost = new ServiceHost(service, baseAddress);
InstanceContext instanceContext = new InstanceContext(serviceHost,service);

string info = "";
info += "    " + "State: " + instanceContext.State.ToString() + "\n";
info += "    " + "ManualFlowControlLimit: " + instanceContext.ManualFlowControlLimit.ToString() + "\n";
info += "    " + "HashCode: " + instanceContext.GetHashCode().ToString() + "\n";
Console.WriteLine(info);

Applies to