Exemplo n.º 1
0
 /// <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); }
 }
Exemplo n.º 2
0
 /// <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;
     }
 }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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); }
        }
Exemplo n.º 5
0
        /// <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();
            }
        }