Пример #1
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();

            //string connectionString = WebConfigurationManager.ConnectionStrings["cs"].ConnectionString;

            string   hibernateCfgFileName = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/hibernate.cfg.xml");
            XElement root  = XElement.Load(hibernateCfgFileName);
            var      nsMgr = new XmlNamespaceManager(new NameTable());

            nsMgr.AddNamespace("NC", "urn:nhibernate-configuration-2.2");
            string connectionString = root.XPathSelectElement("//NC:property[@name='connection.connection_string']", nsMgr).Value;

            //регистрация NHibernate-репозиториев
            NHibernateDataInstaller.Install(container, new PerRequestLifetimeManager());
            NHibernateRepositoryInstaller.Install(container);

            DataInstaller.Install(container, new PerRequestLifetimeManager());

            //регистрация Мигратора
            MigratorInstaller.Install(container, connectionString);

            //регистрация дата-сервисов
            DataServiceInstaller.Install(container);

            container.RegisterType <JsResourceHelper>();
        }
        /// <summary>
        /// Registers the type mappings with the Unity container.
        /// </summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>
        /// There is no need to register concrete types such as controllers or
        /// API controllers (unless you want to change the defaults), as Unity
        /// allows resolving a concrete type even if it was not previously
        /// registered.
        /// </remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["DrinkVendingMachine"].ConnectionString;

            DbContextInstaller.Install(container, new PerRequestLifetimeManager(), connectionString);
            MigratorInstaller.Install(container, connectionString);
            DataServiceInstaller.Install(container);
        }
Пример #3
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();

            //string connectionString = WebConfigurationManager.ConnectionStrings["cs"].ConnectionString;

            string   hibernateCfgFileName = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/hibernate.cfg.xml");
            XElement root  = XElement.Load(hibernateCfgFileName);
            var      nsMgr = new XmlNamespaceManager(new NameTable());

            nsMgr.AddNamespace("NC", "urn:nhibernate-configuration-2.2");
            string connectionString = root.XPathSelectElement("//NC:property[@name='connection.connection_string']", nsMgr).Value;

            //регистрация NHibernate-репозиториев
            NHibernateDataInstaller.Install(container, new PerRequestLifetimeManager());
            NHibernateRepositoryInstaller.Install(container);

            //регистрация кэша
            string redisConnectionString = WebConfigurationManager.AppSettings["cache:RedisConnectionString"];

            CacheLocation defaultLocation = CacheLocation.InMemory;

            Enum.TryParse(WebConfigurationManager.AppSettings["cache:DefaultLocation"], out defaultLocation);


            CacheInstaller.Install(redisConnectionString, defaultLocation, container, new PerRequestLifetimeManager());

            //регистрация Мигратора
            MigratorInstaller.Install(container, connectionString);

            DataServiceCommonInstaller.Install(container);
            //регистрация дата-сервисов
            DataServiceInstaller.Install(container);

            //регистрация шины
            EventBusInstaller.Install(container,
                                      WebConfigurationManager.AppSettings["RabbitMQHost"],
                                      WebConfigurationManager.AppSettings["ServiceAddress"],
                                      WebConfigurationManager.AppSettings["RabbitMQUserName"],
                                      WebConfigurationManager.AppSettings["RabbitMQPassword"]);

            container.RegisterType <JsResourceHelper>();
        }