Ejemplo n.º 1
0
 public Request(Server server, Host host, Connection connection)
     : base(String.Empty, String.Empty, null)
 {
     _connectionPermission = new PermissionSet(PermissionState.Unrestricted);
     _server = server;
     _host = host;
     _connection = connection;
 }
        public void Create_And_Configure_Host()
        {            
            var server = new Server("_temp_CassiniSite".tempDir());

            var host = new Host();
            Assert.IsNotNull(host);            
            
            
            //check values before configure
            Assert.Throws<NullReferenceException>(()=> host.GetProcessToken());
            Assert.Throws<NullReferenceException>(()=> host.GetProcessUser());
            Assert.IsNotNull(host.AppDomain);
            Assert.IsFalse  (host.DisableDirectoryListing);
            Assert.IsNull   (host.NormalizedClientScriptPath);
            Assert.IsNull   (host.NormalizedVirtualPath);
            Assert.IsNull   (host.PhysicalClientScriptPath);
            Assert.IsNull   (host.PhysicalPath);
            Assert.AreEqual (0, host.Port);
            Assert.IsFalse  (host.RequireAuthentication);
            Assert.IsNull   (host.VirtualPath);

            host.Configure(server, server.Port, server.VirtualPath, server.PhysicalPath);

            //check values after configure
            Assert.AreNotEqual(host.GetProcessToken(),IntPtr.Zero);
            Assert.IsNotNull  (host.GetProcessUser());            
            Assert.IsFalse    (host.DisableDirectoryListing);
            Assert.IsNull     (host.InstallPath);
            Assert.IsNotNull  (host.NormalizedClientScriptPath);
            Assert.IsNotNull  (host.NormalizedVirtualPath);
            Assert.IsNotNull  (host.PhysicalClientScriptPath);
            Assert.IsNotNull  (host.PhysicalPath);
            Assert.AreNotEqual(0, host.Port);
            Assert.IsFalse(host.RequireAuthentication);
            Assert.IsNotNull  (host.VirtualPath);
            
            //removed tempDir
            server.PhysicalPath.delete_Folder();
        }
Ejemplo n.º 3
0
        private Host GetHostAndInjectAssemblies()
        {
            if (_shutdownInProgress)
                return null;
            Host host = _host;
            if (host == null)
            {
            #if NET40
                var obj2 = new object();
                bool flag = false;
                try
                {
                    Monitor.Enter(obj2 = _lockObject, ref flag);
                    host = _host;
                    if (host == null)
                    {
                        host =
                            (Host)
                            CreateWorkerAppDomainWithHostAndInjectedAssemblies(_virtualPath, _physicalPath,
                                                                               typeof (Host));
                        host.Configure(this, _port, _virtualPath, _physicalPath, _requireAuthentication,
                                       _disableDirectoryListing);
                        _host = host;
                    }
                }
                finally
                {
                    if (flag)
                    {
                        Monitor.Exit(obj2);
                    }
                }
            #else

                lock (_lockObject)
                {
                    host = _host;
                    if (host == null)
                    {
                        host = (Host)CreateWorkerAppDomainWithHost(_virtualPath, _physicalPath, typeof(Host));
                        host.Configure(this, _port, _virtualPath, _physicalPath, _requireAuthentication, _disableDirectoryListing);
                        _host = host;
                    }
                }

            #endif
            }

            return host;
        }
Ejemplo n.º 4
0
 public void HostStopped()
 {
     _host = null;
 }
Ejemplo n.º 5
0
        public void ShutDown()
        {
            _shutdownInProgress = true;

            try
            {
                if (_socket != null)
                {
                    _socket.Close();
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
            finally
            {
                _socket = null;
            }

            try
            {
                if (_host != null)
                {
                    _host.Shutdown();
                }

                while (_host != null)
                {
                    Thread.Sleep(100);
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
            finally
            {
                _host = null;
            }
        }