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; }
private static void OnCreated(object sender, FileSystemEventArgs e, FileCache cache, FileCacheEntry entry) { var key = e.FullPath.Replace(entry._path, ""); 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); }
private static void OnRenamed(object sender, RenamedEventArgs e, FileCache cache, FileCacheEntry entry) { var oldKey = e.OldFullPath.Replace(entry._path, ""); var oldFile = e.OldFullPath; var newKey = e.FullPath.Replace(entry._path, ""); 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); }
/// <summary> /// Initialize HTTP server /// </summary> public HttpServer() { Cache = new FileCache(); }
/// <summary> /// Initialize HTTPS server /// </summary> /// <param name="context">SSL context</param> public HttpsServer(SslContext context) : base(context) { Cache = new FileCache(); }
/// <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(); }
/// <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(); }