private static void Seed(IApplicationBuilder app)
        {
            var options = app.ApplicationServices.GetRequiredService <IOptions <TableStorageConfigurationOptions> >();

            // seed API resources

            var apiResourceLogger = app.ApplicationServices.GetRequiredService <ILogger <ApiResourceTableStore> >();
            var apiResourceStore  = new ApiResourceTableStore(options, apiResourceLogger);

            foreach (var apiResource in Host.Configuration.Resources.GetApiResources())
            {
                apiResourceStore.StoreAsync(apiResource).GetAwaiter().GetResult();
            }

            // seed Identity resources

            var identityResourceLogger = app.ApplicationServices.GetRequiredService <ILogger <IdentityResourceTableStore> >();
            var identityResourceStore  = new IdentityResourceTableStore(options, identityResourceLogger);

            foreach (var identityResource in Host.Configuration.Resources.GetIdentityResources())
            {
                identityResourceStore.StoreAsync(identityResource).GetAwaiter().GetResult();
            }

            // seed Clients

            var clientLogger = app.ApplicationServices.GetRequiredService <ILogger <ClientStore> >();
            var clientStore  = new ClientStore(options, clientLogger);

            foreach (var client in Clients.Get())
            {
                clientStore.StoreAsync(client).GetAwaiter().GetResult();
            }
        }
예제 #2
0
        private static void InitializeApiResources(IServiceProvider services)
        {
            var options = services.GetRequiredService <IOptions <TableStorageConfigurationOptions> >();

            // seed API resources

            var apiResourceLogger = services.GetRequiredService <ILogger <ApiResourceTableStore> >();
            var apiResourceStore  = new ApiResourceTableStore(options, apiResourceLogger);

            foreach (var apiResource in Config.GetApiResources())
            {
                apiResourceStore.StoreAsync(apiResource).GetAwaiter().GetResult();
            }
        }