本文整理汇总了C#中Array.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# Array.RemoveAll方法的具体用法?C# Array.RemoveAll怎么用?C# Array.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array.RemoveAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IdentifyAllPackages
//.........这里部分代码省略.........
}
var definitionFile = new PackageDefinition(packageDefinitionPath, !Graph.Instance.ForceDefinitionFileUpdate);
definitionFile.Read(true, enforceBamAssemblyVersions);
candidatePackageDefinitions.Add(definitionFile);
foreach (var newRepo in definitionFile.PackageRepositories)
{
if (Graph.Instance.PackageRepositories.Contains(newRepo))
{
continue;
}
packageRepos.Enqueue(newRepo);
}
}
}
// defaults come from
// - the master definition file
// - command line args (these trump the mdf)
// and only requires resolving when referenced
var packageDefinitions = new Array<PackageDefinition>();
PackageDefinition.ResolveDependencies(masterDefinitionFile, packageDefinitions, candidatePackageDefinitions);
// now resolve any duplicate names using defaults
// unless duplicates are allowed
var duplicatePackageNames = packageDefinitions.GroupBy(item => item.Name).Where(item => item.Count() > 1).Select(item => item.Key);
if ((duplicatePackageNames.Count() > 0) && !allowDuplicates)
{
var versionSpeciferArgs = new Options.PackageDefaultVersion();
var packageVersionSpecifiers = CommandLineProcessor.Evaluate(versionSpeciferArgs);
var toRemove = new Array<PackageDefinition>();
foreach (var dupName in duplicatePackageNames)
{
var duplicates = packageDefinitions.Where(item => item.Name == dupName);
PackageDefinition resolvedDuplicate = null;
// command line specifications take precedence to resolve a duplicate
foreach (var specifier in packageVersionSpecifiers)
{
if (!specifier.Contains(dupName))
{
continue;
}
foreach (var dupPackage in duplicates)
{
if (specifier[1] == dupPackage.Version)
{
resolvedDuplicate = dupPackage;
break;
}
}
if (resolvedDuplicate != null)
{
break;
}
var noMatchMessage = new System.Text.StringBuilder();
noMatchMessage.AppendFormat("Command line version specified, {0}, could not resolve to one of the available versions of package {1}:", specifier[1], duplicates.First().Name);
noMatchMessage.AppendLine();
foreach (var dup in duplicates)
{
noMatchMessage.AppendFormat("\t{0}", dup.Version);
noMatchMessage.AppendLine();
}
throw new Exception(noMatchMessage.ToString());
}
if (resolvedDuplicate != null)
{
toRemove.AddRange(packageDefinitions.Where(item => (item.Name == dupName) && (item != resolvedDuplicate)));
continue;
}
// now look at the master dependency file, for any 'default' specifications
var masterDependency = masterDefinitionFile.Dependents.Where(item => item.Item1 == dupName && item.Item3.HasValue && item.Item3.Value).FirstOrDefault();
if (null != masterDependency)
{
toRemove.AddRange(packageDefinitions.Where(item => (item.Name == dupName) && (item.Version != masterDependency.Item2)));
continue;
}
var resolveErrorMessage = new System.Text.StringBuilder();
resolveErrorMessage.AppendFormat("Unable to resolve to a single version of package {0}. Use --{0}.version=<version> to resolve. Available versions of the package are:", duplicates.First().Name);
resolveErrorMessage.AppendLine();
foreach (var dup in duplicates)
{
resolveErrorMessage.AppendFormat("\t{0}", dup.Version);
resolveErrorMessage.AppendLine();
}
throw new Exception(resolveErrorMessage.ToString());
}
packageDefinitions.RemoveAll(toRemove);
}
Graph.Instance.SetPackageDefinitions(packageDefinitions);
}