-
Notifications
You must be signed in to change notification settings - Fork 0
DiGi.Core.IO.FileWatcher.Classes
Watches a configuration file for changes and provides access to its content.
public class ConfigurationFileWatcher : DiGi.Core.IO.FileWatcher.Classes.FileWatcherInheritance System.Object → FileWatcher → ConfigurationFileWatcher
Initializes a new instance of the ConfigurationFileWatcher class.
public ConfigurationFileWatcher(string path, double interval=5000.0, System.Text.Encoding? encoding=null);path System.String
The path to the configuration file to watch.
interval System.Double
The interval in milliseconds between checks for changes.
encoding System.Text.Encoding
The encoding to use when reading the file.
Gets the configuration file associated with this watcher.
public DiGi.Core.Classes.ConfigurationFile ConfigurationFile { get; }DiGi.Core.Classes.ConfigurationFile
Implicitly converts a ConfigurationFileWatcher instance to its associated ConfigurationFile.
public static DiGi.Core.Classes.ConfigurationFile? implicit operator DiGi.Core.Classes.ConfigurationFile?(DiGi.Core.IO.FileWatcher.Classes.ConfigurationFileWatcher? configurationFileWatcher);configurationFileWatcher ConfigurationFileWatcher
The ConfigurationFileWatcher instance to convert.
DiGi.Core.Classes.ConfigurationFile
The ConfigurationFile associated with the watcher, or null if the watcher is null.
Monitors any file and reloads its binary content only if the hash has changed.
public class FileWatcher : System.IDisposable, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObjectInheritance System.Object → FileWatcher
Derived
↳ ConfigurationFileWatcher
↳ FileWatcher<TFile>
Implements System.IDisposable, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject
Initializes a new instance of the FileWatcher class to monitor changes to the specified file at a given interval.
public FileWatcher(string path, double interval=5000.0);path System.String
The full path to the file to be monitored. The file must exist at the time of initialization.
interval System.Double
The interval, in milliseconds, at which the file is checked for changes. The default is 5000 milliseconds.
System.IO.FileNotFoundException
Thrown if the file specified by path does not exist.
Gets the raw bytes of the file content.
public byte[]? Bytes { get; }Gets or sets the interval in milliseconds between checks for file changes.
public double Interval { get; set; }Gets the path to the file being watched.
public string Path { get; }Releases all resources used by the watcher.
public void Dispose();Implements Dispose()
Reads the content of the file as an array of strings.
public string[]? GetLines(System.Text.Encoding? encoding=null);encoding System.Text.Encoding
The encoding to use when reading the file.
System.String[]
An array of strings containing the lines of the file.
Reads the content of the file as a single string.
public string GetString(System.Text.Encoding? encoding=null);encoding System.Text.Encoding
The encoding to use when reading the file.
System.String
The content of the file as a string.
Provides a base implementation for watching a file for changes.
public abstract class FileWatcher<TFile> : DiGi.Core.IO.FileWatcher.Classes.FileWatcher
where TFile : DiGi.Core.IO.File.Interfaces.IFileTFile
The type of the file being watched.
Inheritance System.Object → FileWatcher → FileWatcher<TFile>
Initializes a new instance of the FileWatcher class.
public FileWatcher(string path, double interval=60000.0);path System.String
The path to the file to watch.
interval System.Double
The interval in milliseconds between checks for changes.
Gets the file object being watched.
public TFile? File { get; }