Generates a dynamic implementation of an interface with properties that binds to a settings store and implements INotifyPropertyChanged.
See http://unclassified.software/source/settingsadapterfactory for further information.
- SettingsDemo/Unclassified/Util/SettingsAdapterFactory.cs
Interface implemmentation factory. The dynamic code is produced here. - SettingsDemo/Unclassified/Util/SettingsHelper.cs
Provides methods for specialized settings situations. - SettingsDemo/Unclassified/Util/FileSettingsStore.cs
A data store that contains all setting keys and values of a specified setting file. - SettingsDemo/Unclassified/Util/RegistrySettingsStore.cs
A data store that contains all setting keys and values of a specified registry key.
Copy the first two files and one of the last two into your project to use this code.
Define your settings structure:
public interface IAppSettings : ISettings
{
string LastStartedAppVersion { get; set; }
string[] RecentlyLoadedFiles { get; set; }
bool IsSoundEnabled { get; set; }
}
Then create an instance of its implementation:
IAppSettings settings = SettingsAdapterFactory.New<IAppSettings>(
new FileSettingsStore(
SettingsHelper.GetAppDataPath(@"Company\Product", "Product.conf")));
The settings instance is created in SettingsDemo/App.xaml.cs, InitializeSettings()
.