// 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.Extensibility.Data
{
using System;
///
/// Bind path representation.
///
public class BindPath
{
///
/// Creates an unnamed bind path.
///
/// Path for the bind path.
public BindPath(string path) : this(String.Empty, path, BindStage.Normal)
{
}
///
/// Creates a named bind path.
///
/// Name of the bind path.
/// Path for the bind path.
/// Stage for the bind path.
public BindPath(string name, string path, BindStage stage = BindStage.Normal)
{
this.Name = name;
this.Path = path;
this.Stage = stage;
}
///
/// Name of the bind path or String.Empty if the path is unnamed.
///
public string Name { get; set; }
///
/// Path for the bind path.
///
public string Path { get; set; }
///
/// Stage for the bind path.
///
public BindStage Stage { get; set; }
///
/// Parses a normal bind path from its string representation
///
/// String representation of bind path that looks like: [name=]path
/// Parsed normal bind path.
public static BindPath Parse(string bindPath)
{
string[] namedPath = bindPath.Split(new char[] { '=' }, 2);
return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]);
}
}
}