aboutsummaryrefslogtreecommitdiff
path: root/src/api/wix/WixToolset.Data/SimpleSymbolDefinitionCreator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/wix/WixToolset.Data/SimpleSymbolDefinitionCreator.cs')
-rw-r--r--src/api/wix/WixToolset.Data/SimpleSymbolDefinitionCreator.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/api/wix/WixToolset.Data/SimpleSymbolDefinitionCreator.cs b/src/api/wix/WixToolset.Data/SimpleSymbolDefinitionCreator.cs
new file mode 100644
index 00000000..e22d53e7
--- /dev/null
+++ b/src/api/wix/WixToolset.Data/SimpleSymbolDefinitionCreator.cs
@@ -0,0 +1,31 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Data
4{
5 using System.Collections.Generic;
6
7 internal class SimpleSymbolDefinitionCreator : ISymbolDefinitionCreator
8 {
9 private Dictionary<string, IntermediateSymbolDefinition> CustomDefinitionByName { get; } = new Dictionary<string, IntermediateSymbolDefinition>();
10
11 public void AddCustomSymbolDefinition(IntermediateSymbolDefinition definition)
12 {
13 if (!this.CustomDefinitionByName.TryGetValue(definition.Name, out var existing) || definition.Revision > existing.Revision)
14 {
15 this.CustomDefinitionByName[definition.Name] = definition;
16 }
17 }
18
19 public bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition)
20 {
21 symbolDefinition = SymbolDefinitions.ByName(name);
22
23 if (symbolDefinition == null)
24 {
25 symbolDefinition = this.CustomDefinitionByName.GetValueOrDefault(name);
26 }
27
28 return symbolDefinition != null;
29 }
30 }
31}