本文整理汇总了C#中Request.AddDependency方法的典型用法代码示例。如果您正苦于以下问题:C# Request.AddDependency方法的具体用法?C# Request.AddDependency怎么用?C# Request.AddDependency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.AddDependency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPackage
public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request)
{
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::FindPackage' '{1}','{2}','{3}','{4}','{5}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion, id);
var supplySourceToChainedProvider = new object[] {
new {
GetSources = new Func<IEnumerable<string>>(() => new string[] {"http://nuget.org/api/v2"})
}
, request
};
if (string.IsNullOrEmpty(name) || name == "zlib") {
var pkgs = request.ProviderServices.FindPackageByCanonicalId("nuget:zlib/1.2.8.7", supplySourceToChainedProvider).ToArray();
if (pkgs.Length > 0) {
var p = pkgs[0];
request.YieldSoftwareIdentity("zlib", p.Name, p.Version, p.VersionScheme, p.Summary, "built-in", "zlib", "", "");
foreach (var d in p.Dependencies) {
request.AddDependency(PackageProviderName, request.ProviderServices.ParsePackageName(d), request.ProviderServices.ParsePackageVersion(d), "built-in", null);
}
}
}
if (!string.IsNullOrEmpty(name) && name == "zlib.redist" && requiredVersion == "1.2.8.7") {
var pkgs = request.ProviderServices.FindPackageByCanonicalId("nuget:zlib.redist/1.2.8.7", supplySourceToChainedProvider).ToArray();
if (pkgs.Length > 0) {
var p = pkgs[0];
request.YieldSoftwareIdentity("zlib.redist", p.Name, p.Version, p.VersionScheme, p.Summary, "built-in", "zlib", "", "");
foreach (var d in p.Dependencies) {
request.AddDependency(PackageProviderName, request.ProviderServices.ParsePackageName(d), request.ProviderServices.ParsePackageVersion(d), "built-in", null);
}
}
}
}
示例2: FindPackage
public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request)
{
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::FindPackage' '{1}','{2}','{3}','{4}'", PackageProviderName, requiredVersion, minimumVersion, maximumVersion, id);
if (name == "test") {
// this just returns packages so we can test the calls for creating software identity objects back in the core.
var pkg = request.YieldSoftwareIdentity("firstpackage", "first", "1.0", "multipartnumeric", "first package", "built-in", "test", "", "");
if (pkg != null) {
if (request.IsCanceled) {
return;
} // check early, check often.
// add a dependency to another package.
var link = request.AddDependency(PackageProviderName, "second", "1.1", null, null);
if (request.IsCanceled) {
return;
} // check early, check often.
var entity = request.AddEntity("garrett", "http://fearthecowboy.com", Iso19770_2.Role.Publisher, null);
if (request.IsCanceled) {
return;
} // check early, check often.
var icon = request.AddLink(new Uri("http://contoso.com/icon.png"), "icon", "image/icon", null, null, null, null);
if (request.IsCanceled) {
return;
} // check early, check often.
request.AddMetadata("Something", "Shiny");
request.AddMetadata(pkg, "SomeKey", "SomeValue");
request.AddMetadata(pkg, new Uri("http://oneget.org/oneget"), "testkey", "testvalue");
if (request.IsCanceled) {
return;
} // check early, check often.
// some expected payload data
var payload = request.AddPayload();
request.Debug("Payload:{0}", payload);
if (request.IsCanceled) {
return;
} // check early, check often.
var dir = request.AddDirectory(payload, "installDir", "", "PROGRAMFILES", false);
request.Debug("Directory:{0}", dir);
if (request.IsCanceled) {
return;
} // check early, check often.
var file = request.AddFile(dir, "foo.txt", null, null, true, 10240, "1.0");
request.Debug("File:{0}", file);
if (request.IsCanceled) {
return;
} // check early, check often.
var regkey = request.AddResource(payload, "regkey");
request.AddMetadata(regkey, "key", "hklm/software/testing/foo");
request.AddMetadata(regkey, "value", "hklm/software/testing/foo");
if (request.IsCanceled) {
return;
} // check early, check often.
}
pkg = request.YieldSoftwareIdentity("secondpackage", "second", "1.1", "multipartnumeric", "second package", "built-in", "test", "", "");
if (pkg != null) {
if (request.IsCanceled) {
return;
} // check early, check often.
var entity = request.AddEntity("garrett", "http://fearthecowboy.com", Iso19770_2.Role.Publisher, null);
if (request.IsCanceled) {
return;
} // check early, check often.
// show some evidence (yeah, this should have been in the getinstalledpackages but ... lazy.)
var evidence = request.AddEvidence(DateTime.Now, "thispc");
request.AddProcess(evidence, "foo.exe", 100);
var meta = request.AddMeta(pkg);
request.AddMetadata(meta, "sample", "value");
request.AddMetadata(meta, new Uri("http://oneget.org/oneget"), "testkey", "testvalue");
var link = request.AddDependency(PackageProviderName, "third", "[1.0]", null, null);
}
}
}