• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IReadOnlyCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



IReadOnlyCollection类属于命名空间,在下文中一共展示了IReadOnlyCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
        }
开发者ID:denisivan0v,项目名称:nuclear-river,代码行数:27,代码来源:ImportFactsFromErmHandler.cs


示例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;
            }
        }
开发者ID:tddold,项目名称:Team-TheChurch,代码行数:27,代码来源:FlopHandStrength.cs


示例3: AllCommittedEventsPage

 public AllCommittedEventsPage(
     GlobalPosition nextGlobalPosition,
     IReadOnlyCollection<ICommittedDomainEvent> committedDomainEvents)
 {
     NextGlobalPosition = nextGlobalPosition;
     CommittedDomainEvents = committedDomainEvents;
 }
开发者ID:joaomajesus,项目名称:EventFlow,代码行数:7,代码来源:AllCommittedEventsPage.cs


示例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;
        }
开发者ID:tomekjanicki,项目名称:architecture2,代码行数:29,代码来源:AutofacExtension.cs


示例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));
            }
        }
开发者ID:ItsJustSean,项目名称:TailBlazer,代码行数:27,代码来源:IndexCollection.cs


示例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);
            }
        }
开发者ID:hitesh97,项目名称:C1-CMS,代码行数:33,代码来源:XmlDataProvider_Stores.cs


示例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();
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:33,代码来源:PermissionTypeFacadeCaching.cs


示例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;
        }
开发者ID:preyen,项目名称:MarketSimulator,代码行数:28,代码来源:Agent.cs


示例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();
        }
开发者ID:ryanrousseau,项目名称:Hangfire,代码行数:28,代码来源:InvocationData.cs


示例10: VisitNodeAttributes

 protected virtual void VisitNodeAttributes(IReadOnlyCollection<IXamlAttribute> attributes)
 {
     foreach (var attribute in attributes)
     {
         VisitNodeAttribute(attribute);
     }
 }
开发者ID:VlaTo,项目名称:Libra-Xaml-Styler,代码行数:7,代码来源:XamlNodeVisitor.cs


示例11: VisitNodeChildren

 protected virtual void VisitNodeChildren(IReadOnlyCollection<IXamlNode> children)
 {
     foreach (var child in children)
     {
         VisitNode(child);
     }
 }
开发者ID:VlaTo,项目名称:Libra-Xaml-Styler,代码行数:7,代码来源:XamlNodeVisitor.cs


示例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;
 }
开发者ID:Nementon,项目名称:ck-desktop,代码行数:7,代码来源:ExecutionPlan.cs


示例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;
        }
开发者ID:kokudori,项目名称:Y3,代码行数:25,代码来源:Element.cs


示例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;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:7,代码来源:ToolBarItemDoozer.cs


示例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;
            }
        }
开发者ID:joaomajesus,项目名称:EventFlow,代码行数:32,代码来源:RabbitMqPublisher.cs


示例16: PerformValidation

        /// <summary>
        /// Performs the validation.
        /// </summary>
        /// <param name="validations">The validations.</param>
        /// <param name="validationProcess">The validation process for an item.</param>
        /// <returns>The result of the action.</returns>
        public static ActionResult PerformValidation(IReadOnlyCollection<ItemValidation> validations, Func<ItemValidation, ValidationItemResult, bool> validationProcess)
        {
            var itemResult = new ValidationItemResult();
            var result = new ValidationResult(validations) { IsValid = true };
            result.CheckedItems.Add(itemResult);

            foreach (var validation in validations)
            {
                var successful = validationProcess(validation, itemResult);
                if (!successful)
                {
                    result.IsValid = false;
                }
            }

            if (!result.IsValid)
            {
                return ActionResult.Failure(new ElementExecuteException(
                    "Value comparison(s) failed. See details for validation results.{0}{1}",
                    Environment.NewLine,
                    result.GetComparisonTableByRule()));
            }

            return ActionResult.Successful();
        }
开发者ID:lopezn,项目名称:specbind,代码行数:31,代码来源:ValidateTableHelpers.cs


示例17: RegisterHandlersWithAutofac

		public static void RegisterHandlersWithAutofac(ContainerBuilder containerBuilder, IReadOnlyCollection<MessageRegistration> registrations)
		{
			var handlers = registrations.Select(x => x.Handler).Distinct();
			var piplelineHandlers = registrations.Select(x => x.Pipeline).Distinct().SelectMany(x => x).Distinct();

			RegisterLeafHandlers(containerBuilder, handlers);
			RegisterPipelineHandlers(containerBuilder, piplelineHandlers);

			foreach (var registration in registrations)
			{
				if (registration.Dependancies.Any())
				{
					foreach (var dependancy in registration.Dependancies)
					{
						containerBuilder.RegisterType(dependancy).AsSelf();
					}
				}

				if (registration.ScopedDependancies.Any())
				{
					foreach (var dependancy in registration.ScopedDependancies)
					{
						containerBuilder.RegisterType(dependancy).AsSelf().AsImplementedInterfaces().InstancePerLifetimeScope();
					}
				}
			}
		}
开发者ID:Sandboxed-Forks,项目名称:Enexure.MicroBus,代码行数:27,代码来源:ContainerExtensions.cs


示例18: matchIntoAnagrams

        void matchIntoAnagrams(IReadOnlyCollection<char> source, string lexiconWord, ICollection<Anagram> anagrams)
        {
            if (lexiconWord.Length < MIN_WORD_LENGTH)
                return;

            if (lexiconWord.Length > source.Count)
                return;

            var unused = source.ToList();
            var used = new List<char>();

            foreach (var letter in lexiconWord)
            {
                if (!unused.Move(letter, used))
                    if (!unused.Move(WILDCARD, used))
                        break;
            }

            if (used.Count != lexiconWord.Length)
                return;

            var points = getTotalPoints(used);
            var anagram = new Anagram(lexiconWord, points);

            anagrams.Add(anagram);
        }
开发者ID:rmacfie,项目名称:Words,代码行数:26,代码来源:AnagramFinder.cs


示例19: CombineViewModels

        public static ObservableViewModel CombineViewModels(IViewModelServiceProvider serviceProvider, NodeContainer nodeContainer, IReadOnlyCollection<ObservableViewModel> viewModels)
        {
            if (viewModels == null) throw new ArgumentNullException(nameof(viewModels));
            var combinedViewModel = new ObservableViewModel(serviceProvider, nodeContainer, viewModels.SelectMany(x => x.Dirtiables));

            var rootNodes = new List<ObservableModelNode>();
            foreach (var viewModel in viewModels)
            {
                if (!(viewModel.RootNode is SingleObservableNode))
                    throw new ArgumentException(@"The view models to combine must contains SingleObservableNode.", nameof(viewModels));

                viewModel.parent = combinedViewModel;
                var rootNode = (ObservableModelNode)viewModel.RootNode;
                rootNodes.Add(rootNode);
            }

            if (rootNodes.Count < 2)
                throw new ArgumentException(@"Called CombineViewModels with a collection of view models that is either empty or containt just a single item.", nameof(viewModels));

            // Find best match for the root node type
            var rootNodeType = rootNodes.First().Root.Type;
            if (rootNodes.Skip(1).Any(x => x.Type != rootNodeType))
                rootNodeType = typeof(object);

            CombinedObservableNode rootCombinedNode = CombinedObservableNode.Create(combinedViewModel, "Root", null, rootNodeType, rootNodes, null);
            rootCombinedNode.Initialize();
            combinedViewModel.RootNode = rootCombinedNode;
            return combinedViewModel;
        }
开发者ID:FERRERDEV,项目名称:xenko,代码行数:29,代码来源:ObservableViewModel.cs


示例20: Handle

        private void Handle(IReadOnlyCollection<IAggregateCommand> commands)
        {
            var aggregateRootTypes = commands.Select(x => x.AggregateRootType).ToArray();
            var actors = _aggregateActorFactory.Create(aggregateRootTypes);

            // TODO: Can agreggate actors be executed in parallel? See https://github.com/2gis/nuclear-river/issues/76
            foreach (var actor in actors)
            {
                var actorName = actor.GetType().GetFriendlyName();

                using (var transaction = new TransactionScope(
                    TransactionScopeOption.Required,
                    new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.Zero }))
                {
                    using (Probe.Create($"ETL2 {actorName}"))
                    {
                        actor.ExecuteCommands(commands);
                    }

                    transaction.Complete();
                }
            }

            _telemetryPublisher.Publish<StatisticsProcessedOperationCountIdentity>(commands.Count);
        }
开发者ID:2gis,项目名称:nuclear-river-customer-intelligence,代码行数:25,代码来源:ProjectStatisticsAggregateCommandsHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IReadOnlyDictionary类代码示例发布时间:2022-05-24
下一篇:
C# IReadContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap