Contains() приватный Метод

private Contains ( string key ) : bool
key string
Результат bool
Пример #1
0
        private void LoadTorrent()
        {
            if (data.Contains("announce") == false)
            {
                throw new IncompleteTorrentData("No tracker URL");
            }

            if (data.Contains("info") == false)
            {
                throw new IncompleteTorrentData("No internal torrent information");
            }

            ValueDictionary info = (ValueDictionary)data["info"];

            pieceLength = ((ValueNumber)info["piece length"]).Integer;

            if (info.Contains("pieces") == false)
            {
                throw new IncompleteTorrentData("No piece hash data");
            }

            ValueString pieces = (ValueString)info["pieces"];

            if ((pieces.Length % 20) != 0)
            {
                throw new IncompleteTorrentData("Missing or damaged piece hash codes");
            }

            // Parse out the hash codes
            ParsePieceHashes(pieces.Bytes);

            // if (info.Contains("length") == true)

            // if (data.Contains("files") == true)
            // throw new Exception("This is not a single file");

            // SingleFile = true;

            // Determine what files are in the torrent
            if (SingleFile)
            {
                ParseSingleFile();
            }
            else
            {
                ParseMultipleFiles();
            }
            infohash = InfoHash;
        }
Пример #2
0
        private void LoadTorrent()
        {
            if (!this.data.Contains("announce"))
            {
                throw new IncompleteTorrentData("No tracker URL");
            }
            if (!this.data.Contains("info"))
            {
                throw new IncompleteTorrentData("No internal torrent information");
            }
            ValueDictionary dictionary = (ValueDictionary)this.data["info"];

            this.pieceLength = ((ValueNumber)dictionary["piece length"]).Integer;
            if (!dictionary.Contains("pieces"))
            {
                throw new IncompleteTorrentData("No piece hash data");
            }
            ValueString str = (ValueString)dictionary["pieces"];

            if ((str.Length % 20) != 0)
            {
                throw new IncompleteTorrentData("Missing or damaged piece hash codes");
            }
            this.ParsePieceHashes(str.Bytes);
            if (this.SingleFile)
            {
                this.ParseSingleFile();
            }
            else
            {
                this.ParseMultipleFiles();
            }
            this.infohash = this.InfoHash;
        }