Fenton
Fenton

Reputation: 250822

Web Service Needs To Accept Unspecified Arguments

I have a web service that is used to manage various "events" that occur in a live telephony system.

The method I am working on really needs to accept two arguments.

  1. The type of event
  2. Some arguments

The "some arguments" is a number of key/value pairs.

The web service is going to be called from other languages - not just .NET languages.

What should my method signature look like...

public bool Notify(string eventType, IEnumerable<KeyValuePair<string, string> arguments)

Or...

public bool Notify(string eventType, IDictionary<string, string> arguments)

Or something else.

Upvotes: 1

Views: 62

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

I would stay away from interfaces when defining data contracts. Maybe something like this:

public bool Notify(string eventType, KeyValuePair<string, string>[] arguments)
{

}

Or define a custom class:

public class Argument
{
    public string Name { get; set; }
    public string Value { get; set; }
}

and then:

public bool Notify(string eventType, Argument[] arguments)
{

}

Upvotes: 2

Related Questions