From 634fc916f620ee46c1634327e66328fabb68c9d1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Jul 2020 13:16:30 -0700 Subject: Catch up a few files missed in the Great Tuple to Symbol rename --- .../SimpleSymbolDefinitionCreator.cs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs (limited to 'src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs') diff --git a/src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs b/src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs new file mode 100644 index 00000000..e22d53e7 --- /dev/null +++ b/src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs @@ -0,0 +1,31 @@ +// 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. + +namespace WixToolset.Data +{ + using System.Collections.Generic; + + internal class SimpleSymbolDefinitionCreator : ISymbolDefinitionCreator + { + private Dictionary CustomDefinitionByName { get; } = new Dictionary(); + + public void AddCustomSymbolDefinition(IntermediateSymbolDefinition definition) + { + if (!this.CustomDefinitionByName.TryGetValue(definition.Name, out var existing) || definition.Revision > existing.Revision) + { + this.CustomDefinitionByName[definition.Name] = definition; + } + } + + public bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = SymbolDefinitions.ByName(name); + + if (symbolDefinition == null) + { + symbolDefinition = this.CustomDefinitionByName.GetValueOrDefault(name); + } + + return symbolDefinition != null; + } + } +} -- cgit v1.2.3-55-g6feb