本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipExtraData.GetStreamForTag方法的典型用法代码示例。如果您正苦于以下问题:C# ZipExtraData.GetStreamForTag方法的具体用法?C# ZipExtraData.GetStreamForTag怎么用?C# ZipExtraData.GetStreamForTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.ZipExtraData
的用法示例。
在下文中一共展示了ZipExtraData.GetStreamForTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicOperations
public void BasicOperations()
{
ZipExtraData zed = new ZipExtraData(null);
Assert.AreEqual(0, zed.Length);
zed = new ZipExtraData(new byte[] { 1, 0, 0, 0 });
Assert.AreEqual(4, zed.Length, "A length should be 4");
ZipExtraData zed2 = new ZipExtraData();
Assert.AreEqual(0, zed2.Length);
zed2.AddEntry(1, new byte[] { });
byte[] data = zed.GetEntryData();
for (int i = 0; i < data.Length; ++i) {
Assert.AreEqual(zed2.GetEntryData()[i], data[i]);
}
Assert.AreEqual(4, zed2.Length, "A1 length should be 4");
bool findResult = zed.Find(2);
Assert.IsFalse(findResult, "A - Shouldnt find tag 2");
findResult = zed.Find(1);
Assert.IsTrue(findResult, "A - Should find tag 1");
Assert.AreEqual(0, zed.ValueLength, "A- Length of entry should be 0");
Assert.AreEqual(-1, zed.ReadByte());
Assert.AreEqual(0, zed.GetStreamForTag(1).Length, "A - Length of stream should be 0");
zed = new ZipExtraData(new byte[] { 1, 0, 3, 0, 1, 2, 3 });
Assert.AreEqual(7, zed.Length, "Expected a length of 7");
findResult = zed.Find(1);
Assert.IsTrue(findResult, "B - Should find tag 1");
Assert.AreEqual(3, zed.ValueLength, "B - Length of entry should be 3");
for (int i = 1; i <= 3; ++i) {
Assert.AreEqual(i, zed.ReadByte());
}
Assert.AreEqual(-1, zed.ReadByte());
Stream s = zed.GetStreamForTag(1);
Assert.AreEqual(3, s.Length, "B.1 Stream length should be 3");
for (int i = 1; i <= 3; ++i) {
Assert.AreEqual(i, s.ReadByte());
}
Assert.AreEqual(-1, s.ReadByte());
zed = new ZipExtraData(new byte[] { 1, 0, 3, 0, 1, 2, 3, 2, 0, 1, 0, 56 });
Assert.AreEqual(12, zed.Length, "Expected a length of 12");
findResult = zed.Find(1);
Assert.IsTrue(findResult, "C.1 - Should find tag 1");
Assert.AreEqual(3, zed.ValueLength, "C.1 - Length of entry should be 3");
for (int i = 1; i <= 3; ++i) {
Assert.AreEqual(i, zed.ReadByte());
}
Assert.AreEqual(-1, zed.ReadByte());
findResult = zed.Find(2);
Assert.IsTrue(findResult, "C.2 - Should find tag 2");
Assert.AreEqual(1, zed.ValueLength, "C.2 - Length of entry should be 1");
Assert.AreEqual(56, zed.ReadByte());
Assert.AreEqual(-1, zed.ReadByte());
s = zed.GetStreamForTag(2);
Assert.AreEqual(1, s.Length);
Assert.AreEqual(56, s.ReadByte());
Assert.AreEqual(-1, s.ReadByte());
zed = new ZipExtraData();
zed.AddEntry(7, new byte[] { 33, 44, 55 });
findResult = zed.Find(7);
Assert.IsTrue(findResult, "Add.1 should find new tag");
Assert.AreEqual(3, zed.ValueLength, "Add.1 length should be 3");
Assert.AreEqual(33, zed.ReadByte());
Assert.AreEqual(44, zed.ReadByte());
Assert.AreEqual(55, zed.ReadByte());
Assert.AreEqual(-1, zed.ReadByte());
zed.AddEntry(7, null);
findResult = zed.Find(7);
Assert.IsTrue(findResult, "Add.2 should find new tag");
Assert.AreEqual(0, zed.ValueLength, "Add.2 length should be 0");
zed.StartNewEntry();
zed.AddData(0xae);
zed.AddNewEntry(55);
findResult = zed.Find(55);
Assert.IsTrue(findResult, "Add.3 should find new tag");
Assert.AreEqual(1, zed.ValueLength, "Add.3 length should be 1");
Assert.AreEqual(0xae, zed.ReadByte());
Assert.AreEqual(-1, zed.ReadByte());
zed = new ZipExtraData();
zed.StartNewEntry();
zed.AddLeLong(0);
zed.AddLeLong(-4);
zed.AddLeLong(-1);
zed.AddLeLong(long.MaxValue);
//.........这里部分代码省略.........