-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArticleOrModuleRef.cs
More file actions
59 lines (49 loc) · 1.75 KB
/
ArticleOrModuleRef.cs
File metadata and controls
59 lines (49 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Microsoft.AspNetCore.Components.Forms;
namespace ConvertLearnToDoc.Shared;
public class BrowserFile
{
private const int MAX_FILE_SIZE = 1024 * 1024 * 1024; // 1gb max size
public string ContentType { get; set; } = null!;
public DateTimeOffset LastModified { get; set; }
public string FileName { get; set; } = null!;
public byte[] Contents { get; set; } = null!;
public bool IsArticle { get; set; } = false;
public static async Task<BrowserFile> CreateAsync(IBrowserFile selectedFile)
{
var bf = new BrowserFile
{
ContentType = selectedFile.ContentType,
LastModified = selectedFile.LastModified,
FileName = selectedFile.Name
};
await using var stream = selectedFile.OpenReadStream(maxAllowedSize: MAX_FILE_SIZE);
MemoryStream ms = new();
await stream.CopyToAsync(ms);
bf.Contents = ms.ToArray();
return bf;
}
public override string ToString()
{
return $"FileName={FileName}, Size={Contents.Length}, LastModified={LastModified}, Type={ContentType}";
}
}
public class ModuleRef : ArticleRef
{
public bool IgnoreMetadata { get; set; }
public bool UseGenericIds { get; set; }
}
public class ArticleRef
{
public string? Metadata { get; set; }
public BrowserFile? Document { get; set; }
public bool UsePlainMarkdown { get; set; }
public bool UseAsterisksForBullets { get; set; }
public bool UseAsterisksForEmphasis { get; set; }
public bool OrderedListUsesSequence { get; set; }
public bool UseIndentsForCodeBlocks { get; set; }
public bool PrettyPipeTables { get; set; }
public override string ToString()
{
return $"{GetType().Name}: Document:{Document}";
}
}