I have class like:
public interface IDriver
{
string DriverName { get; }
IDriverConfiguration Config { get; set; }
}
public interface IDriverConfiguration
{
string DriverName { get; }
}
And driver class implementation:
public class MyDriver : IDriver
{
public Configuration Config { get; set; }
}
public class Configuration : IDriverConfiguration
{
public string DriverName { get; private set; }
public bool EnableLogger { get; private set; }
public int ArchiveLogs { get; private set; }
}
It seems that Config property inside MyDriver should return exact interface IDriverConfiguration instead of DriverConfiguration that inherits from IDriverConfiguration.
Is there any way to ensure that MyDriver.Config property will implement at least DriverName property?
IDriverConfigurationinterface ensures that "MyDriver.Config" will at least implement theDriverNameproperty. So just change your return type of theConfigproperty toIDriverConfigurationand you are there...