Пример #1
0
        internal static void StartProvider(Uri providerLocation, object provider, Type providerType)
        {
            if (s_runningProviders.ContainsKey(providerType))
            {
                return;
            }

            string sNamedPipe = providerLocation.ToString();
            // REVIEW: we don't dispose ServiceHost. It might be better to add it to the
            // SingletonsContainer
            ServiceHost providerHost = null;

            try
            {
                providerHost = new ServiceHost(provider);
                // Named pipes are better for Windows...don't tie up a dedicated port and perform better.
                // However, Mono does not yet support them, so on Mono we use a different binding.
                // Note that any attempt to unify these will require parallel changes in Paratext
                // and some sort of coordinated release of the new versions.
#if __MonoCS__
                BasicHttpBinding binding = new BasicHttpBinding();
#else
                NetNamedPipeBinding binding = new NetNamedPipeBinding();
                binding.Security.Mode = NetNamedPipeSecurityMode.None;
#endif
                binding.MaxBufferSize                       *= 4;
                binding.MaxReceivedMessageSize              *= 4;
                binding.MaxBufferPoolSize                   *= 2;
                binding.ReaderQuotas.MaxBytesPerRead        *= 4;
                binding.ReaderQuotas.MaxArrayLength         *= 4;
                binding.ReaderQuotas.MaxDepth               *= 4;
                binding.ReaderQuotas.MaxNameTableCharCount  *= 4;
                binding.ReaderQuotas.MaxStringContentLength *= 4;

                providerHost.AddServiceEndpoint(providerType, binding, sNamedPipe);
                providerHost.Open();
            }
            catch (Exception e)
            {
                Logger.WriteError(e);
                providerHost = null;
                var paratextInstalled = FwRegistryHelper.Paratext7orLaterInstalled();
                if (paratextInstalled)
                {
                    MessageBox.Show(PtCommunicationProb, PtCommunicationProbTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }
            Logger.WriteEvent("Started provider " + providerLocation + " for type " + providerType + ".");
            s_runningProviders.Add(providerType, providerHost);
        }
Пример #2
0
        internal static void StartProvider(Uri providerLocation, object provider, Type providerType)
        {
            if (s_runningProviders.ContainsKey(providerType))
            {
                return;
            }

            string sNamedPipe = providerLocation.ToString();
            // REVIEW: we don't dispose ServiceHost. It might be better to add it to the
            // SingletonsContainer
            ServiceHost providerHost = null;

            try
            {
                providerHost = new ServiceHost(provider);
                // TODO-Linux: various properties of NetNamedPipeBinding are marked with MonoTODO
                // attributes. Test if this affects us.
                NetNamedPipeBinding binding = new NetNamedPipeBinding();
                binding.Security.Mode                        = NetNamedPipeSecurityMode.None;
                binding.MaxBufferSize                       *= 4;
                binding.MaxReceivedMessageSize              *= 4;
                binding.MaxBufferPoolSize                   *= 2;
                binding.ReaderQuotas.MaxBytesPerRead        *= 4;
                binding.ReaderQuotas.MaxArrayLength         *= 4;
                binding.ReaderQuotas.MaxDepth               *= 4;
                binding.ReaderQuotas.MaxNameTableCharCount  *= 4;
                binding.ReaderQuotas.MaxStringContentLength *= 4;

                providerHost.AddServiceEndpoint(providerType, binding, sNamedPipe);
                providerHost.Open();
            }
            catch (Exception e)
            {
                Logger.WriteError(e);
                providerHost = null;
                var paratextInstalled = FwRegistryHelper.Paratext7orLaterInstalled();
                if (paratextInstalled)
                {
                    MessageBox.Show(PtCommunicationProb, PtCommunicationProbTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }

            Logger.WriteEvent("Started provider " + providerLocation + " for type " + providerType + ".");
            s_runningProviders.Add(providerType, providerHost);
        }