当前位置: 首页>>代码示例>>C#>>正文


C# ChannelFactory.Open方法代码示例

本文整理汇总了C#中System.ServiceModel.ChannelFactory.Open方法的典型用法代码示例。如果您正苦于以下问题:C# ChannelFactory.Open方法的具体用法?C# ChannelFactory.Open怎么用?C# ChannelFactory.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.ChannelFactory的用法示例。


在下文中一共展示了ChannelFactory.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Send

        public static void Send(Pager model)
        {
            if (model.To == null || string.IsNullOrWhiteSpace(model.Message)) return;

            using (model.Modifier(x => x.Message))
            {

                Message message = new Message
                {
                    CreatedTime   = DateTime.Now,
                    From          = From,
                    To            = model.To,
                    ContentAsText = model.Message
                };

                model.Message = string.Empty;
                model.History.Add(message)  ;

                m_history.Add(message);

                using (var factory = new ChannelFactory<IMessageHost>(new BasicHttpBinding(), message.To.Uri))
                {
                     factory.Open();
             					 factory.CreateChannel().Send(new Request<Message>(message));
                }

            }
        }
开发者ID:vadimdementey,项目名称:WpfPager,代码行数:28,代码来源:PagerController.cs

示例2: EncodeDecodeWithSecureWcf

        // This test sets a secure service that user our custom encoder/decoder.
        // the service actually modifies the property after deserializing it to simulate what
        // a forwarder/gateway/proxy might do.
        void EncodeDecodeWithSecureWcf()
        {
            Binding binding = WcfHelpers.CreateCustomSecureBinding();
 
            string address = "net.tcp://localhost:8080";
            ServiceHost host = new ServiceHost(new Service(), new Uri(address));
             
            host.AddServiceEndpoint(typeof(IService1), binding, address);
            host.Open();
 
            ChannelFactory<IService1> factory = new ChannelFactory<IService1>(binding, address);
            factory.Open();
            IService1 proxy = factory.CreateChannel();
            ((IChannel)proxy).Open();
 
            Message msg = WcfHelpers.CreateMessage();

            string originalPayloadValue = Guid.NewGuid().ToString();
            WcfHelpers.AddOutOfBandPropertyToMessage(originalPayloadValue, msg);
            
            Message outputMsg = proxy.Operation(msg);

            Console.WriteLine("\nEncoding with secure WCF");
            ValidateResult(originalPayloadValue, outputMsg, Service.TransportModifier);
 
            ((IChannel)proxy).Close();
            host.Close();
        }
开发者ID:krolth,项目名称:CustomWcfEncoder,代码行数:31,代码来源:Program.cs

示例3: ImitatorServiceFactory

		public ImitatorServiceFactory()
		{
			var binding = BindingHelper.CreateBindingFromAddress("net.pipe://127.0.0.1/GKImitator/");
			var endpointAddress = new EndpointAddress(new Uri("net.pipe://127.0.0.1/GKImitator/"));
			_channelFactory = new ChannelFactory<IImitatorService>(binding, endpointAddress);
			_channelFactory.Open();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:7,代码来源:ImitatorServiceFactory.cs

示例4: DoCreate

		IFS2Contract DoCreate(string serverAddress)
		{
			if (serverAddress.StartsWith("net.pipe:"))
			{
				if (!FS2LoadHelper.Load())
					BalloonHelper.ShowFromFiresec("Не удается соединиться с агентом 2");
			}

			var binding = BindingHelper.CreateBindingFromAddress(serverAddress);

			var endpointAddress = new EndpointAddress(new Uri(serverAddress));
			ChannelFactory = new ChannelFactory<IFS2Contract>(binding, endpointAddress);

			foreach (OperationDescription operationDescription in ChannelFactory.Endpoint.Contract.Operations)
			{
				DataContractSerializerOperationBehavior dataContractSerializerOperationBehavior = operationDescription.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
				if (dataContractSerializerOperationBehavior != null)
					dataContractSerializerOperationBehavior.MaxItemsInObjectGraph = Int32.MaxValue;
			}

			ChannelFactory.Open();

			IFS2Contract firesecService = ChannelFactory.CreateChannel();
			(firesecService as IContextChannel).OperationTimeout = TimeSpan.FromMinutes(10);
			return firesecService;
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:26,代码来源:FS2Factory.cs

示例5: CreateInstance

 public static ChannelItem CreateInstance(BasicHttpBinding bind, EndpointAddress address)
 {
     ChannelFactory<IFICService> factory = new ChannelFactory<IFICService>(bind, address);
     factory.Open();
     IFICService service = factory.CreateChannel();
     return ((service == null) ? null : new ChannelItem(service));
 }
开发者ID:NoobSkie,项目名称:taobao-shop-helper,代码行数:7,代码来源:ChannelItem.cs

示例6: joinTopicsManager

        private static void joinTopicsManager(string username)
        {
            ChannelFactory<TopicsManager> dupFactory = null;
            TopicsManager clientProxy = null;
            dupFactory = new ChannelFactory<TopicsManager>(
                new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/TopicManager"));
            dupFactory.Open();
            clientProxy = dupFactory.CreateChannel();
            while (true)
            {
                Console.WriteLine("************TOPICS MANAGER************");
                Console.WriteLine("Liste des rooms diponibles : ");
                List<string> list = clientProxy.listTopics();
                foreach (var t in list)
                {
                    Console.WriteLine(t);
                }
                Console.WriteLine("1. Se connecter a une room \n2.Créer un nouveau chatroom");

                switch (Console.ReadLine())
                {
                    case "1":
                        Console.WriteLine("Entrez le nom de la room");
                        joinChatroom(clientProxy.joinTopic(Console.ReadLine()), username);

                        break;
                    case "2":
                        Console.WriteLine("Entrez le nom de la room");
                        clientProxy.createTopic(Console.ReadLine());
                        break;

                }
            }
        }
开发者ID:HelloItsDev,项目名称:Chat,代码行数:34,代码来源:Program.cs

示例7: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            string page = textBox1.Text;

            try
            {
                EndpointAddress address = new EndpointAddress(new Uri("net.tcp://localhost:2137/Server"));
                NetTcpBinding binding = new NetTcpBinding();
                binding.MaxBufferPoolSize = 4 * 128 * 1024 * 1024;
                binding.MaxBufferSize = 128 * 1024 * 1024;
                binding.MaxReceivedMessageSize = 128 * 1024 * 1024;
                ChannelFactory<IPictureService> fac = new ChannelFactory<IPictureService>(binding, address);
                fac.Open();
                var svc = fac.CreateChannel();

                MessageBox.Show(svc.TextMe("World"));
                Picture pic = svc.DownloadPicture(page);
                Bitmap bmp = pic.GetBitmap();
                pictureBox1.Image = new Bitmap(bmp, new Size(bmp.Width < 894 ? bmp.Width : 894, bmp.Height < 542 ? bmp.Height : 542));
            }
            catch (EndpointNotFoundException ex)
            {
                MessageBox.Show("Brak połączenia z serwerem.\n\n" + ex.Message.ToString());
            }
            
            

        }
开发者ID:konraddroptable,项目名称:AplikacjaRozproszona,代码行数:28,代码来源:Form1.cs

示例8: Main

        static void Main(string[] args)
        {
            // allow server certificate that doesn't match the host in the endpoint address
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreSubjectNameMismatch);

            string uri = "https://" + Environment.MachineName + ":8443/TestService/BinaryEncoderOverHTTPS";
            if (args.Length > 0)
            {
                uri = args[0];
            }
            EndpointAddress address = new EndpointAddress(uri);
            NetHttpBinding binding = new NetHttpBinding();
            ChannelFactory<IEchoService> factory = new ChannelFactory<IEchoService>(binding, address);
            factory.Open();
            IEchoService service = factory.CreateChannel();
            Console.WriteLine(service.Echo(new string('a', 1024)));

            Console.WriteLine("called service successfully using binding in code");

            factory = new ChannelFactory<IEchoService>("EchoServer");
            factory.Open();
            service = factory.CreateChannel();

            Console.WriteLine(service.Echo(new string('b', 1024)));
            Console.WriteLine("called service successfully using binding from config. Press enter to exit...");

            Console.ReadLine();
        }
开发者ID:ssickles,项目名称:archive,代码行数:28,代码来源:Client.cs

示例9: AuthForm

 public AuthForm()
 {
     InitializeComponent();
     ChannelFactory<AuthentificationManager> dupFactory = null;
     dupFactory = new ChannelFactory<AuthentificationManager>(
         new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8999/AuthManager"));
     dupFactory.Open();
     clientProxy = dupFactory.CreateChannel();
 }
开发者ID:HelloItsDev,项目名称:Chat,代码行数:9,代码来源:AuthForm.cs

示例10: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            ChannelFactory<SampleServer.ICalcService> factory = new ChannelFactory<SampleServer.ICalcService>("CustomBinding_ICalcService");
            factory.Open();
            SampleServer.ICalcService channel = factory.CreateChannel();
            string result = channel.SetValue(int.Parse(textBox1.Text));
            factory.Close();

            MessageBox.Show(result);
        }
开发者ID:tsmatsuz,项目名称:20080826_WCFBakaChannelDemo,代码行数:10,代码来源:Form1.cs

示例11: Configure

 public static void Configure()
 {
     try
     {
         PubilcyInfoProxy = new ChannelFactory<IPubilcyInfo>("BindingIPubilcyInfoService");
         PubilcyInfoProxy.Open();
     }
     catch (Exception ex)
     {
         Log4netHelper.Logger.Fatal(ex);
     }
 }
开发者ID:dalinhuang,项目名称:cndreams,代码行数:12,代码来源:WCFClientHelper.cs

示例12: Main

 static void Main(string[] args)
 {
     EndpointAddress address = new EndpointAddress("http://127.0.0.1:3721/demoservice");
     Binding binding = new WebHttpBinding();
     ContractDescription contract = ContractDescription.GetContract(typeof(IContract));
     ServiceEndpoint endpoint = new ServiceEndpoint(contract, binding, address);
     using (ChannelFactory<IContract> channelFactory = new ChannelFactory<IContract>(endpoint))
     {
         channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());
         channelFactory.Open();
     }
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:12,代码来源:Program.cs

示例13: OnBrowserCreated

        public override void OnBrowserCreated(CefBrowserWrapper browser)
        {
            browsers.Add(browser);

            if (parentBrowserId == null)
            {
                parentBrowserId = browser.BrowserId;
            }

            if (ParentProcessId == null || parentBrowserId == null)
            {
                return;
            }

            var browserId = browser.IsPopup ? parentBrowserId.Value : browser.BrowserId;

            var serviceName = RenderprocessClientFactory.GetServiceName(ParentProcessId.Value, browserId);

            var binding = BrowserProcessServiceHost.CreateBinding();

            var channelFactory = new ChannelFactory<IBrowserProcess>(
                binding,
                new EndpointAddress(serviceName)
            );

            channelFactory.Open();

            var browserProcess = channelFactory.CreateChannel();
            var clientChannel = ((IClientChannel)browserProcess);

            try
            {
                clientChannel.Open();
                if (!browser.IsPopup)
                {
                    browserProcess.Connect();
                }

                var javascriptObject = browserProcess.GetRegisteredJavascriptObjects();

                if (javascriptObject.MemberObjects.Count > 0)
                {
                    browser.JavascriptRootObject = javascriptObject;
                }

                browser.ChannelFactory = channelFactory;
                browser.BrowserProcess = browserProcess;
            }
            catch(Exception)
            {
            }
        }
开发者ID:ruisebastiao,项目名称:CefSharp,代码行数:52,代码来源:CefRenderProcess.cs

示例14: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Connecting to service.");
            using (var channelFactory = new ChannelFactory<INetTcpService>("NetTcpBinding_IService1"))
            {
                channelFactory.Open();
                var client = channelFactory.CreateChannel();

                //The line below will throw an exception if .NET 4.6 is installed, works fine with 4.5.x
                string result = client.SayHello(Environment.UserName);
                Console.WriteLine("Recieved response, '{0}'", result);
            }
            Console.ReadLine();
        }
开发者ID:dotnetdan,项目名称:tcp-ssl-bug,代码行数:14,代码来源:Program.cs

示例15: ClientForm_Load

		void ClientForm_Load(object sender, EventArgs e)
		{
			string serviceUrl = "net.tcp://localhost:65500/Communicate";
			NetTcpBinding ntb = new NetTcpBinding();
			ntb.TransactionFlow = false;
			ntb.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
			ntb.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
			ntb.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
			ntb.Security.Mode = SecurityMode.Transport;
			f = new ChannelFactory<ICommunicate>(ntb, serviceUrl);
			f.Credentials.Windows.ClientCredential.UserName = "michael";
			f.Credentials.Windows.ClientCredential.Password = "k:;1n";
			f.Open();
		}
开发者ID:mind0n,项目名称:hive,代码行数:14,代码来源:ClientForm.cs


注:本文中的System.ServiceModel.ChannelFactory.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。