diff --git a/ArgumentContainer.cs b/ArgumentContainer.cs
index 21bf6b7..c644cc4 100644
--- a/ArgumentContainer.cs
+++ b/ArgumentContainer.cs
@@ -110,6 +110,7 @@ namespace ln.types
public bool Contains(string longName)
{
+ if (longName != null)
foreach (Argument argument in arguments)
{
if (longName.Equals(argument.Long))
diff --git a/Extensions.cs b/Extensions.cs
index abbbc6e..e065ada 100644
--- a/Extensions.cs
+++ b/Extensions.cs
@@ -96,6 +96,12 @@ namespace ln.types
}
+ public static byte[] ReadToEnd(this Stream stream)
+ {
+ MemoryStream memoryStream = new MemoryStream();
+ stream.CopyTo(memoryStream);
+ return memoryStream.ToArray();
+ }
public static void WriteBytes(this Stream stream, byte[] bytes)
{
diff --git a/io/ContentSource.cs b/io/ContentSource.cs
new file mode 100644
index 0000000..5afd664
--- /dev/null
+++ b/io/ContentSource.cs
@@ -0,0 +1,8 @@
+using System;
+namespace ln.types.io
+{
+ public interface ContentSource
+ {
+ byte[] Content { get; }
+ }
+}
diff --git a/io/FileStorage.cs b/io/FileStorage.cs
new file mode 100644
index 0000000..962b745
--- /dev/null
+++ b/io/FileStorage.cs
@@ -0,0 +1,19 @@
+using System;
+using System.IO;
+namespace ln.types.io
+{
+ public abstract class FileStorage
+ {
+ public FileStorage(string path)
+ {
+ }
+
+ public abstract string[] ListFiles();
+ public abstract string[] ListDirectories();
+
+ public abstract bool ContainsFile(string path);
+ public abstract bool ContainsDirectory(string path);
+
+ public virtual bool Contains(string path) => ContainsDirectory(path) || ContainsFile(path);
+ }
+}
diff --git a/io/WatchedFile.cs b/io/WatchedFile.cs
new file mode 100644
index 0000000..41f3e49
--- /dev/null
+++ b/io/WatchedFile.cs
@@ -0,0 +1,48 @@
+using System;
+using System.IO;
+namespace ln.types.io
+{
+ public class WatchedFile : IDisposable, ContentSource
+ {
+ public string FileName { get; private set; }
+ public event FileSystemEventHandler Changed;
+
+ FileSystemWatcher fileSystemWatcher;
+
+ public WatchedFile(String filename)
+ {
+ FileName = filename;
+ fileSystemWatcher = new FileSystemWatcher(filename);
+ fileSystemWatcher.Changed += FileSystemWatcher_Changed;
+ }
+
+ public byte[] Content
+ {
+ get
+ {
+ using (FileStream fs = new FileStream(FileName,FileMode.Open))
+ {
+ return fs.ReadBytes((int)fs.Length);
+ }
+ }
+ set
+ {
+ using (FileStream fs = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write))
+ {
+ fs.Position = 0;
+ fs.WriteBytes(value);
+ }
+ }
+ }
+
+ void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
+ {
+ Changed?.Invoke(sender, e);
+ }
+
+ public void Dispose()
+ {
+ fileSystemWatcher.Dispose();
+ }
+ }
+}
diff --git a/ln.types.csproj b/ln.types.csproj
index b0af7cb..d1fe40f 100644
--- a/ln.types.csproj
+++ b/ln.types.csproj
@@ -132,6 +132,9 @@
+
+
+
@@ -156,6 +159,7 @@
+