本文整理汇总了C#中JsonReader.ReadAsDateTimeOffset方法的典型用法代码示例。如果您正苦于以下问题:C# JsonReader.ReadAsDateTimeOffset方法的具体用法?C# JsonReader.ReadAsDateTimeOffset怎么用?C# JsonReader.ReadAsDateTimeOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonReader
的用法示例。
在下文中一共展示了JsonReader.ReadAsDateTimeOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadForType
private bool ReadForType(JsonReader reader, JsonContract contract, bool hasConverter, bool inArray)
{
// don't read properties with converters as a specific value
// the value might be a string which will then get converted which will error if read as date for example
if (hasConverter)
return reader.Read();
ReadType t = (contract != null) ? contract.InternalReadType : ReadType.Read;
switch (t)
{
case ReadType.Read:
do
{
if (!reader.Read())
return false;
} while (reader.TokenType == JsonToken.Comment);
return true;
case ReadType.ReadAsInt32:
reader.ReadAsInt32();
break;
case ReadType.ReadAsDecimal:
reader.ReadAsDecimal();
break;
case ReadType.ReadAsBytes:
reader.ReadAsBytes();
break;
case ReadType.ReadAsString:
reader.ReadAsString();
break;
case ReadType.ReadAsDateTime:
reader.ReadAsDateTime();
break;
#if !NET20
case ReadType.ReadAsDateTimeOffset:
reader.ReadAsDateTimeOffset();
break;
#endif
default:
throw new ArgumentOutOfRangeException();
}
return (reader.TokenType != JsonToken.None);
}
示例2: ReadForType
private bool ReadForType(JsonReader reader, Type t, JsonConverter propertyConverter)
{
// don't read properties with converters as a specific value
// the value might be a string which will then get converted which will error if read as date for example
bool hasConverter = (GetConverter(GetContractSafe(t), propertyConverter) != null);
if (hasConverter)
return reader.Read();
if (t == typeof(byte[]))
{
reader.ReadAsBytes();
return true;
}
else if ((t == typeof(decimal) || t == typeof(decimal?)))
{
reader.ReadAsDecimal();
return true;
}
#if !NET20
else if ((t == typeof(DateTimeOffset) || t == typeof(DateTimeOffset?)))
{
reader.ReadAsDateTimeOffset();
return true;
}
#endif
do
{
if (!reader.Read())
return false;
} while (reader.TokenType == JsonToken.Comment);
return true;
}