InstanceContext.IncomingChannels 属性
定义
获取传入服务实例的会话通道。Gets the sessionful channels that are incoming to the service instance.
public:
property System::Collections::Generic::ICollection<System::ServiceModel::Channels::IChannel ^> ^ IncomingChannels { System::Collections::Generic::ICollection<System::ServiceModel::Channels::IChannel ^> ^ get(); };
public System.Collections.Generic.ICollection<System.ServiceModel.Channels.IChannel> IncomingChannels { get; }
member this.IncomingChannels : System.Collections.Generic.ICollection<System.ServiceModel.Channels.IChannel>
Public ReadOnly Property IncomingChannels As ICollection(Of IChannel)
属性值
ICollection<T> 类型的 IChannel,包含传入服务实例的会话通道。The ICollection<T> of type IChannel that contains the sessionful channels incoming to the service instance.
例外
该服务实例已关闭并且不能使用。The service instance is closed and cannot be used.
该服务实例处于错误状态。The service instance is in a faulted state.
示例
下面的代码演示如何访问 IncomingChannels 属性:The following code illustrates how to access the IncomingChannels property:
OperationContext operationContext = OperationContext.Current;
InstanceContext instanceContext = operationContext.InstanceContext;
ICollection<IChannel> incomingChannels = instanceContext.IncomingChannels;
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");
// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
serviceHost.Open();
OperationContext operationContext = OperationContext.Current;
InstanceContext instanceContext = operationContext.InstanceContext;
ICollection<IChannel> channels = instanceContext.IncomingChannels;
}