From d3d3649a68cb1fa589fdd987a6690dbd5d671f0d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 17 Sep 2017 15:35:20 -0700 Subject: Initial code commit --- src/WixToolset.Core/BinderFileManagerCore.cs | 108 +++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/WixToolset.Core/BinderFileManagerCore.cs (limited to 'src/WixToolset.Core/BinderFileManagerCore.cs') diff --git a/src/WixToolset.Core/BinderFileManagerCore.cs b/src/WixToolset.Core/BinderFileManagerCore.cs new file mode 100644 index 00000000..6a5e1d5e --- /dev/null +++ b/src/WixToolset.Core/BinderFileManagerCore.cs @@ -0,0 +1,108 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + + public class BinderFileManagerCore : IBinderFileManagerCore + { + private Dictionary>[] bindPaths; + + /// + /// Instantiate a new BinderFileManager. + /// + public BinderFileManagerCore() + { + this.bindPaths = new Dictionary>[3]; + this.bindPaths[(int)BindStage.Normal] = new Dictionary>(); + this.bindPaths[(int)BindStage.Target] = new Dictionary>(); + this.bindPaths[(int)BindStage.Updated] = new Dictionary>(); + } + + /// + /// Gets or sets the path to cabinet cache. + /// + /// The path to cabinet cache. + public string CabCachePath { get; set; } + + /// + /// Gets or sets the active subStorage used for binding. + /// + /// The subStorage object. + public SubStorage ActiveSubStorage { get; set; } + + /// + /// Gets or sets the output object used for binding. + /// + /// The output object. + public Output Output { get; set; } + + /// + /// Gets or sets the path to the temp files location. + /// + /// The path to the temp files location. + public string TempFilesLocation { get; set; } + + /// + /// Gets the property if re-basing target is true or false + /// + /// It returns true if target bind path is to be replaced, otherwise false. + public bool RebaseTarget + { + get { return this.bindPaths[(int)BindStage.Target].Any(); } + } + + /// + /// Gets the property if re-basing updated build is true or false + /// + /// It returns true if updated bind path is to be replaced, otherwise false. + public bool RebaseUpdated + { + get { return this.bindPaths[(int)BindStage.Updated].Any(); } + } + + public void AddBindPaths(IEnumerable paths, BindStage stage) + { + Dictionary> dict = this.bindPaths[(int)stage]; + + foreach (BindPath bindPath in paths) + { + List values; + if (!dict.TryGetValue(bindPath.Name, out values)) + { + values = new List(); + dict.Add(bindPath.Name, values); + } + + if (!values.Contains(bindPath.Path)) + { + values.Add(bindPath.Path); + } + } + } + + public IEnumerable GetBindPaths(BindStage stage = BindStage.Normal, string name = null) + { + List paths; + if (this.bindPaths[(int)stage].TryGetValue(name ?? String.Empty, out paths)) + { + return paths; + } + + return Enumerable.Empty(); + } + + /// + /// Sends a message to the message delegate if there is one. + /// + /// Message event arguments. + public void OnMessage(MessageEventArgs e) + { + Messaging.Instance.OnMessage(e); + } + } +} -- cgit v1.2.3-55-g6feb