BindingElement.BuildChannelFactory<TChannel>(BindingContext) 메서드

정의

바인딩 컨텍스트를 사용하여 지정된 형식의 채널을 생성하는 채널 팩터리를 초기화합니다.

public:
generic <typename TChannel>
 virtual System::ServiceModel::Channels::IChannelFactory<TChannel> ^ BuildChannelFactory(System::ServiceModel::Channels::BindingContext ^ context);
public virtual System.ServiceModel.Channels.IChannelFactory<TChannel> BuildChannelFactory<TChannel> (System.ServiceModel.Channels.BindingContext context);
abstract member BuildChannelFactory : System.ServiceModel.Channels.BindingContext -> System.ServiceModel.Channels.IChannelFactory<'Channel>
override this.BuildChannelFactory : System.ServiceModel.Channels.BindingContext -> System.ServiceModel.Channels.IChannelFactory<'Channel>
Public Overridable Function BuildChannelFactory(Of TChannel) (context As BindingContext) As IChannelFactory(Of TChannel)

형식 매개 변수

TChannel

팩터리가 생성하는 채널의 형식입니다.

매개 변수

context
BindingContext

바인딩 요소의 컨텍스트를 제공하는 BindingContext입니다.

반환

IChannelFactory<TChannel>

IChannelFactory<TChannel>에서 초기화되는 TChannel 형식의 context입니다.

예외

context이(가) null인 경우

예제

CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
BindingContext context = new BindingContext(binding, parameters);

IChannelFactory<IRequestChannel> factory = element.BuildChannelFactory<IRequestChannel>(context);
factory.Open();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
IRequestChannel channel = factory.CreateChannel(address);
channel.Open();
Message request = Message.CreateMessage(MessageVersion.Default, "hello");
Message reply = channel.Request(request);
Console.Out.WriteLine(reply.Headers.Action);
reply.Close();
channel.Close();
factory.Close();

적용 대상