本文整理汇总了C#中System.Xml.XmlReader.ReadElementContentValue方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadElementContentValue方法的具体用法?C# XmlReader.ReadElementContentValue怎么用?C# XmlReader.ReadElementContentValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadElementContentValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPrimitiveValue
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;
}
示例2: ReadEnumValue
/// <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);
}
示例3: ReadPrimitiveValue
/// <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;
}