EasySign BETA
Digital Signing Tool
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
Manifest.cs
Go to the documentation of this file.
1using System.Collections.Concurrent;
2using System.Data;
3using System.Text.Json.Serialization;
4
5namespace SAPTeam.EasySign
6{
10 public class Manifest
11 {
12 private ConcurrentDictionary<string, byte[]> entries = new ConcurrentDictionary<string, byte[]>();
13
17 public string? UpdatedBy { get; set; }
18
26 public SortedDictionary<string, byte[]> Entries
27 {
28 get => new(entries); set => entries = new(value);
29 }
30
34 public bool StoreOriginalFiles { get; set; }
35
39 public HashSet<string> ProtectedEntryNames { get; set; } = [];
40
45 public ConcurrentDictionary<string, byte[]> GetEntries() => entries;
46
58 public void AddEntry(string entryName, byte[] hash)
59 {
60 if (!entries.TryAdd(entryName, hash))
61 {
62 throw new DuplicateNameException($"The entry '{entryName}' is already in the manifest.");
63 }
64 }
65
72 public void DeleteEntry(string entryName)
73 {
74 if (!entries.Remove(entryName, out _))
75 {
76 throw new KeyNotFoundException(entryName);
77 }
78 }
79
89 public static string GetNormalizedEntryName(string path) => new UnifiedPath.OSPath(path).Unix;
90 }
91
92 [JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata, WriteIndented = false, DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
93 [JsonSerializable(typeof(Manifest))]
94 internal partial class SourceGenerationManifestContext : JsonSerializerContext
95 {
96
97 }
98}
Represents a manifest that holds entries of file names and their corresponding hashes.
Definition Manifest.cs:11
SortedDictionary< string, byte[]> Entries
Gets or sets the entries in the manifest as a sorted dictionary.
Definition Manifest.cs:27
static string GetNormalizedEntryName(string path)
Converts the path to an standard zip entry name.
void DeleteEntry(string entryName)
Deletes an entry from the manifest.
Definition Manifest.cs:72
string? UpdatedBy
Gets or sets the full name of the class that updated the manifest.
Definition Manifest.cs:17
bool StoreOriginalFiles
Gets or sets a value indicating whether the files should be stored in the bundle.
Definition Manifest.cs:34
void AddEntry(string entryName, byte[] hash)
Adds an entry to the manifest.
Definition Manifest.cs:58
ConcurrentDictionary< string, byte[]> GetEntries()
Gets the entries as a thread-safe concurrent dictionary.
HashSet< string > ProtectedEntryNames
Gets or sets the list of entry names that should be protected by the bundle from accidental modificat...
Definition Manifest.cs:39