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)); }
/// <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); }