我最近学会了如何使用➜ ls-adventures git:(master) ✗ ghci main.hs
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( main.hs, interpreted )
Ok, modules loaded: Main.
*Main> :main
Connected. Take this shell, and may it serve you well.
I will not you create anything yet, but there is a
directory, "/" which you are currently in.
The `ls` command should let you see what else is there
I will do that for you now
[Directory {name = "bin", entries = fromList []}]
来保存app.config
项目的连接字符串。如果我在连接字符串中更改某些内容并且项目已经发布,我发现这非常有帮助。
现在,我正在使用SAP的B1 SDK中的.net
对象,并且我不想在硬编码中保留连接详细信息。因为它不仅仅是一个连接字符串(据我所知),所以我想知道company
是否也可以存储app.config
对象的连接细节。
这就是我通常与company
对象建立联系的方式:
company
答案 0 :(得分:2)
Karol的评论是关键的,这是我们通常如何设置我们的。只有额外的评论是,根据您的部署环境的样子,您可能希望加密app.config(密码)中的敏感凭据。
// In code
Company company = new Company
{
Server = ConfigurationManager.AppSettings["DevServer"],
DbUserName = ConfigurationManager.AppSettings["DevDBUser"],
DbPassword = ConfigurationManager.AppSettings["DevDBPassword"],
CompanyDB = ConfigurationManager.AppSettings["DevDatabase"],
UserName = ConfigurationManager.AppSettings["DevSBOUser"],
Password = ConfigurationManager.AppSettings["DevSBOPassword"],
language = BoSuppLangs.ln_English
};
// In your app.config
<appSettings>
<add key="DevServer" value="DEV-SAP-SRV"/>
<add key="DevDBUser" value="sa"/>
<add key="DevDBPassword" value="sapassword"/>
<add key="DevSBOUser" value="manager"/>
<add key="DevSBOPassword" value="1234"/>
<add key="DevDatabase" value="SBO_COMPANY_NAME"/>
</appSettings>