Beispiel #1
0
        protected void Application_Start()
        {
            //// Setup StructureMap to determine the concrete repository pattern to use.
            //ObjectFactory.Initialize(
            //   x =>
            //   {
            //       x.For<IUnitOfWorkFactory>().Use<EFUnitOfWorkFactory>();
            //       x.For(typeof(IRepository<>)).Use(typeof(Repository<>));
            //   }
            //);
            /*Moved to dependencyResolution IoC.cs*/

            // Select an Entity Framework model to use with the factory.
            EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext());

            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            //Never recreate the database
            Database.SetInitializer <DataShareContext>(null);
#if DEBUG
            //track LINQ queries executed using entity FrameworkProfiler
            HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize();
#endif

            var sqlUtility = new DS.Service.SqlTableUtility();
            sqlUtility.DropTables(sqlUtility.GetUnusedDSTables());
            sqlUtility = null;
        }
Beispiel #2
0
        public static void RegisterComponents()
        {
            var container = new UnityContainer();

            container.RegisterType <IUnitOfWorkFactory, EFUnitOfWorkFactory>();
            container.RegisterType(typeof(IRepository <>), typeof(EFRepository <>));
            EFUnitOfWorkFactory.SetObjectContext(() => new Entities());
            container.LoadConfiguration();
            DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container)); //unity for mvc controllers
        }
 public static void Initialize()
 {
     // Hook up the interception
     ObjectFactory.Initialize(
         x =>
     {
         x.ForRequestedType <IUnitOfWorkFactory>().TheDefaultIsConcreteType <EFUnitOfWorkFactory>();
         x.ForRequestedType(typeof(IRepository <>)).TheDefaultIsConcreteType(typeof(EFRepository <>));
     }
         );
     // We tell the concrete factory what EF model we want to use
     EFUnitOfWorkFactory.SetObjectContext(() => new ALSIEntities());
 }
Beispiel #4
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <remarks></remarks>
        public static void Initialize()
        {
            // Hook up the interception
            ObjectFactory.Initialize(
                x =>
            {
                x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>();
                x.For(typeof(IRepository <>)).Use(typeof(EFRepository <>));
            }
                );

            // We tell the concrete factory what EF model we want to use
            EFUnitOfWorkFactory.SetObjectContext(() => new BOBCardEntities());
        }
Beispiel #5
0
        public DataShareService()
        {
            // Setup StructureMap to determine the concrete repository pattern to use.
            ObjectFactory.Initialize(
                x =>
            {
                x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>();
                x.For(typeof(IRepository <>)).Use(typeof(Repository <>));
            }
                );

            // Select an Entity Framework model to use with the factory.
            EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext());
        }
Beispiel #6
0
        private static void InitialiseDatabase()
        {
            // Setup StructureMap to determine the concrete repository pattern to use.
            ObjectFactory.Initialize(
                x =>
            {
                x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>();
                x.For(typeof(IRepository <>)).Use(typeof(Repository <>));
                x.For <ISqlTableUtility>().Use <SqlTableUtility>();
                x.For <IDataSetSchemaDefinitionService>().Use <DataSetSchemaDefinitionService>();
                x.For <IDataSetDetailSqlRepo>().Use <DataSetDetailSqlRepo>();
                x.For <ISystemConfigurationService>().Use <SystemConfigurationService>();
                x.For <ICacheProvider>().Use <HttpCache>();
                x.For <IDataSetDetailCsvProcessor>().Use <DataSetDetailCsvProcessor>();
                x.For <IDataSetSchemaService>().Use <DataSetSchemaService>();
            }
                );


            // Select an Entity Framework model to use with the factory.
            EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext());

            //Never recreate the database
            Database.SetInitializer <DataShareContext>(null);



            //initialise all services
            _dataSetSchemaService = new DataSetSchemaService(
                ObjectFactory.GetInstance <IRepository <DataSetSchema> >()
                , ObjectFactory.GetInstance <DataSetSchemaDefinitionService>()
                , ObjectFactory.GetInstance <IRepository <DataSetDetail> >()
                , ObjectFactory.GetInstance <ISqlTableUtility>());

            _uploaderService = new DataSetDetailUploaderService(
                _dataSetSchemaService
                , ObjectFactory.GetInstance <IRepository <DataSetDetail> >()
                , ObjectFactory.GetInstance <IDataSetDetailCsvProcessor>()
                , ObjectFactory.GetInstance <IDataSetDetailSqlRepo>());

            _debugInfoService = new DebugInfoService(ObjectFactory.GetInstance <IRepository <DebugInfo> >());
        }