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


C# IReadOnlyList.Select方法代码示例

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


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

示例1: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            if (_modules != null)
            {
                Dictionary<string, object> metadata = new Dictionary<string, object>();

                // Execute the modules for each input document
                if (_forEachDocument)
                {
                    return inputs.Select(input =>
                    {
                        foreach (IDocument result in context.Execute(_modules, new[] { input }))
                        {
                            foreach (KeyValuePair<string, object> kvp in result)
                            {
                                metadata[kvp.Key] = kvp.Value;
                            }
                        }
                        return input.Clone(metadata);
                    });
                }

                // Execute the modules once and apply to each input document
                foreach (IDocument result in context.Execute(_modules))
                {
                    foreach (KeyValuePair<string, object> kvp in result)
                    {
                        metadata[kvp.Key] = kvp.Value;
                    }
                }
                return inputs.Select(input => input.Clone(metadata));
            }

            return inputs.Select(x => x.Clone(new [] { new KeyValuePair<string, object>(_key, _metadata(x, context)) }));
        }
开发者ID:mgnslndh,项目名称:Wyam,代码行数:35,代码来源:Meta.cs

示例2: Save

        public static void Save(IReadOnlyList<Contribution> contributions)
        {
            Guard.AgainstNullArgument(nameof(contributions), contributions);

            using (var writer = new StreamWriter("contributions.txt", false))
            {
                writer.Write("Login/Group");
                foreach (var group in contributions.Select(contribution => contribution.Group).Distinct())
                {
                    writer.Write("\t" + @group);
                }

                writer.WriteLine();

                foreach (var login in contributions.Select(contribution => contribution.Login).Distinct())
                {
                    writer.Write(login);
                    foreach (var group in contributions.Select(contribution => contribution.Group).Distinct())
                    {
                        var contribution =
                            contributions.SingleOrDefault(
                                candidate => candidate.Group == @group && candidate.Login == login);

                        writer.Write(
                            "\t" +
                            (contribution?.Score.ToString(CultureInfo.InvariantCulture) ?? "0"));
                    }

                    writer.WriteLine();
                }
            }
        }
开发者ID:ParticularLabs,项目名称:Uranium,代码行数:32,代码来源:TsvContributionsRepository.cs

示例3: CanSynchronize

        public static bool CanSynchronize(IReadOnlyList<Ticker> tickers, ISimulationSettings settings, out string error)
        {
            if (tickers == null) throw new ArgumentNullException("tickers");
            if (settings == null) throw new ArgumentNullException("settings");

            if (tickers.Count == 0)
            {
                error = "There must be least one ticker.";
                return false;
            }

            if (tickers.Select(t => t.Name.ToLowerInvariant()).GroupBy(name => name).Count() < tickers.Count)
            {
                error = "Ticker names must be unique.";
                return false;
            }

            if (settings.Get<SimulationRangeSetting>().Type == SimulationRangeType.Common &&
                tickers.Select(t => t.From).Max() > tickers.Select(t => t.To).Min())
            {
                error = "Tickers do not have common range.";
                return false;
            }

            if (settings.Get<CommissionSetting>().Value < 0)
            {
                error = "Commission cannot be negative.";
                return false;
            }

            if (settings.Get<CommissionSetting>().Type == CommissionType.Percent &&
                settings.Get<CommissionSetting>().Value >= 100)
            {
                error = "Commission of percentage type must be smaller than 100 %.";
                return false;
            }

            if (settings.Get<SimulationRangeSetting>().Type == SimulationRangeType.FromToDates &&
                settings.Get<SimulationRangeSetting>().From > settings.Get<SimulationRangeSetting>().To)
            {
                error = "Simulation range is invalid.";
                return false;
            }

            if (settings.Get<InitialEquitySetting>().Value < 1)
            {
                error = "Initial equity cannot be smaller than 1.";
                return false;
            }

            if (settings.Get<SimulationRangeSetting>().Type == SimulationRangeType.FromToDates &&
                tickers.All(t => t.From > settings.Get<SimulationRangeSetting>().To || t.To < settings.Get<SimulationRangeSetting>().From))
            {
                error = "No quotes matching specified simulation time range.";
                return false;
            }

            error = null;
            return true;
        }
开发者ID:nabuk,项目名称:IstLight,代码行数:60,代码来源:SyncTickersFactory.cs

示例4: CreateItem

 public override Actuator CreateItem(LegacyMapBuilder context, Tile currentTile, IReadOnlyList<ActuatorItemData> matchedSequence)
 {
     return new SwitchSequenceActuator(
         context.GetWallPosition(matchedSequence[0].TilePosition, context.WallActuatorCreator.CurrentTile),
         matchedSequence.Select(context.GetTargetTile),
         matchedSequence.Select(x => x.GetActionStateX()))
     {
         UpTexture = context.WallTextures[matchedSequence[0].Decoration - 1],
         DownTexture = context.WallTextures[matchedSequence[1].Decoration - 1]
     }; ;
 }
开发者ID:ggrrin,项目名称:DungeonMaster,代码行数:11,代码来源:TimerSwitchFactory.cs

示例5: AggregateMetrics

        public AggregateMetrics(MetricName name, string unit, IReadOnlyList<MetricRunReport> runs)
        {
            Contract.Requires(runs != null);
            Contract.Requires(name != null);
            Contract.Requires(!string.IsNullOrEmpty(unit));
            Name = name;
            Unit = unit;
            Runs = runs == null || runs.Count == 0 ? GetSafeRuns(name, unit) : runs;

            Stats = new BenchmarkStat(runs.Select(x => x.MetricValue));
            PerSecondStats = new BenchmarkStat(runs.Select(x => x.MetricValuePerSecond));
        }
开发者ID:ThomasBombadil,项目名称:NBench,代码行数:12,代码来源:AggregateMetrics.cs

示例6: CreateItem

 public override Actuator CreateItem(LegacyMapBuilder context, Tile currentTile, IReadOnlyList<ActuatorItemData> matchedSequence)
 {
     Texture2D decoration;
     IConstrain constrain;
     Tile targetTile;
     context.PrepareActuatorData(matchedSequence[0], out targetTile, out constrain, out decoration, putOnWall: true);
     return new KeyHoleActuator(context.GetWallPosition(matchedSequence[0].TilePosition, context.WallActuatorCreator.CurrentTile),
         matchedSequence.Select(context.GetTargetTile),
         matchedSequence.Select(x => x.GetActionStateX()), constrain, destroyItem: true)
     {
         DecorationTexture = decoration
     };
 }
开发者ID:ggrrin,项目名称:DungeonMaster,代码行数:13,代码来源:MultiKeyHoleFactory.cs

示例7: WriteRows

        private static void WriteRows(this StringBuilder sb, IReadOnlyList<HelpRow> rows, int maxWidth)
        {
            const int indent = 4;
            var maxColumnWidth = rows.Select(r => r.Header.Length).Max();
            var helpStartColumn = maxColumnWidth + 2 * indent;

            var maxHelpWidth = maxWidth - helpStartColumn;
            if (maxHelpWidth < 0)
                maxHelpWidth = maxWidth;

            foreach (var row in rows)
            {
                var headerStart = sb.Length;

                sb.Append(' ', indent);
                sb.Append(row.Header);

                var headerLength = sb.Length - headerStart;
                var requiredSpaces = helpStartColumn - headerLength;

                sb.Append(' ', requiredSpaces);

                var words = SplitWords(row.Text);
                sb.WriteWordWrapped(words, helpStartColumn, maxHelpWidth);
            }
        }
开发者ID:TerabyteX,项目名称:corefxlab,代码行数:26,代码来源:HelpTextGenerator.cs

示例8: Update

		public void Update(IReadOnlyList<DomAssemblyName> references)
		{
			assemblyNames.Clear();
			if (references != null) {
				assemblyNames.AddRange(references.Select(r => new AssemblyReferenceModel(parentAssemblyModel, r)));
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:7,代码来源:AssemblyReferenceModel.cs

示例9: Build

        /// <summary>
        /// Builds a <see cref="GitHubPullRequest"/>.
        /// </summary>
        /// <param name="number">The pull request number.</param>
        /// <param name="lastCommitId">The last commit ID.</param>
        /// <param name="files">The files in the pull request.</param>
        /// <param name="diff">The full pull request unified diff.</param>
        /// <param name="branches">The <see cref="GitHubPullRequestBranches"/>.</param>
        /// <returns>A <see cref="GitHubPullRequest"/> object.</returns>
        public GitHubPullRequest Build(
            int number,
            string lastCommitId,
            IReadOnlyList<PullRequestFile> files,
            string diff,
            GitHubPullRequestBranches branches)
        {
            if (files == null)
            {
                throw new ArgumentNullException("files");
            }

            var diffs = this.parser.Split(diff);

            var pullRequestFiles =
                files.Select(
                    file =>
                    new GitHubPullRequestFile(
                        file.FileName,
                        (GitHubPullRequestFileStatus)Enum.Parse(typeof(GitHubPullRequestFileStatus), file.Status, true),
                        file.Changes,
                        diffs[file.FileName])).ToList();

            var pullRequest = new GitHubPullRequest(number, lastCommitId, pullRequestFiles, diff, branches);

            return pullRequest;
        }
开发者ID:OlegKleyman,项目名称:OctoStyle,代码行数:36,代码来源:PullRequestBuilder.cs

示例10: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            IRazorPageFactory pageFactory = new VirtualPathRazorPageFactory(context.InputFolder, context, _basePageType);
            IViewStartProvider viewStartProvider = new ViewStartProvider(pageFactory);
            IRazorViewFactory viewFactory = new RazorViewFactory(viewStartProvider);
            IRazorViewEngine viewEngine = new RazorViewEngine(pageFactory, viewFactory);

            return inputs.Select(x =>
            {
                ViewContext viewContext = new ViewContext(null, new ViewDataDictionary(), null, x.Metadata, context, viewEngine);
                string relativePath = "/";
                if (x.ContainsKey(MetadataKeys.RelativeFilePath))
                {
                    relativePath += x.String(MetadataKeys.RelativeFilePath);
                }
                ViewEngineResult viewEngineResult = viewEngine.GetView(viewContext, relativePath, x.Content).EnsureSuccessful();
                using (StringWriter writer = new StringWriter())
                {
                    viewContext.View = viewEngineResult.View;
                    viewContext.Writer = writer;
                    AsyncHelper.RunSync(() => viewEngineResult.View.RenderAsync(viewContext));
                    return x.Clone(writer.ToString());
                }
            });
        }
开发者ID:tareq-s,项目名称:Wyam,代码行数:25,代码来源:Razor.cs

示例11: Go

        public async Task<InvestigationResult> Go(IReadOnlyList<SourcePackageFile> files)
        {
            MakeNamesUnique(files);

            var results = files.Select(Process).ToArray();
            return new InvestigationResult(await Task.WhenAll(results));
        }
开发者ID:yavtech,项目名称:ICanHasDotnetCore,代码行数:7,代码来源:PackageCompatabilityInvestigator.cs

示例12: GetPermissions

        public Task<PermissionSet> GetPermissions(IReadOnlyList<SignatureEvidence> authentication, LedgerPath path, bool recursiveOnly, string recordName)
        {
            HashSet<string> identities = new HashSet<string>(authentication.Select(evidence => keyEncoder.GetPubKeyHash(evidence.PublicKey)), StringComparer.Ordinal);
            LedgerPath pathRecordName;

            // If the path is root and the record name is a tird-party asset owned by the current identity,
            // arbitrary modification of the balance is allowed
            if (LedgerPath.TryParse(recordName, out pathRecordName)
                && thirdPartyAssetPath.IsStrictParentOf(pathRecordName)
                && path.Segments.Count == 0
                && identities.Contains(pathRecordName.Segments[thirdPartyAssetPath.Segments.Count]))
            {
                return Task.FromResult(new PermissionSet(accountNegative: Access.Permit));
            }

            // Account /asset/p2pkh/[addr]/
            if (thirdPartyAssetPath.IsStrictParentOf(path)
                && path.Segments.Count == thirdPartyAssetPath.Segments.Count + 1
                && keyEncoder.IsP2pkh(path.Segments[path.Segments.Count - 1]))
            {
                Access ownAccount = identities.Contains(path.Segments[path.Segments.Count - 1]) && recordName != DynamicPermissionLayout.AclResourceName
                    ? Access.Permit : Access.Unset;

                return Task.FromResult(new PermissionSet(
                    accountModify: Access.Permit,
                    accountCreate: Access.Permit,
                    accountSpend: ownAccount,
                    dataModify: ownAccount));
            }
            else
            {
                return Task.FromResult(new PermissionSet());
            }
        }
开发者ID:juanfranblanco,项目名称:openchain,代码行数:34,代码来源:P2pkhIssuanceImplicitLayout.cs

示例13: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            DotlessConfiguration config = DotlessConfiguration.GetDefault();
            config.RootPath = context.InputFolder;
            config.Logger = typeof (LessLogger);

            EngineFactory engineFactory = new EngineFactory(config);
            ILessEngine engine = engineFactory.GetEngine();

            // TODO: Get rid of RefelectionMagic and this ugly hack as soon as dotless gets better external DI support
            engine.AsDynamic().Underlying.Cache = new LessCache(context.ExecutionCache);

            return inputs.Select(x =>
            {
                string path = x.Get<string>("SourceFilePath", null);
                string fileName = null;
                if (path != null)
                {
                    engine.CurrentDirectory = Path.GetDirectoryName(path);
                    fileName = Path.GetFileName(path);
                }
                else
                {
                    engine.CurrentDirectory = context.InputFolder;
                    fileName = Path.GetRandomFileName();
                }
                using (context.Trace.WithIndent().Verbose("Processing Less for {0}", path ?? "inline content"))
                {
                    string content = engine.TransformToCss(x.Content, fileName);
                    return x.Clone(content);
                }
            });
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:33,代码来源:Less.cs

示例14: Execute

        public override IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            var repositoryLocation = Repository.Discover(context.InputFolder);
            if (repositoryLocation == null)
                throw new ArgumentException("No git repository found");

            using (Repository repository = new Repository(repositoryLocation))
            {

                var data = GetCommitInformation(repository);
                var lookup = data.ToLookup(x => x.Path.ToLower());
                return inputs.Select(x =>
                {
                    string relativePath = GetRelativePath(Path.GetDirectoryName(Path.GetDirectoryName(repositoryLocation.ToLower())), x.Source.ToLower()); // yes we need to do it twice
                    if (!lookup.Contains(relativePath))
                        return x;

                    var commitsOfFile = lookup[relativePath]
                        .GroupBy(y => y.Author)
                        .ToDictionary(y => y.Key,
                                    y => y.OrderByDescending(z => z.AuthorDateTime).First())
                        .Select(y => y.Value)
                        .ToArray();

                    return x.Clone(new[]
                    {
                        new KeyValuePair<string, object>(_metadataName, commitsOfFile)
                    });
                }).ToArray(); // Don't do it lazy or Commit is disposed.
            }
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:31,代码来源:GitContributor.cs

示例15: PickSlices

        public List<Bitmap> PickSlices(IReadOnlyList<Bitmap> inputImages, Size sliceSize)
        {
            var edgeImages = inputImages.Select(grayscaleFilter.Apply).ToList();
             edgeImages.ForEach(edgeDetectionFilter.ApplyInPlace);

             var edgeDensityHistograms = edgeImages.Select(x => new HorizontalIntensityStatistics(x).Gray).ToList();

             var imagesAndHistograms = Enumerable.Range(0, inputImages.Count).Select(index => {
            return new ImagesAndHistogram {
               OriginalImage = inputImages[index],
               EdgeImage = edgeImages[index],
               EdgeDensityHistogram = edgeDensityHistograms[index],
               Rating = ratingCalculator.ComputeRating(inputImages[index], edgeDensityHistograms[index], sliceSize.Width, sliceSize.Height)
            };
             }).OrderBy(x => x.Rating).ToList();

             var sliceAspect = sliceSize.Width / (double)sliceSize.Height;
             foreach (var imagesAndHistogram in imagesAndHistograms) {
            var desiredWidth = (int)(imagesAndHistogram.OriginalImage.Height * sliceAspect);
            if (desiredWidth > imagesAndHistogram.OriginalImage.Width) {
               continue;
            }
            var range = thumbnailGeneratorUtilities.GetRangeOfWidth(imagesAndHistogram.EdgeDensityHistogram, desiredWidth);

            var horizontalCrop = new Crop(new Rectangle(range.Min, 0, range.Max - range.Min, imagesAndHistogram.OriginalImage.Height)).Apply(imagesAndHistogram.OriginalImage);
            var horizontalCrop24bpp = horizontalCrop.Clone(new Rectangle(Point.Empty, horizontalCrop.Size), PixelFormat.Format24bppRgb);
            imagesAndHistogram.SliceImage = horizontalCrop24bpp;
            var resizer = new ResizeBicubic(sliceSize.Width, sliceSize.Height);
            imagesAndHistogram.SliceImageResized = resizer.Apply(horizontalCrop24bpp);
             }

             return imagesAndHistograms.Where(x => x.SliceImageResized != null).Select(x => x.SliceImageResized).ToList();
        }
开发者ID:ItzWarty,项目名称:the-dargon-project,代码行数:33,代码来源:SlicePicker.cs


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