Beispiel #1
0
#pragma warning restore CS0067 // The event is never used

        protected ServiceHostBase()
        {
            InternalBaseAddresses = new UriSchemeKeyedCollection(ThisLock);
            ChannelDispatchers    = new ChannelDispatcherCollection(this, ThisLock);
            _extensions           = new ExtensionCollection <ServiceHostBase>(this, ThisLock);
            _instances            = new InstanceContextManager(ThisLock);
        }
Beispiel #2
0
 protected ServiceHostBase()
 {
     this.baseAddresses      = new UriSchemeKeyedCollection(this.ThisLock);
     this.channelDispatchers = new ChannelDispatcherCollection(this, this.ThisLock);
     this.extensions         = new ExtensionCollection <ServiceHostBase>(this, this.ThisLock);
     this.instances          = new InstanceContextManager(this.ThisLock);
 }
Beispiel #3
0
        protected ServiceHostBase()
        {
            open_timeout  = DefaultOpenTimeout;
            close_timeout = DefaultCloseTimeout;

            credentials         = new ServiceCredentials();
            contexts            = new List <InstanceContext> ();
            exposed_contexts    = new ReadOnlyCollection <InstanceContext> (contexts);
            channel_dispatchers = new ChannelDispatcherCollection(this);
        }
Beispiel #4
0
 protected ServiceHostBase()
 {
     TraceUtility.SetEtwProviderId();
     this.baseAddresses      = new UriSchemeKeyedCollection(base.ThisLock);
     this.channelDispatchers = new ChannelDispatcherCollection(this, base.ThisLock);
     this.extensions         = new ExtensionCollection <ServiceHostBase>(this, base.ThisLock);
     this.instances          = new InstanceContextManager(base.ThisLock);
     this.serviceThrottle    = new System.ServiceModel.Dispatcher.ServiceThrottle(this);
     base.TraceOpenAndClose  = true;
     base.Faulted           += new EventHandler(this.OnServiceHostFaulted);
 }
        private static ChannelDispatcherModel[] GetChannelDispatchers(ServiceHostBase serviceHost)
        {
            ChannelDispatcherCollection   channelDispatchers     = serviceHost?.ChannelDispatchers;
            List <ChannelDispatcherModel> channelDispatchersList = new List <ChannelDispatcherModel>(channelDispatchers?.Count ?? 0);

            if (channelDispatchers != null && channelDispatchers.Count > 0)
            {
                foreach (var channelDispatcher in channelDispatchers)
                {
                    channelDispatchersList.Add(new ChannelDispatcherModel(channelDispatcher));
                }
            }

            return(channelDispatchersList.ToArray());
        }
Beispiel #6
0
        public static void Main()
        {
            // <Snippet0>
            Uri         baseAddress = new Uri("http://localhost:8001/Simple");
            ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

            serviceHost.AddServiceEndpoint(
                typeof(ICalculator),
                new WSHttpBinding(),
                "CalculatorServiceObject");

            // Enable MEX.
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();

            smb.HttpGetEnabled = true;
            serviceHost.Description.Behaviors.Add(smb);

            serviceHost.Open();

            IChannelListener  icl        = serviceHost.ChannelDispatchers[0].Listener;
            ChannelDispatcher dispatcher = new ChannelDispatcher(icl);

            Console.WriteLine("servicehost has {0} ChannelDispatchers", serviceHost.ChannelDispatchers.Count);
            ChannelDispatcherCollection dispatchers = serviceHost.ChannelDispatchers;

            foreach (ChannelDispatcher disp in dispatchers)
            {
                Console.WriteLine("Binding name: " + disp.BindingName);
            }

            Console.WriteLine("The service is ready.");
            Console.WriteLine("Press <ENTER> to terminate service.");
            Console.WriteLine();
            Console.ReadLine();

            // Close the ServiceHostBase to shutdown the service.
            serviceHost.Close();
            // </Snippet0>
        }