I have the following:
internal class Person {
}
internal interface IGetPerson {
Person GetPerson();
}
public class Cat: IGetPerson {
private Person _Person = new Person();
Person IGetPerson.GetPerson() {
return _Person;
}
internal Person GetPerson() { // dry violation -- necessary?
return _Person; // or return (this as IGetPerson).GetPerson();
}
}
It appears to be necessary to get the following to compile, without an "as" cast:
internal class SomeClass {
public static Person GetPerson(Cat someCat) {
return someCat.GetPerson();
}
}
The upshot is that unless I'm missing something, adopting an internal interface will inevitably lead to this kind of DRY violation. The alternative is to make the Person class public.
Am I missing something?