diff options
Diffstat (limited to 'src/tools/heat/Harvester.cs')
-rw-r--r-- | src/tools/heat/Harvester.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/tools/heat/Harvester.cs b/src/tools/heat/Harvester.cs new file mode 100644 index 00000000..791c1cb2 --- /dev/null +++ b/src/tools/heat/Harvester.cs | |||
@@ -0,0 +1,65 @@ | |||
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.Harvesters | ||
4 | { | ||
5 | using System; | ||
6 | using WixToolset.Data; | ||
7 | using WixToolset.Harvesters.Extensibility; | ||
8 | using Wix = WixToolset.Harvesters.Serialize; | ||
9 | |||
10 | /// <summary> | ||
11 | /// The WiX Toolset harvester. | ||
12 | /// </summary> | ||
13 | internal class Harvester : IHarvester | ||
14 | { | ||
15 | private IHarvesterExtension harvesterExtension; | ||
16 | |||
17 | public IHarvesterCore Core { get; set; } | ||
18 | |||
19 | public IHarvesterExtension Extension | ||
20 | { | ||
21 | get | ||
22 | { | ||
23 | return this.harvesterExtension; | ||
24 | } | ||
25 | set | ||
26 | { | ||
27 | if (null != this.harvesterExtension) | ||
28 | { | ||
29 | throw new InvalidOperationException("Multiple harvester extensions specified."); | ||
30 | } | ||
31 | |||
32 | this.harvesterExtension = value; | ||
33 | } | ||
34 | } | ||
35 | |||
36 | public Wix.Wix Harvest(string argument) | ||
37 | { | ||
38 | if (null == argument) | ||
39 | { | ||
40 | throw new ArgumentNullException("argument"); | ||
41 | } | ||
42 | |||
43 | if (null == this.harvesterExtension) | ||
44 | { | ||
45 | throw new WixException(ErrorMessages.HarvestTypeNotFound()); | ||
46 | } | ||
47 | |||
48 | this.harvesterExtension.Core = this.Core; | ||
49 | |||
50 | Wix.Fragment[] fragments = this.harvesterExtension.Harvest(argument); | ||
51 | if (null == fragments || 0 == fragments.Length) | ||
52 | { | ||
53 | return null; | ||
54 | } | ||
55 | |||
56 | Wix.Wix wix = new Wix.Wix(); | ||
57 | foreach (Wix.Fragment fragment in fragments) | ||
58 | { | ||
59 | wix.AddChild(fragment); | ||
60 | } | ||
61 | |||
62 | return wix; | ||
63 | } | ||
64 | } | ||
65 | } | ||