本文整理汇总了C#中Request.AddTagId方法的典型用法代码示例。如果您正苦于以下问题:C# Request.AddTagId方法的具体用法?C# Request.AddTagId怎么用?C# Request.AddTagId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.AddTagId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YieldPackage
private bool YieldPackage(InstallPackage package, string filename, Request request) {
/*
var properties = package.ExecuteStringQuery("SELECT `Property` FROM `Property` ");
foreach (var i in properties) {
Debug.WriteLine("Property {0} = {1}", i, package.Property[i]);
}
*/
if (request.YieldSoftwareIdentity(filename, package.Property["ProductName"], package.Property["ProductVersion"], "multipartnumeric", package.Property["Summary"], filename, filename, filename, Path.GetFileName(filename)) != null) {
var trusted = request.ProviderServices.IsSignedAndTrusted(filename, request);
if (request.AddMetadata(filename, "FromTrustedSource", trusted.ToString()) == null ) {
return false;
}
if (request.AddMetadata(filename, "ProductCode", package.Property["ProductCode"]) == null) {
return false;
}
if (request.AddTagId(package.Property["ProductCode"].Trim(new char[] { '{', '}' })) == null)
{
return false;
}
if (request.AddMetadata(filename, "UpgradeCode", package.Property["UpgradeCode"]) == null) {
return false;
}
return true;
}
return false;
}
示例2: UninstallPackage
/// <summary>
/// Uninstalls a package
/// </summary>
/// <param name="fastPackageReference"></param>
/// <param name="request">
/// An object passed in from the CORE that contains functions that can be used to interact with
/// the CORE and HOST
/// </param>
public void UninstallPackage(string fastPackageReference, Request request) {
if( request == null ) {
throw new ArgumentNullException("request");
}
if( string.IsNullOrWhiteSpace(fastPackageReference) ) {
throw new ArgumentNullException("fastPackageReference");
}
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::UninstallPackage' '{1}'", ProviderName, fastPackageReference);
try {
Guid guid;
if (!Guid.TryParse(fastPackageReference, out guid)) {
request.Error(Microsoft.PackageManagement.Internal.ErrorCategory.InvalidArgument, fastPackageReference, Constants.Messages.UnableToResolvePackage, fastPackageReference);
return;
}
var product = ProductInstallation.GetProducts(fastPackageReference, null, UserContexts.All).FirstOrDefault();
if (product == null) {
request.Error(Microsoft.PackageManagement.Internal.ErrorCategory.InvalidArgument, fastPackageReference, Constants.Messages.UnableToResolvePackage, fastPackageReference);
return;
}
var productVersion = product.ProductVersion.ToString();
var productName = product.ProductName;
var summary = product["Summary"];
Installer.SetInternalUI(InstallUIOptions.UacOnly | InstallUIOptions.Silent);
_progressId = request.StartProgress(0, Resources.Messages.UninstallingMSIPackage, productName);
var handler = CreateProgressHandler(request, Resources.Messages.UnInstalling);
Installer.SetExternalUI(handler, InstallLogModes.Progress | InstallLogModes.Info);
Installer.InstallProduct(product.LocalPackage, "REMOVE=ALL REBOOT=REALLYSUPPRESS");
Installer.SetInternalUI(InstallUIOptions.Default);
Installer.SetExternalUI(handler, InstallLogModes.None);
// YieldPackage(product,fastPackageReference, request);
if (request.YieldSoftwareIdentity(fastPackageReference, productName, productVersion, "multipartnumeric", summary, "", fastPackageReference, "", "") != null) {
request.AddMetadata(fastPackageReference, "ProductCode", fastPackageReference);
request.AddTagId(fastPackageReference.Trim(new char[] { '{', '}' }));
}
request.Warning(Resources.Messages.UninstallRequireReboot);
} catch (Exception e) {
e.Dump();
}
request.CompleteProgress(_progressId, true);
_progressId = 0;
}