/* |-------------------------------------------------------------------------------| | Copyright © Computer Ease Limited | | Address: 1/9 Bloack-A Lalmatia, Dhaka-1207, Bangladesh | | Email: info@celimited.com, cease@bol-online.com, web: www.celimited.com | | Unauthorized copy or distribution is strictly prohibited | | Author: S. M. Russel, Last modified date: 23/07/2012 | |-------------------------------------------------------------------------------| */ using System; using System.Configuration; using System.Collections.Specialized; namespace Ease.Core.Utility { #region Framework: Configuration related class /// /// Summary description for ConfigUtility. /// //public sealed class ConfigUtility //{ // /// // /// If section does not exist the return instance of NameValueCollection // /// // /// A valid name of section // /// Return the NameValueCollection object // public static NameValueCollection GetConfigSettings(string sectionName) // { // object configSection = null; //#### ConfigurationManager.GetSection(sectionName); // if (configSection == null|| !(configSection is NameValueCollection)) // return new NameValueCollection(); // return (NameValueCollection)configSection; // } // /// // /// If section does not exist return new instance of object rather than null // /// // /// A valid section in the config file // /// Return a instatnce of system.object // public static object GetConfig(string sectionName) // { // object configSection = null; //#### ConfigurationManager.GetSection(sectionName); // if (configSection == null|| !(configSection is NameValueCollection)) // return new object(); // return configSection; // } // /// // /// If key does not exist in appSettings section return empty string othewise actual value // /// // /// A valid key from the appSettings section // /// Return string if key exist in the appSettings section else empty string // public static string GetAppSettings(string keyName) // { // string configValue = null; //#### ConfigurationManager.AppSettings[keyName]; // if (string.IsNullOrEmpty(configValue)) // return string.Empty; // return configValue; // } // /// // /// Returns the a string according to specified parameter // /// // /// A valid name of section // /// A valid name of key of given section // /// Returns string if the key exist in the key else empty string // public static string GetConfigSetting(string sectionName, string key) // { // NameValueCollection configSection = ConfigUtility.GetConfigSettings(sectionName); // if (configSection == null || configSection.Count == 0 || configSection[key].Trim().Length<=0) // return string.Empty; // return configSection[key]; // } // /// // /// Set app settings // /// // /// Valid key // /// value // public static void SetAppSettings(string key, string value) // { // //#### ConfigurationManager.AppSettings.Set(key, value); // } // /// // /// Hide the constructor // /// // private ConfigUtility(){} //} #endregion }