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


C# IEnumerable.All方法代码示例

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


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

示例1: ValidAttributesFor

        public bool ValidAttributesFor(string table, string featureType, IEnumerable<FeatureActions> actions)
        {
            if (string.IsNullOrEmpty(featureType))
            {
                return false;
            }

            featureType = featureType.ToLower();

            if (featureType == "affected area" && actions == null)
            {
                return true;
            }

            if (string.IsNullOrEmpty(table))
            {
                return false;
            }

            table = table.ToLower();

            if (actions == null)
            {
                return false;
            }

            switch (table)
            {
                case "poly":
                    return
                        actions.All(
                            x =>
                                !string.IsNullOrEmpty(x.Action) &&
                                x.Treatments.All(t => !string.IsNullOrEmpty(t.Treatment)));
                case "point":
                    if (actions.Count() != 1)
                    {
                        return false;
                    }

                    if (new[] {"guzzler", "fish passage structure"}.Contains(featureType))
                    {
                        return actions.All(x => !string.IsNullOrEmpty(x.Action) &&
                                                 !string.IsNullOrEmpty(x.Type));
                    }

                    return actions.All(x => !string.IsNullOrEmpty(x.Description));
                case "line":
                    if (actions.Count() != 1)
                    {
                        return false;
                    }

                    return actions.All(x => !string.IsNullOrEmpty(x.Action) &&
                                                 !string.IsNullOrEmpty(x.Type));

            }

            return false;
        }
开发者ID:agrc,项目名称:wri-webapi,代码行数:60,代码来源:AttributeValidator.cs

示例2: ExportStops

        /// <summary>
        /// Exports specified stops to serializable stop information.
        /// </summary>
        /// <param name="stops">The reference to the collection of stops to be exported.</param>
        /// <param name="capacitiesInfo">The reference to capacities info object to be used
        /// for retrieving custom order properties for stops.</param>
        /// <param name="orderCustomPropertiesInfo">The reference custom order properties info
        /// object.</param>
        /// <param name="addressFields">The reference to address fields object to be used
        /// for retrieving custom order properties for stops.</param>
        /// <param name="solver">The reference to VRPSolver to be used for retrieving
        /// curb approach policies for stops.</param>
        /// <param name="orderPropertiesFilter">Function returning true for custom order
        /// property names which should not be exported.</param>
        /// <returns>A reference to the collection of serializable stop information objects.
        /// </returns>
        public static IEnumerable<StopInfo> ExportStops(
            IEnumerable<Stop> stops,
            CapacitiesInfo capacitiesInfo,
            OrderCustomPropertiesInfo orderCustomPropertiesInfo,
            AddressField[] addressFields,
            IVrpSolver solver,
            Func<string, bool> orderPropertiesFilter = null)
        {
            Debug.Assert(stops != null);
            Debug.Assert(stops.All(stop => stop != null));
            Debug.Assert(stops.All(stop => stop.Route != null));
            Debug.Assert(capacitiesInfo != null);
            Debug.Assert(orderCustomPropertiesInfo != null);
            Debug.Assert(addressFields != null);

            if (!stops.Any())
            {
                return Enumerable.Empty<StopInfo>();
            }

            var capacityProperties = Order.GetPropertiesInfo(capacitiesInfo);
            var addressProperties = Order.GetPropertiesInfo(addressFields);
            var customProperties = Order.GetPropertiesInfo(orderCustomPropertiesInfo);

            var exportOrderProperties = _CreateExportOrderProperties(
                capacitiesInfo,
                orderCustomPropertiesInfo,
                addressFields,
                orderPropertiesFilter);

            // Make a dictionary for mapping routes to collection of sorted route stops.
            var routesSortedStops = stops
                .Select(stop => stop.Route)
                .Distinct()
                .ToDictionary(route => route, route => CommonHelpers.GetSortedStops(route));

            // Prepare result by exporting each stop individually.
            var settings = CommonHelpers.GetSolverSettings(solver);
            var result = stops
                .Select(stop => _ExportStop(
                    stop,
                    routesSortedStops[stop.Route],
                    exportOrderProperties,
                    addressProperties,
                    capacityProperties,
                    customProperties,
                    settings))
                .ToList();

            return result;
        }
开发者ID:erindm,项目名称:route-planner-csharp,代码行数:67,代码来源:RouteExporter.cs

示例3: Create

        public static ValidationResult Create(RuleValidator validator, RuleValidatorContext context, IList<Object> parameterValues, object messageKey, IEnumerable<ValidationResult> nestedValidationResults = null)
        {
            string message = string.Empty;
            var messageService = new MessageService();

            if (String.IsNullOrEmpty(validator.Message))
            {
                var messageContext = new MessageContext(context, validator.GetType(), validator.Negate, validator.MessageStoreName, messageKey, validator.MessageFormatter);
                message = messageService.GetDefaultMessageAndFormat(messageContext, parameterValues);
            }
            else
            {
                //Since the message was supplied, don't get the default message from the store, just format it
                message = messageService.FormatMessage(validator.Message, context, parameterValues, validator.MessageFormatter);
            }

            //Override level if all the nested validation errors are Warnings

            if (nestedValidationResults != null && nestedValidationResults.All(vr => vr.Level == ValidationLevelType.Warn))
            {
                return new ValidationResult(context.PropertyInfo, message, ValidationLevelType.Warn, context.PropertyValue, nestedValidationResults);
            }
            else
            {
                return new ValidationResult(context.PropertyInfo, message, context.Level, context.PropertyValue, nestedValidationResults);
            }

            //return new ValidationResult(context.PropertyInfo, message, context.Level, context.PropertyValue, nestedValidationResults);
        }
开发者ID:rbell,项目名称:SpecExpress,代码行数:29,代码来源:ValidationResultFactory.cs

示例4: SpanNearQuery

        /// <summary>
        /// Create a span_near query.
        /// </summary>
        /// <param name="clauses">The span queries used to find documents.</param>
        public SpanNearQuery(IEnumerable<SpanQueryBase> clauses)
        {
            if (clauses == null || clauses.All(x => x == null))
                throw new ArgumentNullException("clauses", "SpanNearQuery requires at least one span query for clauses.");

            Clauses = clauses;
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:11,代码来源:SpanNearQuery.cs

示例5: GetBlockWrapper

		public IReadOnlyCollection<string> GetBlockWrapper(IEnumerable<string> code)
		{
			// If the code doesn't have any braces, surround it in a ruleset so that properties are valid.
			if (code.All(t => t.IndexOfAny(new[] { '{', '}' }) == -1))
				return new[] { ".GeneratedClass-" + Guid.NewGuid() + " {", "}" };
			return null;
		}
开发者ID:billwaddyjr,项目名称:WebEssentials2015,代码行数:7,代码来源:CodeLanguageEmbedders.cs

示例6: ScriptFieldRequest

        /// <summary>
        /// Create a script_field value.
        /// </summary>
        /// <param name="fields">The fields to create, and the scripts to create them with.</param>
        public ScriptFieldRequest(IEnumerable<ScriptField> fields)
        {
            if (fields == null || fields.All(x => x == null))
                throw new ArgumentNullException("fields", "ScriptFields requires at least one field.");

            Fields = fields.Where(x => x != null);
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:11,代码来源:ScriptFieldRequest.cs

示例7: MergeXml

        static XDocument MergeXml(IEnumerable<XDocument> inputs)
        {
            // What assembly is this?
            var assemblyName = GetAssemblyName(inputs.First());

            if (!inputs.All(input => GetAssemblyName(input) == assemblyName))
            {
                throw new Exception("All input files must be for the same assembly.");
            }

            // Merge all the member documentation into a single list.
            var mergedMembers = from input in inputs
                                from member in input.Element("doc").Element("members").Elements()
                                where !IsNamespace(member)
                                select member;

            // Remove documentation tags that Intellisense does not use, to minimize the size of the shipping XML files.
            RemoveUnwantedElements(mergedMembers);

            // Generate new Intellisense XML.
            return new XDocument(
                new XElement("doc",
                    new XElement("assembly",
                        new XElement("name", assemblyName)
                    ),
                    new XElement("members",
                        mergedMembers
                    )
                )
            );
        }
开发者ID:Himansh1306,项目名称:Win2D,代码行数:31,代码来源:Program.cs

示例8: ValidateUniqueCurrency

        private void ValidateUniqueCurrency(IEnumerable<Currency> otherCurrencies, ref ModelStateDictionary modelStateDictionary)
        {
            if (otherCurrencies.All(oc => oc.CurrencyType != CurrencyType))
                return;

            modelStateDictionary.AddModelError(BaseCache.CurrencyTypeField, String.Format(ValidationResource.Global_OwnUnique_ErrorMessage, FieldResource.Global_Currency_Name));
        }
开发者ID:MulderFox,项目名称:Main,代码行数:7,代码来源:Currency.cs

示例9: SavePackageSources

        public async void SavePackageSources(IEnumerable<IPackageSource> packageSources)
        {
            if (_busy)
                return;

            _busy = true;

            await Task.Run(() =>
            {
                foreach (var packageSource in _packageSources.ToArray())
                {
                    if (packageSources.All(n => n != packageSource))
                    {
                        Remove(packageSource);
                    }
                }

                foreach (var packageSource in packageSources.ToArray())
                {
                    if (!_packageSources.Any(n => n.Name == packageSource.Name && n.Location == packageSource.Location && n.Provider == packageSource.Provider))
                    {
                        Add(packageSource);
                    }
                }
            });

            Reload();

            _busy = false;
        }
开发者ID:henjuv,项目名称:Mg2,代码行数:30,代码来源:OneGetPackageSourceProvider.cs

示例10: Suggest

        /// <summary>
        /// Create a suggest request body document.
        /// </summary>
        /// <param name="suggestors">Sets the fields to get suggests from.</param>
        public Suggest(IEnumerable<ISuggester> suggestors)
        {
            if (suggestors == null || suggestors.All(x => x == null))
                throw new ArgumentNullException("suggestors", "Suggest requires at least one field suggest.");

            Suggestors = suggestors.Where(x => x != null);
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:11,代码来源:Suggest.cs

示例11: GenerateVariants

 private static IEnumerable<Variant> GenerateVariants(Variant variant, Potter aBook, IEnumerable<Variant> alreadyGenerated)
 {
     return variant.Piles
         .Where(pile => !pile.Contains(aBook))
         .Select(pile => CreateNewVariant(variant, pile, aBook))
         .Where(newVariant => alreadyGenerated.All(v => !v.Equals(newVariant)));
 }
开发者ID:darkiri,项目名称:Kata,代码行数:7,代码来源:ExpansivePriceCalculator.cs

示例12: Highlighter

        /// <summary>
        /// Create the highlighter.
        /// </summary>
        /// <param name="fieldHighlighters">Sets the fields to highlight.</param>
        public Highlighter(IEnumerable<FieldHighlighter> fieldHighlighters)
        {
            if (fieldHighlighters == null || fieldHighlighters.All(x => x == null))
                throw new ArgumentNullException("fieldHighlighters", "Highlighter requires at least one field highlighter.");

            FieldHighlighters = fieldHighlighters.Where(x => x != null);
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:11,代码来源:Highlighter.cs

示例13: Prepend

		public void Prepend( IEnumerable<object> sut, object[] items )
		{
			var prepended = sut.Prepend( items );
			Assert.Equal( sut.Count() + items.Length, prepended.Count() );
			Assert.True( sut.All( x => prepended.Contains( x ) ) );
			Assert.True( items.All( x => prepended.Contains( x ) ) );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:7,代码来源:EnumerableExtensionsTests.cs

示例14: Facets

        public Facets(IEnumerable<IFacet> facetGenerators)
        {
            if (facetGenerators == null || facetGenerators.All(x => x == null))
                throw new ArgumentNullException("facetGenerators", "Facets requires at least one facet generator.");

            FacetGenerators = facetGenerators.Where(x => x != null);
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:7,代码来源:Facets.cs

示例15: Aggregations

        /// <summary>
        /// Create an aggregations object.
        /// </summary>
        /// <param name="aggregators">Sets the aggregations.</param>
        public Aggregations(IEnumerable<IAggregation> aggregators)
        {
            if (aggregators == null || aggregators.All(x => x == null))
                throw new ArgumentNullException("aggregators", "Aggregations requires at least one aggregator.");

            Aggregators = aggregators.Where(x => x != null);
        }
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:11,代码来源:Aggregations.cs


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