main
cs 103 lines 3.89 KB
Raw
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 WixToolset.Data;
8 using WixToolset.Data.Symbols;
9 using WixToolset.Data.WindowsInstaller;
10 using WixToolset.Extensibility.Data;
11 using WixToolset.Extensibility.Services;
12
13 /// <summary>
14 /// Base class for creating a windows installer backend extension.
15 /// </summary>
16 public abstract class BaseWindowsInstallerBackendBinderExtension : IWindowsInstallerBackendBinderExtension
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 IWindowsInstallerBackendHelper BackendHelper { get; private set; }
32
33 /// <summary>
34 /// Optional table definitions.
35 /// </summary>
36 public virtual IReadOnlyCollection<TableDefinition> TableDefinitions => Array.Empty<TableDefinition>();
37
38 /// <summary>
39 /// Creates a resolved cabinet result.
40 /// </summary>
41 protected IResolvedCabinet CreateResolvedCabinet()
42 {
43 return this.Context.ServiceProvider.GetService<IResolvedCabinet>();
44 }
45
46 /// <summary>
47 /// See <see cref="IWindowsInstallerBackendBinderExtension.PreBackendBind(IBindContext)"/>
48 /// </summary>
49 public virtual void PreBackendBind(IBindContext context)
50 {
51 this.Context = context;
52
53 this.Messaging = context.ServiceProvider.GetService<IMessaging>();
54
55 this.BackendHelper = context.ServiceProvider.GetService<IWindowsInstallerBackendHelper>();
56 }
57
58 /// <summary>
59 /// See <see cref="IWindowsInstallerBackendBinderExtension.SymbolsFinalized(IntermediateSection)"/>
60 /// </summary>
61 public virtual void SymbolsFinalized(IntermediateSection section)
62 {
63 }
64
65 /// <summary>
66 /// See <see cref="IWindowsInstallerBackendBinderExtension.FinalizePatchFilterIds(WindowsInstallerData, IDictionary{Row, string}, string)"/>
67 /// </summary>
68 public virtual void FinalizePatchFilterIds(WindowsInstallerData data, IDictionary<Row, string> rowToFilterId, string filterIdPrefix)
69 {
70 }
71
72 /// <summary>
73 /// See <see cref="IWindowsInstallerBackendBinderExtension.PreBackendBind(IBindContext)"/>
74 /// </summary>
75 public virtual IResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<IBindFileWithPath> files)
76 {
77 return null;
78 }
79
80 /// <summary>
81 /// See <see cref="IWindowsInstallerBackendBinderExtension.PreBackendBind(IBindContext)"/>
82 /// </summary>
83 public virtual string ResolveMedia(MediaSymbol mediaRow, string mediaLayoutDirectory, string layoutDirectory)
84 {
85 return null;
86 }
87
88 /// <summary>
89 /// See <see cref="IWindowsInstallerBackendBinderExtension.TryProcessSymbol(IntermediateSection, IntermediateSymbol, WindowsInstallerData, TableDefinitionCollection)"/>
90 /// </summary>
91 public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinitionCollection tableDefinitions)
92 {
93 return false;
94 }
95
96 /// <summary>
97 /// See <see cref="IWindowsInstallerBackendBinderExtension.PreBackendBind(IBindContext)"/>
98 /// </summary>
99 public virtual void PostBackendBind(IBindResult result)
100 {
101 }
102 }
103 }