当前位置: 首页>>代码示例>>C#>>正文


C# Box.Clone方法代码示例

本文整理汇总了C#中Box.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Box.Clone方法的具体用法?C# Box.Clone怎么用?C# Box.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Box的用法示例。


在下文中一共展示了Box.Clone方法的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);
                    }
                });
            }
        }
开发者ID:networkelements,项目名称:Library,代码行数:100,代码来源:Test_Library_Net_Amoeba.cs

示例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))
                    {

                    }
                });
            }
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:70,代码来源:Test_Library_Net_Amoeba.cs


注:本文中的Box.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。