當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。