Exemplo n.º 1
0
        protected override void OnApplyConfiguration(Binding binding)
        {
            var b = (WSHttpBindingBase)binding;

            b.BypassProxyOnLocal     = BypassProxyOnLocal;
            b.HostNameComparisonMode = HostNameComparisonMode;
            b.MaxBufferPoolSize      = MaxBufferPoolSize;
            b.MaxReceivedMessageSize = MaxReceivedMessageSize;
            b.MessageEncoding        = MessageEncoding;
            b.ProxyAddress           = ProxyAddress;
            b.ReaderQuotas           = ReaderQuotas.Create();
            ReliableSession.ApplyConfiguration(b.ReliableSession);
            b.TextEncoding       = TextEncoding;
            b.TransactionFlow    = TransactionFlow;
            b.UseDefaultWebProxy = UseDefaultWebProxy;
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            NetTcpBinding n = (NetTcpBinding)binding;

            n.CloseTimeout           = CloseTimeout;
            n.HostNameComparisonMode = HostNameComparisonMode;
            n.ListenBacklog          = ListenBacklog;
            n.MaxBufferPoolSize      = MaxBufferPoolSize;
            n.MaxBufferSize          = MaxBufferSize;
            n.MaxConnections         = MaxConnections;
            n.MaxReceivedMessageSize = MaxReceivedMessageSize;
            n.OpenTimeout            = OpenTimeout;
            n.PortSharingEnabled     = PortSharingEnabled;
            if (ReaderQuotas != null)
            {
                n.ReaderQuotas = ReaderQuotas.Create();
            }
            n.ReceiveTimeout = ReceiveTimeout;

            // FIXME: apply this too.
            //ReliableSession.ApplyTo (n.ReliableSession);

            if (Security != null)
            {
                n.Security.Mode = Security.Mode;
                if (Security.Message != null)
                {
                    n.Security.Message.AlgorithmSuite       = Security.Message.AlgorithmSuite;
                    n.Security.Message.ClientCredentialType = Security.Message.ClientCredentialType;
                }
                if (Security.Transport != null)
                {
                    n.Security.Transport.ClientCredentialType = Security.Transport.ClientCredentialType;
                    n.Security.Transport.ProtectionLevel      = Security.Transport.ProtectionLevel;
                }
            }

            n.SendTimeout         = SendTimeout;
            n.TransactionFlow     = TransactionFlow;
            n.TransactionProtocol = TransactionProtocol;
            n.TransferMode        = TransferMode;
        }
        protected override void OnApplyConfiguration(Binding binding)
        {
            var n = (NetPeerTcpBinding)binding;

            n.ListenIPAddress        = ListenIPAddress;
            n.MaxBufferPoolSize      = MaxBufferPoolSize;
            n.MaxReceivedMessageSize = MaxReceivedMessageSize;
            n.Port         = Port;
            n.ReaderQuotas = ReaderQuotas.Create();
            if (Resolver != null)
            {
                if (Resolver.Custom != null)
                {
                    n.Resolver.Custom.Address = new EndpointAddress(Resolver.Custom.Address, Resolver.Custom.Identity.Create(), Resolver.Custom.Headers.Headers);
                    if (Resolver.Custom.Binding != null)
                    {
                        var bcol = ConfigUtil.BindingsSection [Resolver.Custom.Binding];
                        var bc   = bcol.ConfiguredBindings.First(b => b.Name == Resolver.Custom.BindingConfiguration);
                        n.Resolver.Custom.Binding = (Binding)Activator.CreateInstance(bcol.BindingType, new object[0]);
                        bc.ApplyConfiguration(n.Resolver.Custom.Binding);
                    }
                    // FIXME: correct type instantiation.
                    if (!String.IsNullOrEmpty(Resolver.Custom.ResolverType))
                    {
                        n.Resolver.Custom.Resolver = (PeerResolver)Activator.CreateInstance(Type.GetType(Resolver.Custom.ResolverType), new object [0]);
                    }
                }
                n.Resolver.Mode           = Resolver.Mode;
                n.Resolver.ReferralPolicy = Resolver.ReferralPolicy;
            }
            if (Security != null)
            {
                n.Security.Mode = Security.Mode;
                n.Security.Transport.CredentialType = Security.Transport.CredentialType;
            }
        }