当前位置: 首页>>代码示例>>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;未经允许,请勿转载。