diff options
Diffstat (limited to 'src/WixToolset.Core/BinderFileManagerCore.cs')
| -rw-r--r-- | src/WixToolset.Core/BinderFileManagerCore.cs | 108 |
1 files changed, 108 insertions, 0 deletions
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 @@ | |||
| 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 | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Linq; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Extensibility; | ||
| 10 | |||
| 11 | public class BinderFileManagerCore : IBinderFileManagerCore | ||
| 12 | { | ||
| 13 | private Dictionary<string, List<string>>[] bindPaths; | ||
| 14 | |||
| 15 | /// <summary> | ||
| 16 | /// Instantiate a new BinderFileManager. | ||
| 17 | /// </summary> | ||
| 18 | public BinderFileManagerCore() | ||
| 19 | { | ||
| 20 | this.bindPaths = new Dictionary<string, List<string>>[3]; | ||
| 21 | this.bindPaths[(int)BindStage.Normal] = new Dictionary<string, List<string>>(); | ||
| 22 | this.bindPaths[(int)BindStage.Target] = new Dictionary<string, List<string>>(); | ||
| 23 | this.bindPaths[(int)BindStage.Updated] = new Dictionary<string, List<string>>(); | ||
| 24 | } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Gets or sets the path to cabinet cache. | ||
| 28 | /// </summary> | ||
| 29 | /// <value>The path to cabinet cache.</value> | ||
| 30 | public string CabCachePath { get; set; } | ||
| 31 | |||
| 32 | /// <summary> | ||
| 33 | /// Gets or sets the active subStorage used for binding. | ||
| 34 | /// </summary> | ||
| 35 | /// <value>The subStorage object.</value> | ||
| 36 | public SubStorage ActiveSubStorage { get; set; } | ||
| 37 | |||
| 38 | /// <summary> | ||
| 39 | /// Gets or sets the output object used for binding. | ||
| 40 | /// </summary> | ||
| 41 | /// <value>The output object.</value> | ||
| 42 | public Output Output { get; set; } | ||
| 43 | |||
| 44 | /// <summary> | ||
| 45 | /// Gets or sets the path to the temp files location. | ||
| 46 | /// </summary> | ||
| 47 | /// <value>The path to the temp files location.</value> | ||
| 48 | public string TempFilesLocation { get; set; } | ||
| 49 | |||
| 50 | /// <summary> | ||
| 51 | /// Gets the property if re-basing target is true or false | ||
| 52 | /// </summary> | ||
| 53 | /// <value>It returns true if target bind path is to be replaced, otherwise false.</value> | ||
| 54 | public bool RebaseTarget | ||
| 55 | { | ||
| 56 | get { return this.bindPaths[(int)BindStage.Target].Any(); } | ||
| 57 | } | ||
| 58 | |||
| 59 | /// <summary> | ||
| 60 | /// Gets the property if re-basing updated build is true or false | ||
| 61 | /// </summary> | ||
| 62 | /// <value>It returns true if updated bind path is to be replaced, otherwise false.</value> | ||
| 63 | public bool RebaseUpdated | ||
| 64 | { | ||
| 65 | get { return this.bindPaths[(int)BindStage.Updated].Any(); } | ||
| 66 | } | ||
| 67 | |||
| 68 | public void AddBindPaths(IEnumerable<BindPath> paths, BindStage stage) | ||
| 69 | { | ||
| 70 | Dictionary<string, List<string>> dict = this.bindPaths[(int)stage]; | ||
| 71 | |||
| 72 | foreach (BindPath bindPath in paths) | ||
| 73 | { | ||
| 74 | List<string> values; | ||
| 75 | if (!dict.TryGetValue(bindPath.Name, out values)) | ||
| 76 | { | ||
| 77 | values = new List<string>(); | ||
| 78 | dict.Add(bindPath.Name, values); | ||
| 79 | } | ||
| 80 | |||
| 81 | if (!values.Contains(bindPath.Path)) | ||
| 82 | { | ||
| 83 | values.Add(bindPath.Path); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | public IEnumerable<string> GetBindPaths(BindStage stage = BindStage.Normal, string name = null) | ||
| 89 | { | ||
| 90 | List<string> paths; | ||
| 91 | if (this.bindPaths[(int)stage].TryGetValue(name ?? String.Empty, out paths)) | ||
| 92 | { | ||
| 93 | return paths; | ||
| 94 | } | ||
| 95 | |||
| 96 | return Enumerable.Empty<string>(); | ||
| 97 | } | ||
| 98 | |||
| 99 | /// <summary> | ||
| 100 | /// Sends a message to the message delegate if there is one. | ||
| 101 | /// </summary> | ||
| 102 | /// <param name="e">Message event arguments.</param> | ||
| 103 | public void OnMessage(MessageEventArgs e) | ||
| 104 | { | ||
| 105 | Messaging.Instance.OnMessage(e); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | } | ||
