private static bool TryAssertStringConstantAsType(IEdmStringConstantExpression expression, IEdmTypeReference type, out IEnumerable <EdmError> discoveredErrors) { if (type.IsString()) { IEdmStringTypeReference edmStringTypeReference = type.AsString(); int?maxLength = edmStringTypeReference.MaxLength; if (maxLength.HasValue) { int?nullable = edmStringTypeReference.MaxLength; if (expression.Value.Length > nullable.Value) { EdmError[] edmError = new EdmError[1]; int? maxLength1 = edmStringTypeReference.MaxLength; edmError[0] = new EdmError(expression.Location(), EdmErrorCode.StringConstantLengthOutOfRange, Strings.EdmModel_Validator_Semantic_StringConstantLengthOutOfRange(expression.Value.Length, maxLength1.Value)); discoveredErrors = edmError; return(false); } } discoveredErrors = Enumerable.Empty <EdmError>(); return(true); } else { EdmError[] edmErrorArray = new EdmError[1]; edmErrorArray[0] = new EdmError(expression.Location(), EdmErrorCode.ExpressionPrimitiveKindNotValidForAssertedType, Strings.EdmModel_Validator_Semantic_ExpressionPrimitiveKindNotValidForAssertedType); discoveredErrors = edmErrorArray; return(false); } }
private static bool TryAssertStringConstantAsType(IEdmStringConstantExpression expression, IEdmTypeReference type, out IEnumerable <EdmError> discoveredErrors) { if (!type.IsString()) { discoveredErrors = new EdmError[] { new EdmError(expression.Location(), EdmErrorCode.ExpressionPrimitiveKindNotValidForAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionPrimitiveKindNotValidForAssertedType) }; return(false); } IEdmStringTypeReference stringType = type.AsString(); if (stringType.MaxLength.HasValue && expression.Value.Length > stringType.MaxLength.Value) { discoveredErrors = new EdmError[] { new EdmError(expression.Location(), EdmErrorCode.StringConstantLengthOutOfRange, Edm.Strings.EdmModel_Validator_Semantic_StringConstantLengthOutOfRange(expression.Value.Length, stringType.MaxLength.Value)) }; return(false); } discoveredErrors = Enumerable.Empty <EdmError>(); return(true); }
private static bool TryCastStringConstantAsType(IEdmStringConstantExpression expression, IEdmTypeReference type, out IEnumerable<EdmError> discoveredErrors) { if (!type.IsString()) { discoveredErrors = new EdmError[] { new EdmError(expression.Location(), EdmErrorCode.ExpressionPrimitiveKindNotValidForAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionPrimitiveKindNotValidForAssertedType) }; return false; } IEdmStringTypeReference stringType = type.AsString(); if (stringType.MaxLength.HasValue && expression.Value.Length > stringType.MaxLength.Value) { discoveredErrors = new EdmError[] { new EdmError(expression.Location(), EdmErrorCode.StringConstantLengthOutOfRange, Edm.Strings.EdmModel_Validator_Semantic_StringConstantLengthOutOfRange(expression.Value.Length, stringType.MaxLength.Value)) }; return false; } discoveredErrors = Enumerable.Empty<EdmError>(); return true; }
private static bool TryAssertStringConstantAsType(IEdmStringConstantExpression expression, IEdmTypeReference type, out IEnumerable<EdmError> discoveredErrors) { if (type.IsString()) { IEdmStringTypeReference edmStringTypeReference = type.AsString(); int? maxLength = edmStringTypeReference.MaxLength; if (maxLength.HasValue) { int? nullable = edmStringTypeReference.MaxLength; if (expression.Value.Length > nullable.Value) { EdmError[] edmError = new EdmError[1]; int? maxLength1 = edmStringTypeReference.MaxLength; edmError[0] = new EdmError(expression.Location(), EdmErrorCode.StringConstantLengthOutOfRange, Strings.EdmModel_Validator_Semantic_StringConstantLengthOutOfRange(expression.Value.Length, maxLength1.Value)); discoveredErrors = edmError; return false; } } discoveredErrors = Enumerable.Empty<EdmError>(); return true; } else { EdmError[] edmErrorArray = new EdmError[1]; edmErrorArray[0] = new EdmError(expression.Location(), EdmErrorCode.ExpressionPrimitiveKindNotValidForAssertedType, Strings.EdmModel_Validator_Semantic_ExpressionPrimitiveKindNotValidForAssertedType); discoveredErrors = edmErrorArray; return false; } }