protected string ValidateEnumMembersPath(string path) { if (string.IsNullOrEmpty(path.Trim())) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidEnumMemberPath, Edm.Strings.CsdlParser_InvalidEnumMemberPath(path)); } string[] enumValues = path.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray(); string enumType = null; foreach (var enumValue in enumValues) { string[] segments = enumValue.Split('/'); if (!(segments.Count() == 2 && EdmUtil.IsValidDottedName(segments[0]) && EdmUtil.IsValidUndottedName(segments[1]))) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidEnumMemberPath, Edm.Strings.CsdlParser_InvalidEnumMemberPath(path)); } if (enumType != null && segments[0] != enumType) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidEnumMemberPath, Edm.Strings.CsdlParser_InvalidEnumMemberPath(path)); } enumType = segments[0]; } return(string.Join(" ", enumValues)); }
private string ValidateAlias(string name) { if (!EdmUtil.IsValidUndottedName(name)) { base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidQualifiedName, Strings.CsdlParser_InvalidAlias(name)); } return(name); }
private string ValidateEnumMemberPath(string path) { string[] segments = path.Split('/'); if (!(segments.Count() == 2 && EdmUtil.IsValidDottedName(segments[0]) && EdmUtil.IsValidUndottedName(segments[1]))) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidEnumMemberPath, Edm.Strings.CsdlParser_InvalidEnumMemberPath(path)); } return(path); }
public void IsValidUndottedName_Test(string name, bool expected) { var actual = EdmUtil.IsValidUndottedName(name); Assert.Equal(expected, actual); }
private string ValidateEnumMemberPath(string path) { char[] chrArray = new char[1]; chrArray[0] = '/'; string[] strArrays = path.Split(chrArray); if (strArrays.Count <string>() != 2 || !EdmUtil.IsValidDottedName(strArrays[0]) || !EdmUtil.IsValidUndottedName(strArrays[1])) { base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidEnumMemberPath, Strings.CsdlParser_InvalidEnumMemberPath(path)); } return(path); }