Data() public static method

public static Data ( object data ) : void
data object
return void
示例#1
0
        /// <summary>
        ///     Loads a torrent from a byte[] containing the bencoded data
        /// </summary>
        /// <param name="data">The byte[] containing the data</param>
        /// <returns></returns>
        public static Torrent Load(byte[] data)
        {
            Check.Data(data);

            using (var s = new MemoryStream(data))
                return(Load(s, ""));
        }
示例#2
0
        /// <summary>
        ///     Loads a .torrent from the specified byte[]. A return value indicates
        ///     whether the operation was successful.
        /// </summary>
        /// <param name="data">The byte[] to load the .torrent from</param>
        /// <param name="torrent">If loading was successful, it contains the Torrent</param>
        /// <returns>True if successful</returns>
        public static bool TryLoad(byte[] data, out Torrent torrent)
        {
            Check.Data(data);

            try
            {
                torrent = Load(data);
            }
            catch
            {
                torrent = null;
            }

            return(torrent != null);
        }