main
cs 59 lines 2.1 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 WixToolset.Data;
6 using WixToolset.Extensibility.Data;
7 using WixToolset.Extensibility.Services;
8
9 /// <summary>
10 /// Base class for creating a resolver extension.
11 /// </summary>
12 public abstract class BaseResolverExtension : IResolverExtension
13 {
14 /// <summary>
15 /// Context for use by the extension.
16 /// </summary>
17 protected IResolveContext Context { get; private set; }
18
19 /// <summary>
20 /// Messaging for use by the extension.
21 /// </summary>
22 protected IMessaging Messaging { get; private set; }
23
24 /// <summary>
25 /// Creates a resolve file result.
26 /// </summary>
27 protected IResolveFileResult CreateResolveFileResult() => this.Context.ServiceProvider.GetService<IResolveFileResult>();
28
29 /// <summary>
30 /// Called at the beginning of the resolving variables and files.
31 /// </summary>
32 public virtual void PreResolve(IResolveContext context)
33 {
34 this.Context = context;
35
36 this.Messaging = context.ServiceProvider.GetService<IMessaging>();
37 }
38
39 /// <summary>
40 /// See <see cref="IResolverExtension.ResolveFile(string, IntermediateSymbolDefinition, SourceLineNumber, BindStage)"/>
41 /// </summary>
42 /// <param name="source"></param>
43 /// <param name="symbolDefinition"></param>
44 /// <param name="sourceLineNumbers"></param>
45 /// <param name="bindStage"></param>
46 /// <returns></returns>
47 public virtual IResolveFileResult ResolveFile(string source, IntermediateSymbolDefinition symbolDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage)
48 {
49 return null;
50 }
51
52 /// <summary>
53 /// Called at the end of resolve.
54 /// </summary>
55 public virtual void PostResolve(IResolveResult result)
56 {
57 }
58 }
59 }