Пример #1
0
        public string DeleteResources(ResourcesHelper item)
        {
            string msg = "";

            try
            {
                //read existing resource
                ReadResource();
                //Modify resources here...
                if (_resourceEn.ContainsKey(item.Key))
                {
                    _resourceEn.Remove(item.Key);
                    _resourceNe.Remove(item.Key);
                }
                //update resource file
                UpdateResourceFile();
                msg = "SuccessfullyDeleted";
            }
            catch (Exception ex)
            {
                msg = "ExceptionError";
            }
            return(msg);
        }
Пример #2
0
        public List <ResourcesHelper> SearchList(string searchKey, string searchBy)
        {
            List <ResourcesHelper> lst = new List <ResourcesHelper>();

            if (Directory.Exists(_path))
            {
                return(null);
            }
            //       _readerEn = new ResXResourceReader(@"E:\Project\NCOC\Maple.Resources\Resource.resx");

            //    _resourceEn = new Hashtable();
            ReadResource();
            List <DictionaryEntry> lst1 = _resourceEn.OfType <DictionaryEntry>().Where(x => x.Key.ToString().ToLower().Contains(searchKey.ToLower())).OrderBy(x => x.Key).ToList();
            List <DictionaryEntry> lst2 = _resourceNe.OfType <DictionaryEntry>().Where(x => x.Key.ToString().ToLower().Contains(searchKey.ToLower())).OrderBy(x => x.Key).ToList();
            List <ResourcesHelper> res  = new List <ResourcesHelper>();
            ResourcesHelper        helper;

            // int i = 0;
            foreach (var item in lst1)
            {
                helper         = new ResourcesHelper();
                helper.English = item.Value.ToString();
                helper.Key     = item.Key.ToString();
                res.Add(helper);
            }
            foreach (var item in lst2)
            {
                var resource = res.Find(x => x.Key.ToLower() == item.Key.ToString().ToLower());
                if (resource == null)
                {
                    helper        = new ResourcesHelper();
                    helper.Key    = item.Key.ToString();
                    helper.Nepali = item.Value.ToString();
                    res.Add(helper);
                }
                else
                {
                    res.Find(x => x.Key.ToLower() == item.Key.ToString().ToLower()).Nepali = item.Value.ToString();
                }
            }
            //if (_readerEn != null)
            //{
            //    foreach (DictionaryEntry d in _readerEn)
            //    {

            //        string key = d.Key.ToString();
            //        string english = d.Value.ToString();
            //        string nepali = GetNepaliValue(key);
            //        switch (searchBy)
            //        {
            //            case ("Key"):
            //                if (key == searchKey)
            //                {
            //                    res.Key = key;
            //                    res.English = english;
            //                    res.Nepali = nepali;
            //                    lst.Add(res);
            //                }
            //                break;
            //            case ("English"):
            //                if (english == searchKey)
            //                {
            //                    res.Key = key;
            //                    res.English = english;
            //                    res.Nepali = nepali;
            //                    lst.Add(res);
            //                }
            //                break;
            //            default:
            //                lst = null;
            //                break;
            //        }
            //    }
            //    _readerEn.Close();
            //}

            return(res);
        }