Exemple #1
0
        private void Initialize(ClientConfiguration configuration, string defaultBucket, CouchbaseStorageOptions options)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (string.IsNullOrEmpty(defaultBucket))
            {
                throw new ArgumentNullException(nameof(defaultBucket));
            }

            Options = options ?? new CouchbaseStorageOptions();
            Options.DefaultBucket = defaultBucket;

            configuration.Serializer = () => new DocumentDefaultSerializer();
            Client = new Cluster(configuration);

            string  indexPrefix = $"IDX_{defaultBucket}";
            IBucket bucket      = Client.OpenBucket(Options.DefaultBucket);
            {
                IBucketManager manager = bucket.CreateManager(bucket.Configuration.Username, bucket.Configuration.Password);
                manager.CreateN1qlPrimaryIndex($"{indexPrefix}_Primary", false);
                manager.CreateN1qlIndex($"{indexPrefix}_Type", false, "type");
                manager.CreateN1qlIndex($"{indexPrefix}_Id", false, "id");
                manager.CreateN1qlIndex($"{indexPrefix}_Expire", false, "expire_on");
                manager.CreateN1qlIndex($"{indexPrefix}_Name", false, "name");
            }

            JobQueueProvider provider = new JobQueueProvider(this);

            QueueProviders = new PersistentJobQueueProviderCollection(provider);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IBucketManager bucketManager, ICouchbaseClientStore clientStore, ICouchbaseScopeStore scopeStore)
        {
            loggerFactory.AddConsole(_configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            bucketManager.CreateN1qlPrimaryIndex("primary", false);

            // Our client for the Mvc sample site
            var client = new Client
            {
                ClientId   = "mvc_implicit",
                ClientName = "MVC Implicit",
                ClientUri  = "http://identityserver.io",

                RedirectUris = new List <string>
                {
                    "http://*****:*****@email.com",
                SubjectId = Guid.NewGuid().ToString(),
                Claims    = new List <Claim>()
                {
                    new Claim(JwtClaimTypes.Name, "*****@*****.**"),
                }
            }, "Alice1#").Result;

            loggerFactory.AddDebug();

            app.UseMiddleware <ErrorCodeMiddleware>();

            app.UseIdentityServer();

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }