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


C# ICollection.All方法代码示例

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


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

示例1: GenerateRooms

		public static IEnumerable<Room> GenerateRooms(Random _random, Rct _rct, ICollection<Point> _objects, Point _blockId)
		{
			var ableVert = _rct.Width - MIN_ROOM_SIZE*2;
			var ableHor = _rct.Height - MIN_ROOM_SIZE*2;

			if ((ableHor > 1 || ableVert > 1) && (_rct.Width*_rct.Height < MIN_ROOM_SQUARE || _rct.Width > MAX_DIV_SIZE || _rct.Height > MAX_DIV_SIZE || _random.Next(_rct.Width + _rct.Height) > MIN_ROOM_SIZE))
			{
				var divVert = 0;
				var divHor = 0;
				while (divVert == divHor)
				{
					divVert = ableVert > 0 ? _random.Next(ableVert + 1) : 0;
					divHor = ableHor > 0 ? _random.Next(ableHor + 1) : 0;
				}
				var rects = new List<Rct>();
				if (divVert > divHor)
				{
					int vert;
					do
					{
						vert = MIN_ROOM_SIZE + _random.Next(ableVert);
						var val = vert;
						if (_objects.All(_point => _point.X != (_rct.Left + val))) break;
					} while (true);
					rects.Add(new Rct(_rct.Left, _rct.Top, vert, _rct.Height));
					rects.Add(new Rct(_rct.Left + vert + 1, _rct.Top, _rct.Width - (vert + 1), _rct.Height));
				}
				else
				{
					int hor;
					do
					{
						hor = MIN_ROOM_SIZE + _random.Next(ableHor);
						var val = hor;
						if (_objects.All(_point => _point.Y != (_rct.Top + val))) break;
					} while (true);
					rects.Add(new Rct(_rct.Left, _rct.Top, _rct.Width, hor));
					rects.Add(new Rct(_rct.Left, _rct.Top + hor + 1, _rct.Width, _rct.Height - (hor + 1)));
				}
				foreach (var rct in rects)
				{
					if (rct.Width > _rct.Width || rct.Height > _rct.Height)
					{
						throw new ApplicationException("Доля больше чем место под нее");
					}

					foreach (var room in GenerateRooms(_random, rct, _objects, _blockId))
					{
						yield return room;
					}
				}
				yield break;
			}
			yield return MakeRoom(_rct, _random, _objects, _blockId);
		}
开发者ID:Foxbow74,项目名称:my-busycator,代码行数:55,代码来源:LayerHelper.cs

示例2: AddIfPrime

 private static void AddIfPrime(ICollection<long> primes, int i)
 {
     if (primes.All(x => i % x != 0))
     {
         primes.Add(i);
     }
 }
开发者ID:devneil,项目名称:codemire-katas,代码行数:7,代码来源:PrimeNumberGenerator.cs

示例3: GetUniqueName

 public static string GetUniqueName(ICollection<Property> props)
 {
     foreach (var suffix in Suffixes)
     {
         var unique = suffix;
         if (props.All(p => p.Name != unique))
             return unique;
     }
     for (var i = 0; i < 100; i++)
     {
         var unique = "A" + i;
         if (props.All(p => p.Name != unique))
             return unique;
     }
     throw new InvalidOperationException("Could not find a unique name for property");
 }
开发者ID:Gufalagupagup,项目名称:raml-dotnet-tools,代码行数:16,代码来源:UniquenessHelper.cs

示例4: VerifySeedAcceptedNodes

 private void VerifySeedAcceptedNodes(
         IEnumerable<CstNode> seedCsts, ICollection<CstNode> uppermostSeedAcceptedNodes,
         LearningExperiment oracle) {
     var anotherUppermostSeedAcceptedNodes = seedCsts
             .SelectMany(cst => LearningExperimentUtil
                     .GetUppermostNodesByNames(cst, SelectedNodeNames))
             .Where(oracle.ProtectedIsAcceptedUsingOracle)
             .ToList();
     var b1 = !uppermostSeedAcceptedNodes.All(oracle.IsAcceptedUsingOracle);
     var b2 = anotherUppermostSeedAcceptedNodes
             .Select(node => node.AncestorWithSingleChild())
             .Any(e => !uppermostSeedAcceptedNodes.Contains(e));
     var b3 = uppermostSeedAcceptedNodes.Count != anotherUppermostSeedAcceptedNodes.Count;
     Console.WriteLine("Initial: " + string.Join(", ", oracle.OracleNames));
     Console.WriteLine("Learned: " + string.Join(", ", SelectedNodeNames));
     if (b1 || b2 || b3) {
         Console.WriteLine("--------------------------------------------------");
         foreach (var e in uppermostSeedAcceptedNodes) {
             Console.WriteLine(e);
         }
         Console.WriteLine("--------------------------------------------------");
         foreach (var e in anotherUppermostSeedAcceptedNodes) {
             Console.WriteLine(e);
         }
         throw new Exception("Wrong Oracle.");
     }
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:27,代码来源:SeedNodeSet.cs

示例5: ValidateAll

        public void ValidateAll(ICollection<object> objectsToValidate)
        {
            var canValidateAll = objectsToValidate
                .All(obj => _validator
                    .CanValidateInstancesOfType(obj.GetType()));

            if (!canValidateAll)
                throw new ArgumentException(
                    $"Not all objects can be validated by {_validator.GetType().Name}");

            var errors = new List<string>();

            foreach (var obj in objectsToValidate)
            {
                var result = _validator.Validate(obj);

                if (!result.IsValid)
                {
                    errors.AddRange(
                        result
                            .Errors
                            .Select(Mapping.FailureTransformerFunc));
                }
            }

            if (errors.Any())
            {
                throw new ValidationException(
                    "Error validating collection of objects", 
                    errors);
            }
        }
开发者ID:carlos-vicente,项目名称:Playground,代码行数:32,代码来源:FluentValidationValidator.cs

示例6: Compute

 private void Compute(string expression, string key, ICollection<IGrouping<string, ParentChildCategory>> grouping, ICollection<string> categoryList)
 {
     if (grouping.All(g => g.Key != key) && expression.StartsWith(Separator))
         categoryList.Add(expression.TrimStart(Separator.ToArray()));
     else if(grouping.Any(g => g.Key == key))
         grouping.Single(g => g.Key == key).ToList().ForEach(c => Compute(expression + Separator + c.Child, c.Child, grouping, categoryList));
 }
开发者ID:dmcliver,项目名称:DonateMe,代码行数:7,代码来源:CategoryHierarchyServiceImpl.cs

示例7: LoadMetaData

		private void LoadMetaData(ICollection<IControllerMetaData> controllersMetaContainers, IEnumerable<Type> types, IEnumerable<Type> typesToIgnore)
		{
			foreach (var t in types.Where(t => typesToIgnore.All(x => x.FullName != t.FullName) &&
											   controllersMetaContainers.All(x => x.ControllerType != t)))
			{
				BuildControllerMetaData(controllersMetaContainers, t);
			}
		}
开发者ID:i4004,项目名称:Simplify.Web,代码行数:8,代码来源:ControllersMetaStore.cs

示例8: StraightFlushCheck

 public static bool StraightFlushCheck(ICollection<Card> cardsinHand)
 {
     // Are all cards in hand of the same Rank?
         var firstCard = cardsinHand.First();
         if (cardsinHand.All(s => s.Rank == firstCard.Rank))
             return true;
         return false;
 }
开发者ID:MattPuzey,项目名称:Katas,代码行数:8,代码来源:PokerHands.cs

示例9: DetectNotification

 /// <summary>
 /// Checks for any new tracks entered airspace
 /// track entered event raised if any new tracks exist
 /// new event logged to the file
 /// </summary>
 /// <param name="oldTransponderDatas"></param>
 /// <param name="newTransponderDatas"></param>
 public override void DetectNotification(ICollection<IATMTransponderData> oldTransponderDatas, ICollection<IATMTransponderData> newTransponderDatas)
 {
     foreach (var item in newTransponderDatas.Where(item => oldTransponderDatas.All(t => t.Tag != item.Tag)))
     {
         const string logString = " TrackEnteredAirspace Notification ";
         Notify(new NotificationEventArgs(item.Tag, "TrackEnteredAirspace", item.Timestamp));
         _atmLog.Log(item.Timestamp + logString + item.Tag);
     }
 }
开发者ID:AlexJCarstensen,项目名称:AirTrafficMonitoring-I4SWT,代码行数:16,代码来源:TrackEnteredAirspace.cs

示例10: CreateAuthenticatedClaimsIdentity

        /// <summary>
        /// Creates new authenticated claims identity by using the provided claims and authentication type.
        /// </summary>
        /// <param name="claims">Collection of claims to add to the authenticated identity.</param>
        /// <param name="authenticationType">Authentication type to use for the authenticated identity.</param>
        /// <param name="nameType">Type of the username claim. Default is <see cref="ClaimTypes.Name"/>.</param>
        /// <param name="roleType">Type of the role claim. Default is <see cref="ClaimTypes.Role"/>.</param>
        /// <returns>Mocked <see cref="ClaimsIdentity"/>.</returns>
        protected static ClaimsIdentity CreateAuthenticatedClaimsIdentity(
            ICollection<Claim> claims = null,
            string authenticationType = null,
            string nameType = null,
            string roleType = null)
        {
            claims = claims ?? new List<Claim>();
            authenticationType = authenticationType ?? DefaultAuthenticationType;
            nameType = nameType ?? DefaultNameType;
            roleType = roleType ?? DefaultRoleType;

            if (claims.All(c => c.Type != ClaimTypes.NameIdentifier))
            {
                claims.Add(new Claim(ClaimTypes.NameIdentifier, DefaultIdentifier));
            }

            if (claims.All(c => c.Type != nameType))
            {
                claims.Add(new Claim(nameType, DefaultUsername));
            }

            return new ClaimsIdentity(claims, authenticationType, nameType, roleType);
        }
开发者ID:Cream2015,项目名称:MyTested.AspNetCore.Mvc,代码行数:31,代码来源:BaseUserBuilder.cs

示例11: SetNewSolution

 /// <summary>
 /// Sets new solution of the problem.
 /// </summary>
 /// <param name="nodes">Collection of nodes representing new solution.</param>
 public void SetNewSolution(ICollection<Node> nodes)
 {
     if (nodes == null) throw new ArgumentException(nameof(nodes));
     if (!IsInitialized) return;
     if (nodes.All(n => Graph.ContainsNode(n.Key) && Graph.Equals(n.Parent)))
     {
         lock (_currentCover)
         {
             _currentCover = new HashSet<Node>(nodes);
         }
     }
     else
     {
         throw new ProblemException("Setting new solution", "Graph mismatch or node key not found");
     }
 }
开发者ID:m-wilczynski,项目名称:Graphinder,代码行数:20,代码来源:MinimumVertexCover.cs

示例12: GetAuthenticatedClaimsIdentity

        private static ClaimsIdentity GetAuthenticatedClaimsIdentity(
            ICollection<Claim> claims = null,
            string authenticationType = DefaultAuthenticationType)
        {
            claims = claims ?? new List<Claim>();

            if (claims.All(c => c.Type != ClaimTypes.NameIdentifier))
            {
                claims.Add(new Claim(ClaimTypes.NameIdentifier, DefaultIdentifier));
            }

            if (claims.All(c => c.Type != ClaimTypes.Name))
            {
                claims.Add(new Claim(ClaimTypes.Name, DefaultUsername));
            }

            return new ClaimsIdentity(claims, authenticationType);
        }
开发者ID:ivaylokenov,项目名称:MyTested.WebApi,代码行数:18,代码来源:MockedIPrincipal.cs

示例13: ResolveHandlerPath

        public static string ResolveHandlerPath(ICollection<Type> types)
        {
            var tenant = ASC.Core.CoreContext.TenantManager.GetCurrentTenant();
            var version = ""; 
            var resultPath = "";
            var listHandlers  = new List<ClientScript>();

            foreach (var type in types)
            {
                if (!typeof(ClientScript).IsAssignableFrom(type))
                {
                    throw new ArgumentException(string.Format("{0} is not assignable to ClientScriptHandler", type));
                }
                var instance = (ClientScript)Activator.CreateInstance(type);
                version += instance.GetCacheHash();
                resultPath = resultPath + type.FullName.ToLowerInvariant().Replace('.', '_');

                listHandlers.Add(instance);
            }

            resultPath = HttpServerUtility.UrlTokenEncode(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(resultPath)));

            if (!Hash.ContainsKey(resultPath))
            {
                Hash[resultPath] = new ClientScriptHandler {ClientScriptHandlers = listHandlers};
            }

            if (tenant != null && types.All(r => r.BaseType != typeof(ClientScriptLocalization)))
                version = String.Join("_",
                                      new[]
                                              {
                                                  tenant.TenantId.ToString(CultureInfo.InvariantCulture),
                                                  tenant.Version.ToString(CultureInfo.InvariantCulture),
                                                  tenant.LastModified.Ticks.ToString(CultureInfo.InvariantCulture),
                                                  version
                                              });

            var versionHash = HttpServerUtility.UrlTokenEncode(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(version)));

            return new Uri(VirtualPathUtility.ToAbsolute("~/clientscriptbundle/" + versionHash + "/" + resultPath + ClientSettings.ClientScriptExtension),
                    UriKind.Relative).ToString();
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:42,代码来源:ClientScriptBundle.cs

示例14: VillagesContextMenu

        public VillagesContextMenu(Map map, ICollection<Village> villages, Action<VillageType> onVillageTypeChangeDelegate = null)
        {
            _villages = villages;
            _map = map;
            _onVillageTypeChangeDelegate = onVillageTypeChangeDelegate;

            _menu = JanusContextMenu.Create();
            // TODO: hehe, the ActiveVillageManipulator takes the first player and selects all his villages...
            //if (map.Display.IsVisible(_villages))
            //{
            //    _menu.AddCommand("Pinpoint", OnPinPoint);
            //}
            //_menu.AddCommand("Pinpoint && Center", OnPinpointAndCenter, Properties.Resources.TeleportIcon);
            //_menu.AddSeparator();

            _menu.AddSetVillageTypeCommand(OnVillageTypeChange, null);
            _menu.AddCommand("Remove purpose", OnRemovePurpose);

            if (World.Default.Settings.Church)
            {
                VillageContextMenu.AddChurchCommands(_menu, null, ChurchChange_Click);
            }

            _menu.AddSeparator();
            if (!World.Default.You.Empty && villages.All(x => x.Player == World.Default.You))
            {
                _menu.AddCommand("Defend these villages", OnAddTargets, Properties.Resources.swordsman);

                AttackersPoolContextMenuCommandCreator.Add(_menu, _villages);
            }
            else
            {
                _menu.AddCommand("Attack these villages", OnAddTargets, Properties.Resources.barracks);
            }
            _menu.AddSeparator();

            _menu.AddCommand("BBCode", OnBbCode, Properties.Resources.clipboard);
        }
开发者ID:kindam,项目名称:TWTactics,代码行数:38,代码来源:VillagesContextMenu.cs

示例15: GeneticAlgorithm

        /// <summary>
        /// Creates instance of genetic algorithm
        /// </summary>
        /// <param name="graph">Graph on which algorithm will operate</param>
        /// <param name="problem">Problem for which algorithm will attempt to find solution</param>
        /// <param name="geneticOperators">Genetic operators used for breeding new generations</param>
        /// <param name="settings">General settings for solution finding process</param>
        /// <param name="startingPopulation">Starting population for algorithm</param>
        //TODO: Introduce SavedState complex type
        public GeneticAlgorithm(Graph graph, IProblem problem, GeneticOperators geneticOperators, 
            GeneticAlgorithmSettings settings, ICollection<Individual> startingPopulation = null, 
            uint currentGeneration = 0, Guid? id = null)
            : base(graph, problem, id)
        {
            if (geneticOperators == null)
                throw new ArgumentNullException(nameof(geneticOperators));
            if (!geneticOperators.IsValid())
                throw new ArgumentException("Genetic operators are not valid", nameof(geneticOperators));
            if (settings == null)
                throw new ArgumentNullException(nameof(settings));
            GeneticOperators = geneticOperators;
            Settings = settings;
            if (startingPopulation == null || startingPopulation.Count == 0 || !startingPopulation.All(IsIndividualValid))
                GenerateInitialPopulation();
            else
            {
                CurrentPopulation = new SortedSet<Individual>();
                foreach (var element in startingPopulation)
                    CurrentPopulation.Add(element);
            }

            CurrentGeneration = currentGeneration;
        }
开发者ID:m-wilczynski,项目名称:Graphinder,代码行数:33,代码来源:GeneticAlgorithm.cs


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