本文整理汇总了C#中IEnumerable.Each方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.Each方法的具体用法?C# IEnumerable.Each怎么用?C# IEnumerable.Each使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.Each方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SolutionGraph
public SolutionGraph(IEnumerable<Solution> solutions)
{
_allNugets = new Lazy<IEnumerable<NugetSpec>>(() => _solutions.SelectMany(x => x.PublishedNugets).ToList());
solutions.Each(s => _solutions[s.Name] = s);
solutions.Each(s => s.DetermineDependencies(FindNugetSpec));
_orderedSolutions = new Lazy<IList<Solution>>(() =>
{
var graph = new DependencyGraph<Solution>(s => s.Name, s => s.SolutionDependencies().Select(x => x.Name));
solutions.Each(graph.RegisterItem);
return graph.Ordered().ToList();
});
}
示例2: FubuMvcContext
public FubuMvcContext(IFubuMvcSystem system)
{
_system = system;
_contextualProviders = system.ContextualProviders ?? new IContextualInfoProvider[0];
_contextualProviders.Each(x => x.Reset());
}
示例3: ThreadSafeLocaleCache
public ThreadSafeLocaleCache(CultureInfo culture, IEnumerable<LocalString> strings)
{
_data = new Dictionary<LocalizationKey, string>();
strings.Each(s => _data.Add(new LocalizationKey(s.value), s.display));
_culture = culture;
}
示例4: GenerateType
public static Type GenerateType(Type baseType, IEnumerable<Type> interfaceTypes)
{
var newType = dynamicModule.DefineType(
Prefix + "." + baseType.GetName(),
TypeAttributes.AutoLayout | TypeAttributes.Public | TypeAttributes.Class,
baseType);
interfaceTypes.Each(interfaceType =>
{
newType.AddInterfaceImplementation(interfaceType);
interfaceType.GetMethods().Each(method =>
{
ImplementInterfaceMethod(newType, method);
});
});
baseType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Each(constructor =>
{
switch (constructor.Attributes & MethodAttributes.MemberAccessMask)
{
case MethodAttributes.Family:
case MethodAttributes.Public:
case MethodAttributes.FamORAssem:
ImplementConstructor(newType, constructor);
break;
}
});
return newType.CreateType();
}
示例5: CreateInclusionPolicy
public static FileInclusionPolicy CreateInclusionPolicy(IEnumerable<string> excludes = null, IEnumerable<string> includes = null)
{
var policy = new FileInclusionPolicy();
if (excludes != null) excludes.Each(policy.AddExclude);
if(includes != null) includes.Each(policy.AddInclude);
return policy;
}
示例6: AggregateResult
public AggregateResult(IEnumerable<GameResult> results)
{
_playerToScoreMap = new Dictionary<BotPlayer, int>();
results.SelectMany(x => x.Players).Each(x => _playerToScoreMap[x] = 0);
results.Each(result =>
{
if (result.IsTie)
{
result.Players.Each(player =>
{
_playerToScoreMap[player]++;
});
}
else
{
_playerToScoreMap[result.Winner] += 3;
}
});
var winners = _playerToScoreMap.GroupBy(x => x.Value).OrderByDescending(x => x.Key).First();
if (winners.Count() == _playerToScoreMap.Count)
{
IsTie = true;
}
else
{
Winner = winners.First().Key;
}
}
示例7: Activate
public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
{
var provider = new FileSystemVirtualPathProvider();
HostingEnvironment.RegisterVirtualPathProvider(provider);
packages.Each(x => x.ForFolder(FubuMvcPackages.WebContentFolder, provider.RegisterContentDirectory));
}
示例8: Activate
public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
{
ReadScriptConfig(FubuMvcPackageFacility.GetApplicationPath(), log);
packages.Each(p => p.ForFolder(BottleFiles.WebContentFolder, folder => ReadScriptConfig(folder, log)));
_assets.CompileDependencies(log);
}
示例9: Report
public void Report(IEnumerable<SuiteRunResult> executed)
{
var totalPasses = executed.Sum(x => x.Passes);
var totalFailures = executed.Sum(x => x.Failures);
var total = totalPasses + totalFailures;
_output.WriteLine("Loaded: {0}".FormatWith(executed.Select(s => s.Name).Join(", ")));
_output.WriteLine(" {0} {1} loaded.".FormatWith(
total,
"test".Pluralize(total)));
_output.WriteLine(" {0}/{1} {2} passed ({3} {4}).".FormatWith(
totalPasses,
total,
"test".Pluralize(total),
totalFailures,
"failure".Pluralize(totalFailures)));
if (totalFailures > 0)
_output.WriteLine("Failures: ");
executed.Each(suiteResult => suiteResult
.Results
.Where(containerResult => containerResult.Results.Any(r => !r.Pass))
.Each(f =>
{
_output.WriteLine(" {0}.{1} contained {2} failures.".FormatWith(suiteResult.Name, f.Name, f.Failures));
f.Results.Where(r => !r.Pass).Each(r => _output.WriteLine(" {0} failed. [{1}]".FormatWith(r.Name, r.Message)));
}));
_output.Flush();
}
示例10: EachWithFunc
public void EachWithFunc( IEnumerable<object> sut )
{
var copy = sut.ToList();
Func<object, bool> action = copy.Remove;
var results = sut.Each( action );
Assert.All( results, b => b.IsFalse( () => { throw new InvalidOperationException( "was not true." ); } ) );
}
示例11: Each
public void Each( IEnumerable<object> sut )
{
var count = 0;
Action<object> action = o => count++;
sut.Each( action );
Assert.Equal( sut.Count(), count );
}
示例12: Bootstrap
public IEnumerable<IActivator> Bootstrap(IPackageLog log)
{
_services = _inner.Bootstrap(log).Select(x => new BottleService(x, log));
_services.Each(x => x.Start());
return new IActivator[0];
}
示例13: Draw
public void Draw(IEnumerable<Card> cards)
{
cards.Each(card =>
{
RemoveCardFromDeck(card);
Player.AddCardToHand(card);
});
}
示例14: Discard
public void Discard(IEnumerable<Card> cards)
{
cards.Each(card =>
{
RemoveCardFromDeck(card);
Player.AddToDiscard(card);
});
}
示例15: applyBufferingToChildSectionLines
protected override void applyBufferingToChildSectionLines(IEnumerable<Line> sectionLines, int index)
{
if (isSubsequentLine(index))
{
var buffer = (Convert.ToChar(9475).ToString() + " ").PadLeft(_tabWidth);
sectionLines.Each(x => x.Prepend(buffer));
}
}