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


C# IReadOnlyCollection.SelectMany方法代码示例

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


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

示例1: CombineViewModels

        public static ObservableViewModel CombineViewModels(IViewModelServiceProvider serviceProvider, ModelContainer modelContainer, IReadOnlyCollection<ObservableViewModel> viewModels)
        {
            if (viewModels == null) throw new ArgumentNullException("viewModels");
            var combinedViewModel = new ObservableViewModel(serviceProvider, modelContainer, viewModels.SelectMany(x => x.Dirtiables));

            var rootNodes = new List<ObservableModelNode>();
            foreach (var viewModel in viewModels)
            {
                if (!(viewModel.RootNode is SingleObservableNode))
                    throw new ArgumentException(@"The view models to combine must contains SingleObservableNode.", "viewModels");

                viewModel.parent = combinedViewModel;
                var rootNode = (ObservableModelNode)viewModel.RootNode;
                rootNodes.Add(rootNode);
            }

            if (rootNodes.Count < 2)
                throw new ArgumentException(@"Called CombineViewModels with a collection of view models that is either empty or containt just a single item.", "viewModels");

            // Find best match for the root node type
            var rootNodeType = rootNodes.First().Root.Type;
            if (rootNodes.Skip(1).Any(x => x.Type != rootNodeType))
                rootNodeType = typeof(object);

            CombinedObservableNode rootCombinedNode = CombinedObservableNode.Create(combinedViewModel, "Root", null, rootNodeType, rootNodes, null);
            combinedViewModel.Identifier = new ObservableViewModelIdentifier(rootNodes.Select(x => x.ModelGuid));
            rootCombinedNode.Initialize();
            combinedViewModel.RootNode = rootCombinedNode;
            return combinedViewModel;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:30,代码来源:ObservableViewModel.cs

示例2: GetContextFeatures

 private static IEnumerable<ArrangeMetadataElement.ContextStateFeature> GetContextFeatures(IReadOnlyCollection<TestCaseMetadataElement> testCaseMetadataElements)
 {
     return testCaseMetadataElements.SelectMany(x => x.Arrange.Features.OfType<ArrangeMetadataElement.ContextStateFeature>())
                                    .Union(testCaseMetadataElements.SelectMany(x => x.Act.Features.OfType<ArrangeMetadataElement.ContextStateFeature>()));
 }
开发者ID:2gis,项目名称:nuclear-data-test,代码行数:5,代码来源:ContextEntityTypesProvider.cs

示例3: ExtractValues

        public static IReadOnlyCollection<int> ExtractValues(IReadOnlyCollection<Cell> cells)
        {
            var output = cells.SelectMany(cell => cell.PotentialValues).Distinct().ToList();

            return new ReadOnlyCollection<int>(output);
        }
开发者ID:cheng93,项目名称:Sudoku,代码行数:6,代码来源:Logic.cs

示例4: CreateBsplineCurve

        public static ICurve CreateBsplineCurve(IReadOnlyCollection<Vector4> controlPoints, IEnumerable knotVectorU, int order, bool isPeriodic, IModeler modeler)
        {
            var controlPointsList = controlPoints
                .SelectMany(p => new double[] {p.X, p.Y, p.Z, p.W}.ToArray())
                .ToArray();

            var dimensionControlPoints = BitConverter.GetBytes(4);
            var orderBytes = BitConverter.GetBytes((int) order);
            var numControlPointsBytes = BitConverter.GetBytes((int) controlPoints.Count);

            var periodicity = BitConverter.GetBytes(isPeriodic ? 1 : 0);

            var props = new[]
            {
                BitConverter.ToDouble(dimensionControlPoints.Concat(orderBytes).ToArray(), 0),
                BitConverter.ToDouble(numControlPointsBytes.Concat(periodicity).ToArray(), 0)
            };

            return (Curve) modeler.CreateBsplineCurve(props, knotVectorU, controlPointsList);
        }
开发者ID:Weingartner,项目名称:SolidworksAddinFramework,代码行数:20,代码来源:ModellerExtensions.cs

示例5: Get

        public static async Task<IReadOnlyList<Contribution>> Get(
            IReadOnlyCollection<CommitterGroup> committerGroups, IIssueService issueService)
        {
            Guard.AgainstNullArgument(nameof(committerGroups), committerGroups);
            Guard.AgainstNullArgument(nameof(issueService), issueService);

            return
                (await Task.WhenAll(committerGroups.SelectMany(group => @group.RepositoryList.Select(id =>
                {
                    log.InfoFormat("Getting issues for {@Repository}...", id);
                    return issueService.Get(id.Owner, id.Name).ContinueWith(task =>
                    {
                        if (task.Exception != null)
                        {
                            log.ErrorException("Failed to get issues for {@Repository}.", task.Exception.InnerException, id);
                            return Enumerable.Empty<Issue>();
                        }

                        log.InfoFormat("Got issues for {@Repository}.", id);
                        return task.Result;
                    });
                }))))
                .SelectMany(_ => _)
                .Select(issue => new { issue.Repository, Login = issue.Creator, issue.Created.LocalDateTime })
                .Distinct()
                .GroupBy(contribution => new
                {
                    Group = committerGroups.First(group => @group.RepositoryList.Contains(contribution.Repository)).Name,
                    contribution.Login
                })
                .Select(g => new Contribution(g.Key.Group, g.Key.Login, g.Sum(contribution => Score(contribution.LocalDateTime))))
                .ToList();
        }
开发者ID:ParticularLabs,项目名称:Uranium,代码行数:33,代码来源:ContributionService.cs

示例6: GetDoubleConditionFormatLsit

        /// <summary>
        /// 重複した条件付き書式を抽出しリスト化する
        /// </summary>
        /// <param name="conditionFormatLsit">条件付き書式の定義一覧</param>
        /// <returns>削除対象の定義一覧</returns>
        private static IEnumerable<string> GetDoubleConditionFormatLsit(
            IReadOnlyCollection<ConditionFormat> conditionFormatLsit)
        {
            var combinations = conditionFormatLsit.SelectMany(
                (x, i) => conditionFormatLsit.Skip(i + 1).Select(y => new List<ConditionFormat> {x, y}));

            return
                combinations.Where(x => x[0].Sqref == x[1].Sqref && x[0].RuleList == x[1].RuleList)
                    .Select(x => x[1].FullText)
                    .Distinct()
                    .ToList();
        }
开发者ID:yamatoya,项目名称:ExcelCleaner,代码行数:17,代码来源:Program.cs

示例7: ActorRegistry

        public ActorRegistry(IReadOnlyCollection<Tuple<ActorDescriptor, IRingBuffer, ActorId>> actors)
        {
            if (actors.Count > ActorId.MaxValue)
            {
                throw new ArgumentException("To many actors");
            }

            var messageTypesOrdered = actors.Select(t => t.Item1)
                .SelectMany(d => d.HandledMessageTypes)
                .Distinct()
                .OrderBy(t => t.TypeHandle.Value.ToInt64())
                .ToArray();

            if (messageTypesOrdered.Length == 0)
            {
                throw new ArgumentException("The handled messages set is empty. This is a useless registry");
            }

            _messageTypeDiff = messageTypesOrdered.First().TypeHandle.Value.ToInt64() - 1;

            var ringsGroupedByMessageId = actors.SelectMany(
                t =>
                    t.Item1.HandledMessageTypes.Select(
                        messageType => new {MessageTypeId = GetMessageTypeId(messageType), Buffer = t.Item2}))
                .GroupBy(a => a.MessageTypeId)
                .ToArray();

            var buffers = new List<IRingBuffer>();
            AddPadding(buffers);

            var count = ringsGroupedByMessageId.Length;
            var keys = new int[count];
            var values = new Tuple<int, int>[count];
            var index = 0;

            foreach (var g in ringsGroupedByMessageId)
            {
                keys[index] = g.Key;
                var start = buffers.Count;
                buffers.AddRange(g.Select(tuple => tuple.Buffer));
                var end = buffers.Count;
                var length = end - start;

                values[index] = Tuple.Create(start, length);
                index += 1;
            }

            AddPadding(buffers);

            // create one table
            var bufferArray = buffers.ToArray();
            var valuesArray =
                values.Select(tuple => new ArraySegment<IRingBuffer>(bufferArray, tuple.Item1, tuple.Item2)).ToArray();

            _messageTypeToBuffers = new IntLookup<ArraySegment<IRingBuffer>>(keys, valuesArray);

            // by actor
            var max = actors.Max(t => t.Item3.Value);
            _buffersByActor = new IRingBuffer[max + 1];

            foreach (var actor in actors)
            {
                _buffersByActor[actor.Item3.Value] = actor.Item2;
            }
        }
开发者ID:Scooletz,项目名称:RampUp,代码行数:65,代码来源:ActorRegistry.cs

示例8: ShipPartViewModel

 public ShipPartViewModel(IReadOnlyCollection<ShipPart> parts)
 {
     _parts = parts;
     CommonFlags = new HashSet<string>(_parts.SelectMany(s => s.Flags));
 }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:5,代码来源:ShipPartEditorViewModel.cs

示例9: FetchAllRequestedPackages

 private Task FetchAllRequestedPackages(IReadOnlyCollection<SpecificVersion> specificVersions) {
     var i = 0;
     var totalCount = specificVersions.Count;
     var lObject = new object();
     var allRemotes =
         specificVersions.SelectMany(x => FindRemotesWithPackage(x.GetFullName())).Distinct().ToArray();
     return
         SyncEvilGlobal.DownloadHelper.DownloadFilesAsync(allRemotes, StatusRepo,
             specificVersions.ToDictionary(x => new FileFetchInfo("packages/" + x.GetFullName() + ".json"),
                 x =>
                     (ITransferStatus)
                     new Status(x.GetFullName(), StatusRepo) {
                         RealObject = "packages/" + x + ".json",
                         OnComplete =
                             () => {
                                 lock (lObject)
                                     Progress.PackageFetching.Update(null, (++i).ToProgress(totalCount));
                                 return TaskExt.Default;
                             }
                     }),
             Repo.RootPath);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:22,代码来源:PackageManager.cs

示例10: SynchronizeCollections

 Task SynchronizeCollections(IReadOnlyCollection<Game> games) {
     if (Common.Flags.Verbose)
         MainLog.Logger.Info($"Syncing collections for games: {string.Join(", ", games.Select(x => x.Id))}");
     return
         _networkContentSyncer.SyncCollections(games.SelectMany(x => x.SubscribedCollections).ToArray(), false);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:6,代码来源:SetupGameStuff.cs


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