示例#1
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;
                }
            }
        }
 static void TryInitializeHosting()
 {
     if (HostManager == null)
     {
         lock (_syncRoot)
         {
             Thread.MemoryBarrier();
             if (HostManager == null)
             {
                 var hostManager = HostManager.RegisterHost(Host);
                 Thread.MemoryBarrier();
                 HostManager = hostManager;
                 try
                 {
                     Host.RaiseStart();
                     Log = HostManager.Resolver.Resolve <ILogger <AspNetLogSource> >();
                 }
                 catch
                 {
                     HostManager.UnregisterHost(Host);
                     HostManager = null;
                 }
             }
         }
     }
 }
示例#3
0
        void TryInitializeHosting(CancellationToken onDisposing, StartupProperties startup)
        {
            if (_hostManager != null)
            {
                return;
            }
            lock (SyncRoot)
            {
                Thread.MemoryBarrier();
                if (_hostManager != null)
                {
                    return;
                }

                var hostManager = HostManager.RegisterHost(_host);

                onDisposing.Register(Dispose);

                Thread.MemoryBarrier();
                _hostManager = hostManager;
                try
                {
                    _host.RaiseStart(startup);
                }
                catch
                {
                    HostManager.UnregisterHost(_host);
                    _hostManager = null;
                    throw;
                }
            }
        }
示例#4
0
 public InMemoryHost(IConfigurationSource configuration)
 {
     _configuration         = configuration;
     Resolver               = new InternalDependencyResolver();
     ApplicationVirtualPath = "/";
     HostManager            = HostManager.RegisterHost(this);
     RaiseStart();
 }
示例#5
0
 public InMemoryHost(IConfigurationSource configuration, IDependencyResolver dependencyResolver = null)
 {
     Resolver               = dependencyResolver ?? new InternalDependencyResolver();
     _configuration         = configuration;
     ApplicationVirtualPath = "/";
     HostManager            = HostManager.RegisterHost(this);
     RaiseStart(new StartupProperties());
 }
示例#6
0
 public NullHost(IConfigurationSource configuration, string path = "/")
 {
     _configuration         = configuration;
     Resolver               = new InternalDependencyResolver();
     ApplicationVirtualPath = path;
     HostManager            = HostManager.RegisterHost(this);
     RaiseStart();
 }
示例#7
0
 public InMemoryHost(
     IConfigurationSource configuration,
     IDependencyResolver dependencyResolver = null,
     StartupProperties startup = null)
 {
     Resolver               = dependencyResolver ?? (configuration as IDependencyResolverAccessor)?.Resolver ?? new InternalDependencyResolver();
     _configuration         = configuration ?? new DelegateConfigurationSource(null);
     ApplicationVirtualPath = "/";
     HostManager            = HostManager.RegisterHost(this);
     RaiseStart(startup ?? new StartupProperties());
 }
示例#8
0
        public void Initialize(IEnumerable <string> prefixes, string appPathVDir, Type dependencyResolverFactory)
        {
            CheckNotDisposed();
            ApplicationVirtualPath = appPathVDir;

            _resolverFactory = dependencyResolverFactory;
            _listener        = new System.Net.HttpListener();
            foreach (string prefix in prefixes)
            {
                _listener.Prefixes.Add(prefix);
            }
            HostManager.RegisterHost(this);
        }
示例#9
0
 public void Init(HttpApplication context)
 {
     context.PostResolveRequestCache += HandleHttpApplicationPostResolveRequestCacheEvent;
     context.EndRequest += HandleHttpApplicationEndRequestEvent;
     if (HostManager == null)
     {
         lock (_syncRoot)
         {
             Thread.MemoryBarrier();
             if (HostManager == null)
             {
                 HostManager = HostManager.RegisterHost(Host);
                 Host.RaiseStart();
                 Log = HostManager.Resolver.Resolve <ILogger <AspNetLogSource> >();
             }
         }
     }
 }
        public void Initialize(IEnumerable <string> prefixes, string appPathVDir, Type dependencyResolverFactory = null)
        {
            CheckNotDisposed();

            if (dependencyResolverFactory != null && _resolverAccessor != null)
            {
                throw new ArgumentException("Cannot set a resolver factory if a resolver has been provided in the constructor.",
                                            nameof(dependencyResolverFactory));
            }

            ApplicationVirtualPath = appPathVDir;

            _resolverFactory = dependencyResolverFactory;
            _listener        = new System.Net.HttpListener();
            foreach (string prefix in prefixes)
            {
                _listener.Prefixes.Add(prefix);
            }
            HostManager.RegisterHost(this);
        }