private void Decrypt(CategoryPropertyItem item) { item.Encrypted = false; foreach (CategoryPropertyItem i in item.PropertyItems) { Decrypt(i); } }
//[DebuggerHidden] //[ConfigurationProperty( "LoggerCategories", IsRequired = false )] //public virtual LoggerCategories LoggerCategories //{ // get // { // return ( LoggerCategories ) this[ "LoggerCategories" ]; // } // set // { // this[ "LoggerCategories" ] = value; // } //} #endregion #region Private method(s) private void Encrypt(CategoryPropertyItem item) { item.Encrypted = true; foreach (CategoryPropertyItem i in item.PropertyItems) { Encrypt(i); } }
/// <summary> /// Parses the boolean value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="value">if set to <c>true</c> [value].</param> /// <returns> /// True, if the parse was successful, otherwise False. /// </returns> /// <example> /// <code> /// mSessionReusable = true; /// ConfigurationAccessHelper.ParseBooleanValue(pi.PropertyItems, "SessionReusable", ref mSessionReusable); /// </code> /// </example> public static bool ParseBooleanValue(CategoryPropertyItems root, String entryId, ref bool value) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root, entryId); if (pi != null) { result = bool.TryParse(pi.EntryValue, out value); } return(result); }
/// <summary> /// Parses the string value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="value">The value.</param> /// <returns> /// True, if the parse was successful, otherwise False. /// </returns> /// <example> /// <code> /// ConfigurationAccessHelper.ParseStringValue(UpdateConfiguration.Settings.CategoryPropertyItems, DOWNLOAD_FOLDER, ref mDownloadFolder); /// </code> /// </example> public static bool ParseStringValue(CategoryPropertyItems root, String entryId, ref string value) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root, entryId); if (pi != null) { value = pi.EntryValue; result = true; } return(result); }
/// <summary> /// Get configuration categoryproperty item by path like X-Path. /// </summary> /// <param name="propertyItems">Root categoryproperty where the search begins</param> /// <param name="configPath">The expression, example: Animals\Dogs\Charles</param> /// <returns> /// The value or NULL if item does not exist /// </returns> /// <example> /// <code> /// CategoryPropertyItem configItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider/NHibernateStorages/Default"); /// if (configItem != null) /// { /// DEFAULT_SESSION_FACTORY = CreateEntityManagerFactory(configItem); /// } /// </code> /// </example> /// <exception cref="System.ArgumentNullException"> /// propertyItems /// or /// configPath /// </exception> public static CategoryPropertyItem GetCategoryPropertyByPath(CategoryPropertyItems propertyItems, string configPath) { if (propertyItems == null) { throw new ArgumentNullException("propertyItems"); } if (String.IsNullOrEmpty(configPath)) { throw new ArgumentNullException("configPath"); } List <string> keys = new List <string>(configPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries)); CategoryPropertyItem result = FindCategoryPropertyByKey(propertyItems, keys); keys.Clear(); return(result); }
/// <summary> /// Parses the enum value. /// </summary> /// <typeparam name="TEnum">The type of the enum.</typeparam> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="value">The value.</param> /// <returns></returns> public static bool ParseEnumValue <TEnum>(CategoryPropertyItems root, string entryId, ref TEnum value) where TEnum : struct { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root, entryId); if (pi != null) { try { value = (TEnum)Enum.Parse(typeof(TEnum), pi.EntryValue, true); result = true; } catch (Exception) { } } return(result); }
private static CategoryPropertyItem FindCategoryPropertyByKey(CategoryPropertyItems propertyItems, List <string> keys) { CategoryPropertyItem result = null; CategoryPropertyItem item = propertyItems[keys[0]]; if (item != null) { if (item.Id.Equals(keys[0])) { if (keys.Count == 1) { result = item; } else { keys.RemoveAt(0); result = FindCategoryPropertyByKey(item.PropertyItems, keys); } } } return(result); }
/// <summary> /// Parses the float value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="minValue">The min value.</param> /// <param name="maxValue">The max value.</param> /// <param name="value">The value.</param> /// <returns> /// True, if the parse was successful, otherwise False. /// </returns> /// <exception cref="InvalidConfigurationValueException"> /// </exception> public static bool ParseFloatValue(CategoryPropertyItems root, String entryId, float minValue, float maxValue, ref float value) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root, entryId); if (pi != null) { result = float.TryParse(pi.EntryValue, out value); if (result) { if (value < minValue) { throw new InvalidConfigurationValueException(String.Format("Minimum value ({0}) is out of range ({1}) for item: {2}", minValue, result, entryId)); } if (value > maxValue) { throw new InvalidConfigurationValueException(String.Format("Maximum value ({0}) is out of range ({1}) for item: {2}", maxValue, result, entryId)); } } } return(result); }