//public UnityEFConfiguration WithObjectContextAndLogger(Func<ObjectContext> objectContextProvider, Func<ILoggingAdapter> loggingProvider)
        //{
        //    Guard.Against<ArgumentNullException>(objectContextProvider == null,
        //                                         "Expected a non-null Func<ObjectContext> instance.");
        //    Guard.Against<ArgumentNullException>(loggingProvider == null,
        //                                         "Expected a non-null Func<ILoggingAdapter> instance.");
        //    _factory.RegisterObjectContextProvider(objectContextProvider, loggingProvider);
        //    return this;
        //}

        //public UnityEFConfiguration WithLoggerProvider(Func<DbContext, ILoggingAdapter> loggerProvider)
        //{
        //    this.loggerProvider = loggerProvider;
        //    return this;
        //}

        /// <summary>
        /// Called by NCommon <see cref="Configure"/> to configure data providers.
        /// </summary>
        /// <param name="containerAdapter">The <see cref="IContainerAdapter"/> instance that allows
        /// registering components.</param>
        public void Configure(IContainerAdapter containerAdapter)
        {
            //Guard.Against<NotSupportedException>(loggerProvider==null, "Ошибка установки конфигурации EF: не определен логгер");
            //Guard.Against<NotSupportedException>(!(objectContextProvider() is ILoggerDataContext<DbContext>), "Ошибка установки конфигурации EF: дата контекст не поддерживает ILoggerDataContext");

            //(objectContextProvider() as ILoggerDataContext<DbContext>).LoggerProvider = loggerProvider;
            containerAdapter.RegisterInstance <IUnitOfWorkFactory>(_factory);
            containerAdapter.RegisterGeneric(typeof(IRepository <>), typeof(UnityEFRepository <>));
        }
Esempio n. 2
0
 /// <summary>
 /// Called by NCommon <see cref="Configure"/> to configure data providers.
 /// </summary>
 /// <param name="containerAdapter">The <see cref="IContainerAdapter"/> instance that allows
 /// registering components.</param>
 public void Configure(IContainerAdapter containerAdapter)
 {
     //#if DEBUG
     using (MiniProfiler.Current.Step("EFConfiguration.Configure")) {
     //#endif
         containerAdapter.RegisterInstance<IUnitOfWorkFactory>(_factory);
         containerAdapter.RegisterGeneric(typeof(IRepository<>), typeof(EFRepository<>));
     //#if DEBUG
     }
     //#endif
 }
Esempio n. 3
0
        /// <summary>
        /// Called by NCommon <see cref="Configure"/> to configure data providers.
        /// </summary>
        /// <param name="containerAdapter">The <see cref="IContainerAdapter"/> instance that allows
        /// registering components.</param>
        public void Configure(IContainerAdapter containerAdapter)
        {
//#if DEBUG
            using (MiniProfiler.Current.Step("EFConfiguration.Configure")) {
//#endif
                containerAdapter.RegisterInstance <IUnitOfWorkFactory>(_factory);
                containerAdapter.RegisterGeneric(typeof(IRepository <>), typeof(EFRepository <>));
//#if DEBUG
            }
//#endif
        }
Esempio n. 4
0
 /// <summary>
 /// Called by Kt.Framework.Repository <see cref="Configure"/> to configure data providers.
 /// </summary>
 /// <param name="containerAdapter">The <see cref="IContainerAdapter"/> instance that allows
 /// registering components.</param>
 public void Configure(IContainerAdapter containerAdapter)
 {
     containerAdapter.RegisterInstance<IUnitOfWorkFactory>(_factory);
     containerAdapter.RegisterGeneric(typeof(IRepository<>), typeof(EFRepository<>));
 }