コード例 #1
0
            private void StartWatcher(FileCache cache, string path, string filter)
            {
                FileCacheEntry entry = this;

                // Initialize a new filesystem watcher
                _watcher.Created += (sender, e) => OnCreated(sender, e, cache, entry);
                _watcher.Changed += (sender, e) => OnChanged(sender, e, cache, entry);
                _watcher.Deleted += (sender, e) => OnDeleted(sender, e, cache, entry);
                _watcher.Renamed += (sender, e) => OnRenamed(sender, e, cache, entry);
                _watcher.Path     = path;
                _watcher.IncludeSubdirectories = true;
                _watcher.Filter              = filter;
                _watcher.NotifyFilter        = NotifyFilters.FileName | NotifyFilters.LastWrite;
                _watcher.EnableRaisingEvents = true;
            }
コード例 #2
0
            private static void OnCreated(object sender, FileSystemEventArgs e, FileCache cache, FileCacheEntry entry)
            {
                var key  = e.FullPath.Replace(entry._path, entry._prefix);
                var file = e.FullPath;

                // Skip missing files
                if (!File.Exists(file))
                {
                    return;
                }
                // Skip directory updates
                if (IsDirectory(file))
                {
                    return;
                }

                cache.InsertFileInternal(entry._path, file, key, entry._timespan, entry._handler);
            }
コード例 #3
0
            private static void OnRenamed(object sender, RenamedEventArgs e, FileCache cache, FileCacheEntry entry)
            {
                var oldKey  = e.OldFullPath.Replace(entry._path, entry._prefix);
                var oldFile = e.OldFullPath;
                var newKey  = e.FullPath.Replace(entry._path, entry._prefix);
                var newFile = e.FullPath;

                // Skip missing files
                if (!File.Exists(newFile))
                {
                    return;
                }
                // Skip directory updates
                if (IsDirectory(newFile))
                {
                    return;
                }

                cache.RemoveFileInternal(entry._path, oldKey);
                cache.InsertFileInternal(entry._path, newFile, newKey, entry._timespan, entry._handler);
            }
コード例 #4
0
 /// <summary>
 /// Initialize HTTP server with a given IP endpoint
 /// </summary>
 /// <param name="endpoint">IP endpoint</param>
 public HttpServer(IPEndPoint endpoint) : base(endpoint)
 {
     Cache = new FileCache();
 }
コード例 #5
0
 /// <summary>
 /// Initialize HTTP server with a given IP address and port number
 /// </summary>
 /// <param name="address">IP address</param>
 /// <param name="port">Port number</param>
 public HttpServer(string address, int port) : base(address, port)
 {
     Cache = new FileCache();
 }
コード例 #6
0
 /// <summary>
 /// Initialize HTTP server with a given IP address and port number
 /// </summary>
 /// <param name="address">IP address</param>
 /// <param name="port">Port number</param>
 public HttpServer(IPAddress address, int port) : base(address, port)
 {
     Cache = new FileCache();
 }
コード例 #7
0
 /// <summary>
 /// Initialize HTTPS server with a given IP endpoint
 /// </summary>
 /// <param name="context">SSL context</param>
 /// <param name="endpoint">IP endpoint</param>
 public HttpsServer(SslContext context, IPEndPoint endpoint) : base(context, endpoint)
 {
     Cache = new FileCache();
 }
コード例 #8
0
 /// <summary>
 /// Initialize HTTPS server with a given IP address and port number
 /// </summary>
 /// <param name="context">SSL context</param>
 /// <param name="address">IP address</param>
 /// <param name="port">Port number</param>
 public HttpsServer(SslContext context, string address, int port) : base(context, address, port)
 {
     Cache = new FileCache();
 }