當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。