protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            if (binding.GetType() != typeof(NetUdpBinding))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                    "Invalid type for binding. Expected type: {0}. Type passed in: {1}.",
                    typeof(NetUdpBinding).AssemblyQualifiedName,
                    binding.GetType().AssemblyQualifiedName));
            }
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            if (binding.GetType() != typeof(AmqpBinaryBinding))
            {
                throw new ArgumentException(string.Format("Invalid type for configuring an AMQP binding. Expected type: {0}. Type passed in: {1}.",
                    typeof(AmqpBinaryBinding).AssemblyQualifiedName,
                    binding.GetType().AssemblyQualifiedName));
            }

            base.OnApplyConfiguration(binding);
        }
 protected internal virtual void InitializeFrom(Binding binding)
 {
     if (binding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binding");
     }
     if (binding.GetType() != this.BindingElementType)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.ServiceModel.SR.GetString("ConfigInvalidTypeForBinding", new object[] { (this.BindingElementType == null) ? string.Empty : this.BindingElementType.AssemblyQualifiedName, binding.GetType().AssemblyQualifiedName }));
     }
     this.CloseTimeout = binding.CloseTimeout;
     this.OpenTimeout = binding.OpenTimeout;
     this.ReceiveTimeout = binding.ReceiveTimeout;
     this.SendTimeout = binding.SendTimeout;
 }
 public void ApplyConfiguration(Binding binding)
 {
     if (binding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binding");
     }
     if (binding.GetType() != this.BindingElementType)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.ServiceModel.SR.GetString("ConfigInvalidTypeForBinding", new object[] { (this.BindingElementType == null) ? string.Empty : this.BindingElementType.AssemblyQualifiedName, binding.GetType().AssemblyQualifiedName }));
     }
     binding.CloseTimeout = this.CloseTimeout;
     binding.OpenTimeout = this.OpenTimeout;
     binding.ReceiveTimeout = this.ReceiveTimeout;
     binding.SendTimeout = this.SendTimeout;
     this.OnApplyConfiguration(binding);
 }
示例#5
0
        void AddBinding(TreeNode endpointNode, System.ServiceModel.Channels.Binding binding)
        {
            string bindingName = ExtractTypeName(binding.GetType());

            TreeNode bindingNode = new BindingNode(this, binding, bindingName, BindingIndex, BindingIndex);

            endpointNode.Nodes.Add(bindingNode);
        }
 public static void Trace(TraceEventType type, int v, string description, System.Type contractType, Binding binding)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusTypedChannelBuilderSchema schema = new ComPlusTypedChannelBuilderSchema(contractType.ToString(), (binding != null) ? binding.GetType().ToString() : null);
         TraceUtility.TraceEvent(type, v, System.ServiceModel.SR.GetString(description), (TraceRecord) schema);
     }
 }
      internal static void ConfigureBinding(Binding binding,bool anonymous)
      {
         if(binding is NetTcpRelayBinding)
         {
            NetTcpRelayBinding tcpBinding = (NetTcpRelayBinding)binding;
            tcpBinding.Security.Mode  = EndToEndSecurityMode.Message;
            if(anonymous)
            {
               tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
            }
            else
            {
               tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
            }

            tcpBinding.ConnectionMode = TcpRelayConnectionMode.Hybrid;
            tcpBinding.ReliableSession.Enabled = true; 

            return;
         }
         if(binding is WSHttpRelayBinding)
         {
            WSHttpRelayBinding wsBinding = (WSHttpRelayBinding)binding;
            wsBinding.Security.Mode = EndToEndSecurityMode.Message;
            if(anonymous)
            {
               wsBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
            }
            else
            {
               wsBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
            }
            wsBinding.ReliableSession.Enabled = true; 

            return;
         }
         if(binding is NetOnewayRelayBinding)
         {
            NetOnewayRelayBinding onewayBinding = (NetOnewayRelayBinding)binding;
            onewayBinding.Security.Mode = EndToEndSecurityMode.Message;
            if(anonymous)
            {
               onewayBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
            }
            else
            {
               onewayBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
            }
            return;
         }
         throw new InvalidOperationException(binding.GetType() + " is unsupported");
      }
示例#8
0
        void AddBinding(TreeNode endpointNode, System.ServiceModel.Channels.Binding binding)
        {
            string bindingName;

            if (IsServiceBusAddress(m_MexAddressTextBox.Text))
            {
                if (binding.GetType() == typeof(CustomBinding))
                {
                    bindingName = (binding.Name.Split('_'))[0];
                }
                else
                {
                    bindingName = ExtractTypeName(binding.GetType());
                }
            }
            else
            {
                bindingName = ExtractTypeName(binding.GetType());
            }

            TreeNode bindingNode = new BindingNode(this, binding, bindingName, BindingIndex, BindingIndex);

            endpointNode.Nodes.Add(bindingNode);
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            if (binding.GetType() != typeof(SampleProfileUdpBinding))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                    "Invalid type for binding. Expected type: {0}. Type passed in: {1}.",
                    typeof(SampleProfileUdpBinding).AssemblyQualifiedName,
                    binding.GetType().AssemblyQualifiedName));
            }
            SampleProfileUdpBinding udpBinding = (SampleProfileUdpBinding)binding;

            udpBinding.OrderedSession = this.OrderedSession;
            udpBinding.ReliableSessionEnabled = this.ReliableSessionEnabled;
            udpBinding.SessionInactivityTimeout = this.SessionInactivityTimeout;
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            var qpidbinding = binding as QpidBinding;
            if (qpidbinding == null)
            {
                throw new ArgumentException(
                    string.Format("Invalid type for binding. Expected {0}, Passed: {1}",
                        typeof(QpidBinding).AssemblyQualifiedName,
                        binding.GetType().AssemblyQualifiedName));
            }

            qpidbinding.Host = Host;
            qpidbinding.OneWayOnly = OneWayOnly;
            qpidbinding.TransactionFlow = TransactionFlowEnabled;
            qpidbinding.Password = Password;
            qpidbinding.UserName = UserName;
            qpidbinding.VirtualHost = VirtualHost;
            qpidbinding.PortNumber = PortNumber;
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            RabbitMQBinding rabbind = binding as RabbitMQBinding;
            if (rabbind == null)
            {
                throw new ArgumentException(
                    string.Format("Invalid type for binding. Expected {0}, Passed: {1}",
                        typeof(RabbitMQBinding).AssemblyQualifiedName,
                        binding.GetType().AssemblyQualifiedName));
            }

            rabbind.AutoBindExchange = this.AutoBindExchange;
            rabbind.BrokerProtocol = this.Protocol;
            rabbind.ExactlyOnce = this.ExactlyOnce;
            rabbind.Transport.MaxReceivedMessageSize = this.MaxMessageSize;
            rabbind.OneWayOnly = this.OneWayOnly;
            rabbind.PersistentDelivery = this.PersistentDelivery;
            rabbind.ReplyToExchange = this.ReplyToExchange == null ? null : new Uri(this.ReplyToExchange);
            rabbind.ReplyToQueue = this.ReplyToQueue;
            rabbind.TTL = this.TTL;
        }
 public static void Trace(TraceEventType type, int traceCode, string description, XmlQualifiedName bindingQname, XmlQualifiedName contractQname, System.Web.Services.Description.ServiceDescription wsdl, ContractDescription contract, System.ServiceModel.Channels.Binding binding, XmlSchemas schemas)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         string name = "Service";
         if (wsdl.Name != null)
         {
             name = wsdl.Name;
         }
         System.Type      contractType = contract.ContractType;
         XmlQualifiedName serviceQname = new XmlQualifiedName(name, wsdl.TargetNamespace);
         foreach (System.Xml.Schema.XmlSchema schema in schemas)
         {
             ComPlusWsdlChannelBuilderSchema schema2 = new ComPlusWsdlChannelBuilderSchema(bindingQname, contractQname, serviceQname, (contractType != null) ? contractType.ToString() : null, (binding != null) ? binding.GetType().ToString() : null, schema);
             TraceUtility.TraceEvent(type, traceCode, System.ServiceModel.SR.GetString(description), (TraceRecord)schema2);
         }
     }
 }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (null == binding)
            {
                throw new ArgumentNullException("binding");
            }

            if (binding.GetType() != typeof(WSStreamedHttpBinding))
            {
                throw new ArgumentException();
            }
            WSStreamedHttpBinding wssBinding = (WSStreamedHttpBinding)binding;

            wssBinding.HostNameComparisonMode = this.HostNameComparisonMode;
            wssBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            wssBinding.MaxBufferSize = this.MaxBufferSize;
            wssBinding.ProxyAddress = this.ProxyAddress;
            wssBinding.BypassProxyOnLocal = this.BypassProxyOnLocal;
            wssBinding.UseDefaultWebProxy = this.UseDefaultWebProxy;
            wssBinding.TransferMode = this.TransferMode;
            wssBinding.TextEncoding = this.TextEncoding;
            wssBinding.FlowTransactions = this.FlowTransactions;
            wssBinding.SecurityMode = this.SecurityMode;
        }
		protected internal override bool TryAdd (string name, Binding binding, SysConfig config)
		{
			if (!binding.GetType ().Equals (typeof (CustomBinding)))
				return false;
			
			var element = new CustomBindingElement ();
			element.Name = name;
			element.InitializeFrom (binding);
			Bindings.Add (element);
			return true;
		}
        public void ApplyConfiguration(Binding binding)
        {
            if (null == binding)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binding");
            }
            if (binding.GetType() != this.BindingElementType)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.ConfigInvalidTypeForBinding,
                    (this.BindingElementType == null) ? string.Empty : this.BindingElementType.AssemblyQualifiedName,
                    binding.GetType().AssemblyQualifiedName));
            }

            // The properties binding.Name and this.Name are actually two different things:
            //     - binding.Name corresponds to how the WSDL for this binding is surfaced,
            //       it is used in conjunction with binding.Namespace
            //     - this.Name is a token used as a key in the binding collection to identify
            //       a specific bucket of configuration settings.
            // Thus, the Name property is skipped here.
            binding.CloseTimeout = this.CloseTimeout;
            binding.OpenTimeout = this.OpenTimeout;
            binding.ReceiveTimeout = this.ReceiveTimeout;
            binding.SendTimeout = this.SendTimeout;

            this.OnApplyConfiguration(binding);
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if (binding == null)
                throw new ArgumentNullException("binding");

            RabbitMQBinding rabbind = binding as RabbitMQBinding;
            if (rabbind == null)
            {
                throw new ArgumentException(
                    string.Format("Invalid type for binding. Expected {0}, Passed: {1}",
                        typeof(RabbitMQBinding).AssemblyQualifiedName,
                        binding.GetType().AssemblyQualifiedName));
            }

            rabbind.HostName = this.HostName;
            rabbind.Port = this.Port;
            rabbind.BrokerProtocol = this.Protocol;
            rabbind.OneWayOnly = this.OneWayOnly;
            rabbind.TransactionFlow = this.TransactionFlowEnabled;
            rabbind.Transport.Password = this.Password;
            rabbind.Transport.Username = this.Username;
            rabbind.Transport.VirtualHost = this.VirtualHost;
            rabbind.Transport.MaxReceivedMessageSize = this.MaxMessageSize;
            rabbind.QueueName = this.QueueName;
            rabbind.Durable = this.Durable;
            rabbind.AutoDelete = this.AutoDelete;
            rabbind.Exclusive = this.Exclusive;
        }
示例#17
0
        private static string GetDetails(Channels.Binding binding)
        {
            string mode           = null;
            string credentialType = null;
            string name           = null;

            try
            {
                if (binding is HttpBindingBase)
                {
                    GetHttpBindingBaseDetails((HttpBindingBase)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is MsmqIntegration.MsmqIntegrationBinding)
                {
                    GetMsmqIntegrationBindingDetails((MsmqIntegration.MsmqIntegrationBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is NetMsmqBinding)
                {
                    GetNetMsmqBindingDetails((NetMsmqBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is NetNamedPipeBinding)
                {
                    GetNetNamedPipeBindingDetails((NetNamedPipeBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is NetTcpBinding) // NetTcpContextBinding
                {
                    GetNetTcpBindingDetails((NetTcpBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is WSDualHttpBinding)
                {
                    GetWSDualHttpBindingDetails((WSDualHttpBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is WSFederationHttpBinding) // WS2007FederationHttpBinding
                {
                    GetWSFederationHttpBindingDetails((WSFederationHttpBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is WSHttpBinding) // WS2007HttpBinding, WSHttpContextBinding
                {
                    GetWSHttpBindingDetails((WSHttpBinding)binding, ref name, ref mode, ref credentialType);
                }
                else if (binding is Channels.CustomBinding)
                {
                    GetCustomBindingDetails((Channels.CustomBinding)binding, ref name, ref mode, ref credentialType);
                }
#pragma warning disable CS0618
                else if (binding is NetPeerTcpBinding)  // depracated
                {
                    GetNetPeerTcpBindingDetails((NetPeerTcpBinding)binding, ref name, ref mode, ref credentialType);
                }
#pragma warning restore CS0618
                else
                {
                    // Only dump the binding name with a known list while not known type, no details.
                    name = IsKnownType(binding) ? binding.GetType().Name : "UserBinding";
                }
            }
            catch (Exception e)
            {
                // Make sure we won't affect customer logic by collecting telemetry data

                if (Fx.IsFatal(e))
                {
                    throw;
                }

                DiagnosticUtility.TraceHandledException(e, System.Diagnostics.TraceEventType.Warning);
            }

            return($"{binding.Scheme}:{name ?? "unknown"}:{mode ?? "unknown"}:{credentialType ?? "unknown"}");
        }
示例#18
0
#pragma warning restore CS0618

        #region Helper for GDPR

        // To avoid GDPR issue, this function will check if the binding type name is a known type name
        // For user type, we would append "*" at the end of known type name instead of using user type name directly
        private static string GetBindingName <T>(Channels.Binding binding) where T : Channels.Binding
        {
            string name = typeof(T).Name;

            return(binding.GetType().Name == name ? name : $"{name}*");
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            if ((binding == null))
            {
                throw new System.ArgumentNullException("binding");
            }
            if ((binding.GetType() != typeof(ByteStreamHttpBinding)))
            {
                throw new System.ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid type for binding. Expected type: {0}. Type passed in: {1}.", typeof(ByteStreamHttpBinding).AssemblyQualifiedName, binding.GetType().AssemblyQualifiedName));
            }
            ByteStreamHttpBinding ByteStreamHttpBinding = ((ByteStreamHttpBinding)(binding));
            ByteStreamHttpBinding.HostNameComparisonMode = this.HostNameComparisonMode;
            ByteStreamHttpBinding.MaxBufferSize = this.MaxBufferSize;
            ByteStreamHttpBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
            ByteStreamHttpBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            ByteStreamHttpBinding.TransferMode = this.TransferMode;

            // Copy reader quotas over if set from config.
            if (this.ReaderQuotas.MaxDepth != 0)
            {
                ByteStreamHttpBinding.ReaderQuotas.MaxDepth = this.ReaderQuotas.MaxDepth;
            }
            if (this.ReaderQuotas.MaxStringContentLength != 0)
            {
                ByteStreamHttpBinding.ReaderQuotas.MaxStringContentLength = this.ReaderQuotas.MaxStringContentLength;
            }
            if (this.ReaderQuotas.MaxArrayLength != 0)
            {
                ByteStreamHttpBinding.ReaderQuotas.MaxArrayLength = this.ReaderQuotas.MaxArrayLength;
            }
            if (this.ReaderQuotas.MaxBytesPerRead != 0)
            {
                ByteStreamHttpBinding.ReaderQuotas.MaxBytesPerRead = this.ReaderQuotas.MaxBytesPerRead;
            }
            if (this.ReaderQuotas.MaxNameTableCharCount != 0)
            {
                ByteStreamHttpBinding.ReaderQuotas.MaxNameTableCharCount = this.ReaderQuotas.MaxNameTableCharCount;
            }
        }
示例#20
0
		public static BindingCollectionElement FindCollectionElement (Binding binding, SysConfig config)
		{
			var section = (BindingsSection) config.GetSection ("system.serviceModel/bindings");
			foreach (var element in section.BindingCollections) {
				if (binding.GetType ().Equals (element.BindingType))
					return element;
			}
			
			return null;
		}
 protected override void OnApplyConfiguration(Binding binding) {
     if ((binding == null)) {
         throw new System.ArgumentNullException("binding");
     }
     if ((binding.GetType() != typeof(NetHttpBinding))) {
         throw new System.ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid type for binding. Expected type: {0}. Type passed in: {1}.", typeof(NetHttpBinding).AssemblyQualifiedName, binding.GetType().AssemblyQualifiedName));
     }
     NetHttpBinding netHttpBinding = ((NetHttpBinding)(binding));
     netHttpBinding.BypassProxyOnLocal = this.BypassProxyOnLocal;
     netHttpBinding.HostNameComparisonMode = this.HostNameComparisonMode;
     netHttpBinding.MaxBufferSize = this.MaxBufferSize;
     netHttpBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
     netHttpBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
     netHttpBinding.ProxyAddress = this.ProxyAddress;
     netHttpBinding.SecurityMode = this.SecurityMode;
     netHttpBinding.TransferMode = this.TransferMode;
     netHttpBinding.UseDefaultWebProxy = this.UseDefaultWebProxy;
     netHttpBinding.ReaderQuotas = this.ReaderQuotas;
 }