public static void SetValue <T>(this IObjectData data, string name, T value, Func <IObjectData, T, IObjectDataValue> createValue, bool omitDefault = false, bool isDefault = false) { // set the value // Note that null value means "remove the value". // The value is given as not IObjectDataValue but T and convert on demand, // not to create instance in omission case. data.SetValue(name, CreateValue(data, value, createValue, omitDefault, isDefault)); }
protected override void SaveTo(IObjectData data, bool omitDefault) { // argument checks Debug.Assert(data != null); // save settings data.SetStringValue(SettingNames.EndPoint, this.EndPoint, omitDefault, Defaults.IsDefaultEndPoint(this.EndPoint)); data.SetStringValue(SettingNames.UserName, this.UserName, omitDefault, Defaults.IsDefaultUserName(this.UserName)); data.SetValue(SettingNames.ProtectedPassword, this.Password, CreatePasswordValue, omitDefault, Defaults.IsDefaultPassword(this.Password)); data.SetEnumValue(SettingNames.Persistence, this.Persistence, omitDefault, this.Persistence == Defaults.Persistence); data.SetBooleanValue(SettingNames.EnableAssumptionMode, this.EnableAssumptionMode, omitDefault, this.EnableAssumptionMode == Defaults.EnableAssumptionMode); return; }
protected override void SaveTo(IObjectData data, bool omitDefault) { // argument checks Debug.Assert(data != null); // save settings data.SetStringValue(SettingNames.AutoConfigURL, this.AutoConfigURL); data.SetValue(SettingNames.ProxyEnable, this.ProxyEnable, ObjectDataExtension.CreateInt32Value); data.SetStringValue(SettingNames.ProxyServer, this.ProxyServer); data.SetStringValue(SettingNames.ProxyOverride, this.ProxyOverride); data.SetBooleanValue(SettingNames.AutoDetect, this.AutoDetect); data.SetStringValue(SettingNames.HttpProxyEnvironmentVariable, this.HttpProxyEnvironmentVariable); data.SetStringValue(SettingNames.HttpsProxyEnvironmentVariable, this.HttpsProxyEnvironmentVariable); return; }
protected override void SaveTo(IObjectData data, bool omitDefault) { // argument checks Debug.Assert(data != null); // state checks Debug.Assert(this.Address != null); Debug.Assert(IPEndPoint.MinPort <= this.Port && this.Port <= IPEndPoint.MaxPort); Debug.Assert(0 <= this.Backlog); // save settings data.SetValue(SettingNames.Address, this.Address, CreateIPAddressValue); // not omittable data.SetInt32Value(SettingNames.Port, this.Port); // not omittable data.SetInt32Value(SettingNames.Backlog, this.Backlog, omitDefault, isDefault: this.Backlog == Defaults.Backlog); return; }
protected override void SaveTo(IObjectData data, bool omitDefault) { // argument checks Debug.Assert(data != null); // save settings data.SetInt32Value(SettingNames.InitialSetupLevel, this.InitialSetupLevel, omitDefault, this.InitialSetupLevel == Defaults.InitialSetupLevel); data.SetEnumValue(SettingNames.LogLevel, this.LogLevel, omitDefault, this.LogLevel == Defaults.LogLevel); data.SetValue(SettingNames.Culture, this.Culture, CreateCultureInfoValue, omitDefault, Defaults.IsDefaultCulture(this.Culture)); data.SetBooleanValue(SettingNames.NoLogo, this.NoLogo, omitDefault, this.NoLogo == Defaults.NoLogo); // Credentials: Note that only persistent credentials are saved. IEnumerable <CredentialSettings> persistentCredentials = GetPersistentCredentials(); data.SetObjectArrayValue(SettingNames.Credentials, persistentCredentials, omitDefault, Defaults.IsDefaultCredentials(persistentCredentials)); // SystemSettingsSwitcher: overwrite mode, not omittable (that is, isDefault should be false) data.SetObjectValue(SettingNames.SystemSettingsSwitcher, this.SystemSettingsSwitcher, true, omitDefault, false); // Proxy: replace mode, not omittable (that is, isDefault should be false) data.SetObjectValue(SettingNames.Proxy, this.Proxy, false, omitDefault, false); // GUI: overwrite mode, not omittable (that is, isDefault should be false) data.SetObjectValue(SettingNames.GUI, this.GUI, true, omitDefault, false); return; }
public static void SetValue <T>(this IObjectData data, string name, T?value, Func <IObjectData, T, IObjectDataValue> createValue) where T : struct { // set the value data.SetValue(name, (value == null)? null: CreateValue(data, value.Value, createValue, false, false)); }