コード例 #1
0
        public static FileHash CalculateFileHash(this ICakeContext context, FilePath filePath, HashAlgorithm hashAlgorithm)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var fileHashCalculator = new FileHashCalculator(context.FileSystem, new HashAlgorithmBuilder());

            return(fileHashCalculator.Calculate(filePath, hashAlgorithm));
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectoryHashCalculator"/> class.
        /// </summary>
        /// <param name="context">The cake context.</param>
        /// <param name="hashAlgorithmBuilder">The hash algorithm builder.</param>
        public DirectoryHashCalculator(ICakeContext context, IHashAlgorithmBuilder hashAlgorithmBuilder)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (hashAlgorithmBuilder == null)
            {
                throw new ArgumentNullException(nameof(hashAlgorithmBuilder));
            }

            _context = context;
            _hashAlgorithmBuilder = hashAlgorithmBuilder;
            _fileHashCalculator   = new FileHashCalculator(_context.FileSystem, _hashAlgorithmBuilder);
        }