示例#1
0
        public static ServiceEndpoint GetStoreInstanceEndpoint(InstanceGroupConfig cfg, string target, bool isUseDefaultGroup, bool isServerBinding, WcfTimeout timeout = null)
        {
            string storeInstanceEndPointAddress = cfg.GetStoreInstanceEndPointAddress(target, isUseDefaultGroup);
            string bindingName = cfg.ConstructUniqueInstanceBindingName(target, isUseDefaultGroup);

            timeout = (timeout ?? cfg.Settings.StoreInstanceWcfTimeout);
            return(EndpointBuilder.ConstructAndInitializeEndpoint(typeof(IDxStoreInstance), storeInstanceEndPointAddress, bindingName, timeout, isServerBinding));
        }
示例#2
0
        public static ServiceEndpoint GetStoreManagerEndpoint(InstanceManagerConfig cfg, string target, bool isServerBinding, WcfTimeout timeout = null)
        {
            string endPointAddress = cfg.GetEndPointAddress(target);
            string bindingName     = cfg.ConstructUniqueBindingName(target);

            timeout = (timeout ?? cfg.DefaultTimeout);
            return(EndpointBuilder.ConstructAndInitializeEndpoint(typeof(IDxStoreManager), endPointAddress, bindingName, timeout, isServerBinding));
        }
示例#3
0
        public static BasicHttpBinding CreateHttpBindingAndInitialize(string bindingName, WcfTimeout timeout, bool isServerBinding)
        {
            BasicHttpBinding basicHttpBinding = new BasicHttpBinding();

            basicHttpBinding.Name = bindingName;
            basicHttpBinding.MaxBufferPoolSize      = (long)EndpointBuilder.MebiBytes(64);
            basicHttpBinding.MaxBufferSize          = EndpointBuilder.MebiBytes(64);
            basicHttpBinding.MaxReceivedMessageSize = (long)EndpointBuilder.MebiBytes(64);
            if (isServerBinding)
            {
                EndpointBuilder.SetReaderQuotas(basicHttpBinding.ReaderQuotas);
            }
            else
            {
                EndpointBuilder.SetTimeout(basicHttpBinding, timeout);
            }
            return(basicHttpBinding);
        }
示例#4
0
        public static NetNamedPipeBinding CreateNamedPipeBindingAndInitialize(string bindingName, WcfTimeout timeout, bool isServerBinding)
        {
            NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding();

            netNamedPipeBinding.Name = bindingName;
            netNamedPipeBinding.MaxBufferPoolSize      = (long)EndpointBuilder.MebiBytes(64);
            netNamedPipeBinding.MaxBufferSize          = EndpointBuilder.MebiBytes(64);
            netNamedPipeBinding.MaxReceivedMessageSize = (long)EndpointBuilder.MebiBytes(64);
            netNamedPipeBinding.MaxConnections         = 200;
            if (isServerBinding)
            {
                EndpointBuilder.SetReaderQuotas(netNamedPipeBinding.ReaderQuotas);
            }
            else
            {
                EndpointBuilder.SetTimeout(netNamedPipeBinding, timeout);
            }
            return(netNamedPipeBinding);
        }
示例#5
0
 public static void SetTimeout(Binding binding, WcfTimeout timeout)
 {
     EndpointBuilder.IfHasValue <TimeSpan>(timeout.Open, delegate(TimeSpan t)
     {
         binding.OpenTimeout = t;
     });
     EndpointBuilder.IfHasValue <TimeSpan>(timeout.Close, delegate(TimeSpan t)
     {
         binding.CloseTimeout = t;
     });
     EndpointBuilder.IfHasValue <TimeSpan>(timeout.Send, delegate(TimeSpan t)
     {
         binding.SendTimeout = t;
     });
     EndpointBuilder.IfHasValue <TimeSpan>(timeout.Receive, delegate(TimeSpan t)
     {
         binding.ReceiveTimeout = t;
     });
 }
示例#6
0
        public static Binding CreateBindingAndInitialize(string address, string bindingName, WcfTimeout timeout, bool isServerBinding)
        {
            string  a = address.Substring(0, address.IndexOf(':'));
            Binding result;

            if (Utils.IsEqual(a, "http", StringComparison.OrdinalIgnoreCase))
            {
                result = EndpointBuilder.CreateHttpBindingAndInitialize(bindingName, timeout, isServerBinding);
            }
            else if (Utils.IsEqual(a, "net.tcp", StringComparison.OrdinalIgnoreCase))
            {
                result = EndpointBuilder.CreateNettcpBindingAndInitialize(bindingName, timeout, isServerBinding);
            }
            else
            {
                if (!Utils.IsEqual(a, "net.pipe", StringComparison.OrdinalIgnoreCase))
                {
                    throw new DxStoreBindingNotSupportedException(address);
                }
                result = EndpointBuilder.CreateNamedPipeBindingAndInitialize(bindingName, timeout, isServerBinding);
            }
            return(result);
        }
示例#7
0
        public static ServiceEndpoint ConstructAndInitializeEndpoint(Type interfaceType, string address, string bindingName, WcfTimeout timeout, bool isServerBinding)
        {
            Binding binding = EndpointBuilder.CreateBindingAndInitialize(address, bindingName, timeout, isServerBinding);

            return(new ServiceEndpoint(ContractDescription.GetContract(interfaceType), binding, new EndpointAddress(address)));
        }
 public static string ConstructUniqueInstanceBindingName(this InstanceGroupConfig cfg, string target, bool isUseDefaultGroup)
 {
     target = ExtensionMethods.ResolveTarget(cfg.Self, target);
     return(EndpointBuilder.ConstructUniqueBindingName(target, cfg.ComponentName, cfg.Settings.InstanceEndpointProtocolName, "Instance", isUseDefaultGroup ? "B1563499-EA40-4101-A9E6-59A8EB26FF1E" : cfg.Name, cfg.IsZeroboxMode));
 }
 public static string ConstructUniqueBindingName(this InstanceManagerConfig cfg, string target)
 {
     target = ExtensionMethods.ResolveTarget(cfg.Self, target);
     return(EndpointBuilder.ConstructUniqueBindingName(target, cfg.ComponentName, cfg.EndpointProtocolName, "Manager", null, cfg.IsZeroboxMode));
 }
示例#10
0
        public static string GetEndPointAddress(this InstanceManagerConfig cfg, string target)
        {
            string networkAddress = EndpointBuilder.GetNetworkAddress(cfg.Self, target, cfg.NetworkAddress, cfg.NameResolver, false);

            return(EndpointBuilder.ConstructEndpointAddress("Manager", cfg.ComponentName, cfg.Self, target, networkAddress, null, cfg.IsZeroboxMode, cfg.EndpointPortNumber, cfg.EndpointProtocolName));
        }
示例#11
0
 public static string GetGroupEndPointAddress(this InstanceGroupConfig cfg, string interfaceName, string target, int portNumber, string protocolName, bool isUseDefaultGroupIdentifier)
 {
     return(EndpointBuilder.ConstructEndpointAddress(interfaceName, cfg.ComponentName, cfg.Self, target, cfg.GetMemberNetworkAddress(target), isUseDefaultGroupIdentifier ? "B1563499-EA40-4101-A9E6-59A8EB26FF1E" : cfg.Name, cfg.IsZeroboxMode, portNumber, protocolName));
 }
示例#12
0
        public static string GetMemberNetworkAddress(this InstanceGroupConfig cfg, string target)
        {
            InstanceGroupMemberConfig memberConfig = cfg.GetMemberConfig(target);

            return(EndpointBuilder.GetNetworkAddress(cfg.Self, target, (memberConfig != null) ? memberConfig.NetworkAddress : null, cfg.NameResolver, false));
        }
示例#13
0
 public virtual ServiceEndpoint GetStoreInstanceEndpoint(string target, bool isUseDefaultGroup, bool isServerBinding, WcfTimeout timeout = null)
 {
     return(EndpointBuilder.GetStoreInstanceEndpoint(this, target, isUseDefaultGroup, isServerBinding, timeout));
 }
示例#14
0
 public virtual ServiceEndpoint GetEndpoint(string target, bool isServerBinding, WcfTimeout timeout = null)
 {
     return(EndpointBuilder.GetStoreManagerEndpoint(this, target, isServerBinding, timeout));
 }