Exemplo n.º 1
0
        public async Task BeginInitializationAsync(IServiceProvider serviceProvider)
        {
            _initializationTask = InitializationService.InitializeAsync(serviceProvider);
            await IdentityContext.LoadAsync();

            await AwaitInitializedAsync();
        }
Exemplo n.º 2
0
        public static void Initialize(Assembly rootAssembly, Action provideDependenciesCallback)
        {
            var containerConfig = ContainerConfiguration.CreateFromAssembly(
                rootAssembly,
                initializeAutoMapper: true,
                logInitialization: true);

            InitializationService.AssureServicesAreInitialized(containerConfig, provideDependenciesCallback);
            InitializationService.AssureSettingsAreInitialized <AppSettings>(AppSettings.SectionKey, "Release", rootAssembly);
        }
        public void SetUp()
        {
            _mutableType          = ObjectMother.GetMutableType(typeof(DomainType));
            _storageServiceMock   = MockRepository.GenerateStrictMock <IStorageService> ();
            _expressionHelperMock = MockRepository.GenerateStrictMock <IInitializationExpressionHelper>();
            _storageMock          = MockRepository.GenerateStrictMock <IStorage>();
            _aspectType           = ObjectMother.GetAspectType();
            _adviceMethod         = ObjectMother.GetMethodInfo(declaringType: _aspectType);

            _initializationService = new InitializationService(_storageServiceMock, _expressionHelperMock);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Service.Controllers.AgentController"/> class.
        /// </summary>
        /// <param name="initializationService">Initialization service.</param>
        public AgentController(InitializationService initializationService, IRouterService routerService, IStorageService storageService)
        {
            this.storageService = storageService;
            this.Handlers       = new IHandler[]
            {
                new ConnectionHandler(storageService, routerService),
                new MessagesHandler(storageService)
            };

            this.initializationService = initializationService;
            this.routerService         = routerService;
        }
        public static void Initialize()
        {
            var containerConfig = ContainerConfiguration.CreateFromAssembly(
                _currentAssembly,
                initializeAutoMapper: true,
                logInitialization: true);

            InitializationService.AssureServicesAreInitialized(containerConfig, DependenciesProvider.ProvideDependencencies);
            InitializationService.AssureSettingsAreInitialized <AppSettings>(
                AppSettings.Sectionkey,
                string.Empty,
                _currentAssembly);
        }
Exemplo n.º 6
0
        protected override void OnInitialized()
        {
            try
            {
                InitializeComponent();

                // Local Notification tap event listener
                NotificationCenter.Current.NotificationTapped += OnLocalNotificationTapped;

                NavigationService.NavigateAsync(InitializationService.Navigate()).Wait();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Exception: {ex.Message}");
            }
        }
Exemplo n.º 7
0
        public async Task InitializationRoutineTest()
        {
            var userModel = default(UserModel);

            var dbMock = new Mock <IDatabaseAccess>();

            dbMock.Setup(db => db.Create(It.IsAny <UserModel>()))
            .Callback <UserModel>((u) => userModel = u);

            var hasherMock = new Mock <IPasswordHashingService>();

            hasherMock.Setup(h => h.GetEncodedHash(It.IsAny <string>()))
            .ReturnsAsync((string s) => hashed + s);

            var loggerMock = new Mock <ILogger <InitializationService> >();

            var service = new InitializationService(dbMock.Object, GetConfiguration("", password), hasherMock.Object, loggerMock.Object);

            Assert.ThrowsAsync <ArgumentException>(() => service.InitializationRoutine());
            service = new InitializationService(dbMock.Object, GetConfiguration(username, ""), hasherMock.Object, loggerMock.Object);
            Assert.ThrowsAsync <ArgumentException>(() => service.InitializationRoutine());
            service = new InitializationService(dbMock.Object, GetConfiguration(null, password), hasherMock.Object, loggerMock.Object);
            Assert.ThrowsAsync <ArgumentException>(() => service.InitializationRoutine());
            service = new InitializationService(dbMock.Object, GetConfiguration(username, null), hasherMock.Object, loggerMock.Object);
            Assert.ThrowsAsync <ArgumentException>(() => service.InitializationRoutine());

            service = new InitializationService(dbMock.Object, GetConfiguration(), hasherMock.Object, loggerMock.Object);
            await service.InitializationRoutine();

            dbMock.Verify(db => db.Commit());
            Assert.AreEqual(username, userModel.UserName);
            Assert.AreEqual(hashed + password, userModel.PasswordHash);

            dbMock = new Mock <IDatabaseAccess>();
            dbMock.Setup(db => db.GetCount <UserModel>())
            .ReturnsAsync(1)
            .Verifiable();
            service = new InitializationService(dbMock.Object, GetConfiguration(), hasherMock.Object, loggerMock.Object);
            await service.InitializationRoutine();

            dbMock.Verify(db => db.GetCount <UserModel>());
            dbMock.VerifyNoOtherCalls();
        }
Exemplo n.º 8
0
        private static void Main()
        {
            var currentAssembly = typeof(Program).Assembly;
            var containerConfig = ContainerConfiguration.CreateFromAssembly(
                currentAssembly,
                initializeAutoMapper: true,
                logInitialization: true);

            InitializationService.AssureServicesAreInitialized(containerConfig, DependenciesProvider.ProvideDependencencies);
            InitializationService.AssureSettingsAreInitialized <AppSettings>(
                AppSettings.Sectionkey,
                string.Empty,
                currentAssembly);

            ServiceLocatorSingleton
            .Instance
            .GetService <IConsoleCommandsStartupService>()
            .Start();
        }
Exemplo n.º 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              InitializationService initializationService,
                              MarsRoverDbContext marsRoverDbContext)
        {
            marsRoverDbContext.Database.Migrate();

            // Note: If we wanted to secure the API from only one origin do something similar to below code
            // app.UseCors(options => options
            //          .WithOrigins("http://localhost:4200")

            app.UseCors(options => options
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        );

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MarsRoverApi v1"));
            }

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // ***********************************
            // Initialize the photo data
            // ***********************************
            initializationService.Initialize();
        }
Exemplo n.º 10
0
        protected void Application_Start()
        {
            try
            {

                //Read the application mode
                //Remember to set it to Production before release!
                Application["ApplicationMode"] = Enum.Parse(typeof(ApplicationMode), ConfigurationManager.AppSettings["ApplicationMode"]);

                //Recreate database with test data if model changes
                if (ApplicationState.Mode == ApplicationMode.Development)
                {
                    Database.SetInitializer<AppContext>(new AppDbInitializer());
                    //Force recreation of model
                    using (var db = new AppContext())
                    {
                        db.Users.FirstOrDefault();
                    }
                }
                //Inicialización de entidades que siempre debe ocurrir
                var initService = new InitializationService();
                initService.Init();

                AreaRegistration.RegisterAllAreas();

                RegisterGlobalFilters(GlobalFilters.Filters);
                RegisterRoutes(RouteTable.Routes);
            }
            catch (Exception ex)
            {

                //TODO: Handle and log start exceptions
                throw ex;
            }
        }
Exemplo n.º 11
0
 public InitializationController(InitializationService initializationService)
 {
     _initializationService = initializationService;
 }