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


C# ICollection.AddRange方法代码示例

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


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

示例1: ValidateMember

        private bool ValidateMember(ICustomAttributeProvider member, ValidationContext context, ICollection<ValidationResult> results, object value)
        {
            var originalCount = results.Count;
            results.AddRange(
                attributeProvider
                    .GetAttributes(member)
                    .Select(attribute => attribute.GetValidationResult(value, context))
                    .Where(result => result != ValidationResult.Success)
            );

            return results.Count > originalCount;
        }
开发者ID:tmont,项目名称:portoa,代码行数:12,代码来源:EntityValidator.cs

示例2: TryValidateObject

        /// <summary>
        /// Determines whether the specified object is valid using the validation context,
        /// validation results collection, and a value that specifies whether to validate
        /// all properties.
        /// </summary>
        /// <param name="instance">The object to validate.</param>
        /// <param name="validationContext">The context that describes the object to validate.</param>
        /// <param name="validationResults">A collection to hold each failed validation.</param>
        /// <param name="validateAllProperties">True to validate all properties; if false, only required attributes are validated.</param>
        /// <returns>True if the object validates; otherwise, false.</returns>
        public virtual bool TryValidateObject( object instance, IValidationContext validationContext, ICollection<IValidationResult> validationResults, bool validateAllProperties )
        {
            Arg.NotNull( instance, nameof( instance ) );
            Arg.NotNull( validationContext, nameof( validationContext ) );

            ValidationContext context;

            if ( !validationContext.TryGetService( out context ) )
                return true;

            var results = new List<ValidationResult>();
            var valid = Validator.TryValidateObject( instance, context, results, validateAllProperties );

            if ( validationResults != null )
                validationResults.AddRange( results.Select( r => new ValidationResultAdapter( r ) ) );

            return valid;
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:28,代码来源:ValidatorAdapter.cs

示例3: ComputeScore

 /// <summary>
 /// Score the race.
 /// </summary>
 public virtual void ComputeScore()
 {
     if(IsScored || Results.Count == 0)
     {
         return;
     }
     ScoresCollection = new List<TeamScore>();
     IDictionary<Team, TeamScore> scores = new Dictionary<Team, TeamScore>();
     IEnumerable<Team> teams = (from result in Results.Values
                               where result.Team != null
                               select result.Team).Distinct();
     foreach(Team team in teams)
     {
         scores[team] = new TeamScore(this, team);
     }
     // Add the runners to the school
     // Sort the results
     IEnumerable<Performance> results = Results.Values.Sorted();
     foreach(Performance result in results.Where(r => r.Team != null))
     {
         result.Points = 0;
         scores[result.Team].AddRunner(result);
     }
     //Tag runners on teams with fewer than five as scoreless
     //Tag runner 8 and beyond on each team as scorelss
     foreach(TeamScore score in scores.Values)
     {
         int runnerCount = score.Runners.Count();
         IEnumerable<Performance> scorelessRunners = Enumerable.Empty<Performance>();
         if(runnerCount < 5)
         {
             scorelessRunners = score.Runners;
         }
         else if(runnerCount > 7)
         {
             scorelessRunners = score.Runners.Skip(7);
         }
         foreach(Performance runner in scorelessRunners)
         {
             runner.Points = null;
         }
     }
     // Tag first runner on a complete team with a score as the winner
     Performance firstRunnerOnCompleteTeam = results.FirstOrDefault(r => r.HasPoints);
     if(firstRunnerOnCompleteTeam == default(Performance))
     {
         return;
     }
     firstRunnerOnCompleteTeam.Points = 1;
     // Tag each runner with their points
     results.Where(result => result.HasPoints)
            .ForEachIndexedPair(2, (previous, runner, points) =>
     {
         if(runner.Time != previous.Time)
         {
             runner.Points = points;
         }
         else
         {
             runner.Points = previous.Points;
         }
     });
     // Create the final list
     ScoresCollection.Clear();
     ScoresCollection.AddRange(scores.Values.Sorted());
     IsScored = true;
 }
开发者ID:karldickman,项目名称:XCAnalyze,代码行数:70,代码来源:Race.cs

示例4: addSortedList

 /// <summary>
 /// A helper function for sortReplies, adds a vector of wildcard triggers to the running sort buffer.
 /// </summary>
 /// <param name="vector"></param>
 /// <param name="wc"></param>
 /// <returns></returns>
 private ICollection<string> addSortedList(ICollection<string> vector, ICollection<string> wc)
 {
     var itens = Util.SortByLengthDesc(wc.ToArray());
     vector.AddRange(itens);
     return vector;
 }
开发者ID:fabioravila,项目名称:rivescript-csharp,代码行数:12,代码来源:Inheritance.cs

示例5: DownloadAssets

 private void DownloadAssets(ICollection<string> files, string file, MXUIView view)
 {
     view.buttons.ForEach(o => DownloadAssets(files, file, o));
     view.layers.ForEach(o => DownloadAssets(files, file, o));
     view.sliders.ForEach(o => DownloadAssets(files, file, o));
     view.subviews.ForEach(o => DownloadAssets(files, file, o));
     var gallery = view as MXUIGallery;
     if (gallery != null) {
         MXUIView galleryButtonGroup = gallery.subviews.SingleOrDefault(v => v.layerInfo.name == "gallery_button_group");
         if (galleryButtonGroup != null) { // can be null for deleted scene module
             string dir = _context.Config.SecondScreenAssetBase;
             IEnumerable<MXUIButton> galleryInfoButtons = galleryButtonGroup.buttons.Where(b => b.layerInfo.name.Contains("info"));
             IEnumerable<string> infoImageNames = galleryInfoButtons.Select(b => b.layerInfo.name.Split('_').Take(3).JoinString("_"));
             files.AddRange(infoImageNames.Select(name => dir + name + "_info_segment.mxcsi"));
         }
     }
     var flipbook = view as MXUIFlipbook;
     if (flipbook != null) {
         string eventId = new Regex(@"^(IS_\d+)_flipbook$").Match(file).Groups[1].Value;
         for (int i = 0; i < flipbook.sequenceCount; i++)
             files.Add(_context.Config.FlipbookBase + eventId + "_FB_" + i + ".swf");
     }
     var video = view as MXUIVideo;
     if (video != null) {
         files.Add(_context.Config.VideoBase + video.filename);
     }
 }
开发者ID:Athari,项目名称:DisneySecondScreen,代码行数:27,代码来源:Program.cs

示例6: GetItems

        private async Task GetItems(ICollection<Bookmark> items, int pageNumber, DateTime? dateSince)
        {
            while (true)
            {
                var articles = await _readabilityClient.GetBookmarksAsync(new Conditions { AddedSince = dateSince, Page = pageNumber, PerPage = 50 });
                if (articles == null)
                {
                    return;
                }

                items.AddRange(articles.Bookmarks);

                if (items.Count > Constants.MaxArticleCount)
                {
                    break;
                }

                if (items.Count < articles.Meta.ItemCountTotal)
                {
                    pageNumber = pageNumber + 1;
                    continue;
                }
                break;
            }
        }
开发者ID:ScottIsAFool,项目名称:Speader,代码行数:25,代码来源:ReadabilityViewModel.cs

示例7: GetDefaults

        internal static RouteAttribute GetDefaults(this MethodInfo method, ICollection<OnVerbAttribute> verbs, out bool explicitRoute)
        {
            OnVerbAttribute verb = null;
            verbs.AddRange(method.GetCustomAttributes<OnVerbAttribute>(true) ?? method.DeclaringType.GetInterfaces().Select(@interface => @interface.GetCustomAttribute<OnVerbAttribute>()));
            var route = method.GetCustomAttribute<RouteAttribute>(true) ??
                method.DeclaringType.GetInterfaces().Select(@interface => @interface.GetCustomAttribute<RouteAttribute>()).FirstOrDefault();
            explicitRoute = (route != null);
            if ((route == null) || (!verbs.Any()))
            {
                method.ObtainMethodDetailsFromVerbs(ref route, ref verb);
                if (verb != null)
                {
                    verbs.Add(verb);
                    verb = null;
                }
            }

            if ((route == null) || (!verbs.Any()))
            {
                method.ObtainMethodDetailsFromPopularNames(ref route, ref verb);
                if (verb != null)
                {
                    verbs.Add(verb);
                }
            }

            if (route == null)
            {
                route = new RouteAttribute(method.Name.ToLower());
            }

            if (!verbs.Any())
            {
                verbs.Add(new OnVerbAttribute(Verb.GET));
            }

            return route;
        }
开发者ID:alien-mcl,项目名称:URSA,代码行数:38,代码来源:MemberInfoExtensions.cs

示例8: ProcessCheck

        private async Task ProcessCheck(bool noCheckout, bool skipWhenFileMatches, IReadOnlyCollection<Package> packages,
            ICollection<Package> syncedPackages, Package.ObjectMap[] objectsToFetch) {
            StatusRepo.Reset(RepoStatus.CheckOut, packages.Count);
            var i = 0;
            syncedPackages.AddRange(packages);
            var components = packages.Select(x => new ProgressLeaf(x.MetaData.Name)).ToArray();
            if (!noCheckout) {
                foreach (var package in packages) {
                    var p = components[i++];
                    await p.Do(() => ProcessPackageInternal(package, p)).ConfigureAwait(false);
                }
            }

            if (!noCheckout && skipWhenFileMatches) {
                Repo.DeleteObject(objectsToFetch.Select(x => new ObjectInfo(x.FO.Checksum, x.FO.Checksum)));
                // nasty using checksum for packed checksum or ? not needed here anyway??
            }
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:18,代码来源:PackageManager.cs

示例9: HandleRelatedContentChildren

 protected override void HandleRelatedContentChildren(ICollection<IContentSpec<Content>> x) {
     // TODO: Dependencies of dependencies
     x.AddRange(
         Dependencies.Select(d => new ModRepoContentSpec(new ModRepoContent(d.ToLower(), GameId, null))));
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:5,代码来源:LocalContent.cs

示例10: AddEmailAddresses

 private void AddEmailAddresses(string addresses, ICollection<EmailAddress> target)
 {
     var arr = addresses.IsEmpty() ? null : addresses.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
     if (arr != null && arr.Length > 0)
     {
         target.AddRange(arr.Where(x => x.Trim().HasValue()).Select(x => new EmailAddress(x)));
     }
 }
开发者ID:mandocaesar,项目名称:Mesinku,代码行数:8,代码来源:QueuedEmailService.cs


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