/// <summary>
        /// A Method to open the ServiceHost based on given endpoints and service type.
        /// </summary>
        /// <param name="endpoints"></param>
        /// <param name="serviceTypes"></param>
        /// <returns>List of ServiceHost opened based on given endpoints</returns>
        public IDictionary <String, List <ServiceHost> > OpenBindings(IDictionary <string, string> endpoints, IDictionary <string, Type> serviceTypes)
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);

            binding.MaxBufferPoolSize      = Int32.MaxValue;
            binding.MaxReceivedMessageSize = Int32.MaxValue;

            System.Xml.XmlDictionaryReaderQuotas rdQuota = new System.Xml.XmlDictionaryReaderQuotas();
            rdQuota.MaxArrayLength         = Int32.MaxValue;
            rdQuota.MaxStringContentLength = Int32.MaxValue;
            binding.ReaderQuotas           = rdQuota;

            binding.HostNameComparisonMode = HostNameComparisonMode.Exact;

            List <ServiceHost> serviceHosts = new List <ServiceHost>();

            foreach (string key in endpoints.Keys)
            {
                string endpoint = endpoints[key];

                foreach (string serviceTypeKey in serviceTypes.Keys)
                {
                    ServiceHost serviceHost = OpenServiceHost(endpoint, binding, serviceTypeKey, serviceTypes[serviceTypeKey]);
                    serviceHosts.Add(serviceHost);
                }
                m_ServiceHosts.Add(key, serviceHosts);
            }
            Logging("WCF Service binding is opened.");
            return(m_ServiceHosts);
        }
        private void GoIntoRegistrationButton_Click(object sender, RoutedEventArgs e)
        {
            System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas()
            {
                MaxArrayLength = int.MaxValue
            };
            NetTcpBinding binding = new NetTcpBinding()
            {
                MaxReceivedMessageSize = int.MaxValue,
                ReaderQuotas           = quotas
            };

            binding.Security.Mode = SecurityMode.None;
            Contract_Client contract = new Contract_Client(binding, new EndpointAddress("net.tcp://" + AppConfiguration.ConfigurationWorker.ServerIP + ":" + AppConfiguration.ConfigurationWorker.ServerPort.ToString()));

            try
            {
                if (contract.Registrate(LoginTextBox.Text, PasswordTextBox.Text))
                {
                    MessageBox.Show("Пользователь создан");
                }
                else
                {
                    MessageBox.Show("Не удалось зарегистрировать пользователя. Вероятно, пользователь с таким логином уже есть.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            contract.Close();
        }
Esempio n. 3
0
        public static T Deserialize <T>(byte[] data) where T : class
        {
            var ser = new System.Runtime.Serialization.DataContractSerializer(typeof(T));

            System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas();
            using (var binaryDictionaryReader = System.Xml.XmlDictionaryReader.CreateBinaryReader(data, quotas))
            {
                return(ser.ReadObject(binaryDictionaryReader, false) as T);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            ServiceHost arbitrageServiceHost = null;

            try
            {
                Uri httpBaseAddress = new Uri("http://localhost:49359/ArbitrageService");

                arbitrageServiceHost = new ServiceHost(typeof(ArbitrageBetService), httpBaseAddress);

                BasicHttpBinding binding = new BasicHttpBinding()
                {
                    OpenTimeout            = new TimeSpan(0, 20, 0),
                    CloseTimeout           = new TimeSpan(0, 20, 0),
                    SendTimeout            = new TimeSpan(0, 20, 0),
                    ReceiveTimeout         = new TimeSpan(0, 20, 0),
                    MaxBufferPoolSize      = 2147483647,
                    MaxBufferSize          = 2147483647,
                    MaxReceivedMessageSize = 2147483647
                };
                var quotas = new System.Xml.XmlDictionaryReaderQuotas()
                {
                    MaxDepth               = 32,
                    MaxArrayLength         = 2147483647,
                    MaxStringContentLength = 2147483647
                };
                binding.ReaderQuotas = quotas;

                arbitrageServiceHost.Description.Endpoints.Clear();
                arbitrageServiceHost.AddServiceEndpoint(typeof(IArbitrageService), binding, "");

                ServiceMetadataBehavior serviceBehavior = new ServiceMetadataBehavior();
                serviceBehavior.HttpGetEnabled = true;
                arbitrageServiceHost.Description.Behaviors.Add(serviceBehavior);

                arbitrageServiceHost.Open();

                Console.WriteLine("Service is live now at : {0}", httpBaseAddress);
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                arbitrageServiceHost = null;
                Console.WriteLine("There is an issue with ArbitrageService" + ex.Message);
            }

            Console.ReadKey();
        }
Esempio n. 5
0
        public static IWFWorkflowService GetWorkFlowAPI()
        {
            if (m_api != null)
            {
                return(m_api);
            }
            string logusername = ConfigurationSettings.AppSettings["UserName"];
            string logpassword = ConfigurationSettings.AppSettings["Password"];
            string logdomain   = ConfigurationSettings.AppSettings["Domain"];


            System.Net.ICredentials credentials = credentials = new System.Net.NetworkCredential(logusername, logpassword, logdomain);
            if (credentials == null)
            {
                return(m_api);
            }

            string locale = GetLocale();

            string url = ConfigurationSettings.AppSettings["ServerURL"];

            WSHttpBinding wsHttpBinding = new WSHttpBinding(SecurityMode.Message);

            wsHttpBinding.Security.Mode = SecurityMode.Message;
            wsHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            wsHttpBinding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.Windows;

            wsHttpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
            wsHttpBinding.MaxBufferPoolSize      = Int32.MaxValue;
            wsHttpBinding.MaxReceivedMessageSize = Int32.MaxValue;

            System.Xml.XmlDictionaryReaderQuotas rdQuota = new System.Xml.XmlDictionaryReaderQuotas();
            rdQuota.MaxArrayLength         = Int32.MaxValue;
            rdQuota.MaxStringContentLength = Int32.MaxValue;
            wsHttpBinding.ReaderQuotas     = rdQuota;

            string user = String.Empty;

            user = logdomain + @"\" + logusername;
            //string workflowBinding = "WSHttpBinding_IWCFWorkflowService";
            m_api = new WCFWorkflowProxy("TestApp", "", locale, user, credentials, wsHttpBinding, url);
            //m_api = new AgilePointAPICodeSampleProject.WCFWorkflowProxy("ENVOY Mortgage", "", "nl", user, credentials, wsHttpBinding, url);

            return(m_api);
        }
Esempio n. 6
0
        private void setBindingBuffers(NetTcpBinding getBinding)
        {
            // set max buffer size
            int maxIntValue = int.MaxValue;

            getBinding.MaxBufferSize          = maxIntValue;
            getBinding.MaxReceivedMessageSize = maxIntValue;

            /*
             * XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas(); myReaderQuotas.MaxStringContentLength = 2147483647; myReaderQuotas.MaxArrayLength = 2147483647; myReaderQuotas.MaxBytesPerRead = 2147483647; myReaderQuotas.MaxDepth = 64; myReaderQuotas.MaxNameTableCharCount = 2147483647; binding.GetType().GetProperty("ReaderQuotas").SetValue(bindi‌​ng, myReaderQuotas, null);
             */
            System.Xml.XmlDictionaryReaderQuotas readQuotas = getBinding.ReaderQuotas;
            readQuotas.MaxArrayLength         = 1048576;
            readQuotas.MaxBytesPerRead        = 1048576;
            readQuotas.MaxDepth               = 1048576;
            readQuotas.MaxNameTableCharCount  = 1048576;
            readQuotas.MaxStringContentLength = maxIntValue;
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a binding compatible with Jedi web services (very basic binding, with HTTPS support).
        /// </summary>
        /// <param name="uri">The URI that will be connected to.</param>
        /// <returns></returns>
        public static Binding CreateBinding(Uri uri)
        {
            TextMessageEncodingBindingElement encoding = new TextMessageEncodingBindingElement();

            encoding.MessageVersion = MessageVersion.Soap12WSAddressingAugust2004;
            var quota = new System.Xml.XmlDictionaryReaderQuotas();

//						quota.MaxNameTableCharCount = 1 << 20;
// ADD MYs adds until the ending comment
            quota.MaxNameTableCharCount = int.MaxValue;
            quota.MaxDepth = int.MaxValue;
            quota.MaxNameTableCharCount  = int.MaxValue;
            quota.MaxBytesPerRead        = int.MaxValue;
            quota.MaxArrayLength         = int.MaxValue;
            quota.MaxStringContentLength = int.MaxValue;
// To here!

            encoding.ReaderQuotas = quota;

            //HTTPS with Basic auth is the default option for accessing FutureSmart web services
            //HTTP is supported when the "Allow a Non-Secure Connection for Web Services" setting on the EWS's
            //Troubleshooting tab is enabled
            HttpTransportBindingElement httpsTransport;

            if (uri.Scheme == "http")
            {
                httpsTransport = new HttpTransportBindingElement();
            }
            else
            {
                httpsTransport = new HttpsTransportBindingElement();
                httpsTransport.AuthenticationScheme = AuthenticationSchemes.Basic;
            }

            //Tell WCF what resource we're accessing
            System.ServiceModel.Channels.Binding wsBinding;
            wsBinding = new CustomBinding(encoding, httpsTransport);
//            httpsTransport.MaxReceivedMessageSize *= 100;
            httpsTransport.MaxReceivedMessageSize = int.MaxValue;

            //httpsTransport.HostNameComparisonMode = HostNameComparisonMode.Exact;

            return(wsBinding);
        }
Esempio n. 8
0
        public void StartServer(object sender, EventArgs e)
        {
            if (port_TB.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Empty value of port. Error.");
                return;
            }

            try
            {
                //Uri addr = new Uri("tcp://localhost:" + port_TB.Text.Replace(" ", ""));
                Uri addr = new Uri("net.tcp://0.0.0.0:" + port_TB.Text.Replace(" ", ""));
                serviceHost = new ServiceHost(typeof(ServerContract), addr);

                httpBinding = new NetTcpBinding();
                httpBinding.Security.Mode          = SecurityMode.None;
                httpBinding.MaxReceivedMessageSize = int.MaxValue;
                System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas()
                {
                    MaxArrayLength = int.MaxValue
                };
                httpBinding.ReaderQuotas = quotas;


                serviceHost.AddServiceEndpoint(typeof(IContract), httpBinding, addr);

                serviceHost.Open();

                Status_TB.Text = "Server is working";

                port_TB.Enabled = true;

                LogLB.Items.Add(DateTime.Now.ToUniversalTime().ToString() + " Server started");

                button1.Enabled = false;
                button2.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void AuthentificationButton_Click(object sender, RoutedEventArgs e)
        {
            System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas()
            {
                MaxArrayLength = int.MaxValue
            };
            NetTcpBinding binding = new NetTcpBinding()
            {
                MaxReceivedMessageSize = int.MaxValue,
                ReaderQuotas           = quotas
            };

            binding.Security.Mode = SecurityMode.None;
            Contract_Client contract = new Contract_Client(binding, new EndpointAddress("net.tcp://" + AppConfiguration.ConfigurationWorker.ServerIP + ":" + AppConfiguration.ConfigurationWorker.ServerPort.ToString()));

            try
            {
                if (contract.TryAuthentificate(LoginTextBox.Text, PasswordTextBox.Text))
                {
                    new MainMenu.MainMenuModel(contract);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Неверный логин/пароль");
                    contract.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                if (contract.State != CommunicationState.Faulted)
                {
                    contract.Close();
                }
            }
        }
Esempio n. 10
0
        public static SessionAwareCoreServiceClient GetConfiglessCoreService()
        {
            string userName = Tridion.Web.UI.Core.Utils.GetUserName();

            var quotas = new System.Xml.XmlDictionaryReaderQuotas
            {
                MaxStringContentLength = 10485760,
                MaxArrayLength = 10485760,
                MaxBytesPerRead = 10485760
            };

            var httpBinding = new WSHttpBinding
            {
                MaxReceivedMessageSize = 10485760,
                ReaderQuotas = quotas,
                Security = { Mode = SecurityMode.Message, Transport = { ClientCredentialType = HttpClientCredentialType.Windows } }
            };

            var result = new SessionAwareCoreServiceClient();
            result.Impersonate(userName);

            return result;
        }
        private Binding CreateBinding(bool secure)
        {
            var quotas = new System.Xml.XmlDictionaryReaderQuotas {
                MaxArrayLength = int.MaxValue, MaxStringContentLength = int.MaxValue
            };

            return(_isRest ? (Binding)
                   new WebHttpBinding
            {
                ReaderQuotas = quotas,
                Security = new WebHttpSecurity {
                    Mode = secure ? WebHttpSecurityMode.Transport : WebHttpSecurityMode.None
                }
            }
                :
                   new BasicHttpBinding
            {
                ReaderQuotas = quotas,
                Security = new BasicHttpSecurity {
                    Mode = secure ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None
                }
            });
        }
Esempio n. 12
0
        public static SessionAwareCoreServiceClient GetConfiglessCoreService()
        {
            string userName = Tridion.Web.UI.Core.Utils.GetUserName();

            var quotas = new System.Xml.XmlDictionaryReaderQuotas
            {
                MaxStringContentLength = 10485760,
                MaxArrayLength         = 10485760,
                MaxBytesPerRead        = 10485760
            };

            var httpBinding = new WSHttpBinding
            {
                MaxReceivedMessageSize = 10485760,
                ReaderQuotas           = quotas,
                Security = { Mode = SecurityMode.Message, Transport = { ClientCredentialType = HttpClientCredentialType.Windows } }
            };

            var result = new SessionAwareCoreServiceClient();

            result.Impersonate(userName);

            return(result);
        }
 public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     throw null;
 }
 public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession session)
 {
     throw null;
 }
 public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession session)
 {
     throw null;
 }
Esempio n. 16
0
        public static List<WSHttpBinding> GetWsHttpBindings(string exeConfigPath)
        {
            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);

            var configs = new List<WSHttpBinding>();
            foreach (
                var section in
                    svcSection.Bindings.WSHttpBinding.ConfiguredBindings
                        .Cast<WSHttpBindingElement>())
            {
                var df = new WSHttpBinding();
                var binding = new WSHttpBinding
                {
                    Name = section.Name,

                    MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize,
                    MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize,
                    CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout,
                    OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout,
                    SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout,

                    TextEncoding = section.TextEncoding ?? df.TextEncoding,

                    MessageEncoding = section.MessageEncoding,
                    AllowCookies = section.AllowCookies,
                    BypassProxyOnLocal = section.BypassProxyOnLocal,
                    TransactionFlow = section.TransactionFlow,
                    HostNameComparisonMode = section.HostNameComparisonMode,
                    UseDefaultWebProxy = section.UseDefaultWebProxy,
                };

                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }

                var reliableSessionSection = section.ReliableSession;
                var dfRss = new OptionalReliableSession();
                var reliableSession = new OptionalReliableSession
                {
                    Enabled = reliableSessionSection.Enabled,
                    Ordered = reliableSessionSection.Ordered,
                    InactivityTimeout =
                        reliableSessionSection.InactivityTimeout != TimeSpan.Zero
                            ? reliableSessionSection.InactivityTimeout
                            : dfRss.InactivityTimeout,
                };

                var messageSection = section.Security.Message;
                var message = new NonDualMessageSecurityOverHttp
                {
                    EstablishSecurityContext = messageSection.EstablishSecurityContext,
                    ClientCredentialType = messageSection.ClientCredentialType,
                    NegotiateServiceCredential = messageSection.NegotiateServiceCredential,
                    AlgorithmSuite = messageSection.AlgorithmSuite
                };

                var transportSection = section.Security.Transport;
                var transport = new HttpTransportSecurity
                {
                    ClientCredentialType = transportSection.ClientCredentialType,
                    ProxyCredentialType = transportSection.ProxyCredentialType
                };

                var wsHttpSecuritySection = section.Security;
                var wsHttpSecurity = new WSHttpSecurity
                {
                    Mode = wsHttpSecuritySection.Mode,
                    Transport = transport,
                    Message = message
                };
                ;
                binding.Security = wsHttpSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }
                binding.ReliableSession = reliableSession;

                configs.Add(binding);
            }
            return configs;
        }
Esempio n. 17
0
 public static System.Xml.XmlDictionaryReader CreateJsonReader(byte[] buffer, int offset, int count, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose onClose)
 {
     throw null;
 }
 public static System.Xml.XmlDictionaryReader CreateTextReader(System.IO.Stream stream, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     return(default(System.Xml.XmlDictionaryReader));
 }
 public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     return(default(System.Xml.XmlDictionaryReader));
 }
Esempio n. 20
0
 public static System.Xml.XmlDictionaryReader CreateJsonReader(System.IO.Stream stream, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose onClose)
 {
     throw null;
 }
 public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary?dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession?session, System.Xml.OnXmlDictionaryReaderClose?onClose)
 {
     throw null;
 }
Esempio n. 22
0
        public static List<BasicHttpBinding> GetBasicHttpBindings(string exeConfigPath)
        {
            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);

            var configs = new List<BasicHttpBinding>();
            foreach (
                var section in
                    svcSection.Bindings.BasicHttpBinding.ConfiguredBindings
                        .Cast<BasicHttpBindingElement>())
            {
                var df = new BasicHttpBinding();
                var binding = new BasicHttpBinding
                {
                    Name = section.Name,

                    MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize,
                    MaxReceivedMessageSize =
                        section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize,
                    CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout,
                    OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout,
                    SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout,

                    TextEncoding = section.TextEncoding ?? df.TextEncoding,

                    MessageEncoding = section.MessageEncoding,
                    AllowCookies = section.AllowCookies,
                    BypassProxyOnLocal = section.BypassProxyOnLocal,
                    HostNameComparisonMode = section.HostNameComparisonMode,
                    UseDefaultWebProxy = section.UseDefaultWebProxy,
                };

                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }

                var messageSection = section.Security.Message;
                var message = new BasicHttpMessageSecurity
                {
                    ClientCredentialType = messageSection.ClientCredentialType,
                    AlgorithmSuite = messageSection.AlgorithmSuite,
                };
                var transportSection = section.Security.Transport;
                var transport = new HttpTransportSecurity
                {
                    ClientCredentialType = transportSection.ClientCredentialType,
                    ProxyCredentialType = transportSection.ProxyCredentialType
                };
                var basicHttpSecurity = new BasicHttpSecurity()
                {
                    Message = message,
                    Mode = section.Security.Mode,
                    Transport = transport
                };

                binding.Security = basicHttpSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }

                configs.Add(binding);
            }
            return configs;
        }
Esempio n. 23
0
        public static List<NetMsmqBinding> GetNetMsmqBindings(string exeConfigPath)
        {
            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);

            var configs = new List<NetMsmqBinding>();
            foreach (
                var section in
                    svcSection.Bindings.NetMsmqBinding.ConfiguredBindings
                        .Cast<NetMsmqBindingElement>())
            {
                var df = new NetMsmqBinding();
                var binding = new NetMsmqBinding
                {
                    Name = section.Name,
                    MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize,
                    MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize,
                    CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout,
                    OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout,
                    SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout,

                    MaxRetryCycles = section.MaxRetryCycles > 0 ? section.MaxRetryCycles : df.MaxRetryCycles,
                    ReceiveRetryCount = section.ReceiveRetryCount > 0 ? section.ReceiveRetryCount : df.ReceiveRetryCount,
                    RetryCycleDelay = section.RetryCycleDelay != TimeSpan.Zero ? section.RetryCycleDelay : df.RetryCycleDelay,
                    TimeToLive = section.TimeToLive != TimeSpan.Zero ? section.TimeToLive : df.TimeToLive,

                    DeadLetterQueue = section.DeadLetterQueue,
                    Durable = section.Durable,
                    ExactlyOnce = section.ExactlyOnce,
                    ReceiveErrorHandling = section.ReceiveErrorHandling,
                    UseSourceJournal = section.UseSourceJournal,
                    UseMsmqTracing = section.UseMsmqTracing,
                    QueueTransferProtocol = section.QueueTransferProtocol,
                    UseActiveDirectory = section.UseActiveDirectory
                };

                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }
                var msmqSecurity = new NetMsmqSecurity {Mode = section.Security.Mode};
                var securityTransportSection = section.Security.Transport;
                var msmqSecurityTransport = new MsmqTransportSecurity
                {
                    MsmqAuthenticationMode = securityTransportSection.MsmqAuthenticationMode,
                    MsmqEncryptionAlgorithm = securityTransportSection.MsmqEncryptionAlgorithm,
                    MsmqProtectionLevel = securityTransportSection.MsmqProtectionLevel,
                    MsmqSecureHashAlgorithm = securityTransportSection.MsmqSecureHashAlgorithm
                };
                var msmqSecurityMessage = new MessageSecurityOverMsmq
                {
                    ClientCredentialType = section.Security.Message.ClientCredentialType
                };
                msmqSecurity.Message = msmqSecurityMessage;
                msmqSecurity.Transport = msmqSecurityTransport;
                binding.Security = msmqSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }
                configs.Add(binding);

            }
            return configs;
        }
 public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     return(default(System.Xml.XmlDictionaryReader));
 }
 public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession session)
 {
     return(default(System.Xml.XmlDictionaryReader));
 }
 public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     throw null;
 }
 public static System.Xml.XmlDictionaryReader CreateTextReader(System.IO.Stream stream, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose onClose)
 {
     return(default(System.Xml.XmlDictionaryReader));
 }
 public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, string contentType, System.Xml.XmlDictionaryReaderQuotas quotas, int maxBufferSize, System.Xml.OnXmlDictionaryReaderClose onClose)
 {
     throw null;
 }
 public void CopyTo(System.Xml.XmlDictionaryReaderQuotas quotas)
 {
 }
 public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     throw null;
 }
Esempio n. 31
0
 public static System.Xml.XmlDictionaryReader CreateJsonReader(byte[] buffer, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     throw null;
 }
Esempio n. 32
0
        public static List<NetTcpBinding> GetNetTcpBindings(string exeConfigPath)
        {
            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);
            var defaultTimeout = new TimeSpan(0, 0, 60);
            var configs = new List<NetTcpBinding>();
            foreach (
                var section in
                    svcSection.Bindings.NetTcpBinding.ConfiguredBindings
                        .Cast<NetTcpBindingElement>())
            {
                var dfltb = new NetTcpBinding();
                var binding = new NetTcpBinding
                {
                    Name = section.Name,
                    CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : defaultTimeout,
                    OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : defaultTimeout,
                    SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : defaultTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : defaultTimeout,
                    MaxReceivedMessageSize =
                        section.MaxReceivedMessageSize > 0
                            ? section.MaxReceivedMessageSize
                            : dfltb.MaxReceivedMessageSize,
                    MaxBufferPoolSize =
                        section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : dfltb.MaxBufferPoolSize,
                    MaxConnections = section.MaxConnections > 0 ? section.MaxConnections : dfltb.MaxConnections,

                    ListenBacklog = section.ListenBacklog > 0 ? section.ListenBacklog : dfltb.ListenBacklog,
                    PortSharingEnabled = section.PortSharingEnabled,
                    TransactionFlow = section.TransactionFlow,
                    TransferMode = section.TransferMode,
                    HostNameComparisonMode = section.HostNameComparisonMode
                };
                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }
                var netTcpSecurity = new NetTcpSecurity() { Mode = section.Security.Mode };
                var tcpTransportSecurity = new TcpTransportSecurity();

                var msgSecurityOverTcp = new MessageSecurityOverTcp
                {
                    ClientCredentialType = section.Security.Message.ClientCredentialType,
                    AlgorithmSuite = section.Security.Message.AlgorithmSuite
                };
                netTcpSecurity.Message = msgSecurityOverTcp;
                netTcpSecurity.Transport = tcpTransportSecurity;
                binding.Security = netTcpSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }
                binding.ReliableSession = new OptionalReliableSession
                {
                    Enabled = section.ReliableSession.Enabled,
                    InactivityTimeout = section.ReliableSession.InactivityTimeout,
                    Ordered = section.ReliableSession.Ordered
                };

                configs.Add(binding);

            }
            return configs;
        }
Esempio n. 33
0
 public static System.Xml.XmlDictionaryReader CreateJsonReader(System.IO.Stream stream, System.Xml.XmlDictionaryReaderQuotas quotas)
 {
     throw null;
 }
 public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, string contentType, System.Xml.XmlDictionaryReaderQuotas quotas, int maxBufferSize, System.Xml.OnXmlDictionaryReaderClose onClose)
 {
     throw null;
 }