當前位置: 首頁>>代碼示例>>C#>>正文


C# NetNamedPipeBinding.CreateBindingElements方法代碼示例

本文整理匯總了C#中System.ServiceModel.NetNamedPipeBinding.CreateBindingElements方法的典型用法代碼示例。如果您正苦於以下問題:C# NetNamedPipeBinding.CreateBindingElements方法的具體用法?C# NetNamedPipeBinding.CreateBindingElements怎麽用?C# NetNamedPipeBinding.CreateBindingElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ServiceModel.NetNamedPipeBinding的用法示例。


在下文中一共展示了NetNamedPipeBinding.CreateBindingElements方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnStart

        //protected override void OnStart(string[] args)
        //{
        //    //Uri baseAddress = new Uri("http://localhost:8002/mailnotifier/service");
        //    string address = "net.pipe://localhost/mailnotifier/sign";
        //    m_mailNotifierService = new NotifierService();
        //    m_serviceHost = new ServiceHost(m_mailNotifierService, new Uri(address));
        //    NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
        //    m_serviceHost.AddServiceEndpoint(typeof(IMailNotifierService), binding, address);
        //    long maxBufferPoolSize = binding.MaxBufferPoolSize;
        //    int maxBufferSize = binding.MaxBufferSize;
        //    int maxConnections = binding.MaxConnections;
        //    long maxReceivedMessageSize = binding.MaxReceivedMessageSize;
        //    NetNamedPipeSecurity security = binding.Security;
        //    string scheme = binding.Scheme;
        //    var bCollection = binding.CreateBindingElements();
        //    HostNameComparisonMode hostNameComparisonMode = binding.HostNameComparisonMode;
        //    bool TransactionFlow = binding.TransactionFlow;
        //    TransactionProtocol transactionProtocol = binding.TransactionProtocol;
        //    EnvelopeVersion envelopeVersion = binding.EnvelopeVersion;
        //    TransferMode transferMode = binding.TransferMode;
        //    m_serviceHost.Open();
        //    base.OnStart(args);
        //}
        protected override void OnStart(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8002/mailnotifier/service");
            string address = "net.pipe://localhost/mailnotifier/sign";

            m_mailNotifierService = new NotifierService();
            m_serviceHost = new ServiceHost(m_mailNotifierService, baseAddress);

            NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
            m_serviceHost.AddServiceEndpoint(typeof(IMailNotifierService), binding, address);

            // Add a mex endpoint
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.HttpGetUrl = new Uri("http://localhost:8003/mailnotifier");
            m_serviceHost.Description.Behaviors.Add(smb);

            long maxBufferPoolSize = binding.MaxBufferPoolSize;

            int maxBufferSize = binding.MaxBufferSize;

            int maxConnections = binding.MaxConnections;

            long maxReceivedMessageSize =
                binding.MaxReceivedMessageSize;

            NetNamedPipeSecurity security = binding.Security;

            string scheme = binding.Scheme;
            var bCollection = binding.CreateBindingElements();

            HostNameComparisonMode hostNameComparisonMode =
                binding.HostNameComparisonMode;

            bool TransactionFlow = binding.TransactionFlow;

            TransactionProtocol transactionProtocol = binding.TransactionProtocol;
            EnvelopeVersion envelopeVersion = binding.EnvelopeVersion;
            TransferMode transferMode = binding.TransferMode;

            m_serviceHost.Open();

            base.OnStart(args);
        }
開發者ID:rpwjanzen,項目名稱:blinken,代碼行數:67,代碼來源:MailNotifierWindowsService.cs

示例2: Main

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Uri baseAddress = new Uri("http://localhost:8000/ledsign/service");
                ServiceHost serviceHost = new ServiceHost(new SignService(), baseAddress);
                try
                {
                    // full service url is: http://localhost:8000/ledsign/service/ledsign
                    serviceHost.AddServiceEndpoint(typeof(ISignService), new WSHttpBinding(SecurityMode.None), "ledsign");

                    // create a mex behavior
                    ServiceMetadataBehavior smb = new ServiceMetadataBehavior()
                    {
                        HttpGetEnabled = true,
                    };
                    serviceHost.Description.Behaviors.Add(smb);

                    serviceHost.Open();

                    Console.WriteLine("The service is ready.");
                    Console.ReadLine();

                    serviceHost.Close();
                }
                catch (CommunicationException e)
                {
                    Console.WriteLine("An exception occurred " + e.Message);
                    serviceHost.Abort();
                    Console.ReadLine();
                }
            }
            else
            {
                Uri baseAddress = new Uri("http://localhost:8000/ledsign/service");
                string address = "net.pipe://localhost/ledsign/sign";

                // Create a ServiceHost for the CalculatorService type and provide the base address.
                SignService signService = new SignService();
                using (ServiceHost serviceHost = new ServiceHost(signService, baseAddress))
                {
                    NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                    serviceHost.AddServiceEndpoint(typeof(ISignService), binding, address);

                    // Add a mex endpoint
                    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                    smb.HttpGetEnabled = true;
                    smb.HttpGetUrl = new Uri("http://localhost:8001/ledsign");
                    serviceHost.Description.Behaviors.Add(smb);

                    long maxBufferPoolSize = binding.MaxBufferPoolSize;

                    int maxBufferSize = binding.MaxBufferSize;

                    int maxConnections = binding.MaxConnections;

                    long maxReceivedMessageSize =
                        binding.MaxReceivedMessageSize;

                    NetNamedPipeSecurity security = binding.Security;

                    string scheme = binding.Scheme;
                    var bCollection = binding.CreateBindingElements();

                    HostNameComparisonMode hostNameComparisonMode =
                        binding.HostNameComparisonMode;

                    bool TransactionFlow = binding.TransactionFlow;

                    TransactionProtocol transactionProtocol = binding.TransactionProtocol;
                    EnvelopeVersion envelopeVersion = binding.EnvelopeVersion;
                    TransferMode transferMode = binding.TransferMode;

                    serviceHost.Open();

                    Console.WriteLine("The service is ready.");
                    Console.WriteLine("Press <ENTER> to terminate service.");
                    Console.WriteLine();
                    Console.ReadLine();

                    serviceHost.Close();
                }
            }
        }
開發者ID:rpwjanzen,項目名稱:blinken,代碼行數:84,代碼來源:Program.cs


注:本文中的System.ServiceModel.NetNamedPipeBinding.CreateBindingElements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。