本文整理汇总了C#中IReadOnlyCollection类的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection类的具体用法?C# IReadOnlyCollection怎么用?C# IReadOnlyCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IReadOnlyCollection类属于命名空间,在下文中一共展示了IReadOnlyCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
private void Handle(IReadOnlyCollection<FactOperation> operations)
{
_tracer.Debug("Handing fact operations started");
var result = _factsReplicator.Replicate(operations);
_telemetryPublisher.Publish<ErmProcessedOperationCountIdentity>(operations.Count);
var statistics = result.OfType<RecalculateStatisticsOperation>().ToArray();
var aggregates = result.OfType<AggregateOperation>().ToArray();
// We always need to use different transaction scope to operate with operation sender because it has its own store
using (var pushTransaction = new TransactionScope(TransactionScopeOption.RequiresNew,
new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.Zero }))
{
_tracer.Debug("Pushing events for statistics recalculation");
_statisticsSender.Push(statistics);
_telemetryPublisher.Publish<StatisticsEnqueuedOperationCountIdentity>(statistics.Length);
_tracer.Debug("Pushing events for aggregates recalculation");
_aggregateSender.Push(aggregates);
_telemetryPublisher.Publish<AggregateEnqueuedOperationCountIdentity>(aggregates.Length);
pushTransaction.Complete();
}
_tracer.Debug("Handing fact operations finished");
}
示例2: CalculateRisk
public static CardValuationType CalculateRisk(Card leftCard, Card rightCard, IReadOnlyCollection<Card> communityCard)
{
List<Card> cards = new List<Card>(communityCard);
cards.Add(leftCard);
cards.Add(rightCard);
var handRankType = Helpers.GetHandRank(cards);
switch (handRankType)
{
case HandRankType.Pair:
return CardValuationType.Risky;
case HandRankType.TwoPairs:
return CardValuationType.Recommended;
case HandRankType.ThreeOfAKind:
case HandRankType.Straight:
return CardValuationType.VeryRecommended;
case HandRankType.Flush:
case HandRankType.FullHouse:
case HandRankType.FourOfAKind:
return CardValuationType.VeryPowerful;
case HandRankType.StraightFlush:
return CardValuationType.AllIn;
default:
return CardValuationType.Unplayable;
}
}
示例3: AllCommittedEventsPage
public AllCommittedEventsPage(
GlobalPosition nextGlobalPosition,
IReadOnlyCollection<ICommittedDomainEvent> committedDomainEvents)
{
NextGlobalPosition = nextGlobalPosition;
CommittedDomainEvents = committedDomainEvents;
}
示例4: ConfigureContainer
public static IContainer ConfigureContainer(this IAppBuilder app, HttpConfiguration config, IReadOnlyCollection<Assembly> applicationAssemblies, IEnumerable<Module> dependencyModules, WebOption webOption)
{
var builder = new ContainerBuilder();
foreach (var module in dependencyModules)
builder.RegisterModule(module);
var assemblies = applicationAssemblies.ToArray();
ConfigureContainer(builder, webOption, assemblies);
if (webOption.UseApi)
builder.RegisterWebApiFilterProvider(config);
var container = builder.Build();
if (webOption.UseApi)
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
if (webOption.UseMvc)
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
app.UseAutofacMiddleware(container);
if (webOption.UseApi)
app.UseAutofacWebApi(config);
return container;
}
示例5: IndexCollection
public IndexCollection(IReadOnlyCollection<Index> latest,
IndexCollection previous,
FileInfo info,
Encoding encoding)
{
Info = info;
Encoding = encoding;
Count = latest.Select(idx => idx.LineCount).Sum();
Indicies = latest.ToArray();
Diff = Count - (previous?.Count ?? 0);
//need to check whether
if (previous == null)
{
ChangedReason = LinesChangedReason.Loaded;
TailInfo = new TailInfo(latest.Max(idx => idx.End));
}
else
{
var mostRecent = latest.OrderByDescending(l => l.TimeStamp).First();
ChangedReason = mostRecent.Type == IndexType.Tail
? LinesChangedReason.Tailed
: LinesChangedReason.Paged;
TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End));
}
}
示例6: CreateStores
public void CreateStores(IReadOnlyCollection<DataTypeDescriptor> dataTypeDescriptors)
{
var dataTypes = DataTypeTypesManager.GetDataTypes(dataTypeDescriptors);
var storesToCreate = new List<GeneratedTypesInfo>();
foreach (var dataTypeDescriptor in dataTypeDescriptors)
{
Type interfaceType = dataTypes[dataTypeDescriptor.DataTypeId];
storesToCreate.Add(BuildGeneratedTypesInfo(dataTypeDescriptor, interfaceType));
}
CompileMissingTypes(storesToCreate);
foreach (var storeToCreate in storesToCreate)
{
var dataTypeDescriptor = storeToCreate.DataTypeDescriptor;
InterfaceConfigurationManipulator.AddNew(_dataProviderContext.ProviderName, dataTypeDescriptor);
var xmlDataTypeStoreCreator = new XmlDataTypeStoreCreator(_fileStoreDirectory);
XmlDataTypeStore xmlDateTypeStore = xmlDataTypeStoreCreator.CreateStoreResult(
dataTypeDescriptor,
storeToCreate.DataProviderHelperClass,
storeToCreate.DataIdClass, null);
Type interfaceType = storeToCreate.InterfaceType;
AddDataTypeStore(dataTypeDescriptor, interfaceType, xmlDateTypeStore);
}
}
示例7: SetToCache
private static void SetToCache(UserToken userToken, EntityToken entityToken, IReadOnlyCollection<PermissionType> permissionTypes, object cachingKey)
{
// Using RequestLifetimeCache and there for no thread locking /MRJ
Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>> permissionTypeCache;
if (RequestLifetimeCache.HasKey(cachingKey))
{
permissionTypeCache = RequestLifetimeCache.TryGet<Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>>>(cachingKey);
}
else
{
permissionTypeCache = new Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>>();
RequestLifetimeCache.Add(cachingKey, permissionTypeCache);
}
Dictionary<EntityToken, IReadOnlyCollection<PermissionType>> entityTokenPermissionTypes;
if (!permissionTypeCache.TryGetValue(userToken, out entityTokenPermissionTypes))
{
entityTokenPermissionTypes = new Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>();
permissionTypeCache.Add(userToken, entityTokenPermissionTypes);
}
if (!entityTokenPermissionTypes.ContainsKey(entityToken))
{
entityTokenPermissionTypes.Add(entityToken, permissionTypes);
}
else
{
entityTokenPermissionTypes[entityToken] = entityTokenPermissionTypes[entityToken].Concat(permissionTypes).Distinct().ToList();
}
}
示例8: Agent
public Agent(Random randomNumberGenerator, int maxOrderQuantity, string name,IReadOnlyCollection<BitArray> allTimingChromosomes, double initialPropensity, double recency, double experimentation,
double temperature, string group)
{
_random = randomNumberGenerator;
_maxOrderQuantity = maxOrderQuantity;
_name = name;
_initialPropensity = initialPropensity;
_recency = recency;
_experimentation = experimentation;
_temperature = temperature;
_group = @group;
CurrentProfit = 0;
_learningLog = new List<ChromosomeLearning>();
foreach (var chromosome in allTimingChromosomes)
{
_learningLog.Add(new ChromosomeLearning()
{
Probability = 1d/allTimingChromosomes.Count,
Propensity = initialPropensity,
TimingChromosome = chromosome
});
}
TimingChromosome = _learningLog.OrderBy(l => l.Probability*_random.NextDouble()).First().TimingChromosome;
}
示例9: SerializeArguments
internal static string[] SerializeArguments(IReadOnlyCollection<object> arguments)
{
var serializedArguments = new List<string>(arguments.Count);
foreach (var argument in arguments)
{
string value = null;
if (argument != null)
{
if (argument is DateTime)
{
value = ((DateTime)argument).ToString("o", CultureInfo.InvariantCulture);
}
else
{
value = JobHelper.ToJson(argument);
}
}
// Logic, related to optional parameters and their default values,
// can be skipped, because it is impossible to omit them in
// lambda-expressions (leads to a compile-time error).
serializedArguments.Add(value);
}
return serializedArguments.ToArray();
}
示例10: VisitNodeAttributes
protected virtual void VisitNodeAttributes(IReadOnlyCollection<IXamlAttribute> attributes)
{
foreach (var attribute in attributes)
{
VisitNodeAttribute(attribute);
}
}
示例11: VisitNodeChildren
protected virtual void VisitNodeChildren(IReadOnlyCollection<IXamlNode> children)
{
foreach (var child in children)
{
VisitNode(child);
}
}
示例12: ExecutionPlan
internal ExecutionPlan( IEnumerable<IPluginInfo> pluginsToStart, IEnumerable<IPluginInfo> pluginsToStop, IReadOnlyCollection<IPluginInfo> pluginsToDisable )
{
Debug.Assert( pluginsToStart != null && pluginsToStop != null && pluginsToDisable != null );
PluginsToStart = pluginsToStart.ToReadOnlyCollection();
PluginsToStop = pluginsToStop.ToReadOnlyCollection();
PluginsToDisable = pluginsToDisable;
}
示例13: 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;
}
示例14: ToolbarItemDescriptor
public ToolbarItemDescriptor(object parameter, Codon codon, IList subItems, IReadOnlyCollection<ICondition> conditions)
{
this.Parameter = parameter;
this.Codon = codon;
this.SubItems = subItems;
this.Conditions = conditions;
}
示例15: PublishAsync
public async Task PublishAsync(IReadOnlyCollection<RabbitMqMessage> rabbitMqMessages, CancellationToken cancellationToken)
{
var uri = _configuration.Uri;
IRabbitConnection rabbitConnection = null;
try
{
rabbitConnection = await GetRabbitMqConnectionAsync(uri, cancellationToken).ConfigureAwait(false);
await _transientFaultHandler.TryAsync(
c => rabbitConnection.WithModelAsync(m => PublishAsync(m, rabbitMqMessages), c),
Label.Named("rabbitmq-publish"),
cancellationToken)
.ConfigureAwait(false);
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
if (rabbitConnection != null)
{
using (await _asyncLock.WaitAsync(CancellationToken.None).ConfigureAwait(false))
{
rabbitConnection.Dispose();
_connections.Remove(uri);
}
}
_log.Error(e, "Failed to publish domain events to RabbitMQ");
throw;
}
}