diff options
Diffstat (limited to 'src/WixToolset.Data/IntermediateSection.cs')
-rw-r--r-- | src/WixToolset.Data/IntermediateSection.cs | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/src/WixToolset.Data/IntermediateSection.cs b/src/WixToolset.Data/IntermediateSection.cs index cd001d5c..86aa0c89 100644 --- a/src/WixToolset.Data/IntermediateSection.cs +++ b/src/WixToolset.Data/IntermediateSection.cs | |||
@@ -11,18 +11,22 @@ namespace WixToolset.Data | |||
11 | /// </summary> | 11 | /// </summary> |
12 | public class IntermediateSection | 12 | public class IntermediateSection |
13 | { | 13 | { |
14 | private readonly List<IntermediateSymbol> symbols; | ||
15 | |||
14 | /// <summary> | 16 | /// <summary> |
15 | /// Creates a new section as part of an intermediate. | 17 | /// Creates a new section as part of an intermediate. |
16 | /// </summary> | 18 | /// </summary> |
17 | /// <param name="id">Identifier for section.</param> | 19 | /// <param name="id">Identifier for section.</param> |
18 | /// <param name="type">Type of section.</param> | 20 | /// <param name="type">Type of section.</param> |
19 | /// <param name="codepage">Codepage for resulting database.</param> | 21 | /// <param name="codepage">Codepage for resulting database.</param> |
20 | public IntermediateSection(string id, SectionType type, int codepage) | 22 | /// <param name="compilationId">Optional compilation identifier</param> |
23 | public IntermediateSection(string id, SectionType type, int codepage, string compilationId = null) | ||
21 | { | 24 | { |
22 | this.Id = id; | 25 | this.Id = id; |
23 | this.Type = type; | 26 | this.Type = type; |
24 | this.Codepage = codepage; | 27 | this.Codepage = codepage; |
25 | this.Symbols = new List<IntermediateSymbol>(); | 28 | this.CompilationId = compilationId; |
29 | this.symbols = new List<IntermediateSymbol>(); | ||
26 | } | 30 | } |
27 | 31 | ||
28 | /// <summary> | 32 | /// <summary> |
@@ -41,22 +45,53 @@ namespace WixToolset.Data | |||
41 | /// Gets the codepage for the section. | 45 | /// Gets the codepage for the section. |
42 | /// </summary> | 46 | /// </summary> |
43 | /// <value>Codepage for the section.</value> | 47 | /// <value>Codepage for the section.</value> |
44 | public int Codepage { get; set; } | 48 | public int Codepage { get; } |
45 | 49 | ||
46 | /// <summary> | 50 | /// <summary> |
47 | /// Gets and sets the identifier of the compilation of the source file containing the section. | 51 | /// Gets and sets the identifier of the compilation of the source file containing the section. |
48 | /// </summary> | 52 | /// </summary> |
49 | public string CompilationId { get; set; } | 53 | public string CompilationId { get; } |
50 | 54 | ||
51 | /// <summary> | 55 | /// <summary> |
52 | /// Gets and sets the identifier of the library that combined the section. | 56 | /// Gets and sets the identifier of the library that combined the section. |
53 | /// </summary> | 57 | /// </summary> |
54 | public string LibraryId { get; set; } | 58 | public string LibraryId { get; private set; } |
55 | 59 | ||
56 | /// <summary> | 60 | /// <summary> |
57 | /// Symbols in the section. | 61 | /// Symbols in the section. |
58 | /// </summary> | 62 | /// </summary> |
59 | public IList<IntermediateSymbol> Symbols { get; } | 63 | public IReadOnlyCollection<IntermediateSymbol> Symbols => this.symbols; |
64 | |||
65 | /// <summary> | ||
66 | /// Adds a symbol to the section. | ||
67 | /// </summary> | ||
68 | /// <typeparam name="T">Type of IntermediateSymbol to add to the section.</typeparam> | ||
69 | /// <param name="symbol">Symbol to add to the section.</param> | ||
70 | /// <returns>Symbol added to the section.</returns> | ||
71 | public T AddSymbol<T>(T symbol) where T : IntermediateSymbol | ||
72 | { | ||
73 | this.symbols.Add(symbol); | ||
74 | return symbol; | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Assigns the section to a library. | ||
79 | /// </summary> | ||
80 | /// <param name="libraryId">Identifier of the library.</param> | ||
81 | public void AssignToLibrary(string libraryId) | ||
82 | { | ||
83 | this.LibraryId = libraryId; | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Removes a symbol from the section. | ||
88 | /// </summary> | ||
89 | /// <param name="symbol">Symbol to remove.</param> | ||
90 | /// <returns>True if the symbol was removed; otherwise false.</returns> | ||
91 | public bool RemoveSymbol(IntermediateSymbol symbol) | ||
92 | { | ||
93 | return this.symbols.Remove(symbol); | ||
94 | } | ||
60 | 95 | ||
61 | /// <summary> | 96 | /// <summary> |
62 | /// Parse a section from the JSON data. | 97 | /// Parse a section from the JSON data. |
@@ -79,7 +114,7 @@ namespace WixToolset.Data | |||
79 | foreach (JsonObject symbolJson in symbolsJson) | 114 | foreach (JsonObject symbolJson in symbolsJson) |
80 | { | 115 | { |
81 | var symbol = IntermediateSymbol.Deserialize(creator, baseUri, symbolJson); | 116 | var symbol = IntermediateSymbol.Deserialize(creator, baseUri, symbolJson); |
82 | section.Symbols.Add(symbol); | 117 | section.symbols.Add(symbol); |
83 | } | 118 | } |
84 | 119 | ||
85 | return section; | 120 | return section; |