Beispiel #1
0
        // 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);
            //HACK Xpo asp core extensions https://www.devexpress.com/Support/Center/Question/Details/T637597/asp-net-core-dependency-injection-in-xpo
            //HACK https://documentation.devexpress.com/XPO/119377/Getting-Started/Getting-Started-with-NET-Core
            //HACK how to read connection strings https://stackoverflow.com/questions/45796776/get-connectionstring-from-appsettings-json-instead-of-being-hardcoded-in-net-co

            DataStoreResolver DataStoreResolver = new DataStoreResolver();

            services.AddSingleton <IDataStoreResolver>(DataStoreResolver);
            services.AddMemoryCache();
        }
        // 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.Latest);

            //HACK Xpo asp core extensions https://www.devexpress.com/Support/Center/Question/Details/T637597/asp-net-core-dependency-injection-in-xpo
            //HACK https://documentation.devexpress.com/XPO/119377/Getting-Started/Getting-Started-with-NET-Core

            //string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            //string connectionString = SQLiteConnectionProvider.GetConnectionString(Path.Combine(appDataPath, "myXpoApp.db"));

            //HACK how to read connection strings https://stackoverflow.com/questions/45796776/get-connectionstring-from-appsettings-json-instead-of-being-hardcoded-in-net-co
            var cnx = Configuration.GetConnectionString("ConnectionString");

            IDisposable[] DisposableObjects;
            var           DataStore = XpoDefault.GetConnectionProvider(cnx, AutoCreateOption.DatabaseAndSchema, out DisposableObjects);

            DataStoreResolver DataStoreResolver = new DataStoreResolver();

            services.AddSingleton <IDataStoreResolver>(DataStoreResolver);
            services.AddMemoryCache();
            services.AddSingleton <IDataStore>(DataStore);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }