本文整理汇总了C#中ChannelFactory.Open方法的典型用法代码示例。如果您正苦于以下问题:C# ChannelFactory.Open方法的具体用法?C# ChannelFactory.Open怎么用?C# ChannelFactory.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChannelFactory
的用法示例。
在下文中一共展示了ChannelFactory.Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main ()
{
var binding = new NetNamedPipeBinding ();
binding.TransferMode = TransferMode.Streamed;
binding.Security.Mode = NetNamedPipeSecurityMode.None;
IFooChannel proxy = new ChannelFactory<IFooChannel> (
binding,
new EndpointAddress ("net.pipe://localhost/samplepipe")
).CreateChannel ();
proxy.Open ();
Console.WriteLine (proxy.Echo ("TEST FOR ECHO"));
Console.WriteLine (proxy.Add (1000, 2000));
}
示例2: Main
public static void Main ()
{
var uri = new Uri ("soap.udp://239.255.255.250:3802");
for (int i = 0; i < 2; i++) {
var binding = new UdpAnnouncementEndpoint (uri).Binding;
IFooChannel proxy = new ChannelFactory<IFooChannel> (
binding,
new EndpointAddress (uri)
).CreateChannel ();
proxy.Open ();
proxy.SendMsg ("TEST FOR ECHO");
}
}
示例3: CreateChannel_Of_Typed_Proxy_Using_BasicHttpBinding
// Create the channel factory using BasicHttpBinding and open the channel using a user generated interface
public static void CreateChannel_Of_Typed_Proxy_Using_BasicHttpBinding()
{
ChannelFactory<IWcfServiceGenerated> factory = null;
try
{
BasicHttpBinding binding = new BasicHttpBinding();
// Create the channel factory
factory = new ChannelFactory<IWcfServiceGenerated>(binding, new EndpointAddress(BaseAddress.HttpBaseAddress));
factory.Open();
// Create the channel.
IWcfServiceGenerated channel = factory.CreateChannel();
Assert.True(typeof(IWcfServiceGenerated).GetTypeInfo().IsAssignableFrom(channel.GetType().GetTypeInfo()),
String.Format("Channel type '{0}' was not assignable to '{1}'", channel.GetType(), typeof(IRequestChannel)));
}
finally
{
if (factory != null)
{
factory.Close();
}
}
}