public ModelsService(IMongoDbContext mongoDbContext, IOptions <AppSettings> settings, ILoggerService loggerService) { _mongoDbContext = mongoDbContext; _modelsCollection = _mongoDbContext.Database.GetCollection <MetadataModel>(ModelsCollectionName); _settings = settings.Value; _loggerService = loggerService; }
public PermissionsService( IMongoDbContext permissionsContext, ILogger <PermissionsService> logger) { _permissionsContext = permissionsContext as PermissionsContext; _logger = logger; }
/// <summary> /// Configures the MongoDb Identity store adapters for the types of TUser and TRole. /// </summary> /// <typeparam name="TUser">The type representing a user.</typeparam> /// <typeparam name="TRole">The type representing a role.</typeparam> /// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam> /// <param name="services">The collection of service descriptors.</param> /// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param> /// <param name="mongoDbContext">An object representing a MongoDb connection.</param> public static IdentityBuilder ConfigureMongoDbIdentity <TUser, TRole, TKey>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration, IMongoDbContext mongoDbContext = null) where TUser : MongoIdentityUser <TKey>, new() where TRole : MongoIdentityRole <TKey>, new() where TKey : IEquatable <TKey> { IdentityBuilder builder; ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings); if (mongoDbContext == null) { builder = services.AddIdentityCore <TUser>() .AddRoles <TRole>() .AddMongoDbStores <TUser, TRole, TKey>( mongoDbIdentityConfiguration.MongoDbSettings.ConnectionString, mongoDbIdentityConfiguration.MongoDbSettings.DatabaseName); } else { builder = services.AddIdentityCore <TUser>() .AddRoles <TRole>() .AddMongoDbStores <IMongoDbContext>(mongoDbContext); } if (mongoDbIdentityConfiguration.IdentityOptionsAction != null) { services.Configure(mongoDbIdentityConfiguration.IdentityOptionsAction); } return(builder); }
public DbRepository(IMongoDbContext mongoDbContext) { var collectionName = typeof(T).Name; var mongoDatabase = mongoDbContext.GetDatabase(); _mongoDbCollection = mongoDatabase.GetCollection <T>(collectionName); }
public PeopleRepository(IMongoDbContext context) { var client = new MongoClient(context.ConnectionString); var database = client.GetDatabase(context.DatabaseName); _people = database.GetCollection <People>(context.PeopleCollectionName); }
public UserRepository( IMongoDbContext usersContext, ILogger <UserRepository> logger) { _usersContext = usersContext as UsersContext; _logger = logger; }
public PoliceEventRepository(IOptions <RepositorySettings> options, ILogger <PoliceEventRepository> logger, IMongoDbContext mongoDbContext) { _settings = options.Value; _logger = logger; _mongoDbContext = mongoDbContext; }
/// <summary> /// Create a new instance of <see cref="RepositoryBase"/>. /// </summary> /// <param name="mongoDbContext"></param> /// <param name="logger"></param> /// <param name="mapper"></param> protected RepositoryBase(IMongoDbContext mongoDbContext, ILogger <RepositoryBase> logger, IMapper mapper) { MongoDbContext = mongoDbContext; MongoDatabase = MongoDbContext.GetDatabase(); Logger = logger; Mapper = mapper; }
/// <summary> /// Configures the MongoDb Identity store adapters for the types of TUser and TRole. /// </summary> /// <typeparam name="TUser">The type representing a user.</typeparam> /// <typeparam name="TRole">The type representing a role.</typeparam> /// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam> /// <param name="services">The collection of service descriptors.</param> /// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param> /// <param name="mongoDbContext">An object representing a MongoDb connection.</param> public static void ConfigureMongoDbIdentity <TUser, TRole, TKey>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration, IMongoDbContext mongoDbContext = null) where TUser : MongoIdentityUser <TKey>, new() where TRole : MongoIdentityRole <TKey>, new() where TKey : IEquatable <TKey> { ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings); if (mongoDbContext == null) { services.AddIdentity <TUser, TRole>() .AddMongoDbStores <TUser, TRole, TKey>( mongoDbIdentityConfiguration.MongoDbSettings.ConnectionString, mongoDbIdentityConfiguration.MongoDbSettings.DatabaseName) .AddDefaultTokenProviders(); } else { services.AddIdentity <TUser, TRole>() .AddMongoDbStores <IMongoDbContext>(mongoDbContext) .AddDefaultTokenProviders(); } if (mongoDbIdentityConfiguration.IdentityOptionsAction != null) { services.Configure(mongoDbIdentityConfiguration.IdentityOptionsAction); } }
public MongoDbBucketSet(IMongoDbContext context, IDbSetOptions options) { Check.NotNull(context, nameof(context)); Context = context; if (options is BucketSetOptions bucketOptions) { if (bucketOptions.BucketSize < 1) { throw new ArgumentException($"Invalid bucket size of {bucketOptions.BucketSize}"); } BucketSize = bucketOptions.BucketSize; var property = EntityMapping.GetOrCreateDefinition(typeof(TSubEntity)).GetProperty(bucketOptions.EntityTimeProperty); if (property == null) { throw new ArgumentException($"Property {bucketOptions.EntityTimeProperty} doesn't exist on bucket item."); } if (property.PropertyType != typeof(DateTime)) { throw new ArgumentException($"Property {bucketOptions.EntityTimeProperty} on bucket item isn't of type DateTime"); } EntityTimeProperty = property; } else { throw new ArgumentException("Invalid DbSet options supplied", nameof(options)); } }
public MongoDatabaseFixture() { Context = new MongoDbContext( Container.MongoDbIdentityConfiguration.MongoDbSettings.ConnectionString, Container.MongoDbIdentityConfiguration.MongoDbSettings.DatabaseName); UsersToDelete = new ConcurrentBag <TUser>(); }
protected virtual void Dispose(bool disposing) { if (disposing) { Context = null; } }
public MySiteService(IMongoDbContext settings) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); siteDetails = database.GetCollection <SiteDetails>(settings.BooksCollectionName); }
protected MongoDbBase(IMongoDbContext mongoDbContext, IConfiguration configuration, string nomeDaColecao) { _mongoDbContext = mongoDbContext; Mongo = new MongoClient(configuration.GetValue <string>("Database:Url")); DataBase = Mongo.GetDatabase(configuration.GetValue <string>("Database:Name")); Collection = DataBase.GetCollection <T>(nomeDaColecao); }
public Repository(IMongoDbContext dbContext, IMongoDbSettings mongoDbSettings, ILogger <Repository <T, TKey> > logger) { this.dbContext = dbContext; this.mongoDbSettings = mongoDbSettings; this.logger = logger; collection = dbContext.Database.GetCollection <T>(MongoUtils.GetCollectionName <T>()); }
/// <summary> /// Constructs an instance of the BottleMongoRepository class. /// </summary> /// <param name="dbContext">An instance of class implementing the IMongoDbContext interface with generic type parameter BottleMongoBottle.</param> /// <param name="toMongoMapper">An instance of class implementing the IMapper interface with generic type parameters Bottle, BottleMongoModel.</param> /// <param name="toDomainMapper">An instance of class implementing the IMapper interface with generic type parameters BottleMongoModel, Bottle.</param> public BottleMongoRepository(IMongoDbContext <BottleMongoModel> dbContext, IMapper <BottleDomainModel, BottleMongoModel> toMongoMapper, IMapper <BottleMongoModel, BottleDomainModel> toDomainMapper) { this._dbContext = dbContext; this._toMongoMapper = toMongoMapper; this._toDomainMapper = toDomainMapper; }
public GenericRepository(IMongoDbContext context) { _context = context; var collectionName = typeof(TEntity).Name; Collection = _context.Database.GetCollection <TEntity>(collectionName); }
public StuffRepository(IMongoDbContext mongoDbContext, ILogger <RepositoryBase> logger, IMapper mapper, IOptionsSnapshot <DatabaseConfiguration> config, IClientSessionHandle session) : base(mongoDbContext, logger, mapper) { _mapper = mapper; _session = session; _config = config.Value; CreateCollectionIfNeeded(); }
public MongoRepository(string collection, IConfiguration configuration, IMongoDbContext mongoDbContext) : base(mongoDbContext) { var mongoColectionName = configuration.GetSection("MongoConfiguration")[collection]; // Initialize InitializeConventionPack(); this.InitializeCollection(mongoDbContext, mongoColectionName); }
public DepositService(IMongoDbContext context) { _context = context; _Deposit = _context.GetCollection <Deposit>(typeof(Deposit).Name); _currency = _context.GetCollection <Currency>(typeof(Currency).Name); _appUser = _context.GetCollection <AppUser>(typeof(AppUser).Name); _Depositmeth = _context.GetCollection <DepositMethod>(typeof(DepositMethod).Name); }
public CurrencyService(IMongoDbContext context) { _context = context; _Currency = _context.GetCollection <Currency>(typeof(Currency).Name); _AppUser = _context.GetCollection <AppUser>(typeof(AppUser).Name); _CurrencyUpdate = _context.GetCollection <CurrencyUpdate>(typeof(CurrencyUpdate).Name); _Account = _context.GetCollection <Account>(typeof(Account).Name); }
public MongoDbBaseRepository(IMongoDbContext mongoDbContext, string collectionName) { if (string.IsNullOrEmpty(collectionName)) { throw new InvalidOperationException($"Collection name was not informed for {typeof(TDocument).Name} repository"); } collection = mongoDbContext.Database.GetCollection <TDocument>(collectionName); }
public PermissionRepository( IPermissionsService permissionsService, IMongoDbContext permissionsContext, ILogger <PermissionRepository> logger) { _permissionsService = permissionsService; _permissionsContext = permissionsContext as PermissionsContext; _logger = logger; }
public TokenService( IConfiguration configuration, IMongoDbContext db, IUserClaimsService userClaims) : base(db) { _configuration = configuration; _db = db; _userClaims = userClaims; }
public static MongoDbContext ToMongoDbContext(this IMongoDbContext dbContext) { var mongoDbContext = dbContext as MongoDbContext; if (mongoDbContext == null) { throw new ArgumentNullException($"{dbContext.GetType().AssemblyQualifiedName} 无法转换 ${typeof(MongoDbContext).AssemblyQualifiedName}"); } return(mongoDbContext); }
public MongoDbCollectionTests() { _context = Substitute.For <IMongoDbContext>(); _mongoDatabase = Substitute.For <IMongoDatabase>(); _mongoCollection = Substitute.For <IMongoCollection <TestEntity> >(); _testCollection = new MongoDbCollectionTestObj(_context); _context.Db.Returns(_mongoDatabase); _mongoDatabase.GetCollection <TestEntity>(Arg.Is <string>("testEntity")).Returns(_mongoCollection); }
public MongoDbRepository(IMongoDbContext mongoDbContext) { Check.ArgumentNotNull(mongoDbContext); _mongoDbContext = mongoDbContext; Collection = _mongoDbContext.Collection <TEntity>(); Client = mongoDbContext.Client; }
public GenericRepository(IMongoDbContext context) { _context = context; // exclude DO from name of the collection var entityName = typeof(TEntity).Name; var collectionName = entityName.Substring(0, entityName.Length - 2).ToLower(); Collection = _context.Database.GetCollection <TEntity>(collectionName); }
public AppUserService(IMongoDbContext context, IAccountService accserv) { _context = context; _AppUser = _context.GetCollection <AppUser>(typeof(AppUser).Name); _accserv = accserv; _acc = _context.GetCollection <Account>(typeof(Account).Name); _dep = _context.GetCollection <Deposit>(typeof(Deposit).Name); _bet = _context.GetCollection <Bet>(typeof(Bet).Name); _gU = _context.GetCollection <GuestUser>(typeof(GuestUser).Name); }
public TestController(HttpClient httpClient, IConfigurationRoot configuration, IMongoDbContext mongoDbContext, EfDbContext efDbContext, IDistributedCache redisCache) { _httpClient = httpClient; _mongoContext = mongoDbContext; _efContext = efDbContext; _redisCache = redisCache; _testUrl = configuration["TestUrl"]; _testUrl1 = configuration["TestUrl1"]; }
public HomeController(IMongoDbContext mongoContext) { _mongoContext = mongoContext; }
public ReviewQueriesXmlParser(IBookStoreDbContext bookStoreDbContext, IMongoDbContext mongoDbContext) { this.bookStoreDbContext = bookStoreDbContext; this.mongoDbContext = mongoDbContext; }