|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
@ -14,10 +15,12 @@ namespace Microsoft.Extensions.DependencyInjection |
|
|
|
{ |
|
|
|
var options = new AbpMongoDbContextRegistrationOptions(typeof(TMongoDbContext), services); |
|
|
|
|
|
|
|
var replaceDbContextAttribute = typeof(TMongoDbContext).GetCustomAttribute<ReplaceDbContextAttribute>(true); |
|
|
|
if (replaceDbContextAttribute != null) |
|
|
|
var replacedDbContextTypes = typeof(TMongoDbContext).GetCustomAttributes<ReplaceDbContextAttribute>(true) |
|
|
|
.SelectMany( x => x.ReplacedDbContextTypes).ToList(); |
|
|
|
|
|
|
|
foreach (var dbContextType in replacedDbContextTypes) |
|
|
|
{ |
|
|
|
options.ReplacedDbContextTypes.AddRange(replaceDbContextAttribute.ReplacedDbContextTypes); |
|
|
|
options.ReplaceDbContext(dbContextType); |
|
|
|
} |
|
|
|
|
|
|
|
optionsBuilder?.Invoke(options); |
|
|
|
|