/// <summary>
 /// 删除监视 WEB 视图服务
 /// </summary>
 /// <param name="server"></param>
 /// <returns>是否需要删除监视</returns>
 private bool remove(ViewServer server)
 {
     Monitor.Enter(serverLock);
     try
     {
         return(servers.Remove(server) && servers.Count == 0);
     }
     finally { Monitor.Exit(serverLock); }
 }
 /// <summary>
 /// 添加 WEB 视图服务
 /// </summary>
 /// <param name="server"></param>
 private void add(ViewServer server)
 {
     Monitor.Enter(serverLock);
     try
     {
         servers.Add(server);
     }
     finally { Monitor.Exit(serverLock); }
     if (version != null)
     {
         server.StaticFileVersion = version;
     }
 }
        /// <summary>
        /// 网站资源版本号文件监视
        /// </summary>
        /// <param name="server">WEB 视图服务</param>
        private VersionFileWatcher(ViewServer server)
        {
            FileInfo file = new FileInfo(versionFileName = server.WorkPath + AutoCSer.Net.Http.Header.VersionFileName);

            if (file.Exists)
            {
                server.StaticFileVersion = version = System.IO.File.ReadAllText(file.FullName, System.Text.Encoding.ASCII);
            }
            watcher = new FileSystemWatcher(server.WorkPath, "*" + AutoCSer.Net.Http.Header.VersionFileName);//"*.html"
            watcher.IncludeSubdirectories = false;
            watcher.EnableRaisingEvents   = true;
            watcher.Created += onCreated;
            servers.Add(server);
        }
        /// <summary>
        /// 添加监视 WEB 视图服务
        /// </summary>
        /// <param name="server"></param>
        internal static void Add(ViewServer server)
        {
            HashString         path = server.WorkPath;
            VersionFileWatcher watcher;

            Monitor.Enter(watcherLock);
            try
            {
                if (watchers.TryGetValue(path, out watcher))
                {
                    watcher.add(server);
                }
                else
                {
                    watchers.Add(path, new VersionFileWatcher(server));
                }
            }
            finally { Monitor.Exit(watcherLock); }
        }
        /// <summary>
        /// 删除监视 WEB 视图服务
        /// </summary>
        /// <param name="server"></param>
        internal static void Remove(ViewServer server)
        {
            HashString         path = server.WorkPath;
            VersionFileWatcher watcher, removeWatcher = null;

            Monitor.Enter(watcherLock);
            try
            {
                if (watchers.TryGetValue(path, out watcher) && watcher.remove(server))
                {
                    watchers.Remove(path);
                    removeWatcher = watcher;
                }
            }
            finally { Monitor.Exit(watcherLock); }
            if (removeWatcher != null)
            {
                removeWatcher.Dispose();
            }
        }