当前位置: 首页>>代码示例>>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;未经允许,请勿转载。