I’ve got a ServiceContract that has an OperationContract with the following method signature: Manipulate(int fileid, param object[] operations).
I also have five DataContracts defined for the WCF service, and I’d like object[] operations to accept any number and combination of those. The problem is that they aren’t visible unless I use them in the method signature. If I do that though, then only one type of DataContract can be used at a time, defeating the purpose of using an object[].
How do I make all five DataContracts visible on the client side without having to alter the method signature?
Use known types. For example in your config file you could define the different known types:
Now clients will know about the
Foo,BarandBazdata contracts.This being said, I would recommend you to use a common base type for your data contracts instead of object. Having a method signature that takes object as input is hard to understand from a consumer standpoint.