コード例 #1
0
        /// <summary>
        /// Parses a HierarchyPath instance from its string representation.
        /// Type of the path items is specified by the type parameter.
        /// </summary>
        /// <typeparam name="T">type of the path items after conversion</typeparam>
        /// <param name="path">string representation to parse</param>
        /// <param name="convertPathItem">conversion delegate applied to a single parsed path item</param>
        /// <param name="separator">seperator character between the path items in the string representation</param>
        /// <returns></returns>
        public static HierarchyPath <T> Parse <T>(string path, Func <string, T> convertPathItem, string separator = null)
        {
            string separatorSafe = separator ?? "\\";

            return(HierarchyPath.Create <T>(path.Split(separatorSafe.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(p => convertPathItem(p))));
        }
コード例 #2
0
 /// <summary>
 /// Parses a HierarchyPath instance from its string representation. Type of the path items is a string by default.
 /// </summary>
 /// <param name="path">string representation of the HierarchyPath</param>
 /// <param name="separator">Separator betweeen the path items in the string representation</param>
 /// <returns></returns>
 public static HierarchyPath <string> Parse(string path, string separator)
 {
     return(HierarchyPath.Create(path.Split(separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)));
 }