小编Ben*_*ard的帖子

IDictionary <string,string>或NameValueCollection

我目前正在编写一个接口,允许应用程序将异常数据发送到中央存储库以获得支持.我对如何传递额外的上下文数据感到困惑:

public interface IExceptionNotifier
{
    void Notify(Exception ex, NameValueCollection context); //this      
    void Notify(Exception ex, IDictionary<string, string> context); //or this
}
Run Code Online (Sandbox Code Playgroud)

在创建查找时,我经常发现自己处于类似的位置.忽略异常通知程序概念是否良好,是否最好使用IDictionary<string, string>NameValueCollection?你为什么选择一个?

c#

6
推荐指数
2
解决办法
2032
查看次数

Castle Windsor:如何以编程方式将列表参数传递给容器?

在解析类型时是否可以传递列表构造函数参数?我想尽可能使用程序化配置.我一直在使用参数方法,如下所示,但我还没有偶然发现答案.

container.Register(
    Component
    .For<IDoSomething>()
    .ImplementedBy<DoSomething>()
    .Parameters(...)
);
Run Code Online (Sandbox Code Playgroud)

DoSomething类看起来像这样

public class DoSomething : IDoSomething
{
    public DoSomething(List<string> listOfStrings) 
    {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

castle-windsor inversion-of-control

6
推荐指数
1
解决办法
1158
查看次数

标签 统计

c# ×1

castle-windsor ×1

inversion-of-control ×1