本文整理汇总了C#中IReadOnlyCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection.Cast方法的具体用法?C# IReadOnlyCollection.Cast怎么用?C# IReadOnlyCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyCollection
的用法示例。
在下文中一共展示了IReadOnlyCollection.Cast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteCommands
public IReadOnlyCollection<IEvent> ExecuteCommands(IReadOnlyCollection<ICommand> commands)
{
foreach (var command in commands.Cast<ReplicateInBulkCommand>())
{
var commandStopwatch = Stopwatch.StartNew();
var dataObjectTypes = GetDataObjectTypes(_dataObjectTypesProviderFactory.Create(command));
var tableTypesDictionary = dataObjectTypes
.GroupBy(t => GetTable(command.TargetStorageDescriptor.MappingSchema, t))
.ToDictionary(g => g.Key, g => g.ToArray());
var executionStrategy = DetermineExecutionStrategy(command);
executionStrategy.Invoke(command, tableTypesDictionary);
commandStopwatch.Stop();
Console.WriteLine($"[{command.SourceStorageDescriptor.ConnectionStringIdentity}] -> " +
$"[{command.TargetStorageDescriptor.ConnectionStringIdentity}]: {commandStopwatch.Elapsed.TotalSeconds} seconds");
}
return Array.Empty<IEvent>();
}
示例2: testProject_TestClasses_CollectionChanged
void testProject_TestClasses_CollectionChanged(IReadOnlyCollection<ITest> removedItems, IReadOnlyCollection<ITest> addedItems)
{
classesRemoved.AddRange(removedItems.Cast<NUnitTestClass>());
classesAdded.AddRange(addedItems.Cast<NUnitTestClass>());
}