本文整理匯總了C#中Newtonsoft.Json.Linq.JTokenReader.ReadAsBoolean方法的典型用法代碼示例。如果您正苦於以下問題:C# JTokenReader.ReadAsBoolean方法的具體用法?C# JTokenReader.ReadAsBoolean怎麽用?C# JTokenReader.ReadAsBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Newtonsoft.Json.Linq.JTokenReader
的用法示例。
在下文中一共展示了JTokenReader.ReadAsBoolean方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ReadAsBoolean_Integer_Success
public void ReadAsBoolean_Integer_Success()
{
JValue n = new JValue(1);
JTokenReader reader = new JTokenReader(n);
Assert.AreEqual(true, reader.ReadAsBoolean());
}
示例2: ReadAsBoolean_Null_Success
public void ReadAsBoolean_Null_Success()
{
JValue n = JValue.CreateNull();
JTokenReader reader = new JTokenReader(n);
Assert.AreEqual(null, reader.ReadAsBoolean());
}
示例3: ReadAsBoolean_BigInteger_Success
public void ReadAsBoolean_BigInteger_Success()
{
JValue s = new JValue(BigInteger.Parse("99999999999999999999999999999999999999999999999999999999999999999999999999"));
JTokenReader reader = new JTokenReader(s);
Assert.AreEqual(true, reader.ReadAsBoolean());
}
示例4: ReadAsBoolean_String_Success
public void ReadAsBoolean_String_Success()
{
JValue s = JValue.CreateString("true");
JTokenReader reader = new JTokenReader(s);
Assert.AreEqual(true, reader.ReadAsBoolean());
}
示例5: ReadAsBoolean_InvalidToken
public void ReadAsBoolean_InvalidToken()
{
JArray a = new JArray
{
1, 2
};
JTokenReader reader = new JTokenReader(a);
ExceptionAssert.Throws<JsonReaderException>(
() => { reader.ReadAsBoolean(); },
"Error reading boolean. Unexpected token: StartArray. Path ''.");
}