本文整理汇总了C#中IList.All方法的典型用法代码示例。如果您正苦于以下问题:C# IList.All方法的具体用法?C# IList.All怎么用?C# IList.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.All方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileConfigurationStore
public FileConfigurationStore(IList<string> filePaths)
{
if (filePaths == null ||
filePaths.Count == 0 ||
!filePaths.All(c => !String.IsNullOrWhiteSpace(c)))
throw new ArgumentNullException("filePaths", "The parameter filePaths cannot be empty or contains empty string");
this.fileIniDataParser = new FileIniDataParser();
this.fileIniDataParser.Parser.Configuration.CommentString = "#";
this.filePaths = filePaths;
}
示例2: AddWatcher
public PropertyChangeWatcher AddWatcher(IList<string> propertyNames, Action handler)
{
Contract.Requires(handler != null);
Contract.Requires(propertyNames != null);
Contract.Requires(propertyNames.Count > 0);
Contract.Requires(propertyNames.AllUnique());
Util.ThrowUnless(propertyNames.All(name => OwnerType.HasPublicInstanceProperty(name)), "The target object does not contain one or more of the properties provided");
lock (_handlers)
{
foreach (var key in propertyNames)
{
Util.ThrowUnless<ArgumentException>(!IsWatching(key), "Must not already be watching property '{0}'".DoFormat(key));
}
if (_handlers.Count == 0)
{
_owner.PropertyChanged += _owner_PropertyChanged;
}
foreach (var propertyName in propertyNames)
{
_handlers[propertyName] = handler;
}
return this;
}
}
示例3: Create
internal static CompareResult Create(IList<StringDifferencePair> stringDifferenceEnumerable)
{
return Set(
stringDifferenceEnumerable.All(sd => sd.Similar),
stringDifferenceEnumerable
);
}
示例4: CleanOldFiles
private static void CleanOldFiles(IList<string> files, string referencesFile, string sourceFolder, bool needsExtending)
{
if (needsExtending)
{
files = files.Select(x => string.Format("{0}{1}", x, Program.NEEDS_EXTENDING_EXTENSION)).ToList();
}
var lines = File.ReadAllLines(referencesFile).ToList();
var stringBuilder = new StringBuilder();
var linesToRemove = lines
.Where(x => IsAReferenceInFolderButNotSubfolder(x, sourceFolder) && files.All(y => y != GetFileName(x)))
.ToList();
foreach (var line in linesToRemove)
{
lines.Remove(line);
}
var linesToAdd = files
.Where(x => lines.All(y => GetFileName(y) != x))
.Select(x => string.Format("/// <reference path=\"{0}/{1}.ts\" />", sourceFolder.Replace('\\', '/'), x))
.ToList();
lines.AddRange(linesToAdd);
if (linesToRemove.Any() || linesToAdd.Any()) {
File.WriteAllLines(referencesFile, lines);
}
}
示例5: Convert
public static IEnumerable<EntitySet> Convert(
IList<EntitySet> sourceEntitySets,
Version targetEntityFrameworkVersion,
string providerInvariantName,
string providerManifestToken,
IDbDependencyResolver dependencyResolver)
{
Debug.Assert(sourceEntitySets != null, "sourceEntitySets != null");
Debug.Assert(sourceEntitySets.All(e => e.DefiningQuery == null), "unexpected defining query");
Debug.Assert(!string.IsNullOrWhiteSpace(providerInvariantName), "invalid providerInvariantName");
Debug.Assert(!string.IsNullOrWhiteSpace(providerManifestToken), "invalid providerManifestToken");
Debug.Assert(dependencyResolver != null, "dependencyResolver != null");
if (!sourceEntitySets.Any())
{
// it's empty anyways
return sourceEntitySets;
}
var providerServices = dependencyResolver.GetService<DbProviderServices>(providerInvariantName);
Debug.Assert(providerServices != null, "providerServices != null");
var transientWorkspace =
CreateTransientMetadataWorkspace(
sourceEntitySets,
targetEntityFrameworkVersion,
providerInvariantName,
providerManifestToken,
providerServices.GetProviderManifest(providerManifestToken));
return sourceEntitySets.Select(
e => CloneWithDefiningQuery(
e,
CreateDefiningQuery(e, transientWorkspace, providerServices)));
}
示例6: Compare
private static IEnumerable<Sim> Compare(Quest fromQuest, string[] fromRoute, IList<Quest> questDB)
{
DolRoute EL = new DolRoute();
var simList = new List<Sim>();
questDB.All(quest =>
{
if (quest.ID == fromQuest.ID)
return true;
if (quest.RouteForSim.Count != 0)
{
var min = quest.RouteForSim.Min(route =>
{
if (route.Count < 2)
return 2001;
var value = EL.Compute(fromRoute, route.ToArray());
return value;
});
if (min < 2000)
{
simList.Add(new Sim()
{
CompareID = quest.ID,
QuestID = fromQuest.ID,
Value = min,
StartCity = EL.GetCityID(fromRoute[0])
});
}
}
return true;
});
return simList.OrderBy(sim => sim.Value).Take(300);
}
示例7: SlowButSureAssertCollected
static void SlowButSureAssertCollected(IList<WeakReference> nextIterationHolder) {
GC.GetTotalMemory(true);
if(nextIterationHolder.All(wr => !wr.IsAlive))
return;
GC.Collect();
if(nextIterationHolder.All(wr => !wr.IsAlive))
return;
GC.GetTotalMemory(true);
var notCollected = nextIterationHolder.Select(wr => wr.Target).Where(t => t != null).ToArray();
if(notCollected.Length == 0)
return;
var objectsReport = string.Join("\n", notCollected.GroupBy(o => o.GetType()).OrderBy(gr => gr.Key.FullName)
.Select(gr => string.Format("\t{0} object(s) of type {1}:\n{2}", gr.Count(), gr.Key.FullName
, string.Join("\n", gr.Select(o => o.ToString()).OrderBy(s => s).Select(s => string.Format("\t\t{0}", s)))
)));
throw new Exception(string.Format("{0} garbage object(s) not collected:\n{1}", notCollected.Length, objectsReport));
}
示例8: ContainsRequiredHeaders
private bool ContainsRequiredHeaders(IList<string> headers)
{
var requiredHeaders = new List<string>();
requiredHeaders.Add("header1");
requiredHeaders.Add("header2");
return headers.All(requiredHeaders.Contains) && headers.Count == requiredHeaders.Count;
}
示例9: ValidateBarcodes
public bool ValidateBarcodes(IList<string> barcodes)
{
if (barcodes == null)
{
return false;
}
return barcodes.All(b => m_productRepository.GetByBarcodes(b).IsNotEmpty());
}
示例10: TopScore
private static Language? TopScore(IList<AnalysisResult> source)
{
if (source.All(x => x.Score == 0))
{
return null;
}
return source?.Aggregate((l, r) => l.Score > r.Score ? l : r).Language;
}
示例11: LoadNextTheme
private static void LoadNextTheme(string currentThemeName, IList<Theme> allThemes)
{
if (allThemes.All(x => !x.Active)) return; // No active theme, so exit immediatly.
var idx = GetCurrentThemeIndex(allThemes, currentThemeName);
var themeToLoad = GetNextActiveTheme(allThemes, idx);
ThemeLoader.LoadTheme(themeToLoad);
}
示例12: HeightOf
protected static int HeightOf(IList<RectangularStep> upstream)
{
if (upstream == null || upstream.Count == 0) throw new ArgumentException();
int height = upstream[0].Height;
if (!upstream.All(step => step.Height == height)) throw new ArgumentException();
return height;
}
示例13: WidthOf
protected static int WidthOf(IList<RectangularStep> upstream)
{
if (upstream == null || upstream.Count == 0) throw new ArgumentException();
int width = upstream[0].Width;
if (!upstream.All(step => step.Width == width)) throw new ArgumentException();
return width;
}
示例14: GetDiscountAmount
public override double GetDiscountAmount(IList<BasketItem> items)
{
//If there is no bread, do not fuss
if (items.All(i => i.ItemType != BasketItemType.Milk))
{
return 0.0;
}
return items.First(i => i.ItemType == BasketItemType.Milk).Price;
}
示例15: BuildMessage
public string BuildMessage(IList<TeamCityModel> buildStatuses, out bool notify)
{
var success = buildStatuses.Count == _expectedBuildCount &&
buildStatuses.All(buildStatus => IsSuccesfullBuild(buildStatus.build));
notify = !success;
return success ? BuildSuccessMessage(buildStatuses.First().build) :
BuildFailureMessage(buildStatuses.Select(m => m.build).ToList());
}