Add project files.

This commit is contained in:
2025-04-19 20:47:58 +03:00
parent 9e14d137ae
commit bfdcdb1f3b
66 changed files with 2394 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beam.Exports {
public class PlainTextExporter : IExporter, IAsyncExporter {
public PlainTextExporter(IDocument document) {
Document = document;
}
public IDocument Document { get; }
protected virtual string Convert() {
return Document.ToString();
}
protected virtual Task<string> ConvertAsync() {
return Task.FromResult(Document.ToString());
}
public virtual void Write(string path) {
var text = Convert();
if (!Directory.Exists(Path.GetDirectoryName(path)))
throw new ArgumentException(S.M.FileDirectoryDoesNotExist, nameof(path));
File.WriteAllText(path, text, Encoding.Unicode);
}
public virtual async Task WriteAsync(string path) {
var text = await ConvertAsync();
if (!Directory.Exists(path))
throw new ArgumentException(S.M.FileDirectoryDoesNotExist, nameof(path));
await File.WriteAllTextAsync(path, text);
}
}
}