本文整理汇总了C#中IEnumerable类的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable类的具体用法?C# IEnumerable怎么用?C# IEnumerable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEnumerable类属于命名空间,在下文中一共展示了IEnumerable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Build
public string Build(BundleType type, IEnumerable<string> files)
{
if (files == null || !files.Any())
return string.Empty;
string bundleVirtualPath = this.GetBundleVirtualPath(type, files);
var bundleFor = BundleTable.Bundles.GetBundleFor(bundleVirtualPath);
if (bundleFor == null)
{
lock (s_lock)
{
bundleFor = BundleTable.Bundles.GetBundleFor(bundleVirtualPath);
if (bundleFor == null)
{
var nullOrderer = new NullOrderer();
Bundle bundle = (type == BundleType.Script) ?
new CustomScriptBundle(bundleVirtualPath) as Bundle :
new SmartStyleBundle(bundleVirtualPath) as Bundle;
bundle.Orderer = nullOrderer;
bundle.Include(files.ToArray());
BundleTable.Bundles.Add(bundle);
}
}
}
if (type == BundleType.Script)
return Scripts.Render(bundleVirtualPath).ToString();
return Styles.Render(bundleVirtualPath).ToString();
}
开发者ID:GloriousOnion,项目名称:SmartStoreNET,代码行数:33,代码来源:BundleBuilder.cs
示例2: Applies
public bool Applies(ShoppingCartQuantityProduct quantityProduct, IEnumerable<ShoppingCartQuantityProduct> cartProducts) {
if (DiscountPart == null) return false;
var now = _clock.UtcNow;
if (DiscountPart.StartDate != null && DiscountPart.StartDate > now) return false;
if (DiscountPart.EndDate != null && DiscountPart.EndDate < now) return false;
if (DiscountPart.StartQuantity != null &&
DiscountPart.StartQuantity > quantityProduct.Quantity)
return false;
if (DiscountPart.EndQuantity != null &&
DiscountPart.EndQuantity < quantityProduct.Quantity)
return false;
if (!string.IsNullOrWhiteSpace(DiscountPart.Pattern)) {
string path;
if (DiscountPart.DisplayUrlResolver != null) {
path = DiscountPart.DisplayUrlResolver(quantityProduct.Product);
}
else {
var urlHelper = new UrlHelper(_wca.GetContext().HttpContext.Request.RequestContext);
path = urlHelper.ItemDisplayUrl(quantityProduct.Product);
}
if (!path.StartsWith(DiscountPart.Pattern, StringComparison.OrdinalIgnoreCase))
return false;
}
if (DiscountPart.Roles.Any()) {
var user = _wca.GetContext().CurrentUser;
if (user.Has<UserRolesPart>()) {
var roles = user.As<UserRolesPart>().Roles;
if (!roles.Any(r => DiscountPart.Roles.Contains(r))) return false;
}
}
return true;
}
开发者ID:richinoz,项目名称:Orchard1.6,代码行数:32,代码来源:Discount.cs
示例3: Generate
public Dictionary<string, string> Generate(List<NameNode> idNameNodes, IEnumerable<string> excludedNames)
{
Generator.Reset();
int varCount = idNameNodes.Count;
string[] newNames = new string[varCount];
var newSubstitution = new Dictionary<string, string>();
for (int i = 0; i < varCount; i++)
{
string newName;
do
{
newName = Generator.Next();
}
while (excludedNames.Contains(newName) || NamesGenerator.CSharpKeywords.Contains(newName));
newNames[i] = newName;
}
int ind = 0;
foreach (NameNode v in idNameNodes)
if (!newSubstitution.ContainsKey(v.Name))
newSubstitution.Add(v.Name, newNames[ind++]);
return newSubstitution;
}
开发者ID:KvanTTT,项目名称:CSharp-Minifier,代码行数:26,代码来源:Substitutor.cs
示例4: Execute
/// <summary>
/// Executes this operation
/// </summary>
/// <param name="rows">The rows.</param>
/// <returns></returns>
public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
{
using (IDbConnection connection = Use.Connection(ConnectionStringName))
using (IDbTransaction transaction = connection.BeginTransaction())
{
foreach (Row row in new SingleRowEventRaisingEnumerator(this, rows))
{
using (IDbCommand cmd = connection.CreateCommand())
{
currentCommand = cmd;
currentCommand.Transaction = transaction;
PrepareCommand(currentCommand, row);
currentCommand.ExecuteNonQuery();
}
}
if (PipelineExecuter.HasErrors)
{
Warn("Rolling back transaction in {0}", Name);
transaction.Rollback();
Warn("Rolled back transaction in {0}", Name);
}
else
{
Debug("Committing {0}", Name);
transaction.Commit();
Debug("Committed {0}", Name);
}
}
yield break;
}
开发者ID:brumschlag,项目名称:rhino-tools,代码行数:35,代码来源:OutputCommandOperation.cs
示例5: BuildScriptTags
public IEnumerable<HtmlTag> BuildScriptTags(IEnumerable<string> scripts)
{
Func<string, string> toFullUrl = url => _request.ToFullUrl(url);
while (_queuedScripts.Any())
{
var asset = _queuedScripts.Dequeue();
if (_writtenScripts.Contains(asset)) continue;
_writtenScripts.Add(asset);
yield return new ScriptTag(toFullUrl, asset);
}
foreach (var x in scripts)
{
var asset = _finder.FindAsset(x);
if (asset == null)
{
yield return new ScriptTag(toFullUrl, null, x);
}
else if (!_writtenScripts.Contains(asset))
{
_writtenScripts.Add(asset);
yield return new ScriptTag(toFullUrl, asset, x);
}
}
}
开发者ID:joemcbride,项目名称:fubumvc,代码行数:29,代码来源:AssetTagBuilder.cs
示例6: SetUnmodifiedCommand
public SetUnmodifiedCommand(string sitePath, IEnumerable<DocumentFile> documents, IEnumerable<StaticFile> files, IEnumerable<LastRunDocument> lastRunState)
{
this.Documents = documents;
this.Files = files;
this.LastRunState = lastRunState;
this.SitePath = sitePath;
}
开发者ID:fearthecowboy,项目名称:tinysite,代码行数:7,代码来源:SetUnmodifiedCommand.cs
示例7: AddRoleClaims
public static void AddRoleClaims(IEnumerable<string> roles, IList<Claim> claims)
{
foreach (string role in roles)
{
claims.Add(new Claim(RoleClaimType, role, ClaimsIssuer));
}
}
开发者ID:Dyno1990,项目名称:TelerikAcademy-1,代码行数:7,代码来源:IdentityConfig.cs
示例8: RemoveAllRenameAnnotationsAsync
internal async Task RemoveAllRenameAnnotationsAsync(IEnumerable<DocumentId> documentWithRenameAnnotations, AnnotationTable<RenameAnnotation> annotationSet, CancellationToken cancellationToken)
{
foreach (var documentId in documentWithRenameAnnotations)
{
if (_renamedSpansTracker.IsDocumentChanged(documentId))
{
var document = _newSolution.GetDocument(documentId);
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
// For the computeReplacementToken and computeReplacementNode functions, use
// the "updated" node to maintain any annotation removals from descendants.
var newRoot = root.ReplaceSyntax(
nodes: annotationSet.GetAnnotatedNodes(root),
computeReplacementNode: (original, updated) => annotationSet.WithoutAnnotations(updated, annotationSet.GetAnnotations(updated).ToArray()),
tokens: annotationSet.GetAnnotatedTokens(root),
computeReplacementToken: (original, updated) => annotationSet.WithoutAnnotations(updated, annotationSet.GetAnnotations(updated).ToArray()),
trivia: SpecializedCollections.EmptyEnumerable<SyntaxTrivia>(),
computeReplacementTrivia: null);
_intermediateSolutionContainingOnlyModifiedDocuments = _intermediateSolutionContainingOnlyModifiedDocuments.WithDocumentSyntaxRoot(documentId, newRoot, PreservationMode.PreserveIdentity);
}
}
_newSolution = _intermediateSolutionContainingOnlyModifiedDocuments;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:25,代码来源:ConflictResolution.cs
示例9: CreateEvents
public Dictionary<string, List<Event>> CreateEvents(string calendarId, IEnumerable<CalendarItem> eventsToCreate)
{
var service = _GetCalendarService();
var eventsToBeCreated = eventsToCreate.Select(eventFromCalendarItem);
var created = new List<Event>();
var errored = new List<Event>();
foreach (var eventToBeCreated in eventsToBeCreated)
{
try {
Console.WriteLine(string.Format(" -- Creating EVENT [{0}] for dates [{1}]"
,eventToBeCreated.Summary, eventToBeCreated.Start.DateTime.Value));
var result = service.Events.Insert(eventToBeCreated, calendarId).Execute();
if (result.Id != null && result.Id != "")
{
created.Add(result);
}
}catch(Exception ex)
{
Console.WriteLine(ex);
errored.Add(eventToBeCreated);
}
}
return new Dictionary<string, List<Event>>()
{
{ "created", created },
{ "errored", errored}
};
}
开发者ID:greggigon,项目名称:outlook-google-calendar-sync,代码行数:29,代码来源:GoogleCalendar.cs
示例10: Announcement
public Announcement(string description, string type, string operatorName, DateTime? startDate, DateTime? endDate, Coordinate location, IEnumerable<string> modes)
{
this.OperatorName = operatorName;
this.Description = description;
this.StartDate = startDate;
this.EndDate = endDate;
this.Location = location;
this.Type = type;
this.Modes.AddRange(modes);
this.RelativeDateString = TimeConverter.ToRelativeDateString(StartDate, true);
if (modes != null)
{
if (modes.Select(x => x.ToLower()).Contains("bus"))
this.ModeImages.Add("/Images/64/W/ModeBus.png");
if (modes.Select(x => x.ToLower()).Contains("rail"))
this.ModeImages.Add("/Images/64/W/ModeRail.png");
if (modes.Select(x => x.ToLower()).Contains("taxi"))
this.ModeImages.Add("/Images/64/W/ModeTaxi.png");
if (modes.Select(x => x.ToLower()).Contains("boat"))
this.ModeImages.Add("/Images/64/W/ModeBoat.png");
if (!this.ModeImages.Any())
this.ModeImages.Add("/Images/64/W/ModeBus.png");
}
else
{
this.Modes.Add("bus");
this.ModeImages.Add("/Images/64/W/ModeBus.png");
}
}
开发者ID:CodeObsessed,项目名称:drumbleapp,代码行数:31,代码来源:Announcement.cs
示例11: Calculate
static IEnumerable<FileRiskFactor> Calculate(IEnumerable<FileModificationStatistics> statistics)
{
var riskFactors = new List<FileRiskFactor>();
foreach (var statistic in statistics)
{
var fileRiskFactor = new FileRiskFactor
{
CreatedAt = DateTime.Now,
FileName = statistic.FileName,
Statistics = statistic
};
var existingDuration = GetDaysDuration(statistic.FirstCommit.ModifiedAt, DateTime.Now);
var localStatistic = statistic;
foreach (var duration in statistic.OtherCommits.Select(commit => GetDaysDuration(localStatistic.FirstCommit.ModifiedAt, commit.ModifiedAt)))
{
fileRiskFactor.Score += Score(duration, existingDuration);
}
riskFactors.Add(fileRiskFactor);
}
return riskFactors;
}
开发者ID:stabbylambda,项目名称:BugPrediction,代码行数:27,代码来源:RiskFactorCalculator.cs
示例12: GenerateTestFixture
public string GenerateTestFixture(IEnumerable<Test> tests, string fileName)
{
var generator = new CodeGenerator(TemplateEnum.MbUnitTestFixture, TestText, MethodText, PropertyText, TypeText,
AssertText);
var code = generator.GenerateTestFixture(tests.ToList(), fileName);
return code;
}
开发者ID:lynchjames,项目名称:bdUnit,代码行数:7,代码来源:MbUnitCodeGenerator.cs
示例13: DecorateEnumerableForExecution
/// <summary>
/// Add a decorator to the enumerable for additional processing
/// </summary>
/// <param name="operation">The operation.</param>
/// <param name="enumerator">The enumerator.</param>
protected override IEnumerable<Row> DecorateEnumerableForExecution(IOperation operation, IEnumerable<Row> enumerator)
{
foreach (Row row in new EventRaisingEnumerator(operation, enumerator))
{
yield return row;
}
}
开发者ID:smoothdeveloper,项目名称:rhino-etl,代码行数:12,代码来源:SingleThreadedNonCachedPipelineExecuter.cs
示例14: PerformanceCounterInfo
public PerformanceCounterInfo(string name, PerformanceCounter performanceCounters, string alias, IEnumerable<ITag> tags)
{
_name = name;
_performanceCounters = performanceCounters;
_alias = alias;
_tags = (tags ?? new List<ITag>()).ToList();
}
开发者ID:dowc,项目名称:Influx-Capacitor,代码行数:7,代码来源:PerformanceCounterInfo.cs
示例15: AppUpdateControl
public AppUpdateControl(IEnumerable<IAppVersion> appVersions, Action<IAppVersion> updateAction)
{
this.NewestVersion = appVersions.First();
InitializeComponent();
this.AppIconImage.ImageFailed += (sender, e) => { this.AppIconImage.Source = new BitmapImage(new Uri("/Assets/windows_phone.png", UriKind.RelativeOrAbsolute)); };
this.AppIconImage.Source = new BitmapImage(new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".png"));
this.ReleaseNotesBrowser.Opacity = 0;
this.ReleaseNotesBrowser.Navigated += (sender, e) => { (this.ReleaseNotesBrowser.Resources["fadeIn"] as Storyboard).Begin(); };
this.ReleaseNotesBrowser.NavigateToString(WebBrowserHelper.WrapContent(NewestVersion.Notes));
this.ReleaseNotesBrowser.Navigating += (sender, e) =>
{
e.Cancel = true;
WebBrowserTask browserTask = new WebBrowserTask();
browserTask.Uri = e.Uri;
browserTask.Show();
};
this.InstallAETX.Click += (sender, e) =>
{
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".aetx", UriKind.Absolute);
webBrowserTask.Show();
};
this.InstallOverApi.Click += (sender, e) => {
this.Overlay.Visibility = Visibility.Visible;
updateAction.Invoke(NewestVersion);
};
}
开发者ID:bitstadium,项目名称:HockeySDK-Windows,代码行数:30,代码来源:AppUpdateControl.xaml.cs
示例16: Add
public void Add(IEnumerable<Interaction> set)
{
foreach (Interaction interaction in set)
{
Add(interaction);
}
}
开发者ID:Condeti,项目名称:spark,代码行数:7,代码来源:Export.cs
示例17: GetTarget
public static Obj_AI_Hero GetTarget(this Spell spell,
bool ignoreShields = true,
Vector3 from = default(Vector3),
IEnumerable<Obj_AI_Hero> ignoredChampions = null)
{
return TargetSelector.GetTarget(spell, ignoreShields, from, ignoredChampions);
}
开发者ID:juan2202,项目名称:LeagueSharp-Standalones,代码行数:7,代码来源:Extensions.cs
示例18: Organisation
public Organisation(
User createdByUser,
string name,
string description,
string website,
MediaResource avatar,
MediaResource background,
IEnumerable<string> categories,
DateTime createdDateTime,
Group parentGroup)
: base(createdByUser,
name,
createdDateTime,
parentGroup)
{
Check.RequireNotNull(categories != null, "categories");
InitMembers();
SetOrganisationDetails(
description,
website,
avatar,
background,
categories);
ApplyEvent(new DomainModelCreatedEvent<Organisation>(this, createdByUser, this));
}
开发者ID:Bowerbird,项目名称:bowerbird-web,代码行数:28,代码来源:Organisation.cs
示例19: UpdateMainDocument
private static Solution UpdateMainDocument(Document document, SyntaxNode root, MethodDeclarationSyntax method, IEnumerable<IGrouping<Document, ReferenceLocation>> documentGroups)
{
var mainDocGroup = documentGroups.FirstOrDefault(dg => dg.Key.Equals(document));
SyntaxNode newRoot;
if (mainDocGroup == null)
{
newRoot = root.ReplaceNode(method, method.AddModifiers(staticToken));
}
else
{
var diagnosticNodes = mainDocGroup.Select(referenceLocation => root.FindNode(referenceLocation.Location.SourceSpan)).ToList();
newRoot = root.TrackNodes(diagnosticNodes.Union(new[] { method }));
newRoot = newRoot.ReplaceNode(newRoot.GetCurrentNode(method), method.AddModifiers(staticToken));
foreach (var diagnosticNode in diagnosticNodes)
{
var token = newRoot.FindToken(diagnosticNode.GetLocation().SourceSpan.Start);
var tokenParent = token.Parent;
if (token.Parent.IsKind(SyntaxKind.IdentifierName)) continue;
var invocationExpression = newRoot.GetCurrentNode(diagnosticNode).FirstAncestorOrSelfOfType<InvocationExpressionSyntax>()?.Expression;
if (invocationExpression == null || invocationExpression.IsKind(SyntaxKind.IdentifierName)) continue;
var memberAccess = invocationExpression as MemberAccessExpressionSyntax;
if (memberAccess == null) continue;
var newMemberAccessParent = memberAccess.Parent.ReplaceNode(memberAccess, memberAccess.Name)
.WithAdditionalAnnotations(Formatter.Annotation);
newRoot = newRoot.ReplaceNode(memberAccess.Parent, newMemberAccessParent);
}
}
var newSolution = document.Project.Solution.WithDocumentSyntaxRoot(document.Id, newRoot);
return newSolution;
}
开发者ID:nagyistoce,项目名称:code-cracker,代码行数:30,代码来源:MakeMethodStaticCodeFixProvider.cs
示例20: AddDoseTimes
public void AddDoseTimes(IEnumerable<TimeOfDay> times)
{
foreach (var time in times)
{
AddDoseTime(time);
}
}
开发者ID:geekpivot,项目名称:HealthClinic.biz,代码行数:7,代码来源:MedicineWithDoses.cs
注:本文中的IEnumerable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论