我正在使用SavableModelBase
爲了保存/加載配置文件到/從XML。Catel SavableModelBase和繼承
我現在有一個案例,我有我想要重構基類的共同屬性。
是這樣的:
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);
}
然後我想創造某些特定配置(例如SpecificConfig
)與共同配置該共享屬性。如果我繼承CommonConfig
Save()
函數的問題不知道SpecificConfig
的屬性。
我想我可以使用作文(SpecificConfig
將有一個CommonConfig
類型的財產),但這不看/讀得很好。
有什麼建議嗎?
我試了一次,似乎沒有工作。也許問題出在負載上?如果我使用SavanleModelBase加載的類型應該是XML文件中的任何內容? –
不,它必須有一個類才能在xml文件中查看它是否可以加載之前實例化。請創建一個可重現的問題並上傳到http://www.catelproject.com/support/issue-tracker/,然後我可以看看它。 –
嗨 - 直到現在還沒有回到它 - 我發現如果我使用SpecificConfig.Load(...)它可以工作,但使用SpecificConfig.Load(...)不起作用 - 它這個如預期? –