本文整理汇总了C#中ObjectReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectReader.Read方法的具体用法?C# ObjectReader.Read怎么用?C# ObjectReader.Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectReader
的用法示例。
在下文中一共展示了ObjectReader.Read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_ObjectReader_UnknownType
public void Test_ObjectReader_UnknownType()
{
const string raw = "1 0 obj\r\nsomething unknown\r\nendobj";
var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
var reader = new ObjectReader(stream, null);
try
{
reader.Read();
}
finally
{
stream.Dispose();
}
}
示例2: Test_ObjectReader_Regular
public void Test_ObjectReader_Regular()
{
const string raw = "1 0 obj\r\n200\r\nendobj\r\n2 3 obj\r\n-12.5\r\nendobj";
var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
var reader = new ObjectReader(stream, null);
var obj = reader.Read();
Assert.IsNotNull(obj);
Assert.AreEqual(200, ((IntegerObject) obj).Value);
Assert.AreEqual(1u, obj.Number);
Assert.AreEqual(0u, obj.Generation);
obj = reader.Read();
Assert.IsNotNull(obj);
Assert.AreEqual(-12.5f, ((RealObject) obj).Value);
Assert.AreEqual(2u, obj.Number);
Assert.AreEqual(3u, obj.Generation);
stream.Dispose();
}
示例3: Test_ObjectReader_UnexpectedEndOfObject
public void Test_ObjectReader_UnexpectedEndOfObject()
{
const string raw = "1 0 obj\r\n0\r\n5";
var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
var reader = new ObjectReader(stream, null);
try
{
reader.Read();
}
finally
{
stream.Dispose();
}
}
示例4: Test_ObjectReader_NotObject
public void Test_ObjectReader_NotObject()
{
var raw = "%Comment";
var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
var reader = new ObjectReader(stream, null);
var obj = reader.Read();
Assert.IsNull(obj);
Assert.AreEqual(0, stream.Position);
stream.Dispose();
raw = "0 0 obj\r\n5\r\nendobj";
stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
reader = new ObjectReader(stream, null);
obj = reader.Read();
Assert.IsNull(obj);
Assert.AreEqual(0, stream.Position);
stream.Dispose();
raw = "2 -5 obj\r\n5\r\nendobj";
stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
reader = new ObjectReader(stream, null);
obj = reader.Read();
Assert.IsNull(obj);
Assert.AreEqual(0, stream.Position);
stream.Dispose();
}