public ApiModule(ICompositeApp compositeApp, ICommandRegistry registry, IPublisher publisher) : base(BaseRoute) { _compositeApp = compositeApp; _registry = registry; _publisher = publisher; Get[string.Empty] = _ => GetComposite(); Get[AgentMetadataRoute] = p => GetAgent(stripExtension((string)p.agentSystemName)); Get[ReadModelMetadataRoute] = p => GetReadModel((string)p.agentSystemName, stripExtension((string)p.readModelName)); Get[InputModelMetadataRoute] = p => GetInputModel(stripExtension((string)p.inputModelName)); Get[PublicationRecordRoute] = p => GetPublicationRecord((Guid)p.identifier); Get[InputModelMetadataForCommandRoute] = p => GetInputModelMetadata(stripExtension((string)p.commandName)); Get[CommandMetadataRoute] = p => GetCommandMetadata(stripExtension((string)p.commandName)); Get[QueryMetadataRoute] = p => GetQueryMetadata(stripExtension((string)p.queryName)); Get[CommandIsSupportedRoute] = p => GetCommandIsSupported(stripExtension((string)p.commandName)); Get[QueryForReadModelRoute] = p => QueryForReadmodel((string)p.queryName, (string)p.methodName); Get[QueryMethodRoute] = p => GetQueryMethod((string) p.queryName, (string) p.methodName); Post[PublishCommandRoute] = p => PublishCommand(this.Bind<IInputModel>()); }
public RegisterFireAndForgetHandler(ICommandRegistry commandRegistry, IServiceCollection serviceCollection, Type functionHandlerType, ICommandDispatcher customCommandDispatcher) { _commandRegistry = commandRegistry; _serviceCollection = serviceCollection; _functionHandlerType = functionHandlerType; _customCommandDispatcher = customCommandDispatcher; }
public FunctionHostBuilder(IServiceCollection serviceCollection, ICommandRegistry commandRegistry, bool isRuntime) { _isRuntime = isRuntime; ServiceCollection = serviceCollection; CommandRegistry = commandRegistry; }
public FunctionCompiler(Assembly configurationSourceAssembly, string outputBinaryFolder, bool outputProxiesJson, TargetEnum target, IAssemblyCompiler assemblyCompiler = null, ITriggerReferenceProvider triggerReferenceProvider = null) { _configurationSourceAssembly = configurationSourceAssembly; _outputBinaryFolder = outputBinaryFolder; _outputProxiesJson = outputProxiesJson; _target = target; _serviceCollection = new ServiceCollection(); CommandingDependencyResolverAdapter adapter = new CommandingDependencyResolverAdapter( (fromType, toInstance) => _serviceCollection.AddSingleton(fromType, toInstance), (fromType, toType) => _serviceCollection.AddTransient(fromType, toType), (resolveType) => null // we never resolve during compilation ); _commandRegistry = adapter.AddCommanding(); _assemblyCompiler = assemblyCompiler ?? new AssemblyCompiler(); _triggerReferenceProvider = triggerReferenceProvider ?? new TriggerReferenceProvider(); _jsonCompiler = new JsonCompiler(); _proxiesJsonCompiler = new ProxiesJsonCompiler(); _openApiCompiler = new OpenApiCompiler(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(c => { c.Filters.Add <AssignAuthenticatedUserIdActionFilter>(); c.AddAuthenticatedUserIdAwareBodyModelBinderProvider(); }).AddFluentValidation(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Online Store API", Version = "v1" }); c.SchemaFilter <SwaggerAuthenticatedUserIdFilter>(); c.OperationFilter <SwaggerAuthenticatedUserIdOperationFilter>(); }); TelemetryClient client = new TelemetryClient(); services.AddSingleton <IMetricCollectorFactory>(s => new MetricCollectorFactory(client)); CommandingDependencyResolver = new MicrosoftDependencyInjectionCommandingResolver(services); ICommandRegistry registry = CommandingDependencyResolver.UseCommanding(); services .UseShoppingCart(registry) .UseStore(registry) .UseCheckout(registry); services.Replace(new ServiceDescriptor(typeof(ICommandDispatcher), typeof(LoggingCommandDispatcher), ServiceLifetime.Transient)); }
public void Setup() { _testCommand = A.Fake<ICommand>(); _publisher = A.Fake<IPublisher>(); _compositeApp = A.Fake<ICompositeApp>(); _registry = A.Fake<ICommandRegistry>(); _formatter = A.Fake<IResponseFormatter>(); _publicationRecord = A.Fake<ICommandPublicationRecord>(); _jsonSerializer = new DefaultJsonSerializer(); _xmlSerializer = new DefaultXmlSerializer(); A.CallTo(() => _testCommand.Created).Returns(DateTime.MaxValue); A.CallTo(() => _testCommand.CreatedBy).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778")); A.CallTo(() => _testCommand.Identifier).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778")); A.CallTo(() => _formatter.Serializers).Returns(new List<ISerializer> { _jsonSerializer, _xmlSerializer }); A.CallTo(() => _publicationRecord.Dispatched).Returns(true); A.CallTo(() => _publicationRecord.Error).Returns(false); A.CallTo(() => _publicationRecord.Completed).Returns(true); A.CallTo(() => _publicationRecord.Created).Returns(DateTime.MinValue); A.CallTo(() => _publicationRecord.MessageLocation).Returns(new Uri("http://localhost/fake/message")); A.CallTo(() => _publicationRecord.MessageType).Returns(typeof(IPublicationRecord)); A.CallTo(() => _publicationRecord.CreatedBy).Returns(Guid.Empty); A.CallTo(() => _compositeApp.GetCommandForInputModel(A.Dummy<IInputModel>())).Returns(_testCommand); A.CallTo(() => _publisher.PublishMessage(A.Fake<ICommand>())).Returns(_publicationId); A.CallTo(() => _registry.GetPublicationRecord(_publicationId)).Returns(_publicationRecord); _euclidApi = new ApiModule(_compositeApp, _registry, _publisher); }
public static IServiceCollection UseServiceBusScheduler( this IServiceCollection serviceCollection, ICommandRegistry commandRegistry, Options options) { return(UseServiceBusScheduler <ICommandDispatcher>(serviceCollection, commandRegistry, options)); }
private static void ConfigureCommanding(CloudQueue queue, out ICommandDispatcher dispatcher, out IAzureStorageCommandQueueProcessorFactory listenerFactory) { ServiceCollection serviceCollection = new ServiceCollection(); CommandingDependencyResolverAdapter dependencyResolver = serviceCollection.GetCommandingDependencyResolver(() => _serviceProvider); ICommandRegistry registry = dependencyResolver.AddCommanding(); dependencyResolver.AddQueues( (msg, cmd, ex) => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(msg); }, (msg, cmd, ex) => { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(msg); }, (msg, cmd, ex) => { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(msg); }) .AddAzureStorageCommanding(); registry .Register <OutputWorldToConsoleCommandHandler>(1000, dispatcherFactoryFunc: queue.CreateCommandDispatcherFactory()) .Register <OutputBigglesToConsoleCommandHandler>(); _serviceProvider = serviceCollection.BuildServiceProvider(); dispatcher = _serviceProvider.GetService <ICommandDispatcher>(); listenerFactory = _serviceProvider.GetService <IAzureStorageCommandQueueProcessorFactory>(); }
public static ICommandRegistry RegisterFileSystemObjectStore(this ICommandRegistry commandRegistry) { return(commandRegistry .Register <FileSystemStoreObjectCommandHandler>() .Register <FileSystemRetrieveObjectCommandHandler>() .Register <FileSystemListObjectKeysCommandHandler>()); }
public static ICommandRegistry RegisterAmazonS3ObjectStore(this ICommandRegistry commandRegistry) { return(commandRegistry .Register <AmazonS3StoreObjectCommandHandler>() .Register <AmazonS3RetrieveObjectCommandHandler>() .Register <AmazonS3ListObjectKeysCommandHandler>()); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(c => { c.Filters.Add <AssignAuthenticatedUserIdActionFilter>(); c.AddAuthenticatedUserIdAwareBodyModelBinderProvider(); }).AddFluentValidation(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Online Store API", Version = "v1" }); c.SchemaFilter <SwaggerAuthenticatedUserIdFilter>(); c.OperationFilter <SwaggerAuthenticatedUserIdOperationFilter>(); }); CommandingDependencyResolver = new MicrosoftDependencyInjectionCommandingResolver(services); ICommandRegistry registry = CommandingDependencyResolver.UseCommanding(); services .UseShoppingCart(registry) .UseStore(registry) .UseCheckout(registry); }
public static ICommandRegistry RegisterMemoryObjectStore(this ICommandRegistry commandRegistry) { return(commandRegistry .Register <MemoryStoreObjectCommandHandler>() .Register <MemoryRetrieveObjectCommandHandler>() .Register <MemoryListObjectKeysCommandHandler>()); }
public CommandProcessor(ICommandRegistry commandRegistry, ICommandExecutor commandExecutor, ICommandSerializer commandSerializer, IServiceLocator serviceLocator) { this.commandRegistry = commandRegistry; this.commandExecutor = commandExecutor; this.commandSerializer = commandSerializer; this.serviceLocator = serviceLocator; }
public override void BeforeServiceProviderBuild(IServiceCollection serviceCollection, ICommandRegistry commandRegistry) { base.BeforeServiceProviderBuild(serviceCollection, commandRegistry); var consignmentRepository = Substitute.For <IConsignmentRepository>(); consignmentRepository.Get(Arg.Any <Guid>()).Returns(callInfo => Task.FromResult(new ConsignmentRecord { Id = callInfo.Arg <Guid>() })); consignmentRepository.Get(Arg.Is(_withDeliveredTrackingConsignmentId)).Returns(callInfo => Task.FromResult(new ConsignmentRecord { Id = callInfo.Arg <Guid>(), TrackingRecords = new List <TrackingRecord> { new TrackingRecord { Id = Guid.NewGuid(), ConsignmentId = callInfo.Arg <Guid>(), TrackingType = TrackingType.Delivered } } })); serviceCollection.Replace(new ServiceDescriptor(typeof(IConsignmentRepository), consignmentRepository)); }
public static ICommandRegistry RegisterCommands( ICommandRegistry registry, UserRepository repository, Func <string> tokenSource, Func <string, string> passwordHasher, int maxLoginAttempts, Func <DateTimeOffset> lockoutPolicy) { var handler = new UserCommandHandler(tokenSource, passwordHasher, maxLoginAttempts, lockoutPolicy); var userRegistry = registry.For <User>(); userRegistry .WithDefaults(repository.SaveNew, id => repository.Load(id), repository.Save) .Create <CreateUser>(handler.Create) .Execute <VerifyEmailAndSetPassword>(handler.Execute) .Execute <ChangeEmail>(handler.Execute) .Execute <VerifyEmail>(handler.Execute) .Execute <ChangePassword>(handler.Execute) .Execute <ChangeName>(handler.Execute) .Execute <RequestResetPassword>(handler.Execute) .Execute <SetPassword>(handler.Execute); userRegistry .WithDefaults( (_, __) => throw new NotSupportedException(), id => repository.Load(id, true), repository.Save) .Execute <LoginUser, LoginResult>(handler.Execute) .Execute <ManualUnlock>(handler.Execute) .Execute <ManualLock>(handler.Execute); return(registry); }
public HelpCommand(ICommandRegistry registry, SystemCommandRegistry systemRegistry, IOutputWriter outputWriter, GeneralSettings settings) { _registry = registry; _systemRegistry = systemRegistry; _outputWriter = outputWriter; _settings = settings; }
public static ICommandRegistry AddNotificationClient(this ICommandRegistry commandRegistry, string serviceBusConnectionString) { // Configure the SendEmailCommand to be dispatched to a service bus queue QueueClient queueClient = new QueueClient(serviceBusConnectionString, "sendEmailQueue"); commandRegistry.Register <SendEmailCommand>(queueClient.CreateCommandDispatcherFactory()); return(commandRegistry); }
public void Register(ICommandRegistry aCommandRegistry) { aCommandRegistry.AddCommand("install", Guard(Install), "Install (or upgrade) an app from a file."); aCommandRegistry.AddCommand("uninstall", Guard(Uninstall), "Uninstall an app by name."); aCommandRegistry.AddCommand("listapps", Guard(ListApps), "List installed apps."); aCommandRegistry.AddCommand("installnew", Guard(InstallNew), "Install an app from a file."); aCommandRegistry.AddCommand("upgrade", Guard(Upgrade), "Upgrade an app from a file. Usage: 'upgrade <appname> <zipfile>'"); }
public ServerContext(ICommandRegistry registry = null, ICommandBroker broker = null, ICommandStateProvider stateProvider = null) { _registry = registry ?? Implementations.CommandRegistry; _broker = broker ?? Implementations.Broker; _stateProvider = stateProvider ?? Implementations.StateProvider; }
protected override void RegisterMiscHandlersImpl(ICommandRegistry commandRegistry, Func <IServiceProvider> serviceProviderFactory) { commandRegistry.Register <BatchMapDataCommand>(() => serviceProviderFactory().GetService <QueueCommandDispatcher>()); commandRegistry.Register <WriteMappedDataCommand>(() => serviceProviderFactory().GetService <QueueCommandDispatcher>()); commandRegistry.Register <BatchReduceDataCommand>(() => serviceProviderFactory().GetService <QueueCommandDispatcher>()); commandRegistry.Register <WriteReducedDataCommand>(() => serviceProviderFactory().GetService <QueueCommandDispatcher>()); }
public CommandingMiddleware(RequestDelegate next, ICommandRegistry registry, IMemoryCache memoryCache, ILoggerFactory loggerFactory) { _next = next; _registry = registry; _logger = loggerFactory.CreateLogger <CommandingMiddleware>(); _memoryCache = memoryCache; }
public FunctionHostBuilder(IServiceCollection serviceCollection, ICommandRegistry commandRegistry, bool isRuntime) { _isRuntime = isRuntime; ServiceCollection = serviceCollection; CommandRegistry = commandRegistry; FunctionBuilder = new FunctionBuilder(ConnectionStringSettingNames); }
public OptionsBuilder WithCommandRegistry(Func <IOptionsContext, ICommandRegistry> resolver) { Guard.EnsureNotNull(resolver, nameof(resolver)); commandRegistry = resolver(this); Guard.EnsureNotNull(commandRegistry, nameof(commandRegistry)); return(this); }
private static FunctionHostBuilder CreateBuilderFromConfiguration(ICommandRegistry commandRegistry, IFunctionAppConfiguration configuration) { FunctionHostBuilder builder = new FunctionHostBuilder(ServiceCollection, commandRegistry, true); configuration.Build(builder); new PostBuildPatcher().Patch(builder, ""); return(builder); }
public static IServiceCollection UseStore(this IServiceCollection serviceCollection, ICommandRegistry commandRegistry) { serviceCollection.AddSingleton <IStoreProductRepository, StoreProductRepository>(); commandRegistry.Register <GetStoreProductQueryHandler>(); return(serviceCollection); }
public OptionsBuilder WithCommandRegistry(Func<IOptionsContext, ICommandRegistry> resolver) { Guard.EnsureNotNull(resolver, nameof(resolver)); commandRegistry = resolver(this); Guard.EnsureNotNull(commandRegistry, nameof(commandRegistry)); return this; }
public static IServiceCollection UseCheckout(this IServiceCollection serviceCollection, ICommandRegistry registry) { serviceCollection.AddSingleton <IOrderRepository, OrderRepository>(); registry.Register <CreateOrderCommandHandler>(); registry.Register <MakePaymentCommandHandler>(); return(serviceCollection); }
internal Options(ICommandRegistry commandRegistry, IHandlerFactory handlerFactory, CommandPipeline commandPipeline) { Guard.EnsureNotNull(commandRegistry, nameof(commandRegistry)); Guard.EnsureNotNull(handlerFactory, nameof(handlerFactory)); Guard.EnsureNotNull(commandPipeline, nameof(commandPipeline)); CommandRegistry = commandRegistry; HandlerFactory = handlerFactory; CommandPipeline = commandPipeline; }
private FunctionHostBuilder CreateBuilderFromConfiguration(ICommandRegistry commandRegistry, IFunctionAppConfiguration configuration) { FunctionHostBuilder builder = new FunctionHostBuilder(ServiceCollection, commandRegistry, true); configuration.Build(builder); RegisterCommandHandlersForCommandsWithNoAssociatedHandler(builder, commandRegistry); new PostBuildPatcher().Patch(builder, ""); return(builder); }
public static IServiceCollection AddProductApplication(this IServiceCollection serviceCollection, ICommandRegistry commandRegistry) { // Register validators serviceCollection.AddTransient <IValidator <GetProductQuery>, GetProductQueryValidator>(); // Register commands with discovery approach commandRegistry.Discover(typeof(IServiceCollectionExtensions).Assembly); return(serviceCollection); }
public static IServiceCollection UseShoppingCart(this IServiceCollection serviceCollection, ICommandRegistry commandRegistry) { serviceCollection.AddSingleton <IShoppingCartRepository, ShoppingCartRepository>(); commandRegistry.Register <GetCartQueryHandler>(); commandRegistry.Register <AddToCartCommandHandler>(); return(serviceCollection); }
public ScheduledMessageHandler(ICommandRegistry registry, ICommandRescheduler commandRescheduler, TDispatcherType dispatcher) { // NOTE: I need to update the commanding / mediator framework to register the catalogue interface // The below cast is a bit of a nasty workaround until I can. _registry = (IRegistrationCatalogue)registry; _commandRescheduler = commandRescheduler; _dispatcher = dispatcher; }
internal HttpOptions(string commandPath, ICommandRegistry commandRegistry, IHandlerFactory handlerFactory, ICommandNameResolver commandNameResolver, CommandFactory commandFactory, CommandPipeline commandPipeline) : base(commandRegistry, handlerFactory, commandPipeline) { Guard.EnsureNotNullOrWhitespace(commandPath, nameof(commandPath)); Guard.EnsureNotNull(commandNameResolver, nameof(commandNameResolver)); Guard.EnsureNotNull(commandFactory, nameof(commandFactory)); CommandPath = commandPath; CommandNameResolver = commandNameResolver; CommandFactory = commandFactory; }
public CommandDispatcher(ICommandRegistry commandRegistry, ICommandTypeHelper commandTypeHelper, IResponseSender responseSender, IEventBus eventBus, ICommandParser commandParser) { _commandRegistry = commandRegistry; _commandTypeHelper = commandTypeHelper; this._eventBus = eventBus; _commandParser = commandParser; _channelClosedHandler = OnChannelClosed; _eventBus.Add(EventKeys.ChannelClosed, _channelClosedHandler); }
/// <summary> /// Executes the specified command. /// </summary> /// <typeparam name="TBaseCommand">The base type that all commands inherit from, /// or a common interface for all. Can even be <see cref="object"/> if no /// common interface is needed.</typeparam> /// <param name="registry">The command registry to execute the command on.</param> /// <param name="commands">The commands to execute.</param> public static void Execute <TBaseCommand>(this ICommandRegistry <TBaseCommand> registry, IEnumerable <TBaseCommand> commands) { Guard.NotNull(() => registry, registry); Guard.NotNull(() => commands, commands); foreach (var command in commands) { registry.Execute(command, new Dictionary <string, object>()); } }
public CleeEngine(ICommandRegistry commandRegistry, ICommandFactory commandFactory, IArgumentMapper argumentMapper, ICommandExecutor commandExecutor) { _registry = commandRegistry; _commandFactory = commandFactory; _mapper = argumentMapper; _commandExecutor = commandExecutor; _systemRegistry = SystemCommandRegistry.CreateAndInitialize(); // this should be removed from the constructor! _systemCommandFactory = new SystemCommandFactory(); _systemCommandFactory.RegisterInstance<ICommandRegistry>(_registry); _systemCommandFactory.RegisterInstance<ICommandFactory>(_commandFactory); _systemCommandFactory.RegisterInstance<IArgumentMapper>(_mapper); _systemCommandFactory.RegisterInstance<ICommandExecutor>(_commandExecutor); _systemCommandFactory.RegisterInstance<SystemCommandRegistry>(_systemRegistry); _systemCommandFactory.RegisterFactoryMethod<IOutputWriter>(() => _outputWriter); _systemCommandFactory.RegisterInstance(_settings); _history = new LinkedList<HistoryEntry>(); _outputWriter = new DefaultOutputWriter(); }
public DiscoverCommand(OwinMiddleware next, ICommandNameResolver commandNameResolver, ICommandRegistry commandRegistry, ICommandFactory commandFactory) : base(next) { this.commandNameResolver = commandNameResolver; this.commandRegistry = commandRegistry; this.commandFactory = commandFactory; }
protected CommandFactory(ICommandRegistry commandRegistry) { Guard.EnsureNotNull(commandRegistry, nameof(commandRegistry)); this.commandRegistry = commandRegistry; }
public Dispatcher(ICommandRegistry commandRegistry, IOutput output, IMessageBoard messageBoard) { this.commandRegistry = commandRegistry; this.output = output; this.messageBoard = messageBoard; }
public JsonDeserializerCommandFactory(ICommandRegistry commandRegistry, ICommandBodyProvider commandBodyProvider) : this(commandRegistry, commandBodyProvider, new JsonSerializerSettings()) { }
public JsonDeserializerCommandFactory(ICommandRegistry commandRegistry, ICommandBodyProvider commandBodyProvider, JsonSerializerSettings serializerSettings) : base(commandRegistry) { this.commandBodyProvider = commandBodyProvider; this.serializerSettings = serializerSettings; }
public IRegistryConfiguration Use(ICommandRegistry registry) { _registry = registry; return this; }
public RegistryConfiguration() { _registry = new DefaultCommandRegistry(); }
public CommandPublisher(ICommandRegistry registry, IMessageChannel channel) : base(registry, channel) { }