// 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. namespace WixToolset.Core { using System; using System.Diagnostics.CodeAnalysis; using WixToolset.Data; using Wix = WixToolset.Data.Serialize; /// /// The WiX Toolset harvester. /// public class Harvester { private HarvesterExtension harvesterExtension; /// /// Gets or sets the harvester core for the extension. /// /// The harvester core for the extension. public IHarvesterCore Core { get; set; } /// /// Gets or sets the extension. /// /// The extension. [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")] public HarvesterExtension Extension { get { return this.harvesterExtension; } set { if (null != this.harvesterExtension) { throw new InvalidOperationException(WixStrings.EXP_MultipleHarvesterExtensionsSpecified); } this.harvesterExtension = value; } } /// /// Harvest wix authoring. /// /// The argument for harvesting. /// The harvested wix authoring. public Wix.Wix Harvest(string argument) { if (null == argument) { throw new ArgumentNullException("argument"); } if (null == this.harvesterExtension) { throw new WixException(ErrorMessages.HarvestTypeNotFound()); } this.harvesterExtension.Core = this.Core; Wix.Fragment[] fragments = this.harvesterExtension.Harvest(argument); if (null == fragments || 0 == fragments.Length) { return null; } Wix.Wix wix = new Wix.Wix(); foreach (Wix.Fragment fragment in fragments) { wix.AddChild(fragment); } return wix; } } }