当前位置: 首页>>代码示例>>C#>>正文


C# BEncodedString类代码示例

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


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


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