public static ApplicationInstance CreateDispatcherWebJob() { var domainRepository = new NEventStoreDomainRepository(DatabaseConnectionStringName); var db = OpenConnection(); var views = new ApplicationViews(new OrmLiteUserView(db), new InMemoryUserLevelService(), new OrmLiteProfileView(db), new OrmLitePlaceRepository(db), new InMemoryChartTypeView()); var eventHandlers = new EventHandlerContainer(); var dateTimeProvider = new SystemDateTimeProvider(); var userService = new OrmLiteUserView(db); var placeFinder = new OrmLitePlaceRepository(db); var elevationService = new GoogleMapsElevationService(); var domainEntry = new DomainEntry(domainRepository, new ApplicationEventBus(eventHandlers), dateTimeProvider, userService, new InMemoryUserLevelService(), placeFinder, elevationService); var slackSendMessageUriKey = ConfigurationManager.AppSettings[SlackSendMessageUriKey]; eventHandlers.Add(new UserProgressManager(domainEntry)); eventHandlers.Add(new SendGridEmailNotifier(userService)); eventHandlers.Add(new OrmLiteTrackBoundaryView(db)); eventHandlers.Add(new SlackMessageSender(views, new Uri(slackSendMessageUriKey))); return(new ApplicationInstance(domainEntry, views)); }
public static ApplicationInstance BuildApplication() { var domainRepository = new NEventStoreDomainRepository(DatabaseConnectionStringName); var db = OpenConnection(); var views = new ApplicationViews(new OrmLiteUserView(db), new InMemoryUserLevelService(), new OrmLiteProfileView(db), new OrmLitePlaceRepository(db), new InMemoryChartTypeView()); var eventHandlers = new EventHandlerContainer(); eventHandlers.Add(views.Users); eventHandlers.Add(views.Profiles); var storageConnectionString = ConfigurationManager.AppSettings[StorageConnectionStringName]; eventHandlers.Add(new AzureBlobChartImageManager(storageConnectionString)); var dateTimeProvider = new SystemDateTimeProvider(); var userService = new OrmLiteUserView(db); var placeFinder = new OrmLitePlaceRepository(db); var elevationService = new GoogleMapsElevationService(); var domainEntry = new DomainEntry(domainRepository, new ApplicationEventBus(eventHandlers), dateTimeProvider, userService, new InMemoryUserLevelService(), placeFinder, elevationService); //eventHandlers.Add(new UserProgressManager(domainEntry)); //eventHandlers.Add(new SendGridEmailNotifier(userService)); //eventHandlers.Add(new SlackMessageSender(new Uri("https://hooks.slack.com/services/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"))); return(new ApplicationInstance(domainEntry, views)); }
public void Publish <TEvent>(TEvent evnt) where TEvent : class, IEvent { Check.NotNull <TEvent>(evnt, "evnt"); var handlers = EventHandlerContainer.GetEventHandlers <TEvent>(); foreach (var handler in handlers) { EventHandlerInvoker.Invoke(handler, evnt); } }
public void OrmLiteProfileViewShouldBeResolved() { var view = new OrmLiteProfileView(null); var eventHandlers = new EventHandlerContainer(); eventHandlers.Add(view); var handlers = eventHandlers.ResolveAll <IHandleEvent <ProfileCreated> >(); Assert.AreEqual(1, handlers.Length); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <KestrelServerOptions>(options => { options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB }); services.Configure <IISServerOptions>(options => { options.MaxRequestBodySize = int.MaxValue; }); services.Configure <FormOptions>(options => { options.ValueLengthLimit = int.MaxValue; options.MultipartBodyLengthLimit = int.MaxValue; // if don't set default value is: 128 MB options.MultipartHeadersLengthLimit = int.MaxValue; }); services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Files API", Version = "v1" }); }); //App Settings Injection services.Configure <MongoDBAppSettings>(Configuration.GetSection("MongoDBAppSettings")); services.Configure <LiteDBAppSettings>(Configuration.GetSection("LiteDBAppSettings")); //services.AddSingleton<IStorageService, FilesService>(); services.AddScoped <IStorageService, StorageService>(); services.AddSingleton <ISettingsService, SettingsService>(); services.AddScoped <IStorageRepository, StorageRepository>(); services.AddScoped <IFileDetailsRepository, FileDetailsRepository>(); services.AddScoped <RecordDownloadHandler>(); services.AddScoped <EventHandlerContainer>(); EventHandlerContainer.Subscribe <FileDownloadedEvent, RecordDownloadHandler>(); services.AddControllers(); }
public void Setup() { _storageRepository = Substitute.For <IStorageRepository>(); _fileDetailsRepository = Substitute.For <IFileDetailsRepository>(); _serviceProvider = Substitute.For <IServiceProvider>(); _eventContainer = new EventHandlerContainer(_serviceProvider); _storageService = new StorageService(_eventContainer, _storageRepository, _fileDetailsRepository); _fileDetails = new FileDetails { AddedBy = "Welcome Sithole", AddedDate = DateTime.UtcNow, ContentType = "any", Description = "fake file", HashId = "feuiwgfh9843eugvbon", Id = ObjectId.GenerateNewId().ToString(), LastModified = DateTime.UtcNow, Name = "some-file", NumberOfDownloads = 0, Size = 923929, StorageId = ObjectId.GenerateNewId().ToString(), Tags = new List <string> { "tag-1", "tag-2" } }; _fileDetails2 = new FileDetails { AddedBy = "John Vuligate", AddedDate = DateTime.UtcNow, ContentType = "any-2", Description = "fake file-2", HashId = "feuiwgfh9843eugvbon-2", Id = ObjectId.GenerateNewId().ToString(), LastModified = DateTime.UtcNow, Name = "some-file-2", NumberOfDownloads = 0, Size = 923889, StorageId = ObjectId.GenerateNewId().ToString(), Tags = new List <string> { "tag-1", "tag-3" } }; _fileDetailsList = new List <FileDetails> { _fileDetails, _fileDetails2 }; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddScoped <IOrderManager, OrderManager>(); services.AddScoped <IShoppingCartManager, ShoppingCartManager>(); services.AddScoped <IShoppingCartRepository, ShoppingCartRepository>(); services.AddScoped <IOrderRepository, OrderRepository>(); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <CreateOrderHandler>(); services.AddScoped <EventHandlerContainer>(); services.AddScoped <ConfirmEmailSentHandler>(); EventHandlerContainer.Subscribe <ShoppingCartSubmittedEvent, CreateOrderHandler>(); EventHandlerContainer.Subscribe <ShoppingCartSubmittedEvent, ConfirmEmailSentHandler>(); }
public void UnregisterHandlers(params Type[] handlerTypes) { Check.NotNull(handlerTypes, "handlerTypes"); EventHandlerContainer.UnregisterHandlers(handlerTypes); }
public bool UnregisterHandler(Type handlerType) { Check.NotNull(handlerType, "handlerType"); return(EventHandlerContainer.UnregisterHandler(handlerType)); }
public StorageService(EventHandlerContainer eventContainer, IStorageRepository storageRepository, IFileDetailsRepository fileDetailsRepository) { _eventContainer = eventContainer; _storageRepository = storageRepository; _fileDetailsRepository = fileDetailsRepository; }