diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-06-14 11:22:58 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-06-19 13:31:39 +1000 |
commit | 7a846e7869b2705fa0a184224ef53e2d89f2e8dd (patch) | |
tree | c8a7e1fd9d2305197ddb049f9bc42c546abe3613 /src | |
parent | ce397dd68b6699092d0b038b9a8c353f1f6a425d (diff) | |
download | wix-7a846e7869b2705fa0a184224ef53e2d89f2e8dd.tar.gz wix-7a846e7869b2705fa0a184224ef53e2d89f2e8dd.tar.bz2 wix-7a846e7869b2705fa0a184224ef53e2d89f2e8dd.zip |
Add IBurnBackendHelper and TryAddTupleToDataManifest.
Diffstat (limited to 'src')
3 files changed, 85 insertions, 1 deletions
diff --git a/src/WixToolset.Extensibility/BaseBurnBackendExtension.cs b/src/WixToolset.Extensibility/BaseBurnBackendExtension.cs index 58f96b31..5dc36715 100644 --- a/src/WixToolset.Extensibility/BaseBurnBackendExtension.cs +++ b/src/WixToolset.Extensibility/BaseBurnBackendExtension.cs | |||
@@ -6,7 +6,7 @@ namespace WixToolset.Extensibility | |||
6 | using WixToolset.Extensibility.Data; | 6 | using WixToolset.Extensibility.Data; |
7 | using WixToolset.Extensibility.Services; | 7 | using WixToolset.Extensibility.Services; |
8 | 8 | ||
9 | public class BaseBurnBackendExtension : IBurnBackendExtension | 9 | public abstract class BaseBurnBackendExtension : IBurnBackendExtension |
10 | { | 10 | { |
11 | /// <summary> | 11 | /// <summary> |
12 | /// Context for use by the extension. | 12 | /// Context for use by the extension. |
@@ -18,10 +18,20 @@ namespace WixToolset.Extensibility | |||
18 | /// </summary> | 18 | /// </summary> |
19 | protected IMessaging Messaging { get; private set; } | 19 | protected IMessaging Messaging { get; private set; } |
20 | 20 | ||
21 | /// <summary> | ||
22 | /// Backend helper for use by the extension. | ||
23 | /// </summary> | ||
24 | protected IBurnBackendHelper BackendHelper { get; private set; } | ||
25 | |||
21 | public virtual void BundleFinalize() | 26 | public virtual void BundleFinalize() |
22 | { | 27 | { |
23 | } | 28 | } |
24 | 29 | ||
30 | public virtual bool IsTupleForExtension(IntermediateTuple tuple) | ||
31 | { | ||
32 | return false; | ||
33 | } | ||
34 | |||
25 | public virtual void PostBackendBind(IBindResult result) | 35 | public virtual void PostBackendBind(IBindResult result) |
26 | { | 36 | { |
27 | } | 37 | } |
@@ -30,6 +40,7 @@ namespace WixToolset.Extensibility | |||
30 | { | 40 | { |
31 | this.Context = context; | 41 | this.Context = context; |
32 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); | 42 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); |
43 | this.BackendHelper = context.ServiceProvider.GetService<IBurnBackendHelper>(); | ||
33 | } | 44 | } |
34 | 45 | ||
35 | public virtual IResolveFileResult ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage) | 46 | public virtual IResolveFileResult ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage) |
@@ -41,5 +52,16 @@ namespace WixToolset.Extensibility | |||
41 | { | 52 | { |
42 | return null; | 53 | return null; |
43 | } | 54 | } |
55 | |||
56 | public virtual bool TryAddTupleToDataManifest(IntermediateSection section, IntermediateTuple tuple) | ||
57 | { | ||
58 | if (this.IsTupleForExtension(tuple) && tuple.HasTag(WixToolset.Data.Burn.BurnConstants.BootstrapperApplicationDataTupleDefinitionTag)) | ||
59 | { | ||
60 | this.BackendHelper.AddBootstrapperApplicationData(tuple); | ||
61 | return true; | ||
62 | } | ||
63 | |||
64 | return false; | ||
65 | } | ||
44 | } | 66 | } |
45 | } | 67 | } |
diff --git a/src/WixToolset.Extensibility/IBurnBackendExtension.cs b/src/WixToolset.Extensibility/IBurnBackendExtension.cs index 569d8d10..d5f71107 100644 --- a/src/WixToolset.Extensibility/IBurnBackendExtension.cs +++ b/src/WixToolset.Extensibility/IBurnBackendExtension.cs | |||
@@ -17,6 +17,18 @@ namespace WixToolset.Extensibility | |||
17 | string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName); | 17 | string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName); |
18 | 18 | ||
19 | /// <summary> | 19 | /// <summary> |
20 | /// Called for each extension tuple that hasn't been handled yet. | ||
21 | /// Use IBurnBackendHelper to add data to the appropriate data manifest. | ||
22 | /// </summary> | ||
23 | /// <param name="section">The linked section.</param> | ||
24 | /// <param name="tuple">The current tuple.</param> | ||
25 | /// <returns> | ||
26 | /// True if the extension handled the tuple, false otherwise. | ||
27 | /// The Burn backend will warn on all unhandled tuples. | ||
28 | /// </returns> | ||
29 | bool TryAddTupleToDataManifest(IntermediateSection section, IntermediateTuple tuple); | ||
30 | |||
31 | /// <summary> | ||
20 | /// Called after all output changes occur and right before the output is bound into its final format. | 32 | /// Called after all output changes occur and right before the output is bound into its final format. |
21 | /// </summary> | 33 | /// </summary> |
22 | void BundleFinalize(); | 34 | void BundleFinalize(); |
diff --git a/src/WixToolset.Extensibility/Services/IBurnBackendHelper.cs b/src/WixToolset.Extensibility/Services/IBurnBackendHelper.cs new file mode 100644 index 00000000..f6ba7a8f --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IBurnBackendHelper.cs | |||
@@ -0,0 +1,50 @@ | |||
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.Services | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | |||
7 | /// <summary> | ||
8 | /// Interface provided to help Burn backend extensions. | ||
9 | /// </summary> | ||
10 | public interface IBurnBackendHelper | ||
11 | { | ||
12 | /// <summary> | ||
13 | /// Adds the given XML to the BootstrapperApplicationData manifest. | ||
14 | /// </summary> | ||
15 | /// <param name="xml">A valid XML fragment.</param> | ||
16 | void AddBootstrapperApplicationData(string xml); | ||
17 | |||
18 | /// <summary> | ||
19 | /// Adds an XML element for the given tuple to the BootstrapperApplicationData manifest. | ||
20 | /// The tuple's name is used for the element's name. | ||
21 | /// All of the tuple's fields are used for the element's attributes. | ||
22 | /// </summary> | ||
23 | /// <param name="tuple">The tuple to create the element from.</param> | ||
24 | /// <param name="tupleIdIsIdAttribute"> | ||
25 | /// If true and the tuple has an Id, | ||
26 | /// then an Id attribute is created with a value of the tuple's Id. | ||
27 | /// </param> | ||
28 | void AddBootstrapperApplicationData(IntermediateTuple tuple, bool tupleIdIsIdAttribute = false); | ||
29 | |||
30 | /// <summary> | ||
31 | /// Adds the given XML to the BundleExtensionData manifest for the given bundle extension. | ||
32 | /// </summary> | ||
33 | /// <param name="extensionId">The bundle extension's id.</param> | ||
34 | /// <param name="xml">A valid XML fragment.</param> | ||
35 | void AddBundleExtensionData(string extensionId, string xml); | ||
36 | |||
37 | /// <summary> | ||
38 | /// Adds an XML element for the given tuple to the BundleExtensionData manifest for the given bundle extension. | ||
39 | /// The tuple's name is used for the element's name. | ||
40 | /// All of the tuple's fields are used for the element's attributes. | ||
41 | /// </summary> | ||
42 | /// <param name="extensionId">The bundle extension's id.</param> | ||
43 | /// <param name="tuple">The tuple to create the element from.</param> | ||
44 | /// <param name="tupleIdIsIdAttribute"> | ||
45 | /// If true and the tuple has an Id, | ||
46 | /// then an Id attribute is created with a value of the tuple's Id. | ||
47 | /// </param> | ||
48 | void AddBundleExtensionData(string extensionId, IntermediateTuple tuple, bool tupleIdIsIdAttribute = false); | ||
49 | } | ||
50 | } | ||