【发布时间】:2010-10-26 00:30:55
【问题描述】:
因为它应该是应用程序 Windows 窗体中的文件 app.config,以便它们在构建中自动生成给定的访问类?
【问题讨论】:
-
我认为问题 [重述] 是“如何配置我的 app.config 以便亚音速类作为构建的一部分自动生成?”
标签: winforms configuration subsonic app-config
因为它应该是应用程序 Windows 窗体中的文件 app.config,以便它们在构建中自动生成给定的访问类?
【问题讨论】:
标签: winforms configuration subsonic app-config
是的。您所做的是在 configSections 中添加一个名为“SubsonicService”的部分,如下所示:
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
接下来,您添加一个 connectionStrings 分支,其中包含您将在项目中使用的连接字符串,如下所示:
<connectionStrings>
<clear/>
<add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>
最后,添加您在 configSections 中添加的 SubsonicService 节点,如下所示:
<SubSonicService defaultProvider="WheelMUDSQLite">
<providers>
<clear/>
<add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
</providers>
</SubSonicService>
这是您放置所有提供程序的地方。我使用 SubStage 实用程序来生成 DAL。通过这种方式,您可以将您的内容与 Subsonic 附带的 Web 位完全分离。
【讨论】:
您的构建过程需要包含这样的命令:
sonic.exe generate /config "c:\myproject\App.config"
sonic.exe 是SubCommander 实用程序,包含在current release 中。无法让 app.config 直接为您处理。
运行命令的一种方法是使用MSBuild。 Exec MS Build task 任务可能看起来像这样:
<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
<Exec Command="sonic.exe generate /config "c:\myproject\App.config"" WorkingDirectory="c:\path-to-subcommander"/>
</Target>
我只是编造了这个,所以它可能需要调整才能适合你。此命令将进入您的 visual studio 项目 文件(即 someproject.vbproj)。
【讨论】: