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


C# IReadOnlyCollection.Select方法代码示例

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


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

示例1: 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

示例2: Parse

        // Internal for testing
        internal string Parse(string code, IReadOnlyCollection<Type> moduleTypes, IEnumerable<string> namespaces)
        {
            // Rewrite the lambda shorthand expressions
            SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(code, new CSharpParseOptions(kind: SourceCodeKind.Script));
            LambdaRewriter lambdaRewriter = new LambdaRewriter(moduleTypes.Select(x => x.Name));
            SyntaxNode syntaxNode = lambdaRewriter.Visit(syntaxTree.GetRoot());

            // "Lift" class and method declarations
            LiftingWalker liftingWalker = new LiftingWalker();
            liftingWalker.Visit(syntaxNode);

            // Get the using statements
            string usingStatements = string.Join(Environment.NewLine, namespaces.Select(x => "using " + x + ";"));

            // Get the methods to instantiate each module
            Dictionary<string, string> moduleNames = new Dictionary<string, string>();
            string moduleMethods = string.Join(Environment.NewLine,
                moduleTypes.Select(x => GenerateModuleConstructorMethods(x, moduleNames)));

            // Return the fully parsed script
            return 
                [email protected]"// Generated: bring all module namespaces in scope
                {usingStatements}

                // Input: using directives
                {liftingWalker.UsingDirectives}

                public class {ScriptClassName} : ScriptBase
                {{
                    public {ScriptClassName}(Engine engine) : base(engine) {{ }}

                    public override void Run()
                    {{
                        // Input: script code
{liftingWalker.ScriptCode}
                    }}

                    // Input: lifted methods
{liftingWalker.MethodDeclarations}

                    // Generated: methods for module instantiation
                    {moduleMethods} 
                }}

                // Input: lifted object declarations
{liftingWalker.TypeDeclarations}

                public static class ScriptExtensionMethods
                {{
                    // Input: lifted extension methods
{liftingWalker.ExtensionMethodDeclarations}
                }}";
        }
开发者ID:ibebbs,项目名称:Wyam,代码行数:54,代码来源:ScriptManager.cs

示例3: 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

示例4: 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

示例5: WriteAsync

        public Task WriteAsync(IReadOnlyCollection<IUnpersistedRawStreamEvent> events)
        {
            lock (_events)
            {
                var globalSequence = _events.Count + 1;

                var existingEvents = _events.Select(e => e.EventID);

                if (existingEvents.Intersect(events.Select(e => e.EventID)).Any())
                    throw new DuplicatedEntryException();

                foreach (var e in events)
                {
                    e.GlobalSequence = globalSequence++;

                    var p = new PersistedRawEvent
                    {
                        GlobalSequence = e.GlobalSequence,
                        EventID = e.EventID,
                        Stream = e.Stream,
                        EventType = e.EventType,
                        UtcTimestamp = e.UtcTimestamp,
                        Metadata = e.Metadata,
                        Payload = e.Payload
                    };

                    _events.Add(p);
                }
            }

            return Unit.GetCompletedTask();
        }
开发者ID:promontis,项目名称:Even,代码行数:32,代码来源:InMemoryStore.cs

示例6: TryAddSourceItemsToOwnedProjectFileAsync

        public async Task<bool> TryAddSourceItemsToOwnedProjectFileAsync(IReadOnlyCollection<ItemData> items, string projectFilePath) {
            if (!CheckProjectFileOwnership(projectFilePath)) {
                return false;
            }

            var unhandledItems = await _temporaryItems.AddTemporaryFiles(_configuredProject, items.Select(i => i.Item2));
            return unhandledItems.Count < items.Count;
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:8,代码来源:FileSystemMirroringProjectSourceItemProviderExtensionBase.cs

示例7: ProcessDonations

        private static void ProcessDonations(IReadOnlyCollection<Tuple<string, int>> donations)
        {
            // Change the Fs to EF or Dapper for different ORM implementation
            var persons = Fs.PersonLoader.LoadPersons(donations.Select(x => x.Item1)).ToList();

            AddDonations(donations, persons);

            LogOrgAmounts(persons);
        }
开发者ID:onybo,项目名称:OrmDemo,代码行数:9,代码来源:Program.cs

示例8: GenerateCtor

 private static IEnumerable<string> GenerateCtor(EntityModel entity, IReadOnlyCollection<IPropertyModel> classProps)
 {
     var ctorArgs = string.Join(", ", classProps.Select(p => p.TypeFullName + " " + p.Name));
     yield return $"public {entity.Name}({ctorArgs}) {{";
     foreach (var prop in classProps)
     {
         yield return $"\tthis.{prop.Name} = {prop.Name};";
     }
     yield return "}";
 }
开发者ID:ru-sh,项目名称:dnxt,代码行数:10,代码来源:CsCodeGenerator.cs

示例9: SetStartNodes

 public GraphNode SetStartNodes(IReadOnlyCollection<SkillNode> startNodes)
 {
     var supernode = new GraphNode(startNodes.Select(n => n.Id));
     foreach (var node in startNodes)
     {
         NodeDict.Add(node, supernode);
         CheckLinks(node);
     }
     return supernode;
 }
开发者ID:EmmittJ,项目名称:PoESkillTree,代码行数:10,代码来源:SearchGraph.cs

示例10: DetermineErrorMessage

 private static string DetermineErrorMessage(int returnCode, IReadOnlyCollection<int> errorCodes)
 {
     string errorMessage = (OstcMessages.ReturnCodeMessages.ContainsKey(returnCode) ? OstcMessages.ReturnCodeMessages[returnCode] : "Unbekannter Rückgabe-Wert");
     var exceptionMessage = $"Rückgabe-Wert {returnCode}: {errorMessage}";
     if (errorCodes.Count != 0)
     {
         var errorCodesList = string.Join(", ", errorCodes.Select(x => x.ToString()).ToArray());
         exceptionMessage = $"{exceptionMessage}\nFolgende Fehlercodes wurden zurückgeliefert: {errorCodesList}";
     }
     return exceptionMessage;
 }
开发者ID:dataline-gmbh,项目名称:Itsg.Ostc,代码行数:11,代码来源:OstcApplicationRequestException.cs

示例11: PrintFailures

        private static void PrintFailures(IReadOnlyCollection<KeyValuePair<string, Exception>> errors)
        {
            if (errors == null || errors.Count <= 0)
                return;

            Console.WriteLine();
            Console.WriteLine(Resources.StatisticsFailuresHeader);
            Console.WriteLine(String.Join(Environment.NewLine, 
                errors.Select(e => String.Format(CultureInfo.InvariantCulture, 
                    Resources.StatisticsFailureItemFormat, e.Key, e.Value.Message))));
        }
开发者ID:kingkino,项目名称:azure-documentdb-datamigrationtool,代码行数:11,代码来源:TransferStatisticsHandler.cs

示例12: Constructor

        public Constructor(ConstructorInfo constructor)
        {
            Parameters = Array.AsReadOnly(constructor.GetParameters().Select(p => p.ParameterType).ToArray());

            var inputs = Expression.Parameter(typeof(object[]));
            var create = Expression.New(constructor,
                    Parameters.Select((p, i) => Expression.Convert(Expression.ArrayIndex(inputs, Expression.Constant(i)), p)));

            // compile the ConstructorInfo into a function
            _Constructor = Expression.Lambda<Func<object[], object>>(constructor.DeclaringType.IsValueType ?
                Expression.Convert(create, typeof(object)) as Expression : create, inputs).Compile();
        }
开发者ID:ShaneGH,项目名称:Dynamox,代码行数:12,代码来源:Constructor.cs

示例13: GetTranslatedSort

 public static string GetTranslatedSort(string modelColumn, string defaultSort, IReadOnlyCollection<string> allowedColumns)
 {
     if (string.IsNullOrEmpty(modelColumn))
         return defaultSort.ToUpperInvariant();
     var arguments = modelColumn.Split(' ');
     if (arguments.Length != 2)
         return defaultSort.ToUpperInvariant();
     var ascending = arguments[1].ToUpperInvariant() == "ASC";
     var column = arguments[0].ToUpperInvariant();
     if (!allowedColumns.Select(c => c.ToUpperInvariant()).Contains(column))
         return defaultSort.ToUpperInvariant();
     return $"{column} {(@ascending ? "ASC" : "DESC")}";
 }
开发者ID:tomekjanicki,项目名称:architecture2,代码行数:13,代码来源:CommandHelper.cs

示例14: GetMessagesFromStore

        /// <summary>
        /// Gets the selected messages from the store
        /// </summary>
        /// <param name="messageStore">The store to retrieve from</param>
        /// <param name="messageIds">The messages to retrieve</param>
        /// <returns></returns>
        private static IEnumerable<Message> GetMessagesFromStore(IAmAMessageStore<Message> messageStore, IReadOnlyCollection<string> messageIds)
        {
            IEnumerable<Message> foundMessages = messageIds 
                .Select(messageId => messageStore.Get(Guid.Parse(messageId)))
                .Where(fm => fm != null)
                .ToList();

            if (foundMessages.Count() < messageIds.Count)
            {
                throw new SystemException("Cannot find messages " +
                                          string.Join(",", messageIds.Where(id => foundMessages.All(fm => fm.Id.ToString() != id.ToString())).ToArray()));
            }
            return foundMessages;
        }
开发者ID:yonglehou,项目名称:Paramore,代码行数:20,代码来源:MessageRecovery.cs

示例15: LogFoundMessages

 static void LogFoundMessages(IReadOnlyCollection<MessageMetadata> messageDefinitions)
 {
     if (!Logger.IsInfoEnabled)
     {
         return;
     }
     Logger.DebugFormat("Number of messages found: {0}", messageDefinitions.Count);
     if (!Logger.IsDebugEnabled)
     {
         return;
     }
     Logger.DebugFormat("Message definitions: \n {0}",
         string.Concat(messageDefinitions.Select(md => md + "\n")));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:14,代码来源:SerializationFeature.cs


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