Exemple #1
0
        /// <summary>
        /// Registers the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Register(IServiceConventionContext context)
        {
            context.WithMarten();

            var connectionString =
                !string.IsNullOrEmpty(_options.ConnectionString)
                    ? _options.ConnectionString
                    : context.Configuration.GetValue <string?>("PostgresSql:ConnectionString", null)
                ?? context.Configuration.GetValue <string?>("Postgres:ConnectionString", null)
                ?? context.Configuration.GetValue <string?>("Marten:ConnectionString", null);

            if (_options.UseSession)
            {
                context.Services.TryAddScoped(
                    c => c.GetRequiredService <IDocumentStore>().OpenSession(_options.SessionTracking)
                    );
            }

            if (!string.IsNullOrEmpty(connectionString))
            {
                context.Services.Configure <StoreOptions>(options => options.Connection(connectionString));
            }
        }
Exemple #2
0
 public void Register(IServiceConventionContext context)
 {
     context.WithMarten().AddStartupFilter();
 }