private Handlers CreateHandlers(IWorkspaceProjectContext context) { var evaluationHandlers = PooledArray <(IProjectEvaluationHandler handler, string evaluationRuleName)> .GetInstance(); var commandLineHandlers = PooledArray <ICommandLineHandler> .GetInstance(); foreach ((HandlerFactory factory, string evaluationRuleName)factory in s_handlerFactories) { IWorkspaceContextHandler handler = factory.factory(_project); handler.Initialize(context); // NOTE: Handlers can be both IEvaluationHandler and ICommandLineHandler if (handler is IProjectEvaluationHandler evaluationHandler) { evaluationHandlers.Add((evaluationHandler, factory.evaluationRuleName)); } if (handler is ICommandLineHandler commandLineHandler) { commandLineHandlers.Add(commandLineHandler); } } return(new Handlers(evaluationHandlers.ToImmutableAndFree(), commandLineHandlers.ToImmutableAndFree())); }
private Handlers CreateHandlers(IWorkspaceProjectContext context) { var evaluationHandlers = ImmutableArray.CreateBuilder <(IEvaluationHandler handler, string evaluationRuleName)>(s_handlerFactories.Length); var commandLineHandlers = ImmutableArray.CreateBuilder <ICommandLineHandler>(s_handlerFactories.Length); foreach (var factory in s_handlerFactories) { object handler = factory.factory(_project, context); // NOTE: Handlers can be both IEvaluationHandler and ICommandLineHandler if (handler is IEvaluationHandler evaluationHandler) { evaluationHandlers.Add((evaluationHandler, factory.evaluationRuleName)); } if (handler is ICommandLineHandler commandLineHandler) { commandLineHandlers.Add(commandLineHandler); } } return(new Handlers(evaluationHandlers.ToImmutable(), commandLineHandlers.ToImmutable())); }
private Handlers CreateHandlers(IWorkspaceProjectContext context) { ImmutableArray <(IProjectEvaluationHandler handler, string evaluationRuleName)> .Builder evaluationHandlers = ImmutableArray.CreateBuilder <(IProjectEvaluationHandler handler, string evaluationRuleName)>(s_handlerFactories.Length); ImmutableArray <ICommandLineHandler> .Builder commandLineHandlers = ImmutableArray.CreateBuilder <ICommandLineHandler>(s_handlerFactories.Length); foreach ((HandlerFactory factory, string evaluationRuleName)factory in s_handlerFactories) { IWorkspaceContextHandler handler = factory.factory(_project); handler.Initialize(context); // NOTE: Handlers can be both IEvaluationHandler and ICommandLineHandler if (handler is IProjectEvaluationHandler evaluationHandler) { evaluationHandlers.Add((evaluationHandler, factory.evaluationRuleName)); } if (handler is ICommandLineHandler commandLineHandler) { commandLineHandlers.Add(commandLineHandler); } } return(new Handlers(evaluationHandlers.ToImmutable(), commandLineHandlers.ToImmutable())); }