From fb2436ef2e5ba9b5c16c7f0fdc948fc6d1faf8b5 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 25 Jun 2020 14:47:54 -0700 Subject: The Great Tuple to Symbol File Rename (tm) --- .../SymbolDefinitionCreator.cs | 70 ++++++++++++++++++++++ .../TupleDefinitionCreator.cs | 70 ---------------------- 2 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 src/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs delete mode 100644 src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs (limited to 'src/WixToolset.Core/ExtensibilityServices') diff --git a/src/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs b/src/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs new file mode 100644 index 00000000..2bff21d6 --- /dev/null +++ b/src/WixToolset.Core/ExtensibilityServices/SymbolDefinitionCreator.cs @@ -0,0 +1,70 @@ +// 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.Core.ExtensibilityServices +{ + using System; + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; + + internal class SymbolDefinitionCreator : ISymbolDefinitionCreator + { + public SymbolDefinitionCreator(IWixToolsetServiceProvider serviceProvider) + { + this.ServiceProvider = serviceProvider; + } + + private IWixToolsetServiceProvider ServiceProvider { get; } + + private IEnumerable ExtensionData { get; set; } + + 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) + { + // First, look in the built-ins. + symbolDefinition = SymbolDefinitions.ByName(name); + + if (symbolDefinition == null) + { + if (this.ExtensionData == null) + { + this.LoadExtensionData(); + } + + // Second, look in the extensions. + foreach (var data in this.ExtensionData) + { + if (data.TryGetSymbolDefinitionByName(name, out symbolDefinition)) + { + break; + } + } + + // Finally, look in the custom symbol definitions provided during an intermediate load. + if (symbolDefinition == null) + { + this.CustomDefinitionByName.TryGetValue(name, out symbolDefinition); + } + } + + return symbolDefinition != null; + } + + private void LoadExtensionData() + { + var extensionManager = this.ServiceProvider.GetService(); + + this.ExtensionData = extensionManager.GetServices(); + } + } +} diff --git a/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs b/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs deleted file mode 100644 index 2bff21d6..00000000 --- a/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs +++ /dev/null @@ -1,70 +0,0 @@ -// 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.Core.ExtensibilityServices -{ - using System; - using System.Collections.Generic; - using WixToolset.Data; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Services; - - internal class SymbolDefinitionCreator : ISymbolDefinitionCreator - { - public SymbolDefinitionCreator(IWixToolsetServiceProvider serviceProvider) - { - this.ServiceProvider = serviceProvider; - } - - private IWixToolsetServiceProvider ServiceProvider { get; } - - private IEnumerable ExtensionData { get; set; } - - 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) - { - // First, look in the built-ins. - symbolDefinition = SymbolDefinitions.ByName(name); - - if (symbolDefinition == null) - { - if (this.ExtensionData == null) - { - this.LoadExtensionData(); - } - - // Second, look in the extensions. - foreach (var data in this.ExtensionData) - { - if (data.TryGetSymbolDefinitionByName(name, out symbolDefinition)) - { - break; - } - } - - // Finally, look in the custom symbol definitions provided during an intermediate load. - if (symbolDefinition == null) - { - this.CustomDefinitionByName.TryGetValue(name, out symbolDefinition); - } - } - - return symbolDefinition != null; - } - - private void LoadExtensionData() - { - var extensionManager = this.ServiceProvider.GetService(); - - this.ExtensionData = extensionManager.GetServices(); - } - } -} -- cgit v1.2.3-55-g6feb