I have an IFoo interface that defines some functions, an abstract FooBase class that implements IFoo and some internal functions, and several Foo classes derived from FooBase.
I also have a Bar class that should call a method from FooBase, but gets its parameters passed as IFoo. So, it looks like this:
public interface IFoo
{
}
public abstract class FooBase : IFoo
{
internal TInternalType SomeMethod();
}
public class Foo1 : FooBase
{
}
public class Bar
{
public void DoSomething(IFoo foo)
{
TInternalType myT = (foo as FooBase).SomeMethod();
}
}
As already mentioned, this is not so, because anyone can come, write a Baz class that implements IFoo, and calling DoSomething will fail.
/ , , , , IFoo , .. API.
DoSomething, FooBase FooBase , , API, .
, : , (.. ), ?
:
, L . , L , , , , - - L - , .
Foo, , Bar, L. Foo L; Foo , L.
FooBase, Foo L, Bar , , L.
, , .