私はこれに沿って何かをしたいと思っています:
internal interface IInternalStore
{
object GetValue(object key);
}
public interface IStore<in TKey, TValue>
: IInternalStore
{
TValue GetValue(TKey key);
}
public interface IStore
: IInternalStore
{
TValue GetValue<in TKey, TValue>(TKey key);
}
これを行う理由は、個々のインターフェイスの種類を確認しなくても、クラスが IInternalStore であることを確認できるようにするためです。
すなわち。
// Defined by the implementing developer
public class MyStoreA
: IStore<int, int>
{
int GetValue(int key);
}
public class MyStoreB<TKey, TValue>
: IStore
{
TValue GetValue(TKey key);
}
// Internal method used by me
void GetValueFromStore(object store)
{
if (store is IInternalStore)
{
{do something}
}
}
しかし、私が見ることができることから、IInternalStoreは継承されたインターフェイスと同じアクセサーでなければならず、開発者がすべての継承されたメソッドを実装する必要があるため、私がやりたいことは不可能です。
私が間違っている?私が望んでいることをする方法はありますか?