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


C# NetTcpBinding.CreateBindingElements方法代码示例

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


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

示例1: DefaultValues

		public void DefaultValues ()
		{
			var n = new NetTcpBinding ();
			Assert.AreEqual (HostNameComparisonMode.StrongWildcard, n.HostNameComparisonMode, "#1");
			Assert.AreEqual (10, n.ListenBacklog, "#2");
			Assert.AreEqual (false, n.PortSharingEnabled, "#3");

			var tr = n.CreateBindingElements ().Find<TcpTransportBindingElement> ();
			Assert.IsNotNull (tr, "#tr1");
			Assert.AreEqual (false, tr.TeredoEnabled, "#tr2");
			Assert.AreEqual ("net.tcp", tr.Scheme, "#tr3");

			Assert.IsFalse (n.TransactionFlow, "#4");
			var tx = n.CreateBindingElements ().Find<TransactionFlowBindingElement> ();
			Assert.IsNotNull (tx, "#tx1");

			Assert.AreEqual (SecurityMode.Transport, n.Security.Mode, "#sec1");
			Assert.AreEqual (ProtectionLevel.EncryptAndSign, n.Security.Transport.ProtectionLevel, "#sec2");
			Assert.AreEqual (TcpClientCredentialType.Windows/*huh*/, n.Security.Transport.ClientCredentialType, "#sec3");

			var bc = n.CreateBindingElements ();
			Assert.AreEqual (4, bc.Count, "#bc1");
			Assert.AreEqual (typeof (TransactionFlowBindingElement), bc [0].GetType (), "#bc2");
			Assert.AreEqual (typeof (BinaryMessageEncodingBindingElement), bc [1].GetType (), "#bc3");
			Assert.AreEqual (typeof (WindowsStreamSecurityBindingElement), bc [2].GetType (), "#bc4");
			Assert.AreEqual (typeof (TcpTransportBindingElement), bc [3].GetType (), "#bc5");
			
			Assert.IsFalse (n.CanBuildChannelFactory<IRequestChannel> (), "#cbf1");
			Assert.IsFalse (n.CanBuildChannelFactory<IOutputChannel> (), "#cbf2");
			Assert.IsFalse (n.CanBuildChannelFactory<IDuplexChannel> (), "#cbf3");
			Assert.IsTrue (n.CanBuildChannelFactory<IDuplexSessionChannel> (), "#cbf4");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:32,代码来源:NetTcpBindingTest.cs

示例2: DefaultValues

		public void DefaultValues ()
		{
			var n = new NetTcpBinding ();
			Assert.AreEqual (HostNameComparisonMode.StrongWildcard, n.HostNameComparisonMode, "#1");
			Assert.AreEqual (10, n.ListenBacklog, "#2");
			Assert.AreEqual (false, n.PortSharingEnabled, "#3");

			var tr = n.CreateBindingElements ().Find<TcpTransportBindingElement> ();
			Assert.IsNotNull (tr, "#tr1");
			Assert.AreEqual (false, tr.TeredoEnabled, "#tr2");
			Assert.AreEqual ("net.tcp", tr.Scheme, "#tr3");

			Assert.IsFalse (n.TransactionFlow, "#4");
			var tx = n.CreateBindingElements ().Find<TransactionFlowBindingElement> ();
			Assert.IsNotNull (tx, "#tx1");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:16,代码来源:NetTcpBindingTest.cs

示例3: MessageSecurityAndBindings

		public void MessageSecurityAndBindings ()
		{
			var n = new NetTcpBinding ();
			n.Security.Mode = SecurityMode.Message;
			
			Assert.AreEqual (SecurityAlgorithmSuite.Default, n.Security.Message.AlgorithmSuite, "#sec1");
			Assert.AreEqual (MessageCredentialType.Windows/*huh*/, n.Security.Message.ClientCredentialType, "#sec2");

			Assert.AreEqual (TransferMode.Buffered, n.TransferMode, "#sec3");

			var bc = n.CreateBindingElements ();
			Assert.AreEqual (4, bc.Count, "#bc1");
			Assert.AreEqual (typeof (TransactionFlowBindingElement), bc [0].GetType (), "#bc2");
			Assert.AreEqual (typeof (SymmetricSecurityBindingElement), bc [1].GetType (), "#bc3");
			Assert.AreEqual (typeof (BinaryMessageEncodingBindingElement), bc [2].GetType (), "#bc4");
			Assert.AreEqual (typeof (TcpTransportBindingElement), bc [3].GetType (), "#bc5");

			Assert.IsFalse (n.CanBuildChannelFactory<IRequestChannel> (), "#cbf1");
			Assert.IsFalse (n.CanBuildChannelFactory<IOutputChannel> (), "#cbf2");
			Assert.IsFalse (n.CanBuildChannelFactory<IDuplexChannel> (), "#cbf3");
			Assert.IsTrue (n.CanBuildChannelFactory<IDuplexSessionChannel> (), "#cbf4");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:22,代码来源:NetTcpBindingTest.cs

示例4: MessageSecurityAndBindings4

		public void MessageSecurityAndBindings4 ()
		{
			var n = new NetTcpBinding ();
			n.Security.Mode = SecurityMode.Message;
			n.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;

			var bc = n.CreateBindingElements ();
			Assert.AreEqual (4, bc.Count, "#bc1");
			Assert.AreEqual (typeof (TransactionFlowBindingElement), bc [0].GetType (), "#bc2");
			Assert.AreEqual (typeof (SymmetricSecurityBindingElement), bc [1].GetType (), "#bc3");
			Assert.AreEqual (typeof (BinaryMessageEncodingBindingElement), bc [2].GetType (), "#bc4");
			Assert.AreEqual (typeof (TcpTransportBindingElement), bc [3].GetType (), "#bc5");

			Assert.IsFalse (n.CanBuildChannelFactory<IRequestChannel> (), "#cbf1");
			Assert.IsFalse (n.CanBuildChannelFactory<IOutputChannel> (), "#cbf2");
			Assert.IsFalse (n.CanBuildChannelFactory<IDuplexChannel> (), "#cbf3");
			Assert.IsTrue (n.CanBuildChannelFactory<IDuplexSessionChannel> (), "#cbf4");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:18,代码来源:NetTcpBindingTest.cs

示例5: GetBinding

        /// <summary>
        /// Gets the WCF service binding for the specified protocol, security mode, and throttle settings.
        /// </summary>
        /// <param name="protocol">The protocol.</param>
        /// <param name="securityMode">The security mode.</param>
        /// <param name="maxConnections">The max connections.</param>
        /// <param name="leaseTimeout">The lease timeout.</param>
        /// <returns>A <see cref="Binding"/> object.</returns>
        public static Binding GetBinding(BusinessServicesProtocol protocol, SecurityMode? securityMode, int? maxConnections, int? leaseTimeout)
        {
            if (protocol == BusinessServicesProtocol.WSHttp)
            {
                WSHttpBinding binding = new WSHttpBinding();

                binding.Security.Mode = securityMode ?? ConfigSettingsReader.WSHttpWcfSecurityMode();
                binding.MaxReceivedMessageSize = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxBytesPerRead = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxDepth = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxArrayLength = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxStringContentLength = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReceiveTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.SendTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.OpenTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.CloseTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.ReliableSession.InactivityTimeout = ConfigSettingsReader.ServicesClientTimeout();

                return binding;
            }
            else if (protocol == BusinessServicesProtocol.NetTcp)
            {
                NetTcpBinding binding = new NetTcpBinding();

                binding.Security.Mode = securityMode ?? ConfigSettingsReader.NetTcpWcfSecurityMode();
                binding.MaxReceivedMessageSize = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxBytesPerRead = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxDepth = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxArrayLength = ConfigSettingsReader.MaxSendReceiveSize();
                binding.ReaderQuotas.MaxStringContentLength = ConfigSettingsReader.MaxSendReceiveSize();
                binding.PortSharingEnabled = ConfigSettingsReader.PortSharingEnabled();
                binding.ReceiveTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.SendTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.OpenTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.CloseTimeout = ConfigSettingsReader.ServicesClientTimeout();
                binding.ReliableSession.InactivityTimeout = ConfigSettingsReader.ServicesClientTimeout();

                if (maxConnections != null)
                    binding.MaxConnections = maxConnections.Value;

                if (leaseTimeout != null)
                    binding.CreateBindingElements().Find<TcpTransportBindingElement>().ConnectionPoolSettings.LeaseTimeout = new TimeSpan(0, 0, leaseTimeout.Value);

                return binding;
            }
            else
            {
                NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);

                binding.MaxReceivedMessageSize = BusinessServicesConstants.MaxSendReceiveSize;
                binding.ReaderQuotas.MaxBytesPerRead = BusinessServicesConstants.MaxSendReceiveSize;
                binding.ReaderQuotas.MaxDepth = BusinessServicesConstants.MaxSendReceiveSize;
                binding.ReaderQuotas.MaxArrayLength = BusinessServicesConstants.MaxSendReceiveSize;
                binding.ReaderQuotas.MaxStringContentLength = BusinessServicesConstants.MaxSendReceiveSize;
                binding.ReceiveTimeout = new TimeSpan(0, BusinessServicesConstants.ServicesClientTimeout, 0);
                binding.SendTimeout = new TimeSpan(0, BusinessServicesConstants.ServicesClientTimeout, 0);
                binding.OpenTimeout = new TimeSpan(0, BusinessServicesConstants.ServicesClientTimeout, 0);
                binding.CloseTimeout = new TimeSpan(0, BusinessServicesConstants.ServicesClientTimeout, 0);

                if (maxConnections != null)
                    binding.MaxConnections = maxConnections.Value;

                return binding;
            }
        }
开发者ID:rickeygalloway,项目名称:Test,代码行数:73,代码来源:BusinessServicesUtilities.cs


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