当前位置: 首页>>代码示例>>C#>>正文


C# IReadOnlyList.Where方法代码示例

本文整理汇总了C#中IReadOnlyList.Where方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyList.Where方法的具体用法?C# IReadOnlyList.Where怎么用?C# IReadOnlyList.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReadOnlyList的用法示例。


在下文中一共展示了IReadOnlyList.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateEntityTypes

        protected virtual void GenerateEntityTypes(
            IReadOnlyList<IEntityType> entityTypes, IndentedStringBuilder stringBuilder)
        {
            Check.NotNull(entityTypes, nameof(entityTypes));
            Check.NotNull(stringBuilder, nameof(stringBuilder));

            foreach (var entityType in entityTypes)
            {
                stringBuilder.AppendLine();

                GenerateEntityType(entityType, stringBuilder, GenerateEntityTypeOptions.Declared);
            }

            foreach (var entityType in entityTypes.Where(e => e.BaseType != null))
            {
                stringBuilder.AppendLine();

                GenerateEntityType(entityType, stringBuilder, GenerateEntityTypeOptions.BaseType);
            }

            foreach (var entityType in entityTypes.Where(e => e.GetForeignKeys().Any()))
            {
                stringBuilder.AppendLine();

                GenerateEntityType(entityType, stringBuilder, GenerateEntityTypeOptions.Relationships);
            }
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:27,代码来源:CSharpModelGenerator.cs

示例2: AppendUpdateOperation

        public override void AppendUpdateOperation(
            StringBuilder commandStringBuilder,
            string tableName,
            IReadOnlyList<ColumnModification> operations)
        {
            Check.NotNull(commandStringBuilder, "commandStringBuilder");
            Check.NotEmpty(tableName, "tableName");
            Check.NotNull(operations, "operations");

            var writeOperations = operations.Where(o => o.IsWrite).ToArray();
            var conditionOperations = operations.Where(o => o.IsCondition).ToArray();
            var readOperations = operations.Where(o => o.IsRead).ToArray();

            AppendUpdateCommandHeader(commandStringBuilder, tableName, writeOperations);
            if (readOperations.Length > 0)
            {
                AppendOutputClause(commandStringBuilder, readOperations);
            }
            AppendWhereClause(commandStringBuilder, conditionOperations);
            commandStringBuilder.Append(BatchCommandSeparator).AppendLine();

            if (readOperations.Length == 0)
            {
                AppendSelectAffectedCountCommand(commandStringBuilder, tableName);
            }
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:26,代码来源:SqlServerSqlGenerator.cs

示例3: FindBaseClassPattern

        public static string FindBaseClassPattern(IReadOnlyList<Node> nodes)
        {
            var classes = nodes.Where(x => x is ClassNode);
            var lists = classes.Select(x => (x as ClassNode)?.BaseClasses.Select(y => y.ToString())).ToList();

            var common = lists.Aggregate((a, b) => a.Intersect(b)).ToList();
            return common.Any() ? common.First() : null;
        }
开发者ID:davidkron,项目名称:DevArch,代码行数:8,代码来源:PatternFinder.cs

示例4: Sort

 private IReadOnlyList<IEntityType> Sort(IReadOnlyList<IEntityType> entityTypes)
 {
     var entityTypeGraph = new Multigraph<IEntityType, int>();
     entityTypeGraph.AddVertices(entityTypes);
     foreach (var entityType in entityTypes.Where(et => et.BaseType != null))
     {
         entityTypeGraph.AddEdge(entityType.BaseType, entityType, 0);
     }
     return entityTypeGraph.TopologicalSort();
 }
开发者ID:491134648,项目名称:EntityFramework,代码行数:10,代码来源:CSharpSnapshotGenerator.cs

示例5: getImageFromName

 Windows.Storage.StorageFile getImageFromName(string name, IReadOnlyList<Windows.Storage.StorageFile> files)
 {
     try {
         return files.Where(x => x.Name == name).First();
     }
     catch
     {
         return null;
     }
 }
开发者ID:mbellgb,项目名称:10Pass,代码行数:10,代码来源:pkpassHelpers.cs

示例6: ResolveId

        public virtual string ResolveId(string nameOrId, IReadOnlyList<Migration> migrations)
        {
            Check.NotEmpty(nameOrId, nameof(nameOrId));
            Check.NotNull(migrations, nameof(migrations));

            var candidates = IsValidId(nameOrId)
                ? migrations.Where(m => m.Id == nameOrId)
                    .Concat(migrations.Where(m => string.Equals(m.Id, nameOrId, StringComparison.OrdinalIgnoreCase)))
                : migrations.Where(m => GetName(m.Id) == nameOrId)
                    .Concat(migrations.Where(m => string.Equals(GetName(m.Id), nameOrId, StringComparison.OrdinalIgnoreCase)));

            var candidate = candidates.Select(m => m.Id).FirstOrDefault();
            if (candidate == null)
            {
                throw new InvalidOperationException(Strings.MigrationNotFound(nameOrId));
            }

            return candidate;
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:19,代码来源:MigrationIdGenerator.cs

示例7: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            foreach (IDocument input in inputs.Where(x => _where == null || _where(x)))
            {
                bool wrote = false;

                // WritePath
                string path = input.String(MetadataKeys.WritePath);

                // WriteFileName
                if (path == null && input.ContainsKey(MetadataKeys.WriteFileName)
                    && input.ContainsKey(MetadataKeys.RelativeFilePath))
                {
                    path = Path.Combine(Path.GetDirectoryName(input.String(MetadataKeys.RelativeFilePath)), input.String(MetadataKeys.WriteFileName));
                }

                // WriteExtension
                if (path == null && input.ContainsKey(MetadataKeys.WriteExtension)
                    && input.ContainsKey(MetadataKeys.RelativeFilePath))
                {
                    path = Path.ChangeExtension(input.String(MetadataKeys.RelativeFilePath), input.String(MetadataKeys.WriteExtension));
                }

                // Func
                if (path == null)
                {
                    path = _path(input);
                }

                if (path != null)
                {
                    path = Path.Combine(context.OutputFolder, path);
                    if (!string.IsNullOrWhiteSpace(path))
                    {
                        string pathDirectory = Path.GetDirectoryName(path);
                        if (!Directory.Exists(pathDirectory))
                        {
                            Directory.CreateDirectory(pathDirectory);
                        }
                        File.WriteAllText(path, input.Content);
                        context.Trace.Verbose("Wrote file {0}", path);
                        wrote = true;
                        yield return input.Clone(new Dictionary<string, object>
                        {
                            { MetadataKeys.DestinationFilePath, path }
                        });
                    }
                }
                if (!wrote)
                {
                    yield return input;
                }
            }
        }
开发者ID:tareq-s,项目名称:Wyam,代码行数:54,代码来源:WriteFiles.cs

示例8: FilterByMatchingFilter

        private static IReadOnlyList<Issue> FilterByMatchingFilter(
            IReadOnlyList<Issue> issues,
            string filter)
        {
            var regex = new Regex($".*{filter}.*", RegexOptions.IgnoreCase);

            return issues.Where(issue =>
                {
                    var allRelatedIssues = GetAllRelatedIssues(issue, issues).ToList();
                    var match = allRelatedIssues.Any(i => regex.IsMatch(i.Name));
                    return match;
                }).ToList();
        }
开发者ID:ursenzler,项目名称:TechnikPortfolio,代码行数:13,代码来源:IssueFilter.cs

示例9: RunCalculations

        public static IEnumerable<KeyedResult> RunCalculations(IEnumerable<Scene> input, IReadOnlyList<Calculation> calculations)
        {
            foreach (var scene in input)
            {
                foreach (var calc in calculations.Where(x => x.Variable == scene.VarName))
                {
                    calc.Accumulator.Add(calc.PeriodChoice.Calc(scene.Values));
                }
            }

            return
                calculations.Select(x => new KeyedResult { Result = x.StatCalculation.Calc(x.Accumulator), VarName = x.Variable });
        }
开发者ID:pianomanjh,项目名称:Milliman.FileCalc,代码行数:13,代码来源:Calculator.cs

示例10: DisplayMessage

 public DisplayMessage(string subject, DateTimeOffset? dateTimeReceived, Recipient from, IReadOnlyList<IAttachment> attachments)
 {
     Subject = subject;
     this.DateTimeReceived = (DateTimeOffset)dateTimeReceived;
     this.From = string.Format("{0} ({1})", from.EmailAddress.Name,
                     from.EmailAddress.Address);
     var a = attachments.Where(x => (x.ContentType == "application/octet-stream" || x.ContentType == "audio/x-wav") && !x.IsInline).FirstOrDefault();
     if (a != null)
     {
         this.Attachment = (a as FileAttachment).ContentBytes;
         this.TranscribedText = Task.Run(() => Transcribe(new MemoryStream(Attachment))).Result;
         Attachments = a.Name;
     }
 }
开发者ID:robcube,项目名称:DDD2.2,代码行数:14,代码来源:DisplayMessage.cs

示例11: OrderComponents

        private void OrderComponents(IReadOnlyList<IGraphicComponent> components, int realColumns, int realRows)
        {
            var cellWidth = Width / realColumns;
            var cellHeight = Height / realRows;
            var currentY = YPosition;

            for (var row = 0; row < realRows; row++)
            {
                var rowComponents = components.Where((c, i) => i >= row * realColumns && i < (row + 1) * realColumns);
                OrderRow(rowComponents, currentY, cellWidth, cellHeight);

                currentY += cellHeight;
            }
        }
开发者ID:Nexus87,项目名称:PokeClone,代码行数:14,代码来源:GridLayout.cs

示例12: PathTemplate

 /// <summary>
 /// Constructs a template from its textual representation, such as <c>shelves/*/books/**</c>.
 /// </summary>
 /// <param name="template">The textual representation of the template. Must not be null.</param>
 public PathTemplate(string template)
 {
     GaxPreconditions.CheckNotNull(template, nameof(template));
     _segments = template.Split(s_slashSplit).Select(Segment.Parse).ToList();
     _parameterSegments = _segments.Where(s => s.Kind != SegmentKind.Literal).ToList();
     int pathWildcardCount = _segments.Count(s => s.Kind == SegmentKind.PathWildcard);
     if (pathWildcardCount > 1)
     {
         throw new ArgumentException("Template contains multiple path wildcards", nameof(template));
     }
     _hasPathWildcard = pathWildcardCount != 0;
     _originalTemplate = template;
     ParameterNames = _parameterSegments.Select(x => x.Value).ToList().AsReadOnly();
 }
开发者ID:googleapis,项目名称:gax-dotnet,代码行数:18,代码来源:PathTemplate.cs

示例13: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            IRazorPageFactory pageFactory = new VirtualPathRazorPageFactory(context.InputFolder, context, _basePageType);
            List<IDocument> validInputs = inputs
                .Where(x => _ignorePrefix == null || !x.ContainsKey("SourceFileName") || !x.String("SourceFileName").StartsWith(_ignorePrefix))
                .ToList();

            // Compile the pages in parallel
            ConcurrentDictionary<IDocument, Tuple<ViewContext, ViewEngineResult>> compilationResults
                = new ConcurrentDictionary<IDocument, Tuple<ViewContext, ViewEngineResult>>();
            Parallel.ForEach(validInputs, x =>
            {
                context.Trace.Verbose("Compiling Razor for {0}", x.Source);
                IViewStartProvider viewStartProvider = new ViewStartProvider(pageFactory, _viewStartPath?.Invoke(x));
                IRazorViewFactory viewFactory = new RazorViewFactory(viewStartProvider);
                IRazorViewEngine viewEngine = new RazorViewEngine(pageFactory, viewFactory);
                ViewContext viewContext = new ViewContext(null, new ViewDataDictionary(), null, x.Metadata, context, viewEngine);
                ViewEngineResult viewEngineResult;
                using (Stream stream = x.GetStream())
                {
                    viewEngineResult = viewEngine.GetView(viewContext, GetRelativePath(x), stream).EnsureSuccessful();
                }
                compilationResults[x] = new Tuple<ViewContext, ViewEngineResult>(viewContext, viewEngineResult);
            });

            // Now evaluate them in sequence - have to do this because BufferedHtmlContent doesn't appear to work well in multi-threaded parallel execution
            TaskScheduler exclusiveScheduler = new ConcurrentExclusiveSchedulerPair().ExclusiveScheduler;
            CancellationToken cancellationToken = new CancellationToken();
            return validInputs
                .Select(x =>
                {
                    using (context.Trace.WithIndent().Verbose("Processing Razor for {0}", x.Source))
                    {
                        Tuple<ViewContext, ViewEngineResult> compilationResult;
                        if (compilationResults.TryGetValue(x, out compilationResult))
                        {
                            using (StringWriter writer = new StringWriter())
                            {
                                compilationResult.Item1.View = compilationResult.Item2.View;
                                compilationResult.Item1.Writer = writer;
                                Task.Factory.StartNew(() => compilationResult.Item2.View.RenderAsync(compilationResult.Item1),
                                    cancellationToken, TaskCreationOptions.None, exclusiveScheduler).Unwrap().GetAwaiter().GetResult();
                                return x.Clone(writer.ToString());
                            }
                        }
                        context.Trace.Warning("Could not find compilation result for {0}", x.Source);
                        return null;
                    }
                });
        }
开发者ID:mgnslndh,项目名称:Wyam,代码行数:50,代码来源:Razor.cs

示例14: SetupViewModel

        public void SetupViewModel(PipeTest current, BindingList<Category> CategoryTypes, IReadOnlyList<PipeTest> pipeTests) 
        {
            this.CategoryTypes = CategoryTypes;
            IList<PipeTest> list = pipeTests.Where(_ => _.IsActive && !String.IsNullOrEmpty( _.Code)).OrderBy(x => x.Code).ToList<PipeTest>();
            RepeatTestCandidates = new BindingList<Domain.Entity.Setup.PipeTest>(list);
            pipeTest = new PipeTest();

            if (current != null)
            {
                pipeTest.CustomShallowCopy(current);
                if (current.Id != Guid.Empty)
                {
                    PipeTest curr = RepeatTestCandidates.Where(s => s.Id == pipeTest.Id).SingleOrDefault();
                    RepeatTestCandidates.Remove(curr);
                }
            }
        }
开发者ID:AleksMorozova,项目名称:prizm,代码行数:17,代码来源:MillInspectionViewModel.cs

示例15: FilterByKompetenz

        private static IReadOnlyList<Issue> FilterByKompetenz(IReadOnlyList<Issue> issues, IReadOnlyList<string> kompetenzen)
        {
            if (!kompetenzen.Any())
            {
                return issues;
            }

            issues = issues
                .Where(i => 
                    i.Kompetenzen
                        .Select(x => x.ToLowerInvariant())
                        .Intersect(
                            kompetenzen.Select(x => x.ToLowerInvariant()))
                    .Any())
                .ToList();
            return issues;
        }
开发者ID:ursenzler,项目名称:TechnikPortfolio,代码行数:17,代码来源:IssueFilter.cs


注:本文中的IReadOnlyList.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。