public static string[] SplitAtFirstProperty(string path) { if (string.IsNullOrEmpty(path)) { return new string[2] { string.Empty, string.Empty } } ; string pathPart1 = path; string str = string.Empty; int index = path.IndexOfAny(ClrPropertyPathHelper.pathPartSeparators, 1); if (index > 0) { pathPart1 = path.Substring(0, index); if ((int)path[index] == 46) { if (index == path.Length - 1) { return((string[])null); } ++index; } str = path.Substring(index); } ClrPathPart pathPart2 = ClrPropertyPathHelper.GetPathPart(pathPart1); if (pathPart2 == null || pathPart2.Category != ClrPathPartCategory.PropertyName) { return((string[])null); } return(new string[2] { pathPart1, str }); }
public static IList <ClrPathPart> SplitPath(string path) { if (string.IsNullOrEmpty(path)) { return((IList <ClrPathPart>) new List <ClrPathPart>()); } if ((int)path[0] == 46 || (int)path[path.Length - 1] == 46) { return((IList <ClrPathPart>)null); } List <ClrPathPart> list = new List <ClrPathPart>(); int startIndex = 0; for (int index = path.IndexOfAny(ClrPropertyPathHelper.pathPartSeparators, 1); index > 0; index = path.IndexOfAny(ClrPropertyPathHelper.pathPartSeparators, index + 1)) { ClrPathPart pathPart = ClrPropertyPathHelper.GetPathPart(path.Substring(startIndex, index - startIndex)); if (pathPart == null) { return((IList <ClrPathPart>)null); } list.Add(pathPart); if ((int)path[index] == 47) { list.Add(ClrPathPart.CurrentItem); startIndex = index + 1; } else { startIndex = (int)path[index] != 46 ? index : index + 1; } } ClrPathPart pathPart1 = ClrPropertyPathHelper.GetPathPart(path.Substring(startIndex)); if (pathPart1 == null) { return((IList <ClrPathPart>)null); } list.Add(pathPart1); return((IList <ClrPathPart>)list); }