Hi again
I know that WCF doesn't support open generic types. But my example uses
closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is not
the problem.
The problem is not being able to differentiate the names of two closed
generic methods resulting in deriving an interface from a generic interface.
The following is closed:
[ServiceContract]
public interface IAggregate : IGeneric<int>, IGeneric<string>
{
}
It has two methods called Get(), one that takes an int and the other a
string. They will be named GetOf_Int32 and GetOf_String by the runtime. But
I can't see a way to "get at" these methods so that they can have a Name
assigned. For example, if they were overloads you could do this:
[ServiceContract]
public interface IAggregate
{
[OperationContract(Name="GetByInt")]
int Get( int value );
[OperationContract(Name="GetByString")]
int Get( string value );
}
Unfortunately, the serializer doesn't seem to be aware of the fact that it's
possible to derive an interface multiple times from different closed
"versions" of a single generic interface. If it did, it could differentiate
the names itself.
MikeS.
"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
> WCF doesn't not support open generic types
, so the only way to use
> [ServiceContract]
> public interface ISomeInterface<SomeConcreteType>
> {
> [OperationContract]
> T Get();
> }
>
> Arkady
>
> "Mike Scott" <someone@microsoft.com> wrote in message
> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>I seem to have found a limitation in WCF when using generic interfaces.
>>For example:
>>
>> [ServiceContract]
>> public interface IGeneric<T>
>> {
>> [OperationContract]
>> T Get();
>> }
>>
>> [ServiceContract]
>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>> {
>> }
>>
>> Trying to use IAggregate fails because there are two Get() methods, one
>> which takes an int and one which takes a string. WCF's exception message
>> helpfully suggests adding a Name="xxx" parameter to the
>> OperationContract. However, since the Get() method is defined in
>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters of
>> the closed generic methods.
>>
>> Comments?
>>
>> MikeS.
>>
>
>