Example #1
0
        public static List <NameValue> GetConfigItemList(string searchPartial)
        {
            var keys = ConfigurationManager.AppSettings.Keys;

            var itemList = new List <NameValue>();
            var subtitle = string.Empty;
            var keyStr   = string.Empty;
            int pos      = 0;

            foreach (var key in keys)
            {
                if (key.ToString().ToLower().Contains(searchPartial.ToLower()))
                {
                    keyStr   = key.ToString();
                    pos      = keyStr.LastIndexOf("_") + 1;
                    subtitle = keyStr.Substring(pos, keyStr.Length - pos);
                    var item = new NameValue()
                    {
                        Name  = subtitle,
                        Value = ConfigurationManager.AppSettings.Get(key.ToString())
                    };
                    if (!string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Value))
                    {
                        itemList.Add(item);
                    }
                }
            }
            return(itemList);
        }
Example #2
0
        public static List<NameValue> GetConfigItemList(string searchPartial)
        {
            var keys = ConfigurationManager.AppSettings.Keys;

            var itemList = new List<NameValue>();
            var subtitle = string.Empty;
            var keyStr = string.Empty;
            int pos = 0;
            foreach (var key in keys)
            {
                if (key.ToString().ToLower().Contains(searchPartial.ToLower()))
                {
                    keyStr = key.ToString();
                    pos = keyStr.LastIndexOf("_") + 1;
                    subtitle = keyStr.Substring(pos, keyStr.Length - pos);
                    var item = new NameValue()
                    {
                        Name = subtitle,
                        Value = ConfigurationManager.AppSettings.Get(key.ToString())
                    };
                    if (!string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Value))
                    {
                        itemList.Add(item);
                    }
                }
            }
            return itemList;
        }