/// <summary> /// Checks whether a relative path is of URI-2 /// </summary> /// <param name="path">The relative path</param> /// <param name="meta">The metadata document</param> /// <returns>Returns true if it is a URI-2; false otherwise</returns> public static bool IsURI2(string path, XElement meta) { bool result = false; if (!string.IsNullOrEmpty(path)) { int posLP = path.IndexOf('('); if (posLP > 0) { int posRP = path.LastIndexOf(')'); if (posRP > posLP) { string esPath = path.Substring(0, posLP); string keyPredicat = path.Substring(posLP + 1, posRP - posLP - 1).Trim(); // check it is a real URI2 or not based on metadata document string xpath = string.Format("//*[local-name()='EntitySet' and @Name='{0}']", esPath); bool isEntitySet = meta.XPathSelectElement(xpath) != null; if (isEntitySet) { result = RegexInUri.IsKeyPredicate(keyPredicat); } } } } return(result); }
/// <summary> /// Checks whether the input string is a key predicate /// </summary> /// <param name="input">The input string</param> /// <returns>Returns true if input is of a key predicate; false otherwise</returns> public static bool IsKeyPredicate(string input) { return(RegexInUri.IsSingleKeyPredicate(input) || RegexInUri.IsComplexKeyPredicate(input)); }