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


C# IReadOnlyCollection.Any方法代码示例

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


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

示例1: AllMatchingUsersAreRetrieved

        public void AllMatchingUsersAreRetrieved()
        {
            const string customPropertyName = "name";
            const string customPropertyValue = "value";
            var customProperties = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>(customPropertyName, customPropertyValue) };
            AddActiveDirectoryUser(Guid.NewGuid(), "Tim", "timber", false, customProperties);
            AddActiveDirectoryUser(Guid.NewGuid(), "Tom", "tomcat", false, customProperties);
            AddActiveDirectoryUser(Guid.NewGuid(), "John", "johnsnow");

            result = sut.GetUsers(customPropertyName, customPropertyValue, AccountType.ActiveDirectory);

            Assert.AreEqual(2, result.Count);
            Assert.IsTrue(result.Any(u => u.Name.Equals("Tom")));
            Assert.IsTrue(result.Any(u => u.Name.Equals("Tim")));
        }
开发者ID:affecto,项目名称:dotnet-IdentityManagement,代码行数:15,代码来源:FindUsersByCustomPropertyAndAccountTypeTests.cs

示例2: GenerateNewTypes

        public void GenerateNewTypes(string providerName, IReadOnlyCollection<DataTypeDescriptor> dataTypeDescriptors, bool makeAFlush)
        {
            Verify.ArgumentNotNullOrEmpty(providerName, "providerName");
            Verify.ArgumentNotNull(dataTypeDescriptors, "dataTypeDescriptors");

            foreach (var dataTypeDescriptor in dataTypeDescriptors)
            {
                UpdateWithNewMetaDataForeignKeySystem(dataTypeDescriptor);
                UpdateWithNewPageFolderForeignKeySystem(dataTypeDescriptor, false);
            }

            var types = DataTypeTypesManager.GetDataTypes(dataTypeDescriptors);
            
            foreach (var dataTypeDescriptor in dataTypeDescriptors)
            {
                dataTypeDescriptor.TypeManagerTypeName = TypeManager.SerializeType(types[dataTypeDescriptor.DataTypeId]);
            }

            DynamicTypeManager.CreateStores(providerName, dataTypeDescriptors, makeAFlush);

            if (makeAFlush && dataTypeDescriptors.Any(d => d.IsCodeGenerated))
            {
                CodeGenerationManager.GenerateCompositeGeneratedAssembly(true);
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:25,代码来源:GeneratedTypesFacadeImpl.cs

示例3: GenerateNext

		private static Func<IMessage, Task<object>> GenerateNext(
			BusSettings busSettings,
			IDependencyScope dependencyScope,
			IReadOnlyCollection<Type> pipelineHandlerTypes,
			IEnumerable<Type> leftHandlerTypes
			)
		{
			return (async message => {

				if (message == null) {
					throw new NullMessageTypeException();
				}

				if (!pipelineHandlerTypes.Any()) {
					return await RunLeafHandlers(busSettings, dependencyScope, leftHandlerTypes, message);
				}

				var head = pipelineHandlerTypes.First();
				var nextHandler = (IPipelineHandler)dependencyScope.GetService(head);

				var tail = pipelineHandlerTypes.Skip(1).ToList();
				var nextFunction = GenerateNext(busSettings, dependencyScope, tail, leftHandlerTypes);

				return await nextHandler.Handle(nextFunction, message);
			});
		}
开发者ID:Sandboxed-Forks,项目名称:Enexure.MicroBus,代码行数:26,代码来源:PipelineBuilder.cs

示例4: ToHTML5

        public static Generator ToHTML5(this Element self, IReadOnlyCollection<ITag> inners, Generator generator)
        {
            var tags = new Generator(generator.Indention + 1);
            inners.ForEach(x => x.ToHTML5(tags));
            var annotations = String.Concat(self.Annotations.Select(x => x.ToHTML5()));

            var isText = inners.Count == 1 && inners.Single() is Text;
            if (!inners.Any())
            {
                if (self.Name.ToLower() == "script")
                    generator.Write("<{0}{1}></{0}>", self.Name, annotations);
                else
                    generator.Write("<{0}{1} />", self.Name, annotations);
            }
            else if (isText)
            {
                generator.Write("<{0}{1}>{2}</{0}>", self.Name, annotations, tags.Generate().Trim());
            }
            else
            {
                generator.Write("<{0}{1}>{2}", self.Name, annotations, tags.Generate());
                generator.Write("</{0}>", self.Name);
            }
            return generator;
        }
开发者ID:kokudori,项目名称:Y3,代码行数:25,代码来源:Element.cs

示例5: EnsurePolicyIsUpdated

 public void EnsurePolicyIsUpdated(IReadOnlyCollection<string> config)
 {
     if (config.Any())
     {
         var policy = new SnsPolicy(config);
         policy.Save(Arn, Client);
     }
 }
开发者ID:JonahAcquah,项目名称:JustSaying,代码行数:8,代码来源:SnsTopicByName.cs

示例6: Process

 private void Process(IReadOnlyCollection<IScriptable> items, string type)
 {
     if (!items.Any())
         return;
     Console.WriteLine($"{items.Count} {type}");
     foreach (var item in items)
         scripter.ScriptToDisk(item, type);
 }
开发者ID:jaguire,项目名称:Claymore,代码行数:8,代码来源:App.cs

示例7: CombinedNodeCommandWrapper

 public CombinedNodeCommandWrapper(IViewModelServiceProvider serviceProvider, string name, IReadOnlyCollection<ModelNodeCommandWrapper> commands)
     : base(serviceProvider)
 {
     if (commands == null) throw new ArgumentNullException(nameof(commands));
     if (commands.Count == 0) throw new ArgumentException(@"The collection of commands to combine is empty", nameof(commands));
     if (commands.Any(x => !ReferenceEquals(x.NodeCommand, commands.First().NodeCommand))) throw new ArgumentException(@"The collection of commands to combine cannot contain different node commands", nameof(commands));
     this.commands = commands;
     Name = name;
 }
开发者ID:cg123,项目名称:xenko,代码行数:9,代码来源:CombinedNodeCommandWrapper.cs

示例8: EventAggregator

        public EventAggregator(IList<IEvent> aggregatedEvents)
        {
            _supportedEvents = GetType().GenericTypeArguments;

            if (!_supportedEvents.Any())
            {
                throw new NotSupportedException();
            }

            AggregatedEvents = aggregatedEvents;
        }
开发者ID:DrunkyBard,项目名称:CqrsMe,代码行数:11,代码来源:EventAggregator.cs

示例9: AccountTypeDoesNotMatch

        public void AccountTypeDoesNotMatch()
        {
            const string customPropertyName = "name";
            const string customPropertyValue = "value";
            var customProperties = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>(customPropertyName, customPropertyValue) };
            AddActiveDirectoryUser(Guid.NewGuid(), "Tim", "timber", false, customProperties);

            result = sut.GetUsers(customPropertyName, customPropertyValue, AccountType.Federated);

            Assert.IsFalse(result.Any());
        }
开发者ID:affecto,项目名称:dotnet-IdentityManagement,代码行数:11,代码来源:FindUsersByCustomPropertyAndAccountTypeTests.cs

示例10: Handle

        private void Handle(IReadOnlyCollection<RecordDelayCommand> commands)
        {
            if (!commands.Any())
            {
                return;
            }

            var eldestEventTime = commands.Min(x => x.EventTime);
            var delta = DateTime.UtcNow - eldestEventTime;
            _telemetryPublisher.Publish<StatisticsProcessingDelayIdentity>((long)delta.TotalMilliseconds);
        }
开发者ID:2gis,项目名称:nuclear-river-customer-intelligence,代码行数:11,代码来源:ProjectStatisticsAggregateCommandsHandler.cs

示例11: SendMessagesAsync

        internal virtual async Task SendMessagesAsync(IReadOnlyCollection<Message> kafkaMessages)
        {
            Contract.Requires<ArgumentException>(kafkaMessages != null && kafkaMessages.Any());

            var producer = await this.GetOrCreateKafkaProducerAsync().ConfigureAwait(false);

            foreach (var kafkaMessage in kafkaMessages)
            {
                producer.Send(kafkaMessage);
            }
        }
开发者ID:wespday,项目名称:serilog-sinks-kafka,代码行数:11,代码来源:KafkaClient.cs

示例12: Handle

        private void Handle(IReadOnlyCollection<RecordDelayCommand> commands)
        {
            if (!commands.Any())
            {
                return;
            }

            var eldestEventTime = commands.Min(x => x.EventTime);
            var delta = DateTime.UtcNow - eldestEventTime;
            _eventLogger.Log(new IEvent[] { new BatchProcessedEvent(DateTime.UtcNow) });
            _telemetryPublisher.Publish<PrimaryProcessingDelayIdentity>((long)delta.TotalMilliseconds);
        }
开发者ID:2gis,项目名称:nuclear-river-customer-intelligence,代码行数:12,代码来源:ImportFactsFromErmHandler.cs

示例13: WriteAsync

        public async Task<bool> WriteAsync(IReadOnlyCollection<EventData> events, CancellationToken cancellationToken)
        {
            Guard.ArgumentNotNull(events, "events");

            if(!events.Any())
            {
                return false;
            }

            try
            {
                string logMessages;
                using (var serializer = new ElasticSearchEventDataSerializer(_index, _type))
                {
                    logMessages = serializer.Serialize(events);
                }

                using (var client = new HttpClient())
                {
                    var resp = await _retryPolicy.ExecuteAsync(async () =>
                    {
                        var content = new StringContent(logMessages);
                        content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                        var response = await client.PostAsync(_elasticsearchUrl, content, cancellationToken).ConfigureAwait(false);

                        if(response.StatusCode != HttpStatusCode.OK)
                        {
                            WarmStorageEventSource.Log.WriteToElasticSearchFailedPerf(events.Count);

                            await HandleErrorResponse(response);
                        }

                        //This is for retry strategy. If response is not successful it will raise an exception catched by the retry strategy.
                        response.EnsureSuccessStatusCodeEx();

                        WarmStorageEventSource.Log.WriteToElasticSearchSuccessPerf(events.Count);

                        return response;
                    });
                }

                return true;
            }
            catch (Exception ex)
            {
                //If a non-transient error has ocurred or if we ran out of attempts.

                WarmStorageEventSource.Log.WriteToElasticSearchError(ex);

                return false;
            }
        }
开发者ID:carloserodriguez2000,项目名称:iot-journey,代码行数:53,代码来源:ElasticSearchWriter.cs

示例14: CombinedNodeCommandWrapper

 public CombinedNodeCommandWrapper(IViewModelServiceProvider serviceProvider, string name, string observableNodePath, ObservableViewModelIdentifier identifier, IReadOnlyCollection<ModelNodeCommandWrapper> commands)
     : base(serviceProvider, null)
 {
     if (commands == null) throw new ArgumentNullException("commands");
     if (commands.Count == 0) throw new ArgumentException(@"The collection of commands to combine is empty", "commands");
     if (commands.Any(x => !ReferenceEquals(x.NodeCommand, commands.First().NodeCommand))) throw new ArgumentException(@"The collection of commands to combine cannot contain different node commands", "commands");
     service = serviceProvider.Get<ObservableViewModelService>();
     this.commands = commands;
     this.name = name;
     this.identifier = identifier;
     this.serviceProvider = serviceProvider;
     ObservableNodePath = observableNodePath;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:13,代码来源:CombinedNodeCommandWrapper.cs

示例15: Addition

        /// <summary>
        /// Initializes a new instance of the <see cref="Addition"/> class.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="newContent">The new content.</param>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.ArgumentException"></exception>
        internal Addition(int start, IReadOnlyCollection<string> newContent)
        {
            if (newContent == null)
            {
                throw new ArgumentNullException();
            }

            if (!newContent.Any())
            {
                throw new ArgumentException();
            }

            Initialize(start, 0, newContent);
        }
开发者ID:Vadim-Borovikov,项目名称:Automerger,代码行数:22,代码来源:Addition.cs


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