| 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.Converters |
| 4 | { |
| 5 | using System; |
| 6 | using System.Collections.Generic; |
| 7 | using System.Linq; |
| 8 | using System.Xml; |
| 9 | using System.Xml.Linq; |
| 10 | using WixToolset.Data; |
| 11 | |
| 12 | internal enum ConvertOperation |
| 13 | { |
| 14 | Convert, |
| 15 | Format, |
| 16 | } |
| 17 | |
| 18 | |
| 19 | internal class ConversionState |
| 20 | { |
| 21 | public ConversionState(ConvertOperation operation, string sourceFile) |
| 22 | { |
| 23 | this.ConversionMessages = new List<Message>(); |
| 24 | this.ChainPackageElementsById = new Dictionary<string, List<XElement>>(); |
| 25 | this.WixMbaPrereqPackageIdElements = new List<XElement>(); |
| 26 | this.WixMbaPrereqLicenseUrlElements = new List<XElement>(); |
| 27 | this.Operation = operation; |
| 28 | this.SourceFile = sourceFile; |
| 29 | this.SourceVersion = 0; |
| 30 | } |
| 31 | |
| 32 | public List<Message> ConversionMessages { get; } |
| 33 | |
| 34 | public Dictionary<string, List<XElement>> ChainPackageElementsById { get; } |
| 35 | |
| 36 | public List<XElement> WixMbaPrereqPackageIdElements { get; } |
| 37 | |
| 38 | public List<XElement> WixMbaPrereqLicenseUrlElements { get; } |
| 39 | |
| 40 | public ConvertOperation Operation { get; } |
| 41 | |
| 42 | public string SourceFile { get; } |
| 43 | |
| 44 | public int SourceVersion { get; set; } |
| 45 | |
| 46 | public XDocument XDocument { get; set; } |
| 47 | |
| 48 | public void Initialize() |
| 49 | { |
| 50 | this.XDocument = XDocument.Load(this.SourceFile, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
| 51 | } |
| 52 | |
| 53 | public void Initialize(XDocument document) |
| 54 | { |
| 55 | this.XDocument = document; |
| 56 | } |
| 57 | } |
| 58 | } |