diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-11-01 10:59:45 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-11-01 10:59:45 -0700 |
| commit | 2bb37beda887d120a0ddabf874ad25357101faa1 (patch) | |
| tree | c35e97b03274b86cfc9ff7fd2caeee211165a140 /src/WixToolset.Core/TupleDefinitionCreator.cs | |
| parent | df7413aeed3aea3425dff20ae0c8b1be3a3ab525 (diff) | |
| download | wix-2bb37beda887d120a0ddabf874ad25357101faa1.tar.gz wix-2bb37beda887d120a0ddabf874ad25357101faa1.tar.bz2 wix-2bb37beda887d120a0ddabf874ad25357101faa1.zip | |
Update to WiX Intermediate Representation
Diffstat (limited to 'src/WixToolset.Core/TupleDefinitionCreator.cs')
| -rw-r--r-- | src/WixToolset.Core/TupleDefinitionCreator.cs | 52 |
1 files changed, 52 insertions, 0 deletions
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 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Core | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using WixToolset.Data; | ||
| 8 | using WixToolset.Extensibility; | ||
| 9 | using WixToolset.Extensibility.Services; | ||
| 10 | |||
| 11 | internal class TupleDefinitionCreator : ITupleDefinitionCreator | ||
| 12 | { | ||
| 13 | public TupleDefinitionCreator(IServiceProvider serviceProvider) | ||
| 14 | { | ||
| 15 | this.ServiceProvider = serviceProvider; | ||
| 16 | } | ||
| 17 | |||
| 18 | private IServiceProvider ServiceProvider { get; } | ||
| 19 | |||
| 20 | private IEnumerable<IExtensionData> ExtensionData { get; set; } | ||
| 21 | |||
| 22 | public bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) | ||
| 23 | { | ||
| 24 | tupleDefinition = TupleDefinitions.ByName(name); | ||
| 25 | |||
| 26 | if (tupleDefinition == null) | ||
| 27 | { | ||
| 28 | if (this.ExtensionData == null) | ||
| 29 | { | ||
| 30 | this.LoadExtensionData(); | ||
| 31 | } | ||
| 32 | |||
| 33 | foreach (var data in this.ExtensionData) | ||
| 34 | { | ||
| 35 | if (data.TryGetTupleDefinitionByName(name, out tupleDefinition)) | ||
| 36 | { | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | return tupleDefinition != null; | ||
| 43 | } | ||
| 44 | |||
| 45 | private void LoadExtensionData() | ||
| 46 | { | ||
| 47 | var extensionManager = (IExtensionManager)this.ServiceProvider.GetService(typeof(IExtensionManager)); | ||
| 48 | |||
| 49 | this.ExtensionData = extensionManager.Create<IExtensionData>(); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
