Add the missing BaseLibrarianExtension
Rob Mensching committed
May 12, 2019 at 23:05 UTC
65b36792f09658a85401cd50a0efaee0fee698d9
1 file changed
+71
src/WixToolset.Extensibility/BaseLibrarianExtension.cs
new
+71
@@ -0,0 +1,71 @@
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.Collections.Generic;
6
+ using WixToolset.Data;
7
+ using WixToolset.Extensibility.Data;
8
+ using WixToolset.Extensibility.Services;
9
+
10
+ /// <summary>
11
+ /// Base class for creating a librarian extension.
12
+ /// </summary>
13
+ public abstract class BaseLibrarianExtension : ILibrarianExtension
14
+ {
15
+ /// <summary>
16
+ /// Context for use by the extension.
17
+ /// </summary>
18
+ protected ILibraryContext Context { get; private set; }
19
+
20
+ /// <summary>
21
+ /// Messaging for use by the extension.
22
+ /// </summary>
23
+ protected IMessaging Messaging { get; private set; }
24
+
25
+ /// <summary>
26
+ /// Called at the beginning of combining.
27
+ /// </summary>
28
+ /// <param name="context">Librarian context.</param>
29
+ public virtual void PreCombine(ILibraryContext context)
30
+ {
31
+ this.Context = context;
32
+
33
+ this.Messaging = context.ServiceProvider.GetService<IMessaging>();
34
+ }
35
+
36
+ /// <summary>
37
+ /// Resolves a path to a file path on disk.
38
+ /// </summary>
39
+ /// <param name="sourceLineNumber">Source line number for the path to resolve.</param>
40
+ /// <param name="tupleDefinition">Tuple related to the path to resolve.</param>
41
+ /// <param name="path">Path to resolve.</param>
42
+ /// <returns>Optional resolved file result.</returns>
43
+ public virtual IResolveFileResult ResolveFile(SourceLineNumber sourceLineNumber, IntermediateTupleDefinition tupleDefinition, string path)
44
+ {
45
+ return null;
46
+ }
47
+
48
+ /// <summary>
49
+ /// Called at the end of combining.
50
+ /// </summary>
51
+ /// <param name="library">Combined library intermediate.</param>
52
+ public virtual void PostCombine(Intermediate library)
53
+ {
54
+ }
55
+
56
+ /// <summary>
57
+ /// Creates an IResolveFileResult.
58
+ /// </summary>
59
+ /// <param name="path">Optional resolved path to file.</param>
60
+ /// <param name="checkedPaths">Optional collection of paths checked for the file.</param>
61
+ /// <returns>Resolved file result.</returns>
62
+ protected IResolveFileResult CreateResolveFileResult(string path = null, IEnumerable<string> checkedPaths = null)
63
+ {
64
+ var result = this.Context.ServiceProvider.GetService<IResolveFileResult>();
65
+ result.Path = path;
66
+ result.CheckedPaths = checkedPaths;
67
+
68
+ return result;
69
+ }
70
+ }
71
+}