本文整理汇总了C#中IPackage.GetHash方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.GetHash方法的具体用法?C# IPackage.GetHash怎么用?C# IPackage.GetHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackage
的用法示例。
在下文中一共展示了IPackage.GetHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchPackageHash
/// <summary>
/// True if the given package matches PackageHash
/// </summary>
private bool MatchPackageHash(IPackage package)
{
return package != null && package.GetHash(HashProvider).Equals(PackageHash, StringComparison.OrdinalIgnoreCase);
}
示例2: ToODataEntryXElement
/// <summary>
/// Creates an OData entry XElement representation of the package.
/// </summary>
/// <param name="package">The package.</param>
/// <returns>The OData entry XElement.</returns>
private XElement ToODataEntryXElement(IPackage package)
{
string nsAtom = "http://www.w3.org/2005/Atom";
XNamespace nsDataService = "http://schemas.microsoft.com/ado/2007/08/dataservices";
string nsMetadata = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
string downloadUrl = string.Format(
CultureInfo.InvariantCulture,
"{0}package/{1}/{2}", _endPoint, package.Id, package.Version);
string entryId = string.Format(
CultureInfo.InvariantCulture,
"{0}Packages(Id='{1}',Version='{2}')",
_endPoint, package.Id, package.Version);
var entry = new XElement(XName.Get("entry", nsAtom),
new XAttribute(XNamespace.Xmlns + "d", nsDataService.ToString()),
new XAttribute(XNamespace.Xmlns + "m", nsMetadata.ToString()),
new XElement(XName.Get("id", nsAtom), entryId),
new XElement(XName.Get("title", nsAtom), package.Id),
new XElement(XName.Get("content", nsAtom),
new XAttribute("type", "application/zip"),
new XAttribute("src", downloadUrl)),
new XElement(XName.Get("properties", nsMetadata),
new XElement(nsDataService + "Version", package.Version),
new XElement(nsDataService + "PackageHash", package.GetHash("SHA512")),
new XElement(nsDataService + "PackageHashAlgorithm", "SHA512"),
new XElement(nsDataService + "Description", package.Description),
new XElement(nsDataService + "Listed", package.Listed)));
return entry;
}