I am using SavableModelBase
in order to save/load configuration files to/from XML.
I have a case now that I have common properties that I want to refactor to a base class.
Something like:
class CommonConfig: SavableModelBase<CommonConfig>
{
/// <summary>
/// Gets or sets the property value.
/// </summary>
public string CommonPath
{
get { return GetValue<string>(CommonPathProperty); }
set { SetValue(CommonPathProperty, value); }
}
/// <summary>
/// Register the Name property so it is known in the class.
/// </summary>
public static readonly PropertyData CommonPathProperty = RegisterProperty("CommonPath", typeof(string), string.Empty);
}
Then I want to create some specific configuration (e.g. SpecificConfig
) that share properties with the common configuration. The problem that if I inherit CommonConfig
the Save()
function is not aware of the properties of SpecificConfig
.
I guess I can use composition (SpecificConfig
will have a property of type CommonConfig
) but this does not looks/reads well.
Any suggestions?