本文整理汇总了C#中Request.YieldPackageSource方法的典型用法代码示例。如果您正苦于以下问题:C# Request.YieldPackageSource方法的具体用法?C# Request.YieldPackageSource怎么用?C# Request.YieldPackageSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.YieldPackageSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolvePackageSources
/// <summary>
/// Resolves and returns Package Sources to the client.
///
/// Specified sources are passed in via the request object (<c>request.GetSources()</c>).
///
/// Sources are returned using <c>request.YieldPackageSource(...)</c>
/// </summary>
/// <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 ResolvePackageSources(Request request)
{
// TODO: improve this debug message that tells us what's going on.
request.Debug("Entering '{0}::ResolvePackageSources'", PackageProviderName);
foreach (var source in GetSource(request.Sources.ToArray()))
{
request.YieldPackageSource(source.Id, source.Value, false, source.Authenticated, false);
}
}
示例2: RemovePackageSource
public void RemovePackageSource(string name, Request request)
{
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::RemovePackageSource' '{1}'", PackageProviderName, name);
var pkgSource = packageSources.FirstOrDefault(each => each.name.EqualsIgnoreCase(name));
if (pkgSource == null) {
pkgSource = packageSources.FirstOrDefault(each => each.location.EqualsIgnoreCase(name));
}
if (pkgSource == null) {
request.Error(ErrorCategory.ObjectNotFound, name, Constants.Messages.UnableToResolveSource, name);
return;
}
// tell the user what we removed.
request.YieldPackageSource(pkgSource.name, pkgSource.location, pkgSource.isTrusted, true, pkgSource.isValidated);
//remove it from the list.
packageSources = packageSources.Where(each => each != pkgSource).ToArray();
}
示例3: ResolvePackageSources
public void ResolvePackageSources(Request request)
{
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::ResolvePackageSources'", PackageProviderName);
// todo: resolve package sources
if (request.PackageSources.Any()) {
// the system is requesting sources that match the values passed.
// if the value passed can be a legitimate source, but is not registered, return a package source marked unregistered.
packageSources.SerialForEach((each) => {
if (request.PackageSources.Any(s => each.name.EqualsIgnoreCase(s) || each.location.EqualsIgnoreCase(s))) {
request.YieldPackageSource(each.name, each.location, each.isTrusted, true, each.isValidated);
}
});
} else {
// the system is requesting all the registered sources
packageSources.SerialForEach((each) => {request.YieldPackageSource(each.name, each.location, each.isTrusted, true, each.isValidated);});
}
}
示例4: AddPackageSource
public void AddPackageSource(string name, string location, bool trusted, Request request)
{
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::AddPackageSource' '{1}','{2}','{3}'", PackageProviderName, name, location, trusted);
var pkgSource = packageSources.FirstOrDefault(each => each.name.EqualsIgnoreCase(name));
if (pkgSource != null && !request.GetOptionValue(Constants.Parameters.IsUpdate).IsTrue()) {
// pkgSource already exists.
// this is an error.
request.Error(ErrorCategory.ResourceExists, name, Constants.Messages.PackageSourceExists, name);
return;
}
if (pkgSource != null) {
//update
pkgSource.location = location;
pkgSource.isTrusted = trusted;
} else {
// add new
pkgSource = new PkgSource {
name = name,
location = location,
isTrusted = trusted,
isValidated = true
};
// add to the array.
packageSources = packageSources.ConcatSingleItem(pkgSource).ToArray();
}
request.YieldPackageSource(pkgSource.name, pkgSource.location, pkgSource.isTrusted, true, pkgSource.isValidated);
}