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


C# BEncodedDictionary類代碼示例

本文整理匯總了C#中BEncodedDictionary的典型用法代碼示例。如果您正苦於以下問題:C# BEncodedDictionary類的具體用法?C# BEncodedDictionary怎麽用?C# BEncodedDictionary使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: shutdown

        private static void shutdown()
        {
            BEncodedDictionary fastResume = new BEncodedDictionary();
            for (int i = 0; i < torrents.Count; i++)
            {
                WaitHandle handle = torrents[i].Stop(); ;
                while (!handle.WaitOne(10, true))
                    Console.WriteLine(handle.ToString());

                Console.WriteLine(handle.ToString());
                fastResume.Add(torrents[i].Torrent.InfoHash, torrents[i].SaveFastResume().Encode());
            }

            File.WriteAllBytes(dhtNodeFile, engine.DhtEngine.SaveNodes());
            File.WriteAllBytes(fastResumeFile, fastResume.Encode());
            engine.Dispose();

            foreach (TraceListener lst in Debug.Listeners)
            {
                lst.Flush();
                lst.Close();
            }

            System.Threading.Thread.Sleep(2000);
        }
開發者ID:burris,項目名稱:monotorrent,代碼行數:25,代碼來源:main.cs

示例2: shutdown

        private static void shutdown()
        {
            #if !DISABLE_DHT
            File.WriteAllBytes(dhtNodeFile, engine.DhtEngine.SaveNodes());
            #endif

            BEncodedDictionary fastResume = new BEncodedDictionary();
            for (int i = 0; i < torrents.Count; i++)
            {
                torrents[i].Stop(); ;
                while (torrents[i].State != TorrentState.Stopped)
                {
                    Console.WriteLine("{0} is {1}", torrents[i].Torrent.Name, torrents[i].State);
                    Thread.Sleep(250);
                }

                fastResume.Add(torrents[i].Torrent.InfoHash.ToHex (), torrents[i].SaveFastResume().Encode());
            }

            File.WriteAllBytes(fastResumeFile, fastResume.Encode());
            engine.Dispose();

            foreach (TraceListener lst in Debug.Listeners)
            {
                lst.Flush();
                lst.Close();
            }

            System.Threading.Thread.Sleep(2000);
        }
開發者ID:senditu,項目名稱:simpletorrent,代碼行數:30,代碼來源:main.cs

示例3: Shutdown

        private static void Shutdown()
        {
            var fastResume = new BEncodedDictionary();
            foreach (var torrentManager in torrents)
            {
                torrentManager.Stop();
                while (torrentManager.State != TorrentState.Stopped)
                {
                    Console.WriteLine("{0} is {1}", torrentManager.Torrent.Name, torrentManager.State);
                    Thread.Sleep(250);
                }

                fastResume.Add(torrentManager.Torrent.InfoHash.ToHex (), torrentManager.SaveFastResume().Encode());
            }

            #if !DISABLE_DHT
            File.WriteAllBytes(_dhtNodeFile, _engine.DhtEngine.SaveNodes());
            #endif
            File.WriteAllBytes(_fastResumeFile, fastResume.Encode());
            _engine.Dispose();

            foreach (TraceListener lst in Debug.Listeners)
            {
                lst.Flush();
                lst.Close();
            }

            Thread.Sleep(2000);
        }
開發者ID:mrscylla,項目名稱:octotorrent,代碼行數:29,代碼來源:main.cs

示例4: BitTorrentManager

        public BitTorrentManager(BitTorrentCache bittorrentCache, string selfNameSpace,
            DictionaryServiceProxy dhtProxy, DictionaryServiceTracker dhtTracker, ClientEngine clientEngine,
            TorrentSettings torrentDefaults, TorrentHelper torrentHelper,
            bool startSeedingAtStartup)
        {
            _bittorrentCache = bittorrentCache;
              SelfNameSpace = selfNameSpace;
              _dictProxy = dhtProxy;
              _dictTracker = dhtTracker;
              _torrentDefaults = torrentDefaults;
              _startSeedingAtStartup = startSeedingAtStartup;

              RegisterClientEngineEventHandlers(clientEngine);
              _clientEngine = clientEngine;

              _torrentHelper = torrentHelper;

              try {
            _fastResumeData = BEncodedValue.Decode<BEncodedDictionary>(
              File.ReadAllBytes(_bittorrentCache.FastResumeFilePath));
              } catch {
            _fastResumeData = new BEncodedDictionary();
              }

              // CacheRegistry is created here because the default cache registry file path is
              // defined here.
              CacheRegistry = new CacheRegistry(_bittorrentCache.CacheRegistryFilePath, selfNameSpace);
              CacheRegistry.LoadCacheDir(_bittorrentCache.DownloadsDirPath);
        }
開發者ID:xujyan,項目名稱:hurricane,代碼行數:29,代碼來源:BitTorrentManager.cs

示例5: CorruptDictionary

 public void CorruptDictionary()
 {
     BEncodedList l = new BEncodedList();
     BEncodedDictionary d = new BEncodedDictionary();
     l.Add(d);
     IList<Peer> decoded = Peer.Decode(l);
     Assert.AreEqual(0, decoded.Count, "#1");
 }
開發者ID:JacklEventreur,項目名稱:monotorrent,代碼行數:8,代碼來源:PeerTests.cs

示例6: LoadSupports

        private void LoadSupports(BEncodedDictionary supports)
        {
            var list = new ExtensionSupports();
            foreach (var k in supports)
                list.Add(new ExtensionSupport(k.Key.Text, (byte) ((BEncodedNumber) k.Value).Number));

            Supports = list;
        }
開發者ID:claudiuslollarius,項目名稱:monotorrent,代碼行數:8,代碼來源:ExtendedHandshakeMessage.cs

示例7: CheckContent

 private void CheckContent(BEncodedDictionary dict, BEncodedString key, BEncodedNumber value)
 {
     CheckContent(dict, key);
     if (!dict[key].Equals(value))
         throw new TorrentException(
             string.Format("Invalid FastResume data. The value of '{0}' was '{1}' instead of '{2}'", key,
                 dict[key], value));
 }
開發者ID:haroldma,項目名稱:Universal.Torrent,代碼行數:8,代碼來源:FastResume.cs

示例8: CorruptDictionary

 public void CorruptDictionary()
 {
     var l = new BEncodedList();
     var d = new BEncodedDictionary();
     l.Add(d);
     IList<Peer> decoded = Peer.Decode(l);
     Assert.Equal(0, decoded.Count);
 }
開發者ID:claudiuslollarius,項目名稱:monotorrent,代碼行數:8,代碼來源:PeerTests.cs

示例9: Encode

 public BEncodedDictionary Encode()
 {
     var dict = new BEncodedDictionary();
     dict.Add(VersionKey, (BEncodedNumber) 1);
     dict.Add(InfoHashKey, new BEncodedString(Infohash.Hash));
     dict.Add(BitfieldKey, new BEncodedString(Bitfield.ToByteArray()));
     dict.Add(BitfieldLengthKey, (BEncodedNumber) Bitfield.Length);
     return dict;
 }
開發者ID:claudiuslollarius,項目名稱:monotorrent,代碼行數:9,代碼來源:FastResume.cs

示例10: QueryMessage

        protected QueryMessage(NodeId id, BEncodedString queryName, BEncodedDictionary queryArguments, ResponseCreator responseCreator)
            : base(QueryType)
        {
            Properties.Add(QueryNameKey, queryName);
            Properties.Add(QueryArgumentsKey, queryArguments);

            Parameters.Add(IdKey, id.BencodedString());
            ResponseCreator = responseCreator;
        }
開發者ID:mrscylla,項目名稱:octotorrent,代碼行數:9,代碼來源:QueryMessage.cs

示例11: CorruptDictionary

        public void CorruptDictionary()
        {
            var list = new BEncodedList();
            var dictionary = new BEncodedDictionary();

            list.Add(dictionary);
            IList<Peer> decoded = Peer.Decode(list);
            Assert.AreEqual(0, decoded.Count, "#1");
        }
開發者ID:Eskat0n,項目名稱:OctoTorrent,代碼行數:9,代碼來源:PeerTests.cs

示例12: Decode

 public override void Decode(byte[] buffer, int offset, int length)
 {
     peerDict = BEncodedValue.Decode<BEncodedDictionary>(buffer, offset, length, false);
     if (!peerDict.ContainsKey(AddedKey))
         peerDict.Add(AddedKey, (BEncodedString)"");
     if (!peerDict.ContainsKey(AddedDotFKey))
         peerDict.Add(AddedDotFKey, (BEncodedString)"");
     if (!peerDict.ContainsKey(DroppedKey))
         peerDict.Add(DroppedKey, (BEncodedString)"");
 }
開發者ID:Cyarix,項目名稱:monotorrent,代碼行數:10,代碼來源:PeerExchangeMessage.cs

示例13: Encode

 public BEncodedValue Encode()
 {
     BEncodedDictionary result = new BEncodedDictionary();
     result.Add(new BEncodedString("MaxDownloadSpeed"), new BEncodedNumber(MaxDownloadSpeed));
     result.Add(new BEncodedString("MaxUploadSpeed"), new BEncodedNumber(MaxUploadSpeed));
     result.Add(new BEncodedString("MaxConnections"), new BEncodedNumber(MaxConnections));
     result.Add(new BEncodedString("UploadSlots"), new BEncodedNumber(UploadSlots));
     result.Add(new BEncodedString("SavePath"), new BEncodedString(savePath));
     return result;
 }
開發者ID:AssassinUKG,項目名稱:monotorrent,代碼行數:10,代碼來源:GuiTorrentSettings.cs

示例14: DecodeMessage

        public static Message DecodeMessage(BEncodedDictionary dictionary)
        {
            Message message;
            string error;

            if (!TryDecodeMessage(dictionary, out message, out error))
                throw new MessageException(ErrorCode.GenericError, error);

            return message;
        }
開發者ID:burris,項目名稱:monotorrent,代碼行數:10,代碼來源:MessageFactory.cs

示例15: Encode

 public BEncodedDictionary Encode()
 {
     var dict = new BEncodedDictionary
     {
         {VersionKey, (BEncodedNumber) 1},
         {InfoHashKey, new BEncodedString(Infohash.Hash)},
         {BitfieldKey, new BEncodedString(Bitfield.ToByteArray())},
         {BitfieldLengthKey, (BEncodedNumber) Bitfield.Length}
     };
     return dict;
 }
開發者ID:haroldma,項目名稱:Universal.Torrent,代碼行數:11,代碼來源:FastResume.cs


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