示例#1
0
        ///<summary>
        ///</summary>
        ///<param name="port"></param>
        ///<param name="virtualPath"></param>
        ///<param name="physicalPath"></param>
        ///<param name="requireAuthentication"></param>
        ///<param name="disableDirectoryListing"></param>
        public Server(int port, string virtualPath, string physicalPath, bool requireAuthentication,
                      bool disableDirectoryListing)
        {
            try
            {
                Assembly.ReflectionOnlyLoad("Common.Logging");
                _useLogger = true;
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
            _ipAddress               = IPAddress.Loopback;
            _requireAuthentication   = requireAuthentication;
            _disableDirectoryListing = disableDirectoryListing;
            _lockObject              = new object();
            _port         = port;
            _virtualPath  = virtualPath;
            _physicalPath = Path.GetFullPath(physicalPath);

            var dirSeparator = Path.DirectorySeparatorChar.ToString();

            _physicalPath = _physicalPath.EndsWith(dirSeparator, StringComparison.Ordinal)
                                ? _physicalPath
                                : _physicalPath + dirSeparator;
            ProcessConfiguration();

            string uniqueAppString = string.Concat(virtualPath, physicalPath, ":", _port.ToString()).ToLowerInvariant();

            _appId = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture);
            ObtainProcessToken();

            _appHosts = new AppHosts(this, _virtualPath, _physicalPath);

            _appHosts.HostCreated += (s, e) =>
            {
                if (HostCreated != null)
                {
                    HostCreated.Invoke(s, e);
                }
            };

            _appHosts.HostRemoved += (s, e) =>
            {
                if (HostRemoved != null)
                {
                    HostRemoved.Invoke(s, e);
                }
            };

#if NET40
            //m_projMonitor = new HostWatchManager();
            //m_projMonitor.AddSolution(@"D:\Users\mantasi\Documents\Visual Studio 2010\Projects\Core\Core.sln");
#endif
        }
示例#2
0
 private void OnHostRemoved(Host h)
 {
     HostRemoved?.Invoke(h);
 }