本文整理汇总了C#中Box.Export方法的典型用法代码示例。如果您正苦于以下问题:C# Box.Export方法的具体用法?C# Box.Export怎么用?C# Box.Export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box
的用法示例。
在下文中一共展示了Box.Export方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Box
public void Test_Box()
{
var box = new Box();
box.Name = "Box";
box.Comment = "Comment";
box.CreationTime = DateTime.Now;
box.Seeds.Add(new Seed() { Name = "Seed" });
box.Boxes.Add(new Box() { Name = "Box" });
DigitalSignature digitalSignature = new DigitalSignature("123", DigitalSignatureAlgorithm.EcDsaP521_Sha256);
box.CreateCertificate(digitalSignature);
var box2 = box.Clone();
Assert.AreEqual(box, box2, "Box #1");
Box box3;
using (var boxStream = box.Export(_bufferManager))
{
box3 = Box.Import(boxStream, _bufferManager);
}
Assert.AreEqual(box, box3, "Box #2");
Assert.IsTrue(box3.VerifyCertificate(), "Box #3");
{
var parentBox = new Box();
var childBox = parentBox;
for (int i = 0; i < 256; i++)
{
var tempBox = new Box();
childBox.Boxes.Add(tempBox);
childBox = tempBox;
}
using (var binaryBox = parentBox.Export(_bufferManager))
{
}
}
{
var parentBox = new Box();
var childBox = parentBox;
for (int i = 0; i < 256 + 1; i++)
{
var tempBox = new Box();
childBox.Boxes.Add(tempBox);
childBox = tempBox;
}
Assert.Throws<ArgumentException>(() =>
{
using (var binaryBox = parentBox.Export(_bufferManager))
{
}
});
}
{
var parentBox = new T_Box();
var childBox = parentBox;
for (int i = 0; i < 256; i++)
{
var tempBox = new T_Box();
childBox.D_Boxes.Add(tempBox);
childBox = tempBox;
}
using (var binaryBox = parentBox.Export(_bufferManager))
{
Box.Import(binaryBox, _bufferManager);
}
}
{
var parentBox = new T_Box();
var childBox = parentBox;
for (int i = 0; i < 256 + 1; i++)
{
var tempBox = new T_Box();
childBox.D_Boxes.Add(tempBox);
childBox = tempBox;
}
Assert.Throws<ArgumentException>(() =>
{
using (var binaryBox = parentBox.Export(_bufferManager))
{
Box.Import(binaryBox, _bufferManager);
}
});
}
}
示例2: Test_Box
public void Test_Box()
{
var key = new Key(HashAlgorithm.Sha256, new byte[32]);
var metadata = new Metadata(1, key, CompressionAlgorithm.Xz, CryptoAlgorithm.Aes256, new byte[32 + 32]);
var seed = new Seed(metadata);
seed.Name = "aaaa.zip";
seed.Keywords.AddRange(new KeywordCollection
{
"bbbb",
"cccc",
"dddd",
});
seed.CreationTime = DateTime.Now;
seed.Length = 10000;
var box = new Box();
box.Name = "Box";
box.Seeds.Add(seed);
box.Boxes.Add(new Box() { Name = "Box" });
var box2 = box.Clone();
Assert.AreEqual(box, box2, "Box #1");
Box box3;
using (var boxStream = box.Export(_bufferManager))
{
box3 = Box.Import(boxStream, _bufferManager);
}
Assert.AreEqual(box, box3, "Box #2");
{
var parentBox = new Box();
var childBox = parentBox;
for (int i = 0; i < 256; i++)
{
var tempBox = new Box();
childBox.Boxes.Add(tempBox);
childBox = tempBox;
}
using (var binaryBox = parentBox.Export(_bufferManager))
{
}
}
{
var parentBox = new Box();
var childBox = parentBox;
for (int i = 0; i < 256 + 1; i++)
{
var tempBox = new Box();
childBox.Boxes.Add(tempBox);
childBox = tempBox;
}
Assert.Throws<ArgumentException>(() =>
{
using (var binaryBox = parentBox.Export(_bufferManager))
{
}
});
}
}