Exemple #1
0
 public HarmonyOptionsExtension(IDataObjectProvider objectProvider)
 {
     _objectProvider = objectProvider;
     _databaseRoot   = new HarmonyDatabaseRoot {
         Instance = _objectProvider
     };
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public HarmonyQueryContext(
     QueryContextDependencies dependencies,
     IDataObjectProvider store)
     : base(dependencies)
 {
     Store = store;
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public HarmonyQueryContextFactory(
     QueryContextDependencies dependencies,
     IDataObjectProvider provider,
     IDbContextOptions contextOptions)
     : base(dependencies)
 {
     _provider = provider;
 }
Exemple #4
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public HarmonyQueryContext(
     QueryContextDependencies dependencies,
     Func <IQueryBuffer> queryBufferFactory,
     IDataObjectProvider store)
     : base(dependencies, () => new QueryBufferWrapper(dependencies))
 {
     Store = store;
 }
        /// <summary>
        ///     Configures the context to connect to an in-memory database.
        ///     The in-memory database is shared anywhere the same name is used, but only for a given
        ///     service provider. To use the same in-memory database across service providers, call
        ///     <see cref="UseHarmonyDatabase{TContext}(DbContextOptionsBuilder{TContext},string,HarmonyDatabaseRoot,Action{HarmonyDbContextOptionsBuilder})" />
        ///     passing a shared <see cref="HarmonyDatabaseRoot"/> on which to root the database.
        /// </summary>
        /// <typeparam name="TContext"> The type of context being configured. </typeparam>
        /// <param name="optionsBuilder"> The builder being used to configure the context. </param>
        /// <param name="databaseName">
        ///     The name of the in-memory database. This allows the scope of the in-memory database to be controlled
        ///     independently of the context. The in-memory database is shared anywhere the same name is used.
        /// </param>
        /// <param name="inMemoryOptionsAction">An optional action to allow additional in-memory specific configuration.</param>
        /// <returns> The options builder so that further configuration can be chained. </returns>
        //public static DbContextOptionsBuilder<TContext> UseHarmonyDatabase<TContext>(
        //    this DbContextOptionsBuilder<TContext> optionsBuilder,
        //    string databaseName,
        //     Action<HarmonyDbContextOptionsBuilder> inMemoryOptionsAction = null)
        //    where TContext : DbContext
        //    => (DbContextOptionsBuilder<TContext>)UseHarmonyDatabase(
        //        (DbContextOptionsBuilder)optionsBuilder, databaseName, inMemoryOptionsAction);

        /// <summary>
        ///     Configures the context to connect to a named in-memory database.
        ///     The in-memory database is shared anywhere the same name is used, but only for a given
        ///     service provider. To use the same in-memory database across service providers, call
        ///     <see cref="UseHarmonyDatabase(DbContextOptionsBuilder,string,HarmonyDatabaseRoot,Action{HarmonyDbContextOptionsBuilder})" />
        ///     passing a shared <see cref="HarmonyDatabaseRoot"/> on which to root the database.
        /// </summary>
        /// <param name="optionsBuilder"> The builder being used to configure the context. </param>
        /// <param name="databaseName">
        ///     The name of the in-memory database. This allows the scope of the in-memory database to be controlled
        ///     independently of the context. The in-memory database is shared anywhere the same name is used.
        /// </param>
        /// <param name="inMemoryOptionsAction">An optional action to allow additional in-memory specific configuration.</param>
        /// <returns> The options builder so that further configuration can be chained. </returns>
        //public static DbContextOptionsBuilder UseHarmonyDatabase(
        //    this DbContextOptionsBuilder optionsBuilder,
        //    string databaseName,
        //     Action<HarmonyDbContextOptionsBuilder> inMemoryOptionsAction = null)
        //    => UseHarmonyDatabase(optionsBuilder, databaseName, null, inMemoryOptionsAction);

        /// <summary>
        ///     Configures the context to connect to an in-memory database.
        ///     The in-memory database is shared anywhere the same name is used, but only for a given
        ///     service provider.
        /// </summary>
        /// <typeparam name="TContext"> The type of context being configured. </typeparam>
        /// <param name="optionsBuilder"> The builder being used to configure the context. </param>
        /// <param name="databaseName">
        ///     The name of the in-memory database. This allows the scope of the in-memory database to be controlled
        ///     independently of the context. The in-memory database is shared anywhere the same name is used.
        /// </param>
        /// <param name="databaseRoot">
        ///     All in-memory databases will be rooted in this object, allowing the application
        ///     to control their lifetime. This is useful when sometimes the context instance
        ///     is created explicitly with <c>new</c> while at other times it is resolved using dependency injection.
        /// </param>
        /// <param name="inMemoryOptionsAction">An optional action to allow additional in-memory specific configuration.</param>
        /// <returns> The options builder so that further configuration can be chained. </returns>
        //public static DbContextOptionsBuilder<TContext> UseHarmonyDatabase<TContext>(
        //    this DbContextOptionsBuilder<TContext> optionsBuilder,
        //    string databaseName,
        //     HarmonyDatabaseRoot databaseRoot,
        //     Action<HarmonyDbContextOptionsBuilder> inMemoryOptionsAction = null)
        //    where TContext : DbContext
        //    => (DbContextOptionsBuilder<TContext>)UseHarmonyDatabase(
        //        (DbContextOptionsBuilder)optionsBuilder, databaseName, databaseRoot, inMemoryOptionsAction);

        /// <summary>
        ///     Configures the context to connect to a named in-memory database.
        ///     The in-memory database is shared anywhere the same name is used, but only for a given
        ///     service provider.
        /// </summary>
        /// <param name="optionsBuilder"> The builder being used to configure the context. </param>
        /// <param name="databaseName">
        ///     The name of the in-memory database. This allows the scope of the in-memory database to be controlled
        ///     independently of the context. The in-memory database is shared anywhere the same name is used.
        /// </param>
        /// <param name="databaseRoot">
        ///     All in-memory databases will be rooted in this object, allowing the application
        ///     to control their lifetime. This is useful when sometimes the context instance
        ///     is created explicitly with <c>new</c> while at other times it is resolved using dependency injection.
        /// </param>
        /// <param name="inMemoryOptionsAction">An optional action to allow additional in-memory specific configuration.</param>
        /// <returns> The options builder so that further configuration can be chained. </returns>
        public static DbContextOptionsBuilder UseHarmonyDatabase(
            this DbContextOptionsBuilder optionsBuilder,
            IDataObjectProvider dataProvider)
        {
            var extension = optionsBuilder.Options.FindExtension <HarmonyOptionsExtension>() ?? new HarmonyOptionsExtension(dataProvider);

            ConfigureWarnings(optionsBuilder);

            ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);
            return(optionsBuilder);
        }
Exemple #6
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public HarmonyDatabase(
     DatabaseDependencies dependencies,
     IDataObjectProvider dataProvider,
     IServiceProvider serviceProvider,
     IDbContextOptions options,
     IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
     : base(dependencies)
 {
     //_store = storeCache.GetStore(options);
     _updateLogger       = updateLogger;
     _dataObjectProvider = dataProvider;
     _serviceProvider    = serviceProvider;
 }
Exemple #7
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 protected HarmonyOptionsExtension(HarmonyOptionsExtension copyFrom)
 {
     _storeName      = copyFrom._storeName;
     _databaseRoot   = copyFrom._databaseRoot;
     _objectProvider = copyFrom._objectProvider;
 }