protected int?OptionalSrid(string attributeName, int defaultSrid) { int?nullable; XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName); if (optionalAttribute.IsMissing) { return(new int?(defaultSrid)); } else { if (!optionalAttribute.Value.EqualsOrdinalIgnoreCase("Variable")) { if (!EdmValueParser.TryParseInt(optionalAttribute.Value, out nullable)) { base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidSrid, Strings.ValueParser_InvalidSrid(optionalAttribute.Value)); } } else { nullable = null; } return(nullable); } }
public void TryParseIntThatOverFlowsShouldBeFalse() { int?result; Assert.True(EdmValueParser.TryParseInt("-2147483648", out result)); Assert.Equal(int.MinValue, result); Assert.False(EdmValueParser.TryParseInt("-2147483649", out result)); Assert.Null(result); }
public void TryParseIntThatOverFlowsShouldBeFalse() { int?result; EdmValueParser.TryParseInt("-2147483648", out result).Should().BeTrue(); result.Should().Be(int.MinValue); EdmValueParser.TryParseInt("-2147483649", out result).Should().BeFalse(); result.Should().NotHaveValue(); }
protected int?OptionalMaxLength(string attributeName) { XmlAttributeInfo attr = GetOptionalAttribute(this.currentElement, attributeName); if (!attr.IsMissing) { int?value; if (!EdmValueParser.TryParseInt(attr.Value, out value)) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidMaxLength, Edm.Strings.ValueParser_InvalidMaxLength(attr.Value)); } return(value); } return(null); }
protected int?OptionalMaxLength(string attributeName) { int?nullable; XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName); if (optionalAttribute.IsMissing) { int?nullable1 = null; return(nullable1); } else { if (!EdmValueParser.TryParseInt(optionalAttribute.Value, out nullable)) { base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidMaxLength, Strings.ValueParser_InvalidMaxLength(optionalAttribute.Value)); } return(nullable); } }
protected int?OptionalScale(string attributeName) { XmlAttributeInfo attr = GetOptionalAttribute(this.currentElement, attributeName); if (!attr.IsMissing) { int?scale; if (attr.Value.EqualsOrdinalIgnoreCase(CsdlConstants.Value_ScaleVariable)) { scale = null; } else { if (!EdmValueParser.TryParseInt(attr.Value, out scale)) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidSrid, Edm.Strings.ValueParser_InvalidScale(attr.Value)); } } return(scale); } return(CsdlConstants.Default_Scale); }
protected int?OptionalSrid(string attributeName, int defaultSrid) { XmlAttributeInfo attr = this.GetOptionalAttribute(this.currentElement, attributeName); if (!attr.IsMissing) { int?srid; if (attr.Value.EqualsOrdinalIgnoreCase(CsdlConstants.Value_SridVariable)) { srid = null; } else { if (!EdmValueParser.TryParseInt(attr.Value, out srid)) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidSrid, Strings.ValueParser_InvalidSrid(attr.Value)); } } return(srid); } return(defaultSrid); }