我目前正在编写一个接口,允许应用程序将异常数据发送到中央存储库以获得支持.我对如何传递额外的上下文数据感到困惑:
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?你为什么选择一个?
在解析类型时是否可以传递列表构造函数参数?我想尽可能使用程序化配置.我一直在使用参数方法,如下所示,但我还没有偶然发现答案.
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)