本文整理汇总了C#中IEdmPrimitiveTypeReference.IsDecimal方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmPrimitiveTypeReference.IsDecimal方法的具体用法?C# IEdmPrimitiveTypeReference.IsDecimal怎么用?C# IEdmPrimitiveTypeReference.IsDecimal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmPrimitiveTypeReference
的用法示例。
在下文中一共展示了IEdmPrimitiveTypeReference.IsDecimal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPrimitiveValue
/// <summary>
/// Reads a primitive value.
/// </summary>
/// <param name="insideJsonObjectValue">true if the reader is positioned on the first property of the value which is a JSON Object
/// (or the second property if the first one was odata.type).</param>
/// <param name="expectedValueTypeReference">The expected type reference of the value, or null if none is available.</param>
/// <param name="validateNullValue">true to validate null values; otherwise false.</param>
/// <param name="propertyName">The name of the property whose value is being read, if applicable (used for error reporting).</param>
/// <returns>The value of the primitive value.</returns>
/// <remarks>
/// Pre-Condition: insideJsonObjectValue == false -> none - Fails if the current node is not a JsonNodeType.PrimitiveValue
/// insideJsonObjectValue == true -> JsonNodeType.Property or JsonNodeType.EndObject - the first property of the value object,
/// or the second property if first was odata.type, or the end-object.
/// Post-Condition: almost anything - the node after the primitive value.
/// </remarks>
private object ReadPrimitiveValue(bool insideJsonObjectValue, IEdmPrimitiveTypeReference expectedValueTypeReference, bool validateNullValue, string propertyName)
{
object result;
if (expectedValueTypeReference != null && expectedValueTypeReference.IsSpatial())
{
result = ODataJsonReaderCoreUtils.ReadSpatialValue(
this.JsonReader,
insideJsonObjectValue,
this.JsonLightInputContext,
expectedValueTypeReference,
validateNullValue,
this.recursionDepth,
propertyName);
}
else
{
if (insideJsonObjectValue)
{
// We manually throw JSON exception here to get a nicer error message (we expect primitive value and got object).
// Otherwise the ReadPrimitiveValue would fail with something like "expected primitive value but found property/end object" which is rather confusing.
throw new ODataException(ODataErrorStrings.JsonReaderExtensions_UnexpectedNodeDetectedWithPropertyName(JsonNodeType.PrimitiveValue, JsonNodeType.StartObject, propertyName));
}
result = this.JsonReader.ReadPrimitiveValue();
if (expectedValueTypeReference != null)
{
if ((expectedValueTypeReference.IsDecimal() || expectedValueTypeReference.IsInt64())
&& result != null)
{
if ((result is string) ^ this.JsonReader.IsIeee754Compatible)
{
throw new ODataException(ODataErrorStrings.ODataJsonReaderUtils_ConflictBetweenInputFormatAndParameter(expectedValueTypeReference.FullName()));
}
}
result = ODataJsonLightReaderUtils.ConvertValue(
result,
expectedValueTypeReference,
this.MessageReaderSettings,
validateNullValue,
propertyName,
this.Model.GetPayloadValueConverter());
}
else
{
if (result is Decimal)
{
// convert decimal back to double to follow legacy logic when target type is not specified and IEEE754Compatible=false.
// we may lose precision for some range of int64 and decimal.
return Convert.ToDouble((Decimal)result);
}
}
}
return result;
}