aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Linker.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Linker.cs')
-rw-r--r--src/WixToolset.Core/Linker.cs36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs
index 93f50efa..79ddd30a 100644
--- a/src/WixToolset.Core/Linker.cs
+++ b/src/WixToolset.Core/Linker.cs
@@ -12,6 +12,7 @@ namespace WixToolset.Core
12 using WixToolset.Data; 12 using WixToolset.Data;
13 using WixToolset.Data.Tuples; 13 using WixToolset.Data.Tuples;
14 using WixToolset.Extensibility; 14 using WixToolset.Extensibility;
15 using WixToolset.Extensibility.Services;
15 using WixToolset.Link; 16 using WixToolset.Link;
16 17
17 /// <summary> 18 /// <summary>
@@ -27,14 +28,17 @@ namespace WixToolset.Core
27 /// <summary> 28 /// <summary>
28 /// Creates a linker. 29 /// Creates a linker.
29 /// </summary> 30 /// </summary>
30 public Linker() 31 public Linker(IServiceProvider serviceProvider)
31 { 32 {
33 this.ServiceProvider = serviceProvider;
32 this.sectionIdOnRows = true; // TODO: what is the correct value for this? 34 this.sectionIdOnRows = true; // TODO: what is the correct value for this?
33 35
34 //this.extensionData = new List<IExtensionData>(); 36 //this.extensionData = new List<IExtensionData>();
35 //this.inspectorExtensions = new List<InspectorExtension>(); 37 //this.inspectorExtensions = new List<InspectorExtension>();
36 } 38 }
37 39
40 private IServiceProvider ServiceProvider { get; }
41
38 private ILinkContext Context { get; set; } 42 private ILinkContext Context { get; set; }
39 43
40 /// <summary> 44 /// <summary>
@@ -49,11 +53,13 @@ namespace WixToolset.Core
49 /// <value>The option to show pedantic messages.</value> 53 /// <value>The option to show pedantic messages.</value>
50 public bool ShowPedanticMessages { get; set; } 54 public bool ShowPedanticMessages { get; set; }
51 55
52 /// <summary> 56 public OutputType OutputType { get; set; }
53 /// Gets or sets the Wix variable resolver. 57
54 /// </summary> 58 public IEnumerable<Intermediate> Intermediates { get; set; }
55 /// <value>The Wix variable resolver.</value> 59
56 //internal IBindVariableResolver WixVariableResolver { get; set; } 60 public IEnumerable<Intermediate> Libraries { get; set; }
61
62 public ITupleDefinitionCreator TupleDefinitionCreator { get; set; }
57 63
58 /// <summary> 64 /// <summary>
59 /// Links a collection of sections into an output. 65 /// Links a collection of sections into an output.
@@ -61,16 +67,26 @@ namespace WixToolset.Core
61 /// <param name="inputs">The collection of sections to link together.</param> 67 /// <param name="inputs">The collection of sections to link together.</param>
62 /// <param name="expectedOutputType">Expected output type, based on output file extension provided to the linker.</param> 68 /// <param name="expectedOutputType">Expected output type, based on output file extension provided to the linker.</param>
63 /// <returns>Output object from the linking.</returns> 69 /// <returns>Output object from the linking.</returns>
64 public Intermediate Link(ILinkContext context) 70 public Intermediate Execute()
65 { 71 {
66 this.Context = context ?? throw new ArgumentNullException(nameof(context)); 72 var extensionManager = this.ServiceProvider.GetService<IExtensionManager>();
73
74 var creator = this.TupleDefinitionCreator ?? this.ServiceProvider.GetService<ITupleDefinitionCreator>();
75
76 this.Context = this.ServiceProvider.GetService<ILinkContext>();
77 this.Context.Messaging = this.ServiceProvider.GetService<IMessaging>();
78 this.Context.Extensions = extensionManager.Create<ILinkerExtension>();
79 this.Context.ExtensionData = extensionManager.Create<IExtensionData>();
80 this.Context.ExpectedOutputType = this.OutputType;
81 this.Context.Intermediates = this.Intermediates.Union(this.Libraries).ToList();
82 this.Context.TupleDefinitionCreator = creator;
67 83
68 var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList(); 84 var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList();
69 85
70 // Add sections from the extensions with data. 86 // Add sections from the extensions with data.
71 foreach (var data in context.ExtensionData) 87 foreach (var data in this.Context.ExtensionData)
72 { 88 {
73 var library = data.GetLibrary(context.TupleDefinitionCreator); 89 var library = data.GetLibrary(this.Context.TupleDefinitionCreator);
74 90
75 if (library != null) 91 if (library != null)
76 { 92 {