private static async Task AssemblyInitializeAsync()
        {
            ExportProvider = CompositionContainerFactory.Create();

            SettingsInitializer.Initialize <UCenterTestSettings>(
                ExportProvider,
                SettingsDefaultValueProvider <UCenterTestSettings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <Settings>(
                ExportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <DatabaseContextSettings>(
                ExportProvider,
                SettingsDefaultValueProvider <DatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <UCenterEventDatabaseContextSettings>(
                ExportProvider,
                SettingsDefaultValueProvider <UCenterEventDatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);

            // TODO: This will break distributed unit test!
            // await InitProfileImageBlobsAsync(settings.DefaultProfileImageForFemaleBlobName);
            // await InitProfileImageBlobsAsync(settings.DefaultProfileImageForMaleBlobName);
            // await InitProfileImageBlobsAsync(settings.DefaultProfileThumbnailForFemaleBlobName);
            // await InitProfileImageBlobsAsync(settings.DefaultProfileThumbnailForMaleBlobName);
        }
Example #2
0
        protected void Application_Start()
        {
            //
            // Entity Framework sometimes becomes upset that the model doesn't match its
            // record of the schema, even when there is no difference.  To fix this,
            // we're calling SetInitializer(null) per https://digitaltoolfactory.net/blog/2012/08/how-to-fix-the-model-backing-the-context-has-changed-since-the-database-was-created-error/
            //
            // I do not know why this is not needed for DataContext though it is needed
            // for DataContextByUser.  Since the the initializer is not being changed
            // for DataContext, we still get a schema check when those contexts are used.
            // I suspect that Entity Framework caches schema summary information somewhere
            // outside the database, and that the summary information associated with
            // DataContext is updated correctly on migration (since it is used in migration
            // configuration) but not the other DataContextBy* types.
            //
            Database.SetInitializer <KeyHub.Data.DataContextByUser>(null);
            Database.SetInitializer <KeyHub.Data.DataContextByTransaction>(null);
            Database.SetInitializer <KeyHub.Data.DataContextByAuthorizedVendor>(null);

            container = CompositionContainerFactory.Create();
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container.Kernel));
            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new WindsorCompositionRoot(container));

            container.Resolve <IKernelContext>().RunKernelEvents(KernelEventsTypes.Startup);

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;

            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
        }
Example #3
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            // MEF initiliazation
            this.exportProvider = CompositionContainerFactory.Create();
            SettingsInitializer.Initialize <Settings>(
                this.exportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);
            SettingsInitializer.Initialize <DatabaseContextSettings>(
                this.exportProvider,
                SettingsDefaultValueProvider <DatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);
            SettingsInitializer.Initialize <UCenterEventDatabaseContextSettings>(
                this.exportProvider,
                SettingsDefaultValueProvider <UCenterEventDatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);

            CreateDatabaseIndexesAsync().Wait();
        }
        private static async Task AssemblyInitializeAsync()
        {
            ExportProvider = CompositionContainerFactory.Create();

            SettingsInitializer.Initialize <Settings>(
                ExportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <Common.Settings.Settings>(
                ExportProvider,
                SettingsDefaultValueProvider <Common.Settings.Settings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <DatabaseContextSettings>(
                ExportProvider,
                SettingsDefaultValueProvider <DatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);

            var settings = ExportProvider.GetExportedValue <Common.Settings.Settings>();

            await InitProfileImageBlobsAsync(settings.DefaultProfileImageForFemaleBlobName);
            await InitProfileImageBlobsAsync(settings.DefaultProfileImageForMaleBlobName);
            await InitProfileImageBlobsAsync(settings.DefaultProfileThumbnailForFemaleBlobName);
            await InitProfileImageBlobsAsync(settings.DefaultProfileThumbnailForMaleBlobName);
        }
Example #5
0
        public static void AssemblyInitialize(TestContext context)
        {
            ExportProvider = CompositionContainerFactory.Create();

            SettingsInitializer.Initialize <Settings>(ExportProvider, SettingsDefaultValueProvider <Settings> .Default,
                                                      AppConfigurationValueProvider.Default);
            SettingsInitializer.Initialize <Common.Settings.Settings>(ExportProvider,
                                                                      SettingsDefaultValueProvider <Settings> .Default, AppConfigurationValueProvider.Default);
        }
Example #6
0
        public ExceptionFilter()
        {
            var ExportProvider = CompositionContainerFactory.Create();

            SettingsInitializer.Initialize <UCenterEventDatabaseContextSettings>(
                ExportProvider,
                SettingsDefaultValueProvider <UCenterEventDatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);
            this.eventTrace = ExportProvider.GetExportedValue <EventTrace>();
        }
Example #7
0
        /// <summary>
        ///     The application start event
        /// </summary>
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            ExportProvider exportProvider = CompositionContainerFactory.Create();

            ApplicationManager.InitializeApplication(GlobalConfiguration.Configuration, exportProvider);
            SettingsInitializer.Initialize <Settings>(
                exportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);
        }
Example #8
0
        /// <summary>
        /// Function for application start.
        /// </summary>
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ExportProvider exportProvider = CompositionContainerFactory.Create();

            WebApplicationManager.InitializeApplication(GlobalConfiguration.Configuration, exportProvider);
            SettingsInitializer.Initialize <Settings>(
                exportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);
        }
        public UsersController()
        {
            var exportProvider = CompositionContainerFactory.Create();

            SettingsInitializer.Initialize <Settings>(
                exportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <DatabaseContextSettings>(
                exportProvider,
                SettingsDefaultValueProvider <DatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);

            Database = exportProvider.GetExportedValue <DatabaseContext>();
            Settings = exportProvider.GetExportedValue <Settings>();
        }
 public PluginManager(string path)
 {
     this.path           = path;
     this.exportProvider = CompositionContainerFactory.Create();
     SettingsInitializer.Initialize <DatabaseContextSettings>(
         this.exportProvider,
         SettingsDefaultValueProvider <DatabaseContextSettings> .Default,
         AppConfigurationValueProvider.Default);
     this.database = exportProvider.GetExportedValue <ManagerDatabaseContext>();
     this.plugins  = this.GetPlugins(path);
     this.watcher  = new FileSystemWatcher(path, "*" + ManifestFileName);
     this.watcher.IncludeSubdirectories = true;
     this.watcher.NotifyFilter          = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Size;
     this.watcher.Changed            += Watcher_Changed;
     this.watcher.Deleted            += Watcher_Changed;
     this.watcher.Created            += Watcher_Changed;
     this.watcher.EnableRaisingEvents = true;
 }
        public ApiControllerBase(DatabaseContext database, Settings settings)
        {
            //Database = database;
            //Settings = settings;
            var exportProvider = CompositionContainerFactory.Create();

            SettingsInitializer.Initialize <Settings>(
                exportProvider,
                SettingsDefaultValueProvider <Settings> .Default,
                AppConfigurationValueProvider.Default);

            SettingsInitializer.Initialize <DatabaseContextSettings>(
                exportProvider,
                SettingsDefaultValueProvider <DatabaseContextSettings> .Default,
                AppConfigurationValueProvider.Default);

            Database = exportProvider.GetExportedValue <DatabaseContext>();
            Settings = exportProvider.GetExportedValue <Settings>();
        }