public SystemSettingsSwitcherSettings(IObjectData data) : base(data) { // prepare settings bool enableSystemSettingsSwitch = Defaults.EnableSystemSettingsSwitch; ActualProxySettings actualProxy = null; if (data != null) { // get settings from data enableSystemSettingsSwitch = data.GetBooleanValue(SettingNames.EnableSystemSettingsSwitch, enableSystemSettingsSwitch); // Note that ActualProxy should not be empty but null if the settings do not exist. actualProxy = data.GetObjectValue(SettingNames.ActualProxy, actualProxy, this.CreateActualProxySettings); } // set settings try { // may throw ArgumentException for an invalid value this.EnableSystemSettingsSwitch = enableSystemSettingsSwitch; this.ActualProxy = actualProxy; } catch (Exception exception) { throw new FormatException(exception.Message); } return; }
public ProxySettings(IObjectData data) : base(data) { // prepare settings ListenerSettings mainListener = null; IEnumerable <ListenerSettings> additionalListeners = null; int retryCount = Defaults.RetryCount; if (data != null) { // get settings from data mainListener = data.GetObjectValue(SettingNames.MainListener, mainListener, CreateListenerSettings); additionalListeners = data.GetObjectArrayValue(SettingNames.AdditionalListeners, additionalListeners, CreateListenerSettings); retryCount = data.GetInt32Value(SettingNames.RetryCount, retryCount); } if (mainListener == null) { mainListener = Defaults.CreateDefaultMainListener(); } // set settings try { // may throw ArgumentException for an invalid value this.MainListener = mainListener; this.AdditionalListeners = additionalListeners; this.RetryCount = retryCount; } catch (Exception exception) { throw new FormatException(exception.Message); } return; }
public GUIForWindowsGUISettings(IObjectData data) : base(data) { // prepare settings bool chaseLastLog = Defaults.ChaseLastLog; MainWindowSettings mainWindow = null; if (data != null) { // get settings from data chaseLastLog = data.GetBooleanValue(SettingNames.ChaseLastLog, chaseLastLog); mainWindow = data.GetObjectValue(SettingNames.MainWindow, mainWindow, this.CreateMainWindowSettings); } if (mainWindow == null) { mainWindow = CreateMainWindowSettings(null); } // set settings try { // may throw ArgumentException for an invalid value this.ChaseLastLog = chaseLastLog; this.mainWindow = mainWindow; } catch (Exception exception) { throw new FormatException(exception.Message); } return; }
public static IObjectDataValue CreateObjectValue <T>(this IObjectData data, T value, Action <T, IObjectData, bool> saveObject, string name, bool overwrite, bool omitDefault) { // argument checks Debug.Assert(data != null); Debug.Assert(saveObject != null); Debug.Assert(name != null || overwrite == false); IObjectData objectData = null; if (value != null) { // get IObjectData into which the value saves its contents if (overwrite) { // overwirte mode objectData = data.GetObjectValue(name, defaultValue: null); } if (objectData == null) { // create a empty IObjectData objectData = data.CreateObject(); } // save the value's contents saveObject(value, objectData, omitDefault); } return(data.CreateValue(objectData)); }
protected override T GetValueAdapter(IObjectData data, string name, T defaultValue) { return(data.GetObjectValue(name, defaultValue, this.Creator)); }
protected override Tuple <T> GetValueAdapter(IObjectData data, string name) { return(data.GetObjectValue(name, this.Creator)); }