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


C# ICollection.Select方法代码示例

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


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

示例1: CombineSelectors

        private static IEnumerable<string> CombineSelectors(ICollection<string> parents, string child)
        {
            if (!child.Contains("&"))
                return parents.Select(p => p + " " + child);

            return parents.Select(p => child.Replace("&", p));
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:7,代码来源:ScssDocument.cs

示例2: WriteToStream

        public override void WriteToStream(ICollection<TableDefinition> tables, System.IO.StreamWriter output)
        {
            int tableCount = tables.Count;
            int columnCount = tables.Select(t => t.Columns.Count).Sum();
            int indexCount = tables.Select(t => t.Indexes.Count).Sum();
            int keyCount = tables.Select(t => t.ForeignKeys.Count).Sum();

            output.Write(GetMessage(tableCount, columnCount, indexCount, keyCount));
        }
开发者ID:remids,项目名称:fluentmigrator,代码行数:9,代码来源:SchemaTestWriter.cs

示例3: ConstructProvider

        private static Object ConstructProvider(Type providerType, ICollection<ConstructorArgumentElement> arguments)
        {
            foreach (var constructor in providerType.GetConstructors())
            {
                var parameters = constructor.GetParameters().ToArray();

                // not all arguments can be specified
                if (parameters.Select(param => param.Name).Intersect(arguments.Select(a => a.Name)).Count() != arguments.Count)
                    continue;

                // not enough arguments to call constructor
                if (parameters.Any(param => !(param.IsOptional || param.DefaultValue != null || arguments.Any(arg => arg.Name == param.Name))))
                    continue;

                // get correct arguments
                var invocationArguments = parameters
                    .OrderBy(param => param.Position)
                    .Select(p => new { Parameter = p, Argument = arguments.SingleOrDefault(a => a.Name == p.Name) })
                    .Select(pair => pair.Argument == null ? pair.Parameter.DefaultValue : pair.Argument.Value)
                    .ToArray();

                // invoke constructor
                return constructor.Invoke(invocationArguments);
            }
            return null;
        }
开发者ID:BackseatDevelopers,项目名称:BLocal,代码行数:26,代码来源:ProviderPairFactory.cs

示例4: Tags

        public static MvcHtmlString Tags(this HtmlHelper html, ICollection<Tag> tags, Func<string, MvcHtmlString> tagUrl)
        {
            var htmlTags = tags.Select(t => tagUrl(t.Name).ToHtmlString()).ToArray();
            var tagsStr = string.Join(", ", htmlTags);

            return MvcHtmlString.Create(tagsStr);
        }
开发者ID:KuuuPER,项目名称:RussianTeaClubSite,代码行数:7,代码来源:PagingHelpers.cs

示例5: CreatePersistenceModel

        public static AutoPersistenceModel CreatePersistenceModel(ICollection<RecordBlueprint> recordDescriptors)
        {
            if (recordDescriptors == null)
            {
                throw new ArgumentNullException("recordDescriptors");
            }

            return AutoMap.Source(new TypeSource(recordDescriptors))
                // Ensure that namespaces of types are never auto-imported, so that
                // identical type names from different namespaces can be mapped without ambiguity
                .Conventions.Setup(x => x.Add(AutoImport.Never()))

                //此处覆写Table("name"); 本来为统一处理表名(如增加前缀等),现由各个模块自己配置表名
                //.Conventions.Add(new RecordTableNameConvention(recordDescriptors))
                .Conventions.Add(new CacheConventions(recordDescriptors))
                .Alterations(alt =>
                {
                    foreach (var recordAssembly in recordDescriptors.Select(x => x.Type.Assembly).Distinct())
                    {
                        alt.Add(new AutoMappingOverrideAlteration(recordAssembly));
                    }
                    alt.AddFromAssemblyOf<DataModule>();
                    //alt.Add(new ContentItemAlteration(recordDescriptors));
                })
                .Conventions.AddFromAssemblyOf<DataModule>();
        }
开发者ID:akhuang,项目名称:Zing,代码行数:26,代码来源:AbstractDataServicesProvider.cs

示例6: TryGetSubscribers

        public bool TryGetSubscribers(ICollection<Type> contracts, out ICollection<Address> subscribers)
        {
            Mandate.ParameterNotNull(contracts, "contracts");

            locker.EnterReadLock();

            var allSubscriptions = new List<Address>();
            subscribers = allSubscriptions;

            try
            {
                foreach (var subscriptions in contracts.Select(GetSubscribers))
                {
                    if (subscriptions == null)
                        continue;

                    allSubscriptions.AddRange(subscriptions);
                }

                return allSubscriptions.Any();
            }
            finally
            {
                locker.ExitReadLock();
            }
        }
开发者ID:AdrianFreemantle,项目名称:Hermes,代码行数:26,代码来源:SubscriptionCache.cs

示例7: BuildAsync

        public Task<bool> BuildAsync(ICollection<Project> projects)
        {
            var projectHierarchy = projects.Select(project => project.GetHierarchy()).ToArray();
            var buildUpdateFlags = Enumerable.Repeat((uint)VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD, projectHierarchy.Length).ToArray();

            // Launches an asynchronous build operation and returns S_OK immediately if the build begins.
            // The result does not indicate completion or success of the build
            var updateErrorCode = _buildManager.StartUpdateSpecificProjectConfigurations(
                (uint)projects.Count,
                projectHierarchy,
                null,
                null,
                buildUpdateFlags,
                null,
                (uint)VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_BUILD,
                0);

            var tcs = new TaskCompletionSource<bool>();

            if (updateErrorCode == S_OK)
            {
                var builder = new ProjectAsyncBuilder(_buildManager, tcs);
                _buildManager.AdviseUpdateSolutionEvents(builder, out builder.UpdateSolutionEventsCookie);
            }
            else
            {
                tcs.SetResult(false);
            }

            return tcs.Task;
        }
开发者ID:AlexGhiondea,项目名称:dotnet-apiport,代码行数:31,代码来源:ProjectBuilder.cs

示例8: CreateBills

        public static Document CreateBills(ICollection<WordStatementInfo> statements, IProgressReporter progress, bool duplexMode)
        {
            if (statements == null) throw new ArgumentNullException("statements");

            progress = progress ?? new EmptyProgressReporter();

            progress.Caption = "Creating document";

            Dictionary<StatementKind, Range> sourceRanges = new Dictionary<StatementKind, Range>();
            try {
                foreach (var kind in statements.Select(s => s.Kind).Distinct()) {
                    var sd = Word.Documents.Open(
                        FileName: Path.Combine(WordExport.TemplateFolder, kind.ToString() + ".docx"),
                        ReadOnly: true,
                        AddToRecentFiles: false
                    );
                    // Fix Word 2013 bug
                    // http://blogs.msmvps.com/wordmeister/2013/02/22/word2013bug-not-available-for-reading/
                    sd.ActiveWindow.View.Type = WdViewType.wdPrintView;
                    sourceRanges.Add(kind, sd.Range());
                }

                Document doc = Word.Documents.Add();
                doc.ShowGrammaticalErrors = doc.ShowSpellingErrors = false;
                Range range = doc.Range();

                bool firstPage = true;
                using (new ClipboardScope()) {
                    var populator = new StatementPopulator();

                    progress.Maximum = statements.Count;
                    int i = 0;
                    foreach (var info in statements) {
                        if (progress.WasCanceled) return null;
                        progress.Progress = i;

                        progress.Caption = "Creating " + info.Kind.ToString().ToLower(Culture) + " for " + info.Person.VeryFullName;

                        if (firstPage)
                            firstPage = false;
                        else
                            range.BreakPage(forceOddPage: duplexMode);

                        sourceRanges[info.Kind].Copy();
                        range.Paste();

                        populator.Populate(range, info);
                        foreach (Shape shape in range.ShapeRange)
                            populator.Populate(shape.TextFrame.TextRange, info);

                        i++;
                    }
                }
                Word.Activate();
                doc.Activate();
                return doc;
            } finally {
                foreach (var sd in sourceRanges.Values) sd.Document.CloseDoc();
            }
        }
开发者ID:SyedArifulIslamEmon,项目名称:Billing,代码行数:60,代码来源:StatementGenerator.cs

示例9: PackAsync

		public async Task<byte[]> PackAsync(ICollection<ClientFile> files)
		{
			if (files == null) throw new ArgumentNullException("files");
			if (files.Count == 0) throw new ArgumentOutOfRangeException("files");

			var header = new StringBuilder();

			var totalBuffer = new byte[files.Select(f => f.Data.Length).Sum()];

			using (var output = new MemoryStream(totalBuffer))
			{
				foreach (var f in files)
				{
					var data = f.Data;
					await output.WriteAsync(data, 0, data.Length);

					if (header.Length > 0)
					{
						header.Append(FileSeparator);
					}
					header.Append(f.Name);
					header.Append(SizeSeparator);
					header.Append(data.Length);
				}

				var headerData = Encoding.Unicode.GetBytes(header.ToString());
				var headerSize = BitConverter.GetBytes(headerData.Length);

				return Utilities.Concat(headerSize, headerData, totalBuffer);
			}
		}
开发者ID:ppetrov,项目名称:iFSA.Service,代码行数:31,代码来源:PackageHelper.cs

示例10: WhichAuntSueSentTheGift

        /// <summary>
        /// Returns the number of the Aunt Sue that sent the gift from the specified Aunt Sue metadata.
        /// </summary>
        /// <param name="metadata">The metadata about all the Aunt Sues.</param>
        /// <param name="compensateForRetroEncabulator">Whether to compensate for the Retro Encabulator.</param>
        /// <returns>
        /// The number of the Aunt Sue which sent the gift based on forensic analysis of <paramref name="metadata"/>.
        /// </returns>
        internal static int WhichAuntSueSentTheGift(ICollection<string> metadata, bool compensateForRetroEncabulator = false)
        {
            var parsed = metadata.Select(AuntSue.Parse);

            foreach (var item in ForensicAnalysis)
            {
                if (compensateForRetroEncabulator && item.Value.Item2 != 0)
                {
                    if (item.Value.Item2 == 1)
                    {
                        parsed = parsed.Where((p) => !p.Metadata.ContainsKey(item.Key) || p.Metadata[item.Key] > item.Value.Item1);
                    }
                    else
                    {
                        parsed = parsed.Where((p) => !p.Metadata.ContainsKey(item.Key) || p.Metadata[item.Key] < item.Value.Item1);
                    }
                }
                else
                {
                    parsed = parsed.Where((p) => !p.Metadata.ContainsKey(item.Key) || p.Metadata[item.Key] == item.Value.Item1);
                }
            }

            return parsed.Single().Number;
        }
开发者ID:martincostello,项目名称:adventofcode,代码行数:33,代码来源:Day16.cs

示例11: UpdateMenuLinkLists

 private void UpdateMenuLinkLists(ICollection<webModels.MenuLinkList> linkLIsts)
 {
     foreach (var item in linkLIsts.Select(x => x.ToCoreModel()))
     {
         _menuService.Update(item);
     }
 }
开发者ID:shenge321,项目名称:vc-community,代码行数:7,代码来源:ContentExportImport.cs

示例12: GetMaximumTotalChangeInHappiness

        /// <summary>
        /// Gets the maximum total change in happiness for the specified potential happiness of the guests.
        /// </summary>
        /// <param name="potentialHappiness">A collection of potential guess happinesses.</param>
        /// <returns>The optional total change in happiness for the specified potentials.</returns>
        internal static int GetMaximumTotalChangeInHappiness(ICollection<string> potentialHappiness)
        {
            // Parse the input data
            IList<Potential> potentials = potentialHappiness
                .Select(ParsePotentialHappiness)
                .ToList();

            // Determine all of the possible seating arrangements
            List<string> names = potentials
                .Select((p) => p.Name)
                .Distinct()
                .ToList();

            // TODO Remove all permutations which are equal when considering the table is circular
            IList<IList<string>> permutations = Maths.GetPermutations(names)
                .Select((p) => new List<string>(p) as IList<string>)
                .ToList();

            // Key the happiness for each person for the people they could sit next to
            IDictionary<string, Dictionary<string, int>> happinesses = names.ToDictionary(
                (p) => p,
                (p) => potentials.Where((r) => r.Name == p).ToDictionary((r) => r.AdjacentName, (r) => r.Happiness));

            // Get the maximum potential happiness from all the seating arrangements
            return permutations
                .Select((p) => GetHappiness(p, happinesses))
                .Max();
        }
开发者ID:martincostello,项目名称:adventofcode,代码行数:33,代码来源:Day13.cs

示例13: ImportClients

        public void ImportClients(ICollection<MongoDb.Data.Models.Client> mongoClients)
        {
            var clients = mongoClients.Select(c => new Model.Client()
            {
                Address = c.Address,
                Contact = c.Contact,
                Email = c.Email,
                Mobile = c.Mobile,
                Name = c.Name
            });

            var counter = 0;
            foreach (var client in clients)
            {
                this.dbContext.Clients.Add(client);
                counter++;

                if (counter % 50 == 0)
                {
                    this.dbContext.SaveChanges();
                    this.dbContext.Dispose();
                    this.dbContext = new FurnitureFactoryDbContext();
                }
            }

            this.dbContext.SaveChanges();
        }
开发者ID:TelerikAcademyTeamTitanium,项目名称:DatabaseProject,代码行数:27,代码来源:FurnitureFactoryMsSqlImporter.cs

示例14: InstanceProxyException

        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceProxyException"/> class containing specified types which were problematic.
        /// </summary>
        /// <param name="types">The problematic types.</param>
        public InstanceProxyException(ICollection<IType> types)
        {
            Contract.Requires(types != null);
            Contract.Requires(types.Count > 0);

            this.namesOfTypes = types.Select(t => t.FullName).ToList();
        }
开发者ID:MainMa,项目名称:mockeverything,代码行数:11,代码来源:InstanceProxyException.cs

示例15: MailboxModel

        protected MailboxModel(int id, int tenant, IMailAddress address, IMailAccount account,
                            ICollection<IMailAddress> aliases, MailServerBase server)
            : base(new MailAccountBase(account), new MailAddressBase(address), (aliases.Select(a => new MailAddressBase(a)).ToList()))
        {
            if (id < 0)
                throw new ArgumentException("Invalid domain id", "id");

            if (tenant < 0)
                throw new ArgumentException("Invalid tenant id", "tenant");

            if (account == null)
                throw new ArgumentException("Invalid account", "account");

            if (address == null)
                throw new ArgumentException("Invalid address", "address");

            if (aliases == null)
                throw new ArgumentException("Invalid aliases", "aliases");

            if (server == null)
                throw new ArgumentException("Invalid server", "server");

            Id = id;
            Tenant = tenant;
            Account = account;
            Address = address;
            Aliases = aliases;
            Server = server;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:29,代码来源:MailboxModel.cs


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