Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SettingsManager
- {
- static SettingsManager()
- {
- _settings = GetSettings();
- }
- private static ApplicationSettingsBase GetSettings()
- {
- Assembly asm = AssemblyManager.GetEntryAssembly();
- if (asm != null)
- {
- Type settingsType = (from t in asm.GetTypes()
- where t.IsSubclassOf(typeof(ApplicationSettingsBase))
- select t).FirstOrDefault();
- if (settingsType != null)
- {
- PropertyInfo pi = settingsType.GetProperty("Default", BindingFlags.Public | BindingFlags.Static);
- if (pi != null)
- {
- return pi.GetValue(null, null) as ApplicationSettingsBase;
- }
- else
- {
- return Activator.CreateInstance(settingsType) as ApplicationSettingsBase;
- }
- }
- }
- return null;
- }
- private static ApplicationSettingsBase _settings;
- public static ApplicationSettingsBase Settings
- {
- get { return _settings; }
- set { _settings = value; }
- }
- }
- public class SettingBindingExtension : Binding
- {
- public SettingBindingExtension()
- {
- Initialize();
- }
- public SettingBindingExtension(string path)
- : base(path)
- {
- Initialize();
- }
- private void Initialize()
- {
- this.Source = SettingsManager.Settings;
- this.Mode = BindingMode.TwoWay;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement