當前位置: 首頁>>代碼示例>>C#>>正文


C# BitField.SetAll方法代碼示例

本文整理匯總了C#中BitField.SetAll方法的典型用法代碼示例。如果您正苦於以下問題:C# BitField.SetAll方法的具體用法?C# BitField.SetAll怎麽用?C# BitField.SetAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BitField的用法示例。


在下文中一共展示了BitField.SetAll方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: From

        public void From()
        {
            BitField b = new BitField(31);
            b.SetAll(true);
            Assert.AreEqual(31, b.TrueCount, "#1");
            Assert.IsTrue(b.AllTrue, "#1b");

            b = new BitField(32);
            b.SetAll(true);
            Assert.AreEqual(32, b.TrueCount, "#2");
            Assert.IsTrue(b.AllTrue, "#2b");

            b = new BitField(33);
            b.SetAll(true);
            Assert.AreEqual(33, b.TrueCount, "#3");
            Assert.IsTrue(b.AllTrue, "#3b");
        }
開發者ID:Cyarix,項目名稱:monotorrent,代碼行數:17,代碼來源:BitFieldTest.cs

示例2: From

        public void From()
        {
            var b = new BitField(31);
            b.SetAll(true);
            Assert.Equal(31, b.TrueCount);
            Assert.True(b.AllTrue);

            b = new BitField(32);
            b.SetAll(true);
            Assert.Equal(32, b.TrueCount);
            Assert.True(b.AllTrue);

            b = new BitField(33);
            b.SetAll(true);
            Assert.Equal(33, b.TrueCount);
            Assert.True(b.AllTrue);
        }
開發者ID:claudiuslollarius,項目名稱:monotorrent,代碼行數:17,代碼來源:BitFieldTest.cs

示例3: LargeBitfield

 public void LargeBitfield()
 {
     BitField bf = new BitField(1000);
     bf.SetAll(true);
     Assert.AreEqual(1000, bf.TrueCount);
 }
開發者ID:Cyarix,項目名稱:monotorrent,代碼行數:6,代碼來源:BitFieldTest.cs

示例4: PeerHandshakeReceived

        private void PeerHandshakeReceived(bool succeeded, int count, object state)
        {
            PeerId id = (PeerId)state;
            string reason = null;
            bool cleanUp = false;
            PeerMessage msg;

            try
            {
                // If the connection is closed, just return
                if (!succeeded)
                {
                    CleanupSocket(id, "Handshaking failed");
                    return;
                }
                // Decode the handshake and handle it
                id.Decryptor.Decrypt(id.recieveBuffer.Array, id.recieveBuffer.Offset, count);
                msg = new HandshakeMessage();
                msg.Decode(id.recieveBuffer, 0, count);
                msg.Handle(id);

                Logger.Log(id.Connection, "ConnectionManager - Handshake recieved");
                if (id.SupportsFastPeer && ClientEngine.SupportsFastPeer)
                {
                    if (id.TorrentManager.Bitfield.AllFalse || id.TorrentManager.IsInitialSeeding)
                        msg = new HaveNoneMessage();

                    else if (id.TorrentManager.Bitfield.AllTrue)
                        msg = new HaveAllMessage();

                    else
                        msg = new BitfieldMessage(id.TorrentManager.Bitfield);
                }
                else if (id.TorrentManager.IsInitialSeeding)
                {
                    BitField btfld = new BitField(id.TorrentManager.Bitfield.Length);
                    btfld.SetAll(false);
                    msg = new BitfieldMessage(btfld);
                }
                else
                {
                    msg = new BitfieldMessage(id.TorrentManager.Bitfield);
                }

                if (id.SupportsLTMessages && ClientEngine.SupportsExtended)
                {
                    MessageBundle bundle = new MessageBundle();
                    bundle.Messages.Add(new ExtendedHandshakeMessage());
                    bundle.Messages.Add(msg);
                    msg = bundle;
                }

                //ClientEngine.BufferManager.FreeBuffer(ref id.recieveBuffer);
                SendMessage(id, msg, this.bitfieldSentCallback);
            }
            catch (TorrentException)
            {
                Logger.Log(id.Connection, "ConnectionManager - Couldn't decode the message");
                reason = "Couldn't decode handshake";
                cleanUp = true;
                return;
            }
            finally
            {
                if (cleanUp)
                    CleanupSocket(id, reason);
            }
        }
開發者ID:burris,項目名稱:monotorrent,代碼行數:68,代碼來源:ConnectionManager.cs


注:本文中的BitField.SetAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。