From 2bb37beda887d120a0ddabf874ad25357101faa1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Nov 2017 10:59:45 -0700 Subject: Update to WiX Intermediate Representation --- src/WixToolset.Core/TupleDefinitionCreator.cs | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/WixToolset.Core/TupleDefinitionCreator.cs (limited to 'src/WixToolset.Core/TupleDefinitionCreator.cs') diff --git a/src/WixToolset.Core/TupleDefinitionCreator.cs b/src/WixToolset.Core/TupleDefinitionCreator.cs new file mode 100644 index 00000000..8c9b9d29 --- /dev/null +++ b/src/WixToolset.Core/TupleDefinitionCreator.cs @@ -0,0 +1,52 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; + + internal class TupleDefinitionCreator : ITupleDefinitionCreator + { + public TupleDefinitionCreator(IServiceProvider serviceProvider) + { + this.ServiceProvider = serviceProvider; + } + + private IServiceProvider ServiceProvider { get; } + + private IEnumerable ExtensionData { get; set; } + + public bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) + { + tupleDefinition = TupleDefinitions.ByName(name); + + if (tupleDefinition == null) + { + if (this.ExtensionData == null) + { + this.LoadExtensionData(); + } + + foreach (var data in this.ExtensionData) + { + if (data.TryGetTupleDefinitionByName(name, out tupleDefinition)) + { + break; + } + } + } + + return tupleDefinition != null; + } + + private void LoadExtensionData() + { + var extensionManager = (IExtensionManager)this.ServiceProvider.GetService(typeof(IExtensionManager)); + + this.ExtensionData = extensionManager.Create(); + } + } +} -- cgit v1.2.3-55-g6feb