我正在使用Framework 4.0在C#中开发一个应用程序.
在我的应用程序中,我想创建一个不是app.config文件的单独配置文件.配置文件包含我们为产品开发的自定义配置部分.
我不想使用configSource从app.config引用此文件.
我想在运行时加载它并读取它的内容.
我的意思是log4net,它允许您在log4net.config文件中编写配置.
任何人都可以帮助如何做到这一点,而无需编写模仿框架中存在的代码的代码?
更新:
根据Kaido的回答,我写了一个实用程序类来读取自定义配置文件,并且能够在文件系统上的文件发生更改时刷新Config内容.
本课程的用法如下:
获取配置文件内容
// Create configuration reader that reads the files once
var configFileReader = new CustomConfigurationFileReader("c:\\myconfig.config");
var config = configFileReader.Config;
// Do any action you want with the config object like:
config.GetSection("my.custom.section");
// or,
var someVal = config.AppSettings.Settings["someKey"];
Run Code Online (Sandbox Code Playgroud)配置文件更改时获取通知
// Create configuration reader that notifies when the configuraiton file changes
var configFileReader = new CustomConfigurationFileReader("c:\\myconfig.config", true);
// Register to the FileChanged event
configFileReader.FileChanged += MyEventHandler;
...
private void MyEventHanler(object …Run Code Online (Sandbox Code Playgroud)嗨, 我正在实施我的Facebook游戏和Paypal的快速结账支付服务之间的整合.
我的网站是在ASP.net开发的,我使用的是NVP API进行集成.
我的问题是我一直收到10400错误 - 订单总数丢失.
我的代码是:
// Set the key/value pairs to send in the request
var kvpl = new List<KeyValuePair<string, string>>();
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_PAYMENTACTION", "Sale"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_AMT", "23.00"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_ITEMAMT", "15.00"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_TAXAMT", "5.00"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_SHIPPINGAMT", "1.00"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_HANDLINGAMT", "1.00"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_INSURANCEAMT", "1.00"));
kvpl.Add(new KeyValuePair<string, string>("PAYMENTREQUEST_0_CURRENCYCODE", "ILS"));
kvpl.Add(new KeyValuePair<string, string>("L_PAYMENTREQUEST_0_NAME0", "The name of product 1"));
kvpl.Add(new KeyValuePair<string, string>("L_PAYMENTREQUEST_0_NUMBER0", "5543312"));
kvpl.Add(new KeyValuePair<string, string>("L_PAYMENTREQUEST_0_DESC0", "The description of product 1"));
kvpl.Add(new KeyValuePair<string, string>("L_PAYMENTREQUEST_0_AMT0", "10.00")); …Run Code Online (Sandbox Code Playgroud) 我正在实现一个Facebook应用程序,显示为粉丝页面中的选项卡.
该应用程序有一个产品详细信息页面,其中包含like,send和comments插件.
问题是当点击发送和喜欢按钮时,弹出对话框(点击按钮后弹出的窗口)被iframe的左边缘剪切(应用程序是从右到左的语言).
从图形设计角度来看,按钮的位置无法更改,也不允许滚动条.应用程序必须是520px宽,不多也不少.
是否有任何选项来控制弹出窗口的位置以防止其剪裁?有没有其他方法可以防止剪辑?
我在这里搜索了类似的问题没有成功.