本文整理汇总了C#中IPackage.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.Validate方法的具体用法?C# IPackage.Validate怎么用?C# IPackage.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackage
的用法示例。
在下文中一共展示了IPackage.Validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzePackage
internal void AnalyzePackage(IPackage package)
{
IEnumerable<IPackageRule> packageRules = Rules;
if (!String.IsNullOrEmpty(package.Version.SpecialVersion))
{
// If a package contains a special token, we'll warn users if it does not strictly follow semver guidelines.
packageRules = packageRules.Concat(new[] { new StrictSemanticVersionValidationRule() });
}
IList<PackageIssue> issues = package.Validate(packageRules).OrderBy(p => p.Title, StringComparer.CurrentCulture).ToList();
if (issues.Count > 0)
{
Console.WriteLine();
Console.WriteWarning(NuGetResources.PackageCommandPackageIssueSummary, issues.Count, package.Id);
foreach (var issue in issues)
{
PrintPackageIssue(issue);
}
}
}
示例2: AnalyzePackage
internal void AnalyzePackage(IPackage package)
{
var packageRules = new List<IPackageRule>();
foreach (var rule in Rules)
{
// Convert the aggregate DefaultPackageRules into a set of individual rules to allow for filtering.
// We cannot modify the DefaultPackageRules.Rules since it may be used by extensions, such as the "analyze" one.
if (rule is DefaultPackageRules)
{
packageRules.AddRange(DefaultPackageRules.RuleSet);
}
else
{
packageRules.Add(rule);
}
}
if (!String.IsNullOrEmpty(package.Version.SpecialVersion))
{
// If a package contains a special token, we'll warn users if it does not strictly follow semver guidelines.
packageRules.Add(new StrictSemanticVersionValidationRule());
}
if (!String.IsNullOrWhiteSpace(DisableRules))
{
var disabledRulesList = DisableRules.Split(new [] {';'}, StringSplitOptions.RemoveEmptyEntries);
packageRules.RemoveAll(rule => disabledRulesList.Any(disabled => string.Equals(rule.GetType().Name, disabled, StringComparison.OrdinalIgnoreCase)));
}
if (Verbosity == Verbosity.Detailed)
{
Console.WriteLine(LocalizedResourceManager.GetString("PackageCommandEnabledRules"), string.Join(";", packageRules.Select(rule => rule.GetType().Name)));
}
IList<PackageIssue> issues = package.Validate(packageRules).OrderBy(p => p.Title, StringComparer.CurrentCulture).ToList();
if (issues.Count > 0)
{
Console.WriteLine();
Console.WriteWarning(LocalizedResourceManager.GetString("PackageCommandPackageIssueSummary"), issues.Count, package.Id);
foreach (var issue in issues)
{
PrintPackageIssue(issue);
}
}
}