Web服务需要接受未指定的参数
本文关键字:未指定 参数 服务 Web | 更新日期: 2023-09-27 18:00:00
我有一个web服务,用于管理实时电话系统中发生的各种"事件"。
我正在研究的方法确实需要接受两个论点。
- 事件的类型
- 一些论点
"some arguments"是许多键/值对。
web服务将从其他语言调用,而不仅仅是.NET语言。
我的方法签名应该是什么样子。。。
public bool Notify(string eventType, IEnumerable<KeyValuePair<string, string> arguments)
或者。。。
public bool Notify(string eventType, IDictionary<string, string> arguments)
或者其他什么。
在定义数据契约时,我会远离接口。也许是这样的:
public bool Notify(string eventType, KeyValuePair<string, string>[] arguments)
{
}
或者定义一个自定义类:
public class Argument
{
public string Name { get; set; }
public string Value { get; set; }
}
然后:
public bool Notify(string eventType, Argument[] arguments)
{
}