public static string GetString(this INiSettings self, string key) { string value; ErrorUtil.ThrowOnFailure(self.GetSetting(key, out value)); return(value); }
public Interceptor(IServiceProvider serviceProvider, Type settingsType, string group, bool singleton) { _serviceProvider = serviceProvider; _settingsType = settingsType; _group = @group; _singleton = singleton; _settings = (INiSettings)_serviceProvider.GetService(settingsType); }
public static bool?GetBool(this INiSettings self, string key) { var value = GetInt32(self, key); if (value.HasValue) { return(value.Value != 0); } return(null); }
public static Guid?GetGuid(this INiSettings self, string key) { string value = GetString(self, key); Guid result; if ( value == null || !Guid.TryParse(value, out result) ) { return(null); } return(result); }
public static decimal?GetDecimal(this INiSettings self, string key) { string value = GetString(self, key); decimal result; if ( value == null || !decimal.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ) { return(null); } return(result); }
public static int?GetInt32(this INiSettings self, string key) { string value = GetString(self, key); int result; if ( value == null || !int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result) ) { return(null); } return(result); }
public static void SetValue(this INiSettings self, string key, int value) { SetValue(self, key, value.ToString(CultureInfo.InvariantCulture)); }
public static void SetValue(this INiSettings self, string key, string value) { ErrorUtil.ThrowOnFailure(self.SetSetting(key, value)); }
public static Color?GetColor(this INiSettings self, string key) { return(DeserializeColor(self.GetString(key))); }
public static Font GetFont(this INiSettings self, string key) { return(DeserializeFont(self.GetString(key))); }
public static bool HasValue(this INiSettings self, string key) { return(GetString(self, key) != null); }
public static void DeleteValue(this INiSettings self, string key) { SetValue(self, key, (string)null); }
public static void SetValue(this INiSettings self, string key, Color value) { SetValue(self, key, SerializeColor(value)); }
public static void SetValue(this INiSettings self, string key, Font value) { SetValue(self, key, SerializeFont(value)); }
public static void SetValue(this INiSettings self, string key, bool value) { SetValue(self, key, value ? 1 : 0); }
public static void SetValue(this INiSettings self, string key, Guid value) { SetValue(self, key, value.ToString("B").ToUpperInvariant()); }