public void ApplySettingsFrom(IDictionary<string, string> overriddenSettings, SettingsBase settings)
        {
            if (overriddenSettings == null) throw new ArgumentNullException("overriddenSettings");
            if (settings == null) throw new ArgumentNullException("settings");

            foreach (var overriddenSetting in overriddenSettings)
            {
                var settingName = overriddenSetting.Key;
                var settingStringValue = overriddenSetting.Value;

                var propertyInfo = typeof (Settings).GetProperty(settingName);
                if (propertyInfo == null)
                {
                    // TODO: exception should reflect and print all setting options and their System.Type.
                    throw new StatLightException("Unknown setting value of settingName");
                }

                var type = propertyInfo.PropertyType;

                var settingValue = ParseValue(settingStringValue, type);

                _logger.Debug("Overriding setting default value for [{0}] of [{1}] to [{2}]."
                    .FormatWith(settingName, settings[settingName], settingValue));

                settings[settingName] = settingValue;
            }
        }
        private static void InitAndPersistPosition(Window window, SettingsBase settings, Func<Window, string> idGenerator)
        {
            const string settingName = "WindowLocationPersisterData";
            string id = idGenerator(window);
            { // Init data
                Dictionary<string, object> data = GetData((string)settings[settingName], id);
                InitWindow(window, data);
            }

            window.Closing += delegate
            {
                Dictionary<string, object> data = GetData((string)settings[settingName], id);
                PickleWindow(window, data);
                settings[settingName] = SaveData(data, id);
                settings.Save();
            };
        }
Ejemplo n.º 3
0
        public WindowSettings(SettingsBase settings, Form form, string prefix)
        {
            if (settings == null) throw new ArgumentNullException("settings");
            if (form == null) throw new ArgumentNullException("form");

            _form = form;
            _settings = settings;

            if (string.IsNullOrEmpty(prefix))
                prefix = form.GetType().Name;

            var properties = settings.Properties;
            _location = properties[prefix + "Location"];
            _size = properties[prefix + "Size"];
            _windowState = properties[prefix + "WindowState"];

            form.Load += OnFormLoad;
            form.Closing += OnFormClosing;
            form.Disposed += OnFormDisposed;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Starts execution of MqlAdapter.
        /// </summary>
        /// <param name="settings">Settings to look for configuration</param>
        /// <param name="adapter">Mql adapter.</param>
        public MqlLauncher(SettingsBase settings, MqlAdapter adapter)
            : base(settings, adapter)
        {

        }
Ejemplo n.º 5
0
 public static SettingsBase Synchronized(SettingsBase settingsBase)
 {
     return SettingsBase.Synchronized(settingsBase);
 }
Ejemplo n.º 6
0
        private void OnFormDisposed(object sender, EventArgs e)
        {
            var form = _form;

            _form = null;
            _settings = null;
            _location = _size = _windowState = null;

            Debug.Assert(form != null);

            form.Load -= OnFormLoad;
            form.Closing -= OnFormClosing;
            form.Disposed -= OnFormDisposed;
        }
Ejemplo n.º 7
0
 public WindowSettings(SettingsBase settings, Form form) :
     this(settings, form, null) {}
Ejemplo n.º 8
0
 public static SettingsBase Synchronized(SettingsBase settingsBase)
 {
     settingsBase._isSynchronized = true;
     return(settingsBase);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="settings"></param>
 public PlatformSettings(SettingsBase settings)
 {
     _settings = settings;
     _platformUri = new Uri((string)settings["PlatformUriAddress"]);
 }
 protected bool OnSetInitialState(SettingsBase data)
 {
     settings = data;
     //folderPath = (string)data["QuoteDataFolder"];
     return true;
 }
 public bool SetInitialState(SettingsBase data)
 {
     return OnSetInitialState(data);
 }
Ejemplo n.º 12
0
		public ApplicationSettingsStore(SettingsBase appSettings, string propertyName)
		{
			_appSettings = appSettings;
			_propertyName = propertyName;
		}
Ejemplo n.º 13
0
 public static System.Configuration.SettingsBase Synchronized(System.Configuration.SettingsBase settingsBase)
 {
     return(System.Web.Profile.ProfileBase.Synchronized(settingsBase));
 }
 protected virtual bool OnSetInitialState(SettingsBase data)
 {
     return true;
 }
Ejemplo n.º 15
0
		public static SettingsBase Synchronized(SettingsBase settingsBase)
		{
			throw new NotImplementedException();
		}
Ejemplo n.º 16
0
 public static SettingsBase Synchronized(SettingsBase settingsBase)
 {
     settingsBase._IsSynchronized = true;
     return settingsBase;
 }
 public static void InitAndPersistPosition(Window window, SettingsBase settings)
 {
     InitAndPersistPosition(window, settings, w => w.GetType().FullName);
 }