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