Inheritance: IDisposable
コード例 #1
0
        public static HostManager RegisterHost(IHost host)
        {
            if (host == null) throw new ArgumentNullException("host");

            Log.WriteInfo("Registering host of type {0}", host.GetType());

            var manager = new HostManager(host);

            lock (_registrations)
                _registrations.Add(host, manager);
            return manager;
        }
コード例 #2
0
        public static HostManager RegisterHost(IHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            var manager = new HostManager(host);

            lock (_registrations)
                _registrations.Add(host, manager);
            return(manager);
        }
コード例 #3
0
        public static void UnregisterHost(IHost host)
        {
            Log.WriteInfo("Unregistering host of type {0}", host.GetType());
            HostManager managerToDispose = null;

            lock (_registrations)
            {
                if (_registrations.ContainsKey(host))
                {
                    managerToDispose = _registrations[host];
                    _registrations.Remove(host);
                }
            }
            managerToDispose?.Dispose();
        }
コード例 #4
0
        public static HostManager RegisterHost(IHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            Log.WriteInfo("Registering host of type {0}", host.GetType());

            var manager = new HostManager(host);

            lock (_registrations)
                _registrations.Add(host, manager);
            return(manager);
        }
コード例 #5
0
        public static void UnregisterHost(IHost host)
        {
            HostManager managerToDispose = null;

            lock (_registrations)
            {
                if (_registrations.ContainsKey(host))
                {
                    managerToDispose = _registrations[host];
                    _registrations.Remove(host);
                }
            }

            managerToDispose?.Dispose();
        }
コード例 #6
0
        private void TryInitializeHosting()
        {
            if (_hostManager != null) return;
            lock (SyncRoot)
            {
                Thread.MemoryBarrier();
                if (_hostManager != null) return;

                var hostManager = HostManager.RegisterHost(Host);
                Thread.MemoryBarrier();
                _hostManager = hostManager;
                try
                {
                    Host.RaiseStart();
                    _hostManager.Resolver.Resolve<ILogger<OwinLogSource>>();
                }
                catch
                {
                    HostManager.UnregisterHost(Host);
                    _hostManager = null;
                    throw;
                }
            }
        }