diff options
Diffstat (limited to 'src/WixToolset.Data/BindPath.cs')
| -rw-r--r-- | src/WixToolset.Data/BindPath.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/WixToolset.Data/BindPath.cs b/src/WixToolset.Data/BindPath.cs new file mode 100644 index 00000000..823a57c9 --- /dev/null +++ b/src/WixToolset.Data/BindPath.cs | |||
| @@ -0,0 +1,60 @@ | |||
| 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.Data | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using WixToolset.Data.Bind; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Bind path representation. | ||
| 10 | /// </summary> | ||
| 11 | public class BindPath | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Creates an unnamed bind path. | ||
| 15 | /// </summary> | ||
| 16 | /// <param name="path">Path for the bind path.</param> | ||
| 17 | public BindPath(string path) : this(String.Empty, path, BindStage.Normal) | ||
| 18 | { | ||
| 19 | } | ||
| 20 | |||
| 21 | /// <summary> | ||
| 22 | /// Creates a named bind path. | ||
| 23 | /// </summary> | ||
| 24 | /// <param name="name">Name of the bind path.</param> | ||
| 25 | /// <param name="path">Path for the bind path.</param> | ||
| 26 | /// <param name="stage">Stage for the bind path.</param> | ||
| 27 | public BindPath(string name, string path, BindStage stage = BindStage.Normal) | ||
| 28 | { | ||
| 29 | this.Name = name; | ||
| 30 | this.Path = path; | ||
| 31 | this.Stage = stage; | ||
| 32 | } | ||
| 33 | |||
| 34 | /// <summary> | ||
| 35 | /// Name of the bind path or String.Empty if the path is unnamed. | ||
| 36 | /// </summary> | ||
| 37 | public string Name { get; set; } | ||
| 38 | |||
| 39 | /// <summary> | ||
| 40 | /// Path for the bind path. | ||
| 41 | /// </summary> | ||
| 42 | public string Path { get; set; } | ||
| 43 | |||
| 44 | /// <summary> | ||
| 45 | /// Stage for the bind path. | ||
| 46 | /// </summary> | ||
| 47 | public BindStage Stage { get; set; } | ||
| 48 | |||
| 49 | /// <summary> | ||
| 50 | /// Parses a normal bind path from its string representation | ||
| 51 | /// </summary> | ||
| 52 | /// <param name="bindPath">String representation of bind path that looks like: [name=]path</param> | ||
| 53 | /// <returns>Parsed normal bind path.</returns> | ||
| 54 | public static BindPath Parse(string bindPath) | ||
| 55 | { | ||
| 56 | string[] namedPath = bindPath.Split(new char[] { '=' }, 2); | ||
| 57 | return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
