diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-11-14 23:21:52 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-11-14 23:21:52 -0800 |
| commit | aa6f15ec4998a77622fafe9c510b3b547c595679 (patch) | |
| tree | 50249c24429424ee14531a2047954c9df1ee345a /src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs | |
| parent | b6bf1604c32259757f75b4c35444cfe4ecc21a86 (diff) | |
| download | wix-aa6f15ec4998a77622fafe9c510b3b547c595679.tar.gz wix-aa6f15ec4998a77622fafe9c510b3b547c595679.tar.bz2 wix-aa6f15ec4998a77622fafe9c510b3b547c595679.zip | |
Refactor CompilerCore to ParserHelper and other clean up
Diffstat (limited to 'src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs')
| -rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs b/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs new file mode 100644 index 00000000..4075def8 --- /dev/null +++ b/src/WixToolset.Core/ExtensibilityServices/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.ExtensibilityServices | ||
| 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 | } | ||
