public void Initialize() { ILogFilter logFilter = DefaultLogFilter.Warning; #if DEBUG logFilter = PrefixLogFilter.Ignored(new[] { "Root.Json", "Root.CompositeListFormatter", "Root.ApiClient", "Root.ApiAuthenticationState" }); #endif logFactory = new DefaultLogFactory("Root") .AddSerializer(new ConsoleSerializer(new SingleLineLogFormatter(), logFilter)); Json json = new Json(); Domain(json); //priceCalculator = new PriceCalculator(eventDispatcher.Handlers); FormatterContainer formatters = new FormatterContainer(commandFormatter, eventFormatter, queryFormatter, exceptionFormatter); eventDispatcher = new BrowserEventDispatcher(formatters, logFactory, json); BrowserExceptionHandler exceptionHandler = new BrowserExceptionHandler(formatters, logFactory, json); services //.AddSingleton(priceCalculator) .AddSingleton(json) .AddSingleton(formatters) .AddSingleton(logFactory) .AddTransient <CurrencyFormatterFactory>() .AddSingleton <MessageBuilder>() .AddScoped <LocalExpenseOnlineRunner>() .AddTransient <HttpCommandDispatcher>() .AddTransient <CommandStorage>() .AddTransient <CreateExpenseStorage>() .AddTransient <OfflineCommandDispatcher>() .AddSingleton <LocalCommandDispatcher>() .AddSingleton <MenuItemService>() .AddSingleton <ICommandHandlerCollection, LocalCommandHandlerCollection>() .AddTransient <ICommandDispatcher, LocalCommandDispatcher>() .AddTransient <IQueryDispatcher, HttpQueryDispatcher>() .AddTransient(typeof(ILog <>), typeof(DefaultLog <>)) .AddSingleton(eventDispatcher) .AddSingleton(eventDispatcher.Handlers) .AddSingleton(eventDispatcher.Dispatcher) .AddSingleton(exceptionHandler) .AddSingleton(exceptionHandler.Handler) .AddSingleton(exceptionHandler.HandlerBuilder); void AddMiddleware <T>(IServiceCollection services, bool register = true) where T : class, HttpQueryDispatcher.IMiddleware
public ApiHubService(BrowserEventDispatcher events, BrowserExceptionHandler exceptions, IOptions <ApiConfiguration> apiConfiguration, TokenContainer token, ILogFactory logFactory) { Ensure.NotNull(events, "events"); Ensure.NotNull(exceptions, "exceptions"); Ensure.NotNull(apiConfiguration, "apiConfiguration"); Ensure.NotNull(token, "token"); Ensure.NotNull(logFactory, "logFactory"); this.events = events; this.exceptions = exceptions; this.apiConfiguration = apiConfiguration.Value; this.token = token; this.log = logFactory.Scope("ApiHub"); this.eventLog = log.Factory.Scope("Events"); this.exceptionLog = log.Factory.Scope("Exceptions"); }
public void Initialize() { ILogFilter logFilter = DefaultLogFilter.Debug; #if !DEBUG logFilter = DefaultLogFilter.Warning; #endif logFactory = new DefaultLogFactory("Root") .AddSerializer(new ConsoleSerializer(new SingleLineLogFormatter(), logFilter)); Domain(); //priceCalculator = new PriceCalculator(eventDispatcher.Handlers); FormatterContainer formatters = new FormatterContainer(commandFormatter, eventFormatter, queryFormatter, exceptionFormatter); BrowserEventDispatcher eventDispatcher = new BrowserEventDispatcher(formatters, logFactory); BrowserExceptionHandler exceptionHandler = new BrowserExceptionHandler(formatters, logFactory); services //.AddSingleton(priceCalculator) .AddSingleton(formatters) .AddSingleton(logFactory) .AddSingleton <MessageBuilder>() .AddTransient <ICommandDispatcher, HttpCommandDispatcher>() .AddTransient <IQueryDispatcher, HttpQueryDispatcher>() .AddTransient(typeof(ILog <>), typeof(DefaultLog <>)) .AddSingleton(eventDispatcher) .AddSingleton(eventDispatcher.Handlers) .AddSingleton(eventDispatcher.Dispatcher) .AddSingleton(exceptionHandler) .AddSingleton(exceptionHandler.Handler) .AddSingleton(exceptionHandler.HandlerBuilder); QueryMiddlewares(eventDispatcher.Handlers); //CurrencyCache currencyCache = new CurrencyCache(eventDispatcher.Handlers, queryDispatcher); //services // .AddSingleton(currencyCache); //currencyCache.InitializeAsync(queryDispatcher); //priceCalculator.InitializeAsync(queryDispatcher); }
public void Initialize() { ILogFilter logFilter = DefaultLogFilter.Debug; #if !DEBUG logFilter = DefaultLogFilter.Warning; #endif logFactory = new DefaultLogFactory("Root") .AddSerializer(new ConsoleSerializer(new SingleLineLogFormatter(), logFilter)); Json json = new Json(); Domain(json); //priceCalculator = new PriceCalculator(eventDispatcher.Handlers); FormatterContainer formatters = new FormatterContainer(commandFormatter, eventFormatter, queryFormatter, exceptionFormatter); eventDispatcher = new BrowserEventDispatcher(formatters, logFactory, json); BrowserExceptionHandler exceptionHandler = new BrowserExceptionHandler(formatters, logFactory, json); services //.AddSingleton(priceCalculator) .AddSingleton(json) .AddSingleton(formatters) .AddSingleton(logFactory) .AddSingleton <MessageBuilder>() .AddTransient <ICommandDispatcher, HttpCommandDispatcher>() .AddTransient <IQueryDispatcher, HttpQueryDispatcher>() .AddTransient(typeof(ILog <>), typeof(DefaultLog <>)) .AddSingleton(eventDispatcher) .AddSingleton(eventDispatcher.Handlers) .AddSingleton(eventDispatcher.Dispatcher) .AddSingleton(exceptionHandler) .AddSingleton(exceptionHandler.Handler) .AddSingleton(exceptionHandler.HandlerBuilder); void AddMiddleware <T>(IServiceCollection services) where T : class, HttpQueryDispatcher.IMiddleware