本文整理汇总了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);
}
}
示例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);
});
}
示例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;
}
示例5: EnsurePolicyIsUpdated
public void EnsurePolicyIsUpdated(IReadOnlyCollection<string> config)
{
if (config.Any())
{
var policy = new SnsPolicy(config);
policy.Save(Arn, Client);
}
}
示例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);
}
示例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;
}
示例8: EventAggregator
public EventAggregator(IList<IEvent> aggregatedEvents)
{
_supportedEvents = GetType().GenericTypeArguments;
if (!_supportedEvents.Any())
{
throw new NotSupportedException();
}
AggregatedEvents = aggregatedEvents;
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}