C# Castle Windsor 运行时 xmldatasource 配置
我在动态/运行时将数据源指向 Environment.SpecialFolder.Personal 时遇到问题
这是我的 xml
<?xml version="1.0" encoding="utf-8" ?>
<activerecord isDebug="true" isWeb="false">
<config>
<add
key="connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="connection.connection_string"
value="Data Source=**database.s3db**;Version=3" />
<add key="query.substitutions"
value="true=1;false=0"/>
<add key="show_sql"
value="true"/>
<add key="dialect" value="NHibernate.Dialect.SQLiteDialect"/>
<add key="connection.driver_class" value="NHibernate.Driver.SQLite20Driver"/>
<add key="proxyfactory.factory_class"
value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
<!--<add
key="proxyfactory.factory_class"
value="NHibernate.ByteCode.Castle"/>-->
</config>
</activerecord>
所以我想要的是将数据源更改为指向用户 Environment.SpecialFolder.Personal 文件夹。有办法做到这一点吗?
这是我当前的初始化
XmlConfigurationSource source = new XmlConfigurationSource("castle.xml"));
ActiveRecordStarter.Initialize(source, typeof(Account), ... etc);
I have problem dynamically/runtime pointing datasource to Environment.SpecialFolder.Personal
Here is my xml
<?xml version="1.0" encoding="utf-8" ?>
<activerecord isDebug="true" isWeb="false">
<config>
<add
key="connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="connection.connection_string"
value="Data Source=**database.s3db**;Version=3" />
<add key="query.substitutions"
value="true=1;false=0"/>
<add key="show_sql"
value="true"/>
<add key="dialect" value="NHibernate.Dialect.SQLiteDialect"/>
<add key="connection.driver_class" value="NHibernate.Driver.SQLite20Driver"/>
<add key="proxyfactory.factory_class"
value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
<!--<add
key="proxyfactory.factory_class"
value="NHibernate.ByteCode.Castle"/>-->
</config>
</activerecord>
So what I want is to change datasource to point to user Environment.SpecialFolder.Personal folder. Is there is anyway to do that ?
Here is my current initialization
XmlConfigurationSource source = new XmlConfigurationSource("castle.xml"));
ActiveRecordStarter.Initialize(source, typeof(Account), ... etc);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 InPlaceConfigurationSource (示例 ),通过 AppSettings / 自定义配置部分处理程序 / 等公开真正可配置的部分。
Instead of XmlConfigurationSource use InPlaceConfigurationSource (example), expose the really configurable parts via AppSettings / custom config section handler / etc.