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


C# IReadOnlyCollection.Where方法代码示例

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


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

示例1: FilterList

 private IEnumerable<INamedItemInfo> FilterList(IReadOnlyCollection<INamedItemInfo> items, Selector selector) {
     switch (selector) {
         case Selector.Dollar:
             return items.Where(x => !x.Name.StartsWith("@", StringComparison.Ordinal));
         case Selector.At:
             return items.Where(x => x.Name.StartsWith("@", StringComparison.Ordinal))
                         .Select(x => new ReplacementItemInfo(x, x.Name.Substring(1)));
     }
     return items;
 }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:10,代码来源:WorkspaceVariableCompletionProvider.cs

示例2: GetMenuItems

        private static List<ActivityListItem> GetMenuItems(IReadOnlyCollection<ActivityListItem> activities, string prefix)
        {
            // Get menu items at this level
            var items = activities.Where(a => a.IsMenuItem);

            // Get Submenus at this level, but we only need 1 of each
            var submenus = activities.Where(a => a.IsSubMenu).Distinct(new ActivityListItem.NameComparer());

            // Combine, sort, return
            return items.Union(submenus).OrderBy(a => a.Name).ToList();
        }
开发者ID:Dexyon,项目名称:ViewPagerIndicator,代码行数:11,代码来源:ListSamples.cs

示例3: GetAllValidators

 public static Dictionary<Type, Type> GetAllValidators(IReadOnlyCollection<Type> types)
 {
     return types
         .Where(type => type.BaseType != null
                 && type.BaseType.IsGenericType
                 && type.BaseType.GetGenericTypeDefinition() == typeof(AbstractValidator<>))
         .ToDictionary(type => type.BaseType.GenericTypeArguments.First(), type => type);
 }
开发者ID:decojs,项目名称:QvcFluentValidation,代码行数:8,代码来源:Reflection.cs

示例4: Resolve

        private MethodInfo Resolve(IReadOnlyCollection<MethodInfo> candidates, string actionName, bool lowerCase)
        {
            if (lowerCase)
            {
                actionName = actionName.ToLowerInvariant();
            }
            BoltFramework.TrimAsyncPostfix(actionName, out actionName);

            return SelectByPriority(candidates.Where(m => CoerceMethodName(m.Name, lowerCase) == actionName));
        }
开发者ID:geffzhang,项目名称:Bolt,代码行数:10,代码来源:ActionResolver.cs

示例5: GetCombinations

        public static IEnumerable<List<Vector2>> GetCombinations(IReadOnlyCollection<Vector2> allValues)
        {
            var collection = new List<List<Vector2>>();
            for (var counter = 0; counter < (1 << allValues.Count); ++counter)
            {
                var combination = allValues.Where((t, i) => (counter & (1 << i)) == 0).ToList();

                collection.Add(combination);
            }

            return collection;
        }
开发者ID:DZ191,项目名称:LeagueSharp,代码行数:12,代码来源:PositioningHelper.cs

示例6: RemoveOwnedSourceItemsAsync

        public Task<IReadOnlyCollection<IProjectSourceItem>> RemoveOwnedSourceItemsAsync(
            IReadOnlyCollection<IProjectSourceItem> projectItems, DeleteOptions deleteOptions) {
            var projectDirectory = _unconfiguredProject.GetProjectDirectory();
            List<IProjectSourceItem> itemsInProjectFolder = projectItems
                .Where(item => !PathHelper.IsOutsideProjectDirectory(projectDirectory, item.EvaluatedIncludeAsFullPath))
                .ToList();

            return
                Task.FromResult(itemsInProjectFolder.Count == 0
                    ? projectItems
                    : projectItems.Except(itemsInProjectFolder).ToImmutableArray());
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:12,代码来源:FileSystemMirroringProjectSourceItemProviderExtensionBase.cs

示例7: GetMessagesFromStore

        /// <summary>
        /// Gets the selected messages from the store
        /// </summary>
        /// <param name="messageStore">The store to retrieve from</param>
        /// <param name="messageIds">The messages to retrieve</param>
        /// <returns></returns>
        private static IEnumerable<Message> GetMessagesFromStore(IAmAMessageStore<Message> messageStore, IReadOnlyCollection<string> messageIds)
        {
            IEnumerable<Message> foundMessages = messageIds 
                .Select(messageId => messageStore.Get(Guid.Parse(messageId)))
                .Where(fm => fm != null)
                .ToList();

            if (foundMessages.Count() < messageIds.Count)
            {
                throw new SystemException("Cannot find messages " +
                                          string.Join(",", messageIds.Where(id => foundMessages.All(fm => fm.Id.ToString() != id.ToString())).ToArray()));
            }
            return foundMessages;
        }
开发者ID:yonglehou,项目名称:Paramore,代码行数:20,代码来源:MessageRecovery.cs

示例8: BuildChartRow

 private StatsViewModel.Chart.ChartRow BuildChartRow(IReadOnlyCollection<Report> reportsForQuartal,
     DateTime dateTime)
 {
     var monthQuery = reportsForQuartal.Where(report => report.DateHappened.Month == dateTime.Month);
     var reports = monthQuery as Report[] ?? monthQuery.ToArray();
     var monthQueryCompleted = reports.Count(report => report.Status == ReportStatus.Completed);
     var monthQuerySummary = reports.Count();
     return new StatsViewModel.Chart.ChartRow
     {
         Month                 = dateTime.ToMonthName(),
         ReportsCount          = monthQuerySummary,
         CompletedReportsCount = monthQueryCompleted
     };
 }
开发者ID:gboduljak,项目名称:Emergy,代码行数:14,代码来源:StatsService.cs

示例9: OrderList

        private static CompletionList OrderList(IReadOnlyCollection<Completion> completions) {
            // Place 'name =' at the top prioritizing argument names
            // Place items starting with non-alpha characters like .Call and &&
            // at the end of the list.
            var argumentNames = completions.Where(x => RTokenizer.IsIdentifierCharacter(x.DisplayText[0]) && x.DisplayText.EndsWith("=", StringComparison.Ordinal));

            var rtvsNames = completions.Where(x => x.DisplayText.IndexOf(".rtvs") >= 0);
            var specialNames = completions.Where(x => !char.IsLetter(x.DisplayText[0]));
            specialNames = specialNames.Except(rtvsNames);

            var generalEntries = completions.Except(argumentNames);
            generalEntries = generalEntries.Except(rtvsNames);
            generalEntries = generalEntries.Except(specialNames);

            List<Completion> orderedCompletions = new List<Completion>();
            orderedCompletions.AddRange(argumentNames);
            orderedCompletions.AddRange(generalEntries);
            orderedCompletions.AddRange(specialNames);

            return new CompletionList(orderedCompletions);
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:21,代码来源:RCompletionSet.cs

示例10: ComputeStatsForQuartal

        public void ComputeStatsForQuartal(IReadOnlyCollection<Report> reportsForQuartal, StatsViewModel vm)
        { 
            List<StatsViewModel.Chart.ChartRow> chart = new List<StatsViewModel.Chart.ChartRow>();

            var currentMonthQuery = reportsForQuartal.Where(report => report.DateHappened.Month == DateTime.Now.Month);
            var monthQuery = currentMonthQuery as Report[] ?? currentMonthQuery.ToArray();

            var currentMonthCompleted  = monthQuery.Count(report => report.Status == ReportStatus.Completed);
            var currentMonthCreated    = monthQuery.Count(report => report.Status == ReportStatus.Created);
            var currentMonthProcessing = monthQuery.Count(report => report.Status == ReportStatus.Processing);
            var currentMonthFails      = monthQuery.Count(report => report.Status == ReportStatus.Failure);
            var currentMonthSummary    = monthQuery.Count();

            vm.ThisMonthNumbers = new StatsViewModel.Numbers
            {
                ReportsCount      = currentMonthSummary,
                ReportsCreated    = currentMonthCreated,
                ReportsCompleted  = currentMonthCompleted,
                ReportsProcessing = currentMonthProcessing,
                ReportsFailed     = currentMonthFails
            };
            vm.ThisMonthPercentages = new StatsViewModel.Percentages
            {
                AverageReportsCompleted  = (double)currentMonthCompleted  / (currentMonthSummary) * 100.0,
                AverageReportsProcessing = (double)currentMonthProcessing / (currentMonthSummary) * 100.0,
                AverageReportsFailure    = (double)currentMonthFails      / (currentMonthSummary) * 100.0
            };
            
            var offset = TimeSpan.FromDays(30);

            chart.Add(BuildChartRow(reportsForQuartal, DateTime.Now));

            for (int i = 0; i < 3; i++)
            {
                chart.Add(BuildChartRow(reportsForQuartal, DateTime.Now - offset));
                offset += TimeSpan.FromDays(30);
            }
            vm.ReportsChart = chart.AsReadOnly();
        }
开发者ID:gboduljak,项目名称:Emergy,代码行数:39,代码来源:StatsService.cs

示例11: CountHitE

 private static Tuple<int, Dictionary<int, bool>> CountHitE(Vector3 startPos, Vector3 endPos,
     IReadOnlyCollection<Obj_AI_Base> list)
 {
     var count = 0;
     var counted = new Dictionary<int, bool>();
     if (E.IsReady() && list.Count > 0)
     {
         foreach (var obj in list.Where(o => o.IsValidTarget(E.Range)))
         {
             var info = obj.ServerPosition.To2D().ProjectOn(startPos.To2D(), endPos.To2D());
             if (info.IsOnSegment &&
                 obj.ServerPosition.To2D().Distance(info.SegmentPoint, true) <=
                 Math.Pow(E.Width * 1.5f + obj.BoundingRadius / 3, 2))
             {
                 var pred = E.GetPrediction(obj);
                 var hitchancepercent = obj.Type == myHero.Type ? HitChancePercent(E.Slot) : 30;
                 if (pred.HitChancePercent >= hitchancepercent &&
                     pred.CastPosition.Distance(myHero, true) <= E.RangeSquared)
                 {
                     info = pred.CastPosition.To2D().ProjectOn(startPos.To2D(), endPos.To2D());
                     if (info.IsOnSegment &&
                         pred.CastPosition.To2D().Distance(info.SegmentPoint, true) <=
                         Math.Pow(E.Width + obj.BoundingRadius / 3, 2))
                     {
                         count++;
                         counted[obj.NetworkId] = true;
                     }
                 }
             }
         }
     }
     return new Tuple<int, Dictionary<int, bool>>(count, counted);
 }
开发者ID:mezer123,项目名称:EloBuddy,代码行数:33,代码来源:Program.cs

示例12: GetBestHitQ

 private BestPositionResult GetBestHitQ(IReadOnlyCollection<Obj_AI_Base> list, Obj_AI_Base target = null)
 {
     var bestResult = new BestPositionResult();
     if (Q.IsReady)
     {
         var checkTarget = target != null;
         foreach (var obj in list)
         {
             var pred = Q.GetPrediction(obj, new CustomSettings {Width = QAoeWidth});
             if (pred.HitChancePercent >= Q.HitChancePercent)
             {
                 var res = Q.ObjectsInLine(list.Where(o => !o.IdEquals(obj)).ToList(), obj);
                 if (!checkTarget || (res.Contains(target) || obj.IdEquals(target)))
                 {
                     var count = res.Count + 1;
                     if (bestResult.Hits < count)
                     {
                         bestResult.Hits = count;
                         bestResult.Position = pred.CastPosition;
                         bestResult.Target = obj;
                         if (bestResult.Hits == list.Count)
                         {
                             break;
                         }
                     }
                 }
             }
         }
     }
     return bestResult;
 }
开发者ID:lolscripts,项目名称:Otros,代码行数:31,代码来源:Orianna.cs

示例13: GetRelevantMethods

        /// <summary>
        /// Gets the relevant methods.
        /// </summary>
        /// <param name="actionType">Type of the action.</param>
        /// <param name="prefix">The prefix.</param>
        /// <param name="methods">The methods.</param>
        /// <returns></returns>
        private IEnumerable<OnAction> GetRelevantMethods(Type actionType, string prefix, IReadOnlyCollection<OnAction> methods)
        {
            //Optimalization
            if (methods.Count == 0)
                return Enumerable.Empty<OnAction>();

            var aliases = GetAliases(actionType)
                                .Select(x => prefix + x)
                                .ToList();

            return methods.Where(x => aliases.Any(name => name.Equals(x.Name, StringComparison.OrdinalIgnoreCase)) || prefix.Equals(x.Name, StringComparison.OrdinalIgnoreCase));
        }
开发者ID:StevenThuriot,项目名称:Nova,代码行数:19,代码来源:MethodCacheEntry.cs

示例14: ResolveRollbackActions

        private async Task<Dictionary<string, List<ScriptAction>>> ResolveRollbackActions(
            int stageId, 
            IEnumerable<ReleaseAction> actions, 
            IReadOnlyCollection<ScriptAction> scriptElements)
        {
            var rollbackActions = new Dictionary<string, List<ScriptAction>>();

            // Group the rollback action parameters
            var groupedRollbackActions =
                actions.OfType<RollbackBlock>()
                    .GroupBy(
                        g =>
                        string.Format(
                            g.DisplayNameIsMeaningful
                                ? this.meaningfulDisplayNameFolderFormat
                                : this.meaninglessDisplayNameFolderFormat, 
                            g.Sequence, 
                            g.ItemType, 
                            g.DisplayName))
                    .Select(s => new { s.Key, Item = s.First() })
                    .ToList();

            foreach (var rollbackGroup in groupedRollbackActions)
            {
                var rollbackScriptActions = new List<ScriptAction>();
                if (rollbackGroup.Item == null)
                {
                    continue;
                }

                /* Figure out which actions need rollback blocks
                   Normally, a rollback is attached to just the preceding action.
                   Rollback always blocks are attached to all of the actions in the script. Basically, if the script fails, it should always run that block.
                */
                IEnumerable<ScriptAction> scriptElementsToAttachRollbacks;
                if (rollbackGroup.Item.ItemType == BlockType.RollbackAlways)
                {
                    scriptElementsToAttachRollbacks = scriptElements.ToList();
                }
                else
                {
                    // Attach the rollback script to the action directly preceding it, and to all actions that happen after.
                    scriptElementsToAttachRollbacks =
                        scriptElements.Where(se => se.Sequence >= rollbackGroup.Item.Sequence - 1).ToList();
                }

                this.ScriptGenerationNotification?.Invoke(
                    this, 
                    GetContainerGenerationArgs(rollbackGroup.Item, ContainerStart));
                foreach (var rollbackAction in rollbackGroup.Item.SubItems.OfType<ReleaseAction>())
                {
                    this.ScriptGenerationNotification?.Invoke(
                        this, 
                        GetActionGenerationArgs(rollbackAction, ActionStart));
                    var component =
                        await this.componentRepo.GetComponentByIdAsync(rollbackAction.WorkflowActivityId, stageId);
                    await this.deployerToolRepo.WriteToolToDiskAsync(component.DeployerToolId, this.deployerToolsPath);
                    var action = CreateScriptAction(component, rollbackAction);
                    action.Sequence += rollbackGroup.Item.Sequence;
                    rollbackScriptActions.Add(action);
                    this.ScriptGenerationNotification?.Invoke(this, GetActionGenerationArgs(rollbackAction, ActionEnd));
                }

                foreach (var scriptElementToAttachRollback in scriptElementsToAttachRollbacks)
                {
                    scriptElementToAttachRollback.RollbackScripts.Add(rollbackGroup.Key, rollbackScriptActions);
                }

                rollbackActions.Add(rollbackGroup.Key, rollbackScriptActions);
                this.ScriptGenerationNotification?.Invoke(
                    this, 
                    GetContainerGenerationArgs(rollbackGroup.Item, ContainerEnd));
            }

            return rollbackActions;
        }
开发者ID:DanielBMann9000,项目名称:Migrate-assets-from-RM-server-to-VSTS,代码行数:76,代码来源:ScriptGenerator.cs

示例15: UpdateAnalyzers

        private void UpdateAnalyzers()
        {
            if (_analyzerItems == null)
            {
                // The set of AnalyzerItems hasn't been realized yet. Just signal that HasItems
                // may have changed.

                NotifyPropertyChanged("HasItems");
                return;
            }

            var project = _analyzersFolder.Workspace
                            .CurrentSolution
                            .GetProject(_analyzersFolder.ProjectId);

            if (project != null &&
                project.AnalyzerReferences != _analyzerReferences)
            {
                _analyzerReferences = project.AnalyzerReferences;

                _analyzerItems.BeginBulkOperation();

                var itemsToRemove = _analyzerItems
                                        .Where(item => !_analyzerReferences.Contains(item.AnalyzerReference))
                                        .ToArray();

                var referencesToAdd = _analyzerReferences
                                        .Where(r => !_analyzerItems.Any(item => item.AnalyzerReference == r))
                                        .ToArray();

                foreach (var item in itemsToRemove)
                {
                    _analyzerItems.Remove(item);
                }

                foreach (var reference in referencesToAdd)
                {
                    _analyzerItems.Add(new AnalyzerItem(_analyzersFolder, reference, _commandHandler.AnalyzerContextMenuController));
                }

                var sorted = _analyzerItems.OrderBy(item => item.AnalyzerReference.Display).ToArray();
                for (int i = 0; i < sorted.Count(); i++)
                {
                    _analyzerItems.Move(_analyzerItems.IndexOf(sorted[i]), i);
                }

                _analyzerItems.EndBulkOperation();

                NotifyPropertyChanged("HasItems");
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:51,代码来源:AnalyzerItemSource.cs


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