• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BEncodedDictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BEncodedDictionary的典型用法代码示例。如果您正苦于以下问题:C# BEncodedDictionary类的具体用法?C# BEncodedDictionary怎么用?C# BEncodedDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BEncodedDictionary类属于命名空间,在下文中一共展示了BEncodedDictionary类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Deserialize

        public void Deserialize(BEncodedDictionary dict)
        {
            fastResume = new FastResume ((BEncodedDictionary) dict["FastResume"]);
            savePath = dict["SavePath"].ToString ();
            torrentPath = dict["TorrentPath"].ToString ();

            string sb = dict["Settings"].ToString ();
            XmlSerializer s = new XmlSerializer (typeof (TorrentSettings));
            using (System.IO.TextReader reader = new System.IO.StringReader (sb))
                settings = (TorrentSettings) s.Deserialize (reader);
        }
开发者ID:jackgao,项目名称:bitsharp-dbus,代码行数:11,代码来源:TorrentData.cs


示例17: benDictionaryEncodingBuffered

 public void benDictionaryEncodingBuffered()
 {
     var data = Encoding.UTF8.GetBytes("d4:spaml1:a1:bee");
     var dict = new BEncodedDictionary();
     var list = new BEncodedList();
     list.Add(new BEncodedString("a"));
     list.Add(new BEncodedString("b"));
     dict.Add("spam", list);
     var result = new byte[dict.LengthInBytes()];
     dict.Encode(result, 0);
     Assert.True(Toolbox.ByteMatch(data, result));
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:12,代码来源:BEncodeTest.cs


示例18: benDictionaryEncoding

        public void benDictionaryEncoding()
        {
            var data = Encoding.UTF8.GetBytes("d4:spaml1:a1:bee");

            var dict = new BEncodedDictionary();
            var list = new BEncodedList();
            list.Add(new BEncodedString("a"));
            list.Add(new BEncodedString("b"));
            dict.Add("spam", list);
            Assert.Equal(Encoding.UTF8.GetString(data), Encoding.UTF8.GetString(dict.Encode()));
            Assert.True(Toolbox.ByteMatch(data, dict.Encode()));
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:12,代码来源:BEncodeTest.cs


示例19: TorrentCreator

        private bool storeMd5; // True if an MD5 hash of each file should be included

        #endregion Fields

        #region Constructors

        public TorrentCreator()
        {
            BEncodedDictionary info = new BEncodedDictionary();
            this.announces = new List<List<string>>();
            this.ignoreHiddenFiles = true;
            this.dict = new BEncodedDictionary();
            this.dict.Add("info", info);

            // Add in initial values for some of the torrent attributes
            PieceLength = 256 * 1024;   // 256kB default piece size
            this.Encoding = "UTF-8";
        }
开发者ID:burris,项目名称:monotorrent,代码行数:18,代码来源:TorrentCreator.cs


示例20: benDictionaryEncoding

        public void benDictionaryEncoding()
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes("d4:spaml1:a1:bee");

            BEncodedDictionary dict = new BEncodedDictionary();
            BEncodedList list = new BEncodedList();
            list.Add(new BEncodedString("a"));
            list.Add(new BEncodedString("b"));
            dict.Add("spam", list);
            Assert.AreEqual(System.Text.Encoding.UTF8.GetString(data), System.Text.Encoding.UTF8.GetString(dict.Encode()));
            Assert.IsTrue(Toolbox.ByteMatch(data, dict.Encode()));
        }
开发者ID:burris,项目名称:monotorrent,代码行数:12,代码来源:BEncodingTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BEncodedList类代码示例发布时间:2022-05-24
下一篇:
C# BEPUutilities类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap