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


C# ICollection.Any方法代码示例

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


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

示例1: IsValidValuesElementsInArray

        public static bool IsValidValuesElementsInArray(ICollection<int> array, int sizeLimitArray, int limitArrayElementValue)
        {
            if (array.Count == 0 || array.Count > sizeLimitArray)
                return false;

            return !array.Any(i => Math.Abs(i) > limitArrayElementValue);
        }
开发者ID:Wanderer19,项目名称:Tasks,代码行数:7,代码来源:ArrayReader.cs

示例2: BuildTableList

        private static string[] BuildTableList(ICollection<string> allTables, ICollection<Relationship> allRelationships)
        {
            var tablesToDelete = new List<string>();

            while (allTables.Any())
            {
                string[] leafTables = allTables.Except(allRelationships.Select(rel => rel.PrimaryKeyTable)).ToArray();

                if(leafTables.Length == 0)
                {
                    tablesToDelete.AddRange(allTables);
                    break;
                }

                tablesToDelete.AddRange(leafTables);

                foreach (string leafTable in leafTables)
                {
                    allTables.Remove(leafTable);
                    Relationship[] relToRemove =
                        allRelationships.Where(rel => rel.ForeignKeyTable == leafTable).ToArray();
                    foreach (Relationship rel in relToRemove)
                    {
                        allRelationships.Remove(rel);
                    }
                }
            }

            return tablesToDelete.ToArray();
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:30,代码来源:DatabaseEmptier.cs

示例3: EncodeIds

        private string EncodeIds(ICollection<int> ids)
        {
            if (ids == null || !ids.Any()) return string.Empty;

            // Using {1},{2} format so it can be filtered with delimiters.
            return "{" + string.Join("},{", ids.ToArray()) + "}";
        }
开发者ID:SmartFire,项目名称:Lombiq-Fields,代码行数:7,代码来源:MediaLibraryUploadField.cs

示例4: AddNugetReferenceMetadata

 public void AddNugetReferenceMetadata(ISharedPackageRepository sharedPackagesRepository, ICollection<IPackage> packagesToAdd)
 {
     _console.WriteLine("Checking for any project references for {0}...", PackageReferenceFilename);
     if (!packagesToAdd.Any()) return;
     CreatePackagesConfig(packagesToAdd);
     RegisterPackagesConfig(sharedPackagesRepository);
 }
开发者ID:GrahamTheCoder,项目名称:NuGet.Extensions,代码行数:7,代码来源:ProjectNugetifier.cs

示例5: 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

示例6: TryValidate

        public bool TryValidate(ICollection<ValidationResult> results = null)
        {
	        results = results ?? new List<ValidationResult>();

            if (FirstName == null)
            {
                results.Add(new ValidationResult("FirstName is a required field"));
            }
            else if (FirstName.Length == 0 || FirstName.Length > 50)
            {
                results.Add(new ValidationResult("FirstName must be at least 1 character and no more than 50 characters"));
            }

            if (LastName == null)
            {
                results.Add(new ValidationResult("LastName is a required field"));
            }
            else if (LastName.Length == 0 || LastName.Length > 50)
            {
                results.Add(new ValidationResult("LastName must be at least 1 character and no more than 50 characters"));
            }

            const string pattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";

            if (EmailAddress == null)
            {
                results.Add(new ValidationResult("EmailAddress is a required field"));
            }
            else if (!Regex.IsMatch(EmailAddress, pattern))
            {
                results.Add(new ValidationResult("EmailAddress must be a valid email address"));
            }

	        return results.Any() == false;
        }
开发者ID:toddmeinershagen,项目名称:Demo.Domain,代码行数:35,代码来源:PersonWithCustomValidation.cs

示例7: UpdateLeds

        private static void UpdateLeds(ICollection<KeyValuePair<int, CorsairLed>> ledsToUpdate)
        {
            ledsToUpdate = ledsToUpdate.Where(x => x.Value.Color != Color.Transparent).ToList();

            if (!ledsToUpdate.Any())
                return; // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array

            int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
            IntPtr ptr = Marshal.AllocHGlobal(structSize * ledsToUpdate.Count);
            IntPtr addPtr = new IntPtr(ptr.ToInt64());
            foreach (KeyValuePair<int, CorsairLed> led in ledsToUpdate)
            {
                _CorsairLedColor color = new _CorsairLedColor
                {
                    ledId = led.Key,
                    r = led.Value.Color.R,
                    g = led.Value.Color.G,
                    b = led.Value.Color.B
                };

                Marshal.StructureToPtr(color, addPtr, false);
                addPtr = new IntPtr(addPtr.ToInt64() + structSize);
            }
            _CUESDK.CorsairSetLedsColors(ledsToUpdate.Count, ptr);
            Marshal.FreeHGlobal(ptr);
        }
开发者ID:PeterMortensen,项目名称:CUE.NET,代码行数:26,代码来源:AbstractCueDevice.cs

示例8: AnalyzeProjectsAsync

        private async Task AnalyzeProjectsAsync(ICollection<Project> projects)
        {
            if (!projects.Any())
            {
                return;
            }

            try
            {
                WriteHeader();

                using (var innerScope = _scope.BeginLifetimeScope())
                {
                    var projectAnalyzer = innerScope.Resolve<ProjectAnalyzer>();

                    await projectAnalyzer.AnalyzeProjectAsync(projects);
                }
            }
            catch (PortabilityAnalyzerException ex)
            {
                _output.WriteLine();
                _output.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                _output.WriteLine();
                _output.WriteLine(LocalizedStrings.UnknownError);

                Trace.WriteLine(ex);
            }
            finally
            {
                _output.WriteLine();
            }
        }
开发者ID:AlexGhiondea,项目名称:dotnet-apiport,代码行数:35,代码来源:AnalyzeMenu.cs

示例9: FillNewFilteredDocumentHierarchyRecursively

 private INode FillNewFilteredDocumentHierarchyRecursively(ICollection<INode> filteredNodes, INode node, INode viewNodeParent, BackgroundWorker worker)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     if (!filteredNodes.Any(filteredNode => filteredNode.Path.StartsWith(node.Path)))
     {
         return null;
     }
     INode viewNode;
     if (viewNodeParent == null)
     {
         viewNode = this.CreateNewViewNodeWithParents(node);
     }
     else
     {
         viewNode = new ViewNode(node, viewNodeParent);
     }
     IEnumerable<INode> nodeChildren;
     lock (node)
     {
         nodeChildren = new List<INode>(node.Children);
     }
     foreach (INode child in nodeChildren)
     {
         this.FillNewFilteredDocumentHierarchyRecursively(filteredNodes, child, viewNode, worker);
     }
     this.ReportProgress(worker);
     return viewNode;          
 }
开发者ID:c0ns0le,项目名称:PsISEProjectExplorer,代码行数:31,代码来源:DocumentHierarchySearcher.cs

示例10: 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

示例11: Multipoint

		public Multipoint(ICollection<SimplePoint> points)
		{
			if (points == null) { throw new ArgumentNullException("points"); }
			if (points.Any(x => x == null)) { throw new ArgumentException("points", ErrorMessages.msgMultipoint_Error_NoNullPointAllowedInTheCollection); }
			if (points.Count < MINIMUM_AMMOUNT_OF_POINTS) { throw new ArgumentException("points", ErrorMessages.msgMultipoint_Error_AtLeastOnePointInTheCollection); }

			this._points = points;
		}
开发者ID:nodfreitas,项目名称:ArcGISRestToolkit.NET,代码行数:8,代码来源:Multipoint.cs

示例12: Polyline

		public Polyline(ICollection<Path> paths)
		{
			if (paths == null) { throw new ArgumentNullException("paths"); }
			if (paths.Any(x => x == null)) { throw new ArgumentException("paths", ErrorMessages.msgPolyline_Error_NoNullPathAllowedInTheCollection); }
			if (paths.Count < MINIMUM_AMMOUNT_OF_PATHS) { throw new ArgumentException("paths", ErrorMessages.msgPolyline_Error_AtLeastOnePathInTheCollection); }

			this._paths = paths;
		}
开发者ID:nodfreitas,项目名称:ArcGISRestToolkit.NET,代码行数:8,代码来源:Polyline.cs

示例13: CarryForwardParameters

        /// <summary>
        /// Carry forward the cd parameter value to future event & timing activities to know which page they occurred on.
        /// </summary>
        /// <param name="activity">Current activity being processed.</param>
        /// <param name="parameters">Current parameters for this request.</param>
        private void CarryForwardParameters(MeasurementActivity activity, ICollection<KeyValuePair<string, string>> parameters)
        {
            if ((activity is EventActivity || activity is TimedEventActivity) && lastCdParameterValue != null)
                parameters.Add(KeyValuePair.Create("cd", lastCdParameterValue));

            if (parameters.Any(k => k.Key == "cd"))
                lastCdParameterValue = parameters.First(p => p.Key == "cd").Value;
        }
开发者ID:naqvitalha,项目名称:CSharpAnalytics,代码行数:13,代码来源:MeasurementUriBuilder.cs

示例14: Polygon

		public Polygon(ICollection<Ring> rings)
		{
			if (rings == null) { throw new ArgumentNullException("rings"); }
			if (rings.Any(x => x == null)) { throw new ArgumentException("rings", ErrorMessages.msgPolygon_Error_NoNullRingAllowedInTheCollection); }
			if (rings.Count < MINIMUM_AMMOUNT_OF_RINGS) { throw new ArgumentException("rings", ErrorMessages.msgPolygon_Error_AtLeastOneRingInTheCollection); }

			this._rings = rings;
		}
开发者ID:nodfreitas,项目名称:ArcGISRestToolkit.NET,代码行数:8,代码来源:Polygon.cs

示例15: XHasAnyIgnoreCase

        public static bool XHasAnyIgnoreCase(this string @string, ICollection<string> substrings, bool ignoreCasing)
        {
            if (string.IsNullOrEmpty(@string) || substrings == null)
            {
                return false;
            }

            return substrings.Any(substring => XtensionHelpers.ContainsSubstring(@string, substring, ignoreCasing, false));
        }
开发者ID:ThoughtDrive,项目名称:XtensionMethods,代码行数:9,代码来源:String.XHasAnyIgnoreCase.cs


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