public static byte[] TryGetChecksum(ResourceKey resourceKey, PdbChecksumAlgorithm checksumAlgorithm) { Code.AssertArgument(!resourceKey.IsEmpty, nameof(resourceKey), "The resource key should be non empty."); var algName = GetChecksumName(checksumAlgorithm); using (var stream = resourceKey.TryGetResourceStream()) { if (stream == null) { return(Array <byte> .Empty); } using (var hashAlgorithm = HashAlgorithm.Create(algName)) { // ReSharper disable once PossibleNullReferenceException return(hashAlgorithm.ComputeHash(stream)); } } }
public static Stream TryGetResourceStream(this ResourceKey resourceKey) { Code.NotNull(resourceKey.Assembly, nameof(resourceKey.Assembly)); return(resourceKey.Assembly.GetManifestResourceStream(resourceKey.ResourceName)); }