diff options
Diffstat (limited to 'src/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs')
| -rw-r--r-- | src/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs b/src/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs new file mode 100644 index 00000000..3afc8678 --- /dev/null +++ b/src/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs | |||
| @@ -0,0 +1,94 @@ | |||
| 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.Extensibility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Linq; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Data.Burn; | ||
| 10 | using WixToolset.Extensibility.Data; | ||
| 11 | using WixToolset.Extensibility.Services; | ||
| 12 | |||
| 13 | /// <summary> | ||
| 14 | /// Base class for creating a Burn backend extension. | ||
| 15 | /// </summary> | ||
| 16 | public abstract class BaseBurnBackendBinderExtension : IBurnBackendBinderExtension | ||
| 17 | { | ||
| 18 | /// <summary> | ||
| 19 | /// Context for use by the extension. | ||
| 20 | /// </summary> | ||
| 21 | protected IBindContext Context { get; private set; } | ||
| 22 | |||
| 23 | /// <summary> | ||
| 24 | /// Messaging for use by the extension. | ||
| 25 | /// </summary> | ||
| 26 | protected IMessaging Messaging { get; private set; } | ||
| 27 | |||
| 28 | /// <summary> | ||
| 29 | /// Backend helper for use by the extension. | ||
| 30 | /// </summary> | ||
| 31 | protected IBurnBackendHelper BackendHelper { get; private set; } | ||
| 32 | |||
| 33 | /// <summary> | ||
| 34 | /// Optional symbol definitions. | ||
| 35 | /// </summary> | ||
| 36 | protected virtual IEnumerable<IntermediateSymbolDefinition> SymbolDefinitions => Enumerable.Empty<IntermediateSymbolDefinition>(); | ||
| 37 | |||
| 38 | /// <summary> | ||
| 39 | /// See <see cref="IBurnBackendBinderExtension.PreBackendBind(IBindContext)"/> | ||
| 40 | /// </summary> | ||
| 41 | public virtual void PreBackendBind(IBindContext context) | ||
| 42 | { | ||
| 43 | this.Context = context; | ||
| 44 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); | ||
| 45 | this.BackendHelper = context.ServiceProvider.GetService<IBurnBackendHelper>(); | ||
| 46 | } | ||
| 47 | |||
| 48 | /// <summary> | ||
| 49 | /// See <see cref="IBurnBackendBinderExtension.ResolveRelatedFile(String, String, String, SourceLineNumber)"/> | ||
| 50 | /// </summary> | ||
| 51 | public virtual IResolveFileResult ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers) | ||
| 52 | { | ||
| 53 | return null; | ||
| 54 | } | ||
| 55 | |||
| 56 | /// <summary> | ||
| 57 | /// See <see cref="IBurnBackendBinderExtension.SymbolsFinalized(IntermediateSection)"/> | ||
| 58 | /// </summary> | ||
| 59 | public virtual void SymbolsFinalized(IntermediateSection section) | ||
| 60 | { | ||
| 61 | } | ||
| 62 | |||
| 63 | /// <summary> | ||
| 64 | /// See <see cref="IBurnBackendBinderExtension.ResolveUrl(String, String, String, String, String)"/> | ||
| 65 | /// </summary> | ||
| 66 | public virtual string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName) | ||
| 67 | { | ||
| 68 | return null; | ||
| 69 | } | ||
| 70 | |||
| 71 | /// <summary> | ||
| 72 | /// See <see cref="IBurnBackendBinderExtension.TryProcessSymbol(IntermediateSection, IntermediateSymbol)"/> | ||
| 73 | /// </summary> | ||
| 74 | public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol) | ||
| 75 | { | ||
| 76 | if (this.SymbolDefinitions.Any(t => t == symbol.Definition) && | ||
| 77 | symbol.Definition.HasTag(BurnConstants.BootstrapperApplicationDataSymbolDefinitionTag)) | ||
| 78 | { | ||
| 79 | this.BackendHelper.AddBootstrapperApplicationData(symbol); | ||
| 80 | return true; | ||
| 81 | } | ||
| 82 | |||
| 83 | return false; | ||
| 84 | } | ||
| 85 | |||
| 86 | /// <summary> | ||
| 87 | /// See <see cref="IBurnBackendBinderExtension.PostBackendBind(IBindResult)"/> | ||
| 88 | /// </summary> | ||
| 89 | /// <param name="result"></param> | ||
| 90 | public virtual void PostBackendBind(IBindResult result) | ||
| 91 | { | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } | ||
