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

C# BEncodedString类代码示例

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

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



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

示例1: AnnouncePeer

		public AnnouncePeer(NodeId id, NodeId infoHash, BEncodedNumber port, BEncodedString token)
			: base(id, QueryName, responseCreator)
		{
			Parameters.Add(InfoHashKey, infoHash.BencodedString());
			Parameters.Add(PortKey, port);
			Parameters.Add(TokenKey, token);
		}
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:7,代码来源:AnnouncePeer.cs


示例2: Message

 protected Message(BEncodedString messageType)
 {
     properties.Add(TransactionIdKey, null);
     properties.Add(MessageTypeKey, messageType);
     if (UseVersionKey)
         properties.Add(VersionKey, DhtVersion);
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:7,代码来源:Message.cs


示例3: 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


示例4: 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


示例5: NextId

 public static BEncodedString NextId()
 {
     lock (Current)
     {
         var result = new BEncodedString((byte[]) Current.Clone());
         if (Current[0]++ == 255)
             Current[1]++;
         return result;
     }
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:10,代码来源:TransactionId.cs


示例6: CreateTorrent

        private static BEncodedDictionary CreateTorrent(int pieceLength)
        {
            var infoDict = new BEncodedDictionary();
            infoDict[new BEncodedString("piece length")] = new BEncodedNumber(pieceLength);
            infoDict[new BEncodedString("pieces")] = new BEncodedString(new byte[20*15]);
            infoDict[new BEncodedString("length")] = new BEncodedNumber(15*256*1024 - 1);
            infoDict[new BEncodedString("name")] = new BEncodedString("test.files");

            var dict = new BEncodedDictionary();
            dict[new BEncodedString("info")] = infoDict;

            var announceTier = new BEncodedList();
            announceTier.Add(new BEncodedString("custom://transfers1/announce"));
            announceTier.Add(new BEncodedString("custom://transfers2/announce"));
            announceTier.Add(new BEncodedString("http://transfers3/announce"));
            var announceList = new BEncodedList();
            announceList.Add(announceTier);
            dict[new BEncodedString("announce-list")] = announceList;
            return dict;
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:20,代码来源:EngineTestRig.cs


示例7: Save

        public void Save(IList<ResumeItem> resumeItems)
        {
            foreach (var keypair in this._originalDictionary)
            {
                if (keypair.Value is BEncodedDictionary)
                {
                    var dic = (BEncodedDictionary)keypair.Value;
                    var item = resumeItems.FirstOrDefault(c => c.TorrentName == keypair.Key.Text);
                    if (item != null)
                    {
                        if (dic.ContainsKey("label"))
                        {
                            dic["label"] = new BEncodedString(item.Label);

                        }
                        else
                        {
                            dic.Add("label", new BEncodedString(item.Label));
                        }
                    }
                }
            }
            File.WriteAllBytes(this._resumePath, this._originalDictionary.Encode());
        }
开发者ID:harrywong,项目名称:ResumeEditor,代码行数:24,代码来源:Resume.cs


示例8: benStringEncodingBuffered

        public void benStringEncodingBuffered()
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes("22:this is my test string");

            BEncodedString benString = new BEncodedString("this is my test string");
            byte[] result = new byte[benString.LengthInBytes()];
            benString.Encode(result, 0);
            Assert.IsTrue(Toolbox.ByteMatch(data, result));
        }
开发者ID:burris,项目名称:monotorrent,代码行数:9,代码来源:BEncodingTest.cs


示例9: benStringEncoding2

        public void benStringEncoding2()
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes("0:");

            BEncodedString benString = new BEncodedString("");
            Assert.IsTrue(Toolbox.ByteMatch(data, benString.Encode()));
        }
开发者ID:burris,项目名称:monotorrent,代码行数:7,代码来源:BEncodingTest.cs


示例10: GetPeersResponse

 public GetPeersResponse(NodeId id, BEncodedValue transactionId, BEncodedString token)
     : base(id, transactionId)
 {
     Parameters.Add(TokenKey, token);
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:5,代码来源:GetPeersResponse.cs


示例11: AddFiles

        private void AddFiles(BEncodedDictionary dict, TorrentFile[] files)
        {
            long totalSize = piecelength - 1;
            var bFiles = new BEncodedList();
            for (var i = 0; i < files.Length; i++)
            {
                var path = new BEncodedList();
                foreach (var s in files[i].Path.Split('/'))
                    path.Add((BEncodedString) s);
                var d = new BEncodedDictionary();
                d["path"] = path;
                d["length"] = (BEncodedNumber) files[i].Length;
                bFiles.Add(d);
                totalSize += files[i].Length;
            }

            dict[new BEncodedString("files")] = bFiles;
            dict[new BEncodedString("name")] = new BEncodedString("test.files");
            dict[new BEncodedString("piece length")] = new BEncodedNumber(piecelength);
            dict[new BEncodedString("pieces")] = new BEncodedString(new byte[20*(totalSize/piecelength)]);
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:21,代码来源:TestRig.cs


示例12: SetCustomSecure

        public void SetCustomSecure(BEncodedString key, BEncodedValue value)
        {
            CheckCanEditSecure();

            Check.Key(key);
            Check.Value(value);
            InfoDict[key] = value;
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:8,代码来源:EditableTorrent.cs


示例13: GetDictionary

        protected BEncodedDictionary GetDictionary(BEncodedDictionary dictionary, BEncodedString key)
        {
//            // Required? Probably.
//            if (dictionary == InfoDict)
//                CheckCanEditSecure ();

            BEncodedValue value;
            if (dictionary.TryGetValue(key, out value))
                return (BEncodedDictionary) value;
            return null;
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:11,代码来源:EditableTorrent.cs


示例14: Get

		static BEncodedValue Get(BEncodedDictionary dictionary, BEncodedString key)
		{
			return dictionary.ContainsKey(key) ? dictionary[key] : null;
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:4,代码来源:TorrentCreator.cs


示例15: AddCustom

		/// <summary>
		/// Adds a custom value to the main bencoded dictionary
		/// </summary>        
		public void AddCustom(BEncodedString key, BEncodedValue value)
		{
			dict.Add(key, value);
		}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:TorrentCreator.cs


示例16: Decode

        public static MonoTorrentCollection<Peer> Decode(BEncodedString peers)
        {
            // "Compact Response" peers are encoded in network byte order.
            // IP's are the first four bytes
            // Ports are the following 2 bytes
            byte[] byteOrderedData = peers.TextBytes;
            int i = 0;
            UInt16 port;
            StringBuilder sb = new StringBuilder(27);
            MonoTorrentCollection<Peer> list = new MonoTorrentCollection<Peer>((byteOrderedData.Length / 6) + 1);
            while ((i + 5) < byteOrderedData.Length)
            {
                sb.Remove(0, sb.Length);

                sb.Append("tcp://");
                sb.Append(byteOrderedData[i++]);
                sb.Append('.');
                sb.Append(byteOrderedData[i++]);
                sb.Append('.');
                sb.Append(byteOrderedData[i++]);
                sb.Append('.');
                sb.Append(byteOrderedData[i++]);

                port = (UInt16)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(byteOrderedData, i));
                i += 2;
                sb.Append(':');
                sb.Append(port);

                Uri uri = new Uri(sb.ToString());
                list.Add(new Peer("", uri, EncryptionTypes.All));
            }

            return list;
        }
开发者ID:proff,项目名称:ProffTorrent,代码行数:34,代码来源:Peer.cs


示例17: SetString

 protected void SetString(BEncodedDictionary dictionary, BEncodedString key, string value)
 {
     if (dictionary == InfoDict)
         CheckCanEditSecure();
     dictionary[key] = new BEncodedString(value);
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:6,代码来源:EditableTorrent.cs


示例18: SetDictionary

 protected void SetDictionary(BEncodedDictionary dictionary, BEncodedString key, BEncodedDictionary value)
 {
     if (dictionary == InfoDict)
         CheckCanEditSecure();
     dictionary[key] = value;
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:6,代码来源:EditableTorrent.cs


示例19: GetString

 protected string GetString(BEncodedDictionary dictionary, BEncodedString key)
 {
     BEncodedValue value;
     if (dictionary.TryGetValue(key, out value))
         return value.ToString();
     return "";
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:7,代码来源:EditableTorrent.cs


示例20: GetLong

 protected long GetLong(BEncodedDictionary dictionary, BEncodedString key)
 {
     BEncodedValue value;
     if (dictionary.TryGetValue(key, out value))
         return ((BEncodedNumber) value).Number;
     throw new ArgumentException(string.Format("The value for key {0} was not a BEncodedNumber", key));
 }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:7,代码来源:EditableTorrent.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BITMAPINFO类代码示例发布时间:2022-05-24
下一篇:
C# BEncodedList类代码示例发布时间: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