public static void ValidateDocument(ISymUnmanagedDocument document, string url, string algorithmId, byte[] checksum) { ValidateDocumentUrl(document, url); int actualCount, actualCount2; if (checksum != null) { Assert.Equal(HResult.S_OK, document.GetChecksum(0, out actualCount, null)); byte[] actualChecksum = new byte[actualCount]; Assert.Equal(HResult.S_OK, document.GetChecksum(actualCount, out actualCount2, actualChecksum)); Assert.Equal(actualCount, actualCount2); AssertEx.Equal(checksum, actualChecksum); } else { Assert.Equal(HResult.S_FALSE, document.GetChecksum(0, out actualCount, null)); Assert.Equal(0, actualCount); } var guid = Guid.NewGuid(); Assert.Equal(HResult.S_OK, document.GetChecksumAlgorithmId(ref guid)); Assert.Equal(algorithmId != null ? new Guid(algorithmId) : default(Guid), guid); guid = Guid.NewGuid(); Assert.Equal(HResult.S_OK, document.GetLanguageVendor(ref guid)); Assert.Equal(new Guid("994b45c4-e6e9-11d2-903f-00c04fa302a1"), guid); guid = Guid.NewGuid(); Assert.Equal(HResult.S_OK, document.GetDocumentType(ref guid)); Assert.Equal(new Guid("5a869d0b-6611-11d3-bd2a-0000f80849bd"), guid); }
public SymDocument(ISymUnmanagedDocument doc) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } int len; doc.GetUrl(0, out len, null); if (len > 0) { var urlChars = new char[len]; doc.GetUrl(len, out len, urlChars); Url = new string(urlChars, 0, len - 1); } doc.GetChecksum(0, out len, null); if (len > 0) { Checksum = new byte[len]; doc.GetChecksum(len, out len, Checksum); } Guid id = Guid.Empty; doc.GetChecksumAlgorithmId(ref id); ChecksumAlgorithmId = id; }
public static void ValidateDocument(ISymUnmanagedDocument document, string url, string algorithmId, byte[] checksum) { ValidateDocumentUrl(document, url); int actualCount, actualCount2; if (checksum != null) { Assert.Equal(HResult.S_OK, document.GetChecksum(0, out actualCount, null)); byte[] actualChecksum = new byte[actualCount]; Assert.Equal(HResult.S_OK, document.GetChecksum(actualCount, out actualCount2, actualChecksum)); Assert.Equal(actualCount, actualCount2); AssertEx.Equal(checksum, actualChecksum); } else { Assert.Equal(HResult.S_FALSE, document.GetChecksum(0, out actualCount, null)); Assert.Equal(0, actualCount); } var guid = Guid.NewGuid(); Assert.Equal(HResult.S_OK, document.GetChecksumAlgorithmId(ref guid)); Assert.Equal(algorithmId != null ? new Guid(algorithmId) : default(Guid), guid); guid = Guid.NewGuid(); Assert.Equal(HResult.S_OK, document.GetLanguageVendor(ref guid)); Assert.Equal(new Guid("994b45c4-e6e9-11d2-903f-00c04fa302a1"), guid); guid = Guid.NewGuid(); Assert.Equal(HResult.S_OK, document.GetDocumentType(ref guid)); Assert.Equal(new Guid("5a869d0b-6611-11d3-bd2a-0000f80849bd"), guid); }
public SymDocument(ISymUnmanagedDocument doc) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } int len; var hr = doc.GetUrl(0, out len, null); ThrowExceptionForHR(hr); if (len > 0) { var urlChars = new char[len]; hr = doc.GetUrl(len, out len, urlChars); ThrowExceptionForHR(hr); Url = new string(urlChars, 0, len - 1); } hr = doc.GetChecksum(0, out len, null); ThrowExceptionForHR(hr); if (len > 0) { Checksum = new byte[len]; hr = doc.GetChecksum(len, out len, Checksum); ThrowExceptionForHR(hr); } var id = Guid.Empty; hr = doc.GetChecksumAlgorithmId(ref id); ThrowExceptionForHR(hr); ChecksumAlgorithmId = id; if (id == CorSym_SourceHash_MD5) { ChecksumAlgorithm = ChecksumAlgorithmKind.Md5; } else if (id == CorSym_SourceHash_SHA1) { ChecksumAlgorithm = ChecksumAlgorithmKind.Sha1; } }