상속: IIntroService, IDisposable
예제 #1
0
        /// <summary>
        ///   Start the intro service
        /// </summary>
        /// <param name="fallen8"> Fallen-8 instance </param>
        private void StartService(Fallen8 fallen8)
        {
            _uri = new Uri("http://" + _address + ":" + _port + "/" + _uriPattern);

            if (!_uri.IsWellFormedOriginalString())
            {
                throw new Exception("The URI Pattern is not well formed!");
            }

            _service = new IntroService(fallen8);

            _host = new ServiceHost(_service, _uri)
            {
                CloseTimeout = new TimeSpan(0, 0, 0, 0, 50)
            };
            _restServiceAddress = "REST";

            try
            {
                var binding = new WebHttpBinding
                {
                    MaxBufferSize          = 268435456,
                    MaxReceivedMessageSize = 268435456,
                    SendTimeout            = new TimeSpan(1, 0, 0),
                    ReceiveTimeout         = new TimeSpan(1, 0, 0)
                };

                var readerQuotas = new XmlDictionaryReaderQuotas
                {
                    MaxDepth = 2147483647,
                    MaxStringContentLength = 2147483647,
                    MaxBytesPerRead        = 2147483647,
                    MaxNameTableCharCount  = 2147483647,
                    MaxArrayLength         = 2147483647
                };

                binding.ReaderQuotas = readerQuotas;

                var se       = _host.AddServiceEndpoint(typeof(IIntroService), binding, _restServiceAddress);
                var webBehav = new WebHttpBehavior
                {
                    HelpEnabled = true
                };
                se.Behaviors.Add(webBehav);

                ((ServiceBehaviorAttribute)_host.Description.Behaviors[typeof(ServiceBehaviorAttribute)]).
                InstanceContextMode = InstanceContextMode.Single;
            }
            catch (CommunicationException)
            {
                _host.Abort();
                throw;
            }
        }
예제 #2
0
        /// <summary>
        ///   Start the intro service
        /// </summary>
        /// <param name="fallen8"> Fallen-8 instance </param>
        private void StartService(Fallen8 fallen8)
        {
            _uri = new Uri("http://" + _address + ":" + _port + "/" + _uriPattern);

            if (!_uri.IsWellFormedOriginalString())
                throw new Exception("The URI Pattern is not well formed!");

            _service = new IntroService(fallen8);

            _host = new ServiceHost(_service, _uri)
                        {
                            CloseTimeout = new TimeSpan(0, 0, 0, 0, 50)
                        };
            _restServiceAddress = "REST";

            try
            {
                var binding = new WebHttpBinding
                {
                    MaxBufferSize = 268435456,
                    MaxReceivedMessageSize = 268435456,
                    SendTimeout = new TimeSpan(1, 0, 0),
                    ReceiveTimeout = new TimeSpan(1, 0, 0)
                };

                var readerQuotas = new XmlDictionaryReaderQuotas
                {
                    MaxDepth = 2147483647,
                    MaxStringContentLength = 2147483647,
                    MaxBytesPerRead = 2147483647,
                    MaxNameTableCharCount = 2147483647,
                    MaxArrayLength = 2147483647
                };

                binding.ReaderQuotas = readerQuotas;

                var se = _host.AddServiceEndpoint(typeof(IIntroService), binding, _restServiceAddress);
                var webBehav = new WebHttpBehavior
                {
                    HelpEnabled = true
                };
                se.Behaviors.Add(webBehav);

                ((ServiceBehaviorAttribute)_host.Description.Behaviors[typeof(ServiceBehaviorAttribute)]).
                    InstanceContextMode = InstanceContextMode.Single;
            }
            catch (CommunicationException)
            {
                _host.Abort();
                throw;
            }
        }