Ejemplo n.º 1
0
 public void Init()
 {
     iocContainer = IoCContainerManagerFactory.GetIoCContainerManager();
     iocContainer.RegisterLoggerFactory(new Log4NetLoggerFactory());
     iocContainer.RegisterComponent(typeof(ICurrentUserSvc), typeof(CurrentUserSvc));
     iocContainer.RegisterComponent(typeof(IXmlProcessorSvc), typeof(XmlProcessorSvc));
 }
Ejemplo n.º 2
0
        public void Init()
        {
            iocContainer = IoCContainerManagerFactory.GetIoCContainerManager();
            iocContainer.RegisterLoggerFactory(new Log4NetLoggerFactory());

            iocContainer.RegisterComponent(typeof(ICurrentUserSvc), typeof(CurrentUserSvc));
            iocContainer.RegisterComponent(typeof(IConfigurationSvc), typeof(ConfigurationSvc));
            iocContainer.RegisterComponent(typeof(ITestComponent), typeof(TestComponent));

            string redisNetAddr = ConfigurationManager.AppSettings["RedisNetAddr"];
            if (string.IsNullOrEmpty(redisNetAddr)) throw new Exception("Network address for Redis server not configured (RedisNetAddr)");
            iocContainer.RegisterComponentInstance(typeof(IRedisClientsManager), new PooledRedisClientManager(redisNetAddr), "RedisClientsManager");
            using (IRedisClient redis = iocContainer.Resolve<IRedisClientsManager>().GetClient())
            {
                redis.SetValue("BHS:ConfigKey:" + ConfigurationSvcBase.TraceMethodsConfigKey, "true");
            }

            MethodLoggingInterceptorBase.ConfigData loggerCfg = new MethodLoggingInterceptorBase.ConfigData(true, true, new string[] { "pass" });
            IDictionary config = new Hashtable { { MethodLoggingInterceptorBase.ConfigPropertyName, loggerCfg } };
            IEnumerable<string> namespacePrefixes = new string[] { "BerwickHeights.Platform" };
            IEnumerable<string> ignoredTypes = new string[]
            {
                "BerwickHeights.Platform.Core.CurrentUser.CurrentUserSvc",
                "BerwickHeights.Platform.IoC.Castle.Logger",
                "BerwickHeights.Platform.Config.Redis.ConfigurationSvc"
            };
            iocContainer.RegisterInterceptors(new InterceptorDescriptor(typeof (MethodLoggingInterceptor), config, namespacePrefixes, ignoredTypes));
        }
Ejemplo n.º 3
0
        public void Init()
        {
            container = IoCContainerManagerFactory.GetIoCContainerManager();
            container.RegisterLoggerFactory(new Log4NetLoggerFactory());

            MethodLoggingInterceptorBase.ConfigData loggerCfg = new MethodLoggingInterceptorBase.ConfigData(true, true, new string[] { "pass" });
            TransactionInterceptor.ConfigData transCfg = new TransactionInterceptor.ConfigData(new string[] { "BerwickHeights.Platform.NHibernate.Test" });
            container.RegisterInterceptors(
                new InterceptorDescriptor(
                    typeof (MethodLoggingInterceptor),
                    new Hashtable { { MethodLoggingInterceptorBase.ConfigPropertyName, loggerCfg } },
                    new string[] { "BerwickHeights.Platform" },
                    new string[]
                    {
                        "BerwickHeights.Platform.Core.Config.AppConfig.ConfigurationSvc",
                        "BerwickHeights.Platform.Core.CurrentUser.CurrentUserSvc",
                        "BerwickHeights.Platform.IoC.Castle.Logger",
                        "BerwickHeights.Platform.NHibernate.Interceptors.AuditInterceptor",
                        "BerwickHeights.Platform.PerfTest.Svc.PerfTestSvc",
                        "BerwickHeights.Platform.PerfTest.DAL.NHibernate.PerfTestDAL"
                    }),
                new InterceptorDescriptor(
                    typeof(TransactionInterceptor),
                    new Hashtable { { TransactionInterceptor.ConfigPropertyName, transCfg } },
                    new string[] { "BerwickHeights" },
                    new string[]
                    {
                        "BerwickHeights.Platform.Core.Config.AppConfig.ConfigurationSvc",
                        "BerwickHeights.Platform.Core.CurrentUser.CurrentUserSvc",
                        "BerwickHeights.Platform.IoC.Castle.Logger",
                        "BerwickHeights.Platform.NHibernate.Interceptors.AuditInterceptor"
                    }));

            // Register components in assemblies
            container.RegisterInProcComponents(
                "BerwickHeights.Platform.Core",
                "BerwickHeights.Platform.PerfTest");
            container.RegisterComponent(typeof(ITestDataSvc), typeof(TestDataSvc));
            container.RegisterComponent(typeof(IInterceptor), typeof(AuditInterceptor));

            AutoPersistenceModel model = AutoMap
                .AssemblyOf<TestEntity>(new AutomapConfig())
                .Conventions.AddAssembly(typeof (StringConvention).Assembly);
            PerfTestFluentConfig.AutoMap(model);

            container.SetupNHibernateIntegration(
                FluentConfigUtils.ConfigureSqlServer2008("TestDatabase"),
                model,
                FluentConfigUtils.ConfigureNHibernate,
                cacheSettings => FluentConfigUtils.BuildCacheSettings<SysCacheProvider>(cacheSettings, "TestPrefix"),
                false);
        }
        /// <summary>
        /// Returns the singleton instance of the IoC container manager specified by containerType. If containerType
        /// is empty, then uses the container manager configured in application configuration according to the key 
        /// "IoCContainerType". The configured value should be the fully qualified type name of the IoC container 
        /// manager (full type name and assembly).
        /// </summary>
        /// <param name="containerType">The fully qualified type name of the IoC container manager (full type name 
        /// and assembly).</param>
        public static IIoCContainerManager GetIoCContainerManager(string containerType)
        {
            lock (containerManagerLock)
            {
                if (containerManager == null)
                {
                    if (string.IsNullOrEmpty(containerType)) containerType = ConfigurationManager.AppSettings["IoCContainerType"];
                    if (string.IsNullOrEmpty(containerType)) throw new Exception("Configuration missing for IoC container type (IoCContainerType)");

                    Type type = Type.GetType(containerType);
                    if (type == null) throw new Exception("Unknown IoC container manager type: " + containerType);
                    containerManager = Activator.CreateInstance(type) as IIoCContainerManager;
                    if (containerManager == null) throw new Exception("Configured IoC container manager type does not implement IIoCContainerManager: " + containerType);
                }

                return containerManager;
            }
        }
Ejemplo n.º 5
0
        public void Init()
        {
            iocContainer = IoCContainerManagerFactory.GetIoCContainerManager();
            iocContainer.RegisterLoggerFactory(new Log4NetLoggerFactory());

            string redisNetAddr = ConfigurationManager.AppSettings["RedisNetAddr"];
            if (string.IsNullOrEmpty(redisNetAddr)) throw new Exception("Network address for Redis server not configured (RedisNetAddr)");
            iocContainer.RegisterComponentInstance(typeof(IRedisClientsManager), new PooledRedisClientManager(redisNetAddr), "RedisClientsManager");
            iocContainer.RegisterComponent(typeof(IConfigurationSvc), typeof(ConfigurationSvc));

            using (IRedisClient redis = iocContainer.Resolve<IRedisClientsManager>().GetClient())
            {
                redis.SetValue(testKeyPrefix + testBoolCfgTrueKey, "true");
                redis.SetValue(testKeyPrefix + testBoolCfgFalseKey, "false");
                redis.SetValue(testKeyPrefix + testIntCfgKey, testInt + "");
                redis.SetValue(testKeyPrefix + testStrCfgKey, testStr);
                string val = testStrArray.Aggregate("", (current, str) => current + (str + ","));
                val = val.Substring(0, val.Length - 1);
                redis.SetValue(testKeyPrefix + testStrArrayCfgKey, val);
            }
        }