public void Castle() { SystemConfig.ConfigFilesAssemblyName = "CodeSharp.Framework.Castles.Test"; SystemConfig.Configure("ConfigFiles") .Castle() .BusinessDependency(Assembly.GetExecutingAssembly()); Assert.AreEqual("abc", SystemConfig.Settings["key1"]); Assert.DoesNotThrow(() => DependencyResolver.Resolve <ILoggerFactory>().Create(this.GetType()).Info("hi")); Assert.DoesNotThrow(() => DependencyResolver.Resolve <ITestService>()); Assert.DoesNotThrow(() => DependencyResolver.Resolve <NHibernate.ISessionFactory>()); //NH Tests var e = new TestEntity("abc"); var s = DependencyResolver.Resolve <ITestService>(); s.Create(e); DependencyResolver.Resolve <Castle.Facilities.NHibernateIntegration.ISessionManager>().OpenSession().Evict(e); var e2 = s.Get(e.ID); //private setter? Assert.AreEqual(e.Name, e2.Name); Assert.AreEqual("abc", e2.Name); Assert.DoesNotThrow(() => SystemConfig.Cleanup()); }
public override void Main() { Castle.Windsor.IWindsorContainer c = null; //框架配置初始化 SystemConfig.ConfigFilesAssemblyName = "Host"; SystemConfig.Configure("TFlowEngineServiceNode") .Castle() .BusinessDependency(Util.TFlowEngineReference().ToArray()) .Resolve(o => { c = o.Container; this.Prepare(o); }) .Globalization(); //通过NSF暴露该节点的引擎服务 CodeSharp.ServiceFramework.Configuration .Configure() .Castle(c) .Log4Net(false) //.Associate(new Uri(""))//若有中心节点则注册 .Remoting(new Uri("tcp://localhost:8000/remote.rem")) .Endpoint() .Add(this.AllServiceTypesToRegist().ToArray()) .Run(); //基本可用性检查 this.DoTest(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); Castle.Windsor.IWindsorContainer c = null; //配置框架初始化 SystemConfig.ConfigFilesAssemblyName = "Taobao.Workflow.Activities.AdminWeb"; SystemConfig.Configure("TFlowEngineAdminWeb") .Castle() .Resolve(o => { c = o.Container; o.Container.ControllerFactory(); o.Container.RegisterControllers(Assembly.GetExecutingAssembly()); }); //NSF初始化 CodeSharp.ServiceFramework.Configuration .Configure() .Castle(c) .Log4Net(false) .Associate(new Uri("tcp://localhost:8000/remote.rem")) .Endpoint() .Run(); }
public override void Main() { //框架配置初始化 SystemConfig.ConfigFilesAssemblyName = "Host"; SystemConfig.Configure("TFlowEngineSchedulerNode") .Castle() .BusinessDependency(Util.TFlowEngineReference().ToArray()) .Resolve(this.Prepare) .Globalization(); //设置核心使用的容器 ActivityUtilities.Container(new Container()); Taobao.Activities.Hosting.WorkflowInstance.IsEnableDebug = true; //启动调度 DependencyResolver.Resolve <Taobao.Workflow.Activities.Hosting.IScheduler>().Run(); }
/// <summary>启用castle作为容器化架构的默认容器 /// <remarks> /// 若您决定启用容器, /// 强烈建议SystemConfig.Configure(app)之后立刻声明Castle()再进行其他特性的配置, /// 以确保您启用的特性能顺利享受到容器带来的变化 /// 如:SystemConfig.Configure().Castle().DefaultAppAgent(); /// </remarks> /// </summary> /// <param name="config"></param> /// <returns></returns> public static SystemConfigWithCastle Castle(this SystemConfig config) { return(SystemConfig.Configure(new SystemConfigWithCastle(config)) as SystemConfigWithCastle); }