Programmatically configure ActiveRecordFacility for multiple databases

ぃ、小莉子 提交于 2019-12-13 05:45:48

问题


I'm trying to build a small application (ASP.NET MVC) that uses the plugin architecture. Along with Castle ActiveRecord Integration Facility. And I wish to let each plugin configure its own ActiveRecord behaviors. Like database connection string, proxy, etc.. However, I couldn't find a way to set multiple configurations without the use of web.config. The idea is to make this programmatically.

My goal is for each plugin in this system, if it defines its own ActiveRecord settings, the main application can set up next to ActiveRecordFacility these behaviors.

has someone do something like that?

P.S.: sorry, bad grammar...google translate...;P


回答1:


You can set up the ActiveRecord configuration programmatically using InPlaceConfigurationSource (lots of examples around), then after initializing ActiveRecord (in your own code), call the ActiveRecordFacility with the skipARInitialization flag. e.g.:

container.AddFacility("ar", new ActiveRecordFacility(true));

This tells the facility not to try to initialize ActiveRecord, so it picks up the existing configuration.




回答2:


Ok...the example in Lostechies works great. (link text)

Mauricio, thanks for the tip!



来源:https://stackoverflow.com/questions/4456652/programmatically-configure-activerecordfacility-for-multiple-databases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!