internal static object ReadPrimitiveValue(XmlReader reader, IEdmPrimitiveTypeReference primitiveTypeReference) { object obj2; if (!PrimitiveConverter.Instance.TryTokenizeFromXml(reader, EdmLibraryExtensions.GetPrimitiveClrType(primitiveTypeReference), out obj2)) { return ConvertStringToPrimitive(reader.ReadElementContentValue(), primitiveTypeReference); } return obj2; }
/// <summary> /// Reads a string value of an XML element and gets TypeName from model's EdmEnumTypeReference. /// </summary> /// <param name="reader">The XML reader to read the value from.</param> /// <param name="enumTypeReference">The enum rype reference.</param> /// <returns>An ODataEnumValue</returns> internal static ODataEnumValue ReadEnumValue(XmlReader reader, IEdmEnumTypeReference enumTypeReference) { Debug.Assert(reader != null, "reader != null"); // skip the validation on value or type name. string stringValue = reader.ReadElementContentValue(); string typeName = (enumTypeReference != null) ? enumTypeReference.ODataFullName() : null; return new ODataEnumValue(stringValue, typeName); }
/// <summary> /// Reads a value of an XML element and converts it to the target primitive value. /// </summary> /// <param name="reader">The XML reader to read the value from.</param> /// <param name="primitiveTypeReference">The primitive type reference to convert the value to.</param> /// <returns>The primitive value read.</returns> /// <remarks>This method does not read null values, it only reads the actual element value (not its attributes).</remarks> /// <remarks> /// Pre-Condition: XmlNodeType.Element - the element to read the value for. /// XmlNodeType.Attribute - an attribute on the element to read the value for. /// Post-Condition: XmlNodeType.Element - the element was empty. /// XmlNodeType.EndElement - the element had some value. /// </remarks> internal static object ReadPrimitiveValue(XmlReader reader, IEdmPrimitiveTypeReference primitiveTypeReference) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(reader != null, "reader != null"); object spatialValue; if (!PrimitiveConverter.Instance.TryTokenizeFromXml(reader, EdmLibraryExtensions.GetPrimitiveClrType(primitiveTypeReference), out spatialValue)) { string stringValue = reader.ReadElementContentValue(); return ConvertStringToPrimitive(stringValue, primitiveTypeReference); } return spatialValue; }