Ejemplo n.º 1
0
        /// <summary>
        /// This method is used for get the label information from resource file according to navigation id.
        /// </summary>
        /// <param name="navigationId"></param>
        /// <returns></returns>
        public List <ResourceKeyValueModel> GetLabelInfoValues(int navigationId)
        {
            try
            {
                List <ResourceKeyValueModel>     arrayList = new List <ResourceKeyValueModel>();
                ResourceKeyValueModel            objResourceKeyValueModel = new ResourceKeyValueModel();
                System.Resources.ResourceManager rm = new System.Resources.ResourceManager("GEE_Web.Resource", this.GetType().Assembly);

                var entry =
                    rm.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentCulture, true, true)
                    .OfType <DictionaryEntry>();


                var abc = entry.Where(a => a.Key.ToString().Contains(navigationId.ToString())).ToList();
                foreach (var item in abc)
                {
                    if (item.Key.ToString().ToLower().Contains("lbl"))
                    {
                        objResourceKeyValueModel.Key   = item.Key.ToString();
                        objResourceKeyValueModel.Value = item.Value.ToString();
                        arrayList.Add(objResourceKeyValueModel);
                    }
                }
                return(arrayList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        //public static List<T> ConvertDataTable<T>(DataTable dt)
        //{
        //    List<T> data = new List<T>();
        //    foreach (DataRow row in dt.Rows)
        //    {
        //        T item = GetItem<T>(row);
        //        data.Add(item);
        //    }
        //    return data;
        //}
        //public static T GetItem<T>(DataRow dr)
        //{
        //    Type temp = typeof(T);
        //    T obj = Activator.CreateInstance<T>();

        //    foreach (DataColumn column in dr.Table.Columns)
        //    {
        //        foreach (PropertyInfo pro in temp.GetProperties())
        //        {
        //            if (pro.Name.ToLower() == column.ColumnName.ToLower())
        //                pro.SetValue(obj, dr[column.ColumnName], null);
        //            else
        //                continue;
        //        }
        //    }
        //    return obj;
        //}

        /// <summary>
        /// This method is used to get value from rex file based on Key
        /// Added by Jiya
        /// Addded when 09-April-2018
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string  GetKeyValueFromResx(string keys)
        {
            try
            {
                string    keyValue = string.Empty;
                string [] splkeys  = keys.Split(',');
                List <ResourceKeyValueModel>     arrayList = new List <ResourceKeyValueModel>();
                ResourceKeyValueModel            objResourceKeyValueModel = new ResourceKeyValueModel();
                System.Resources.ResourceManager rm = new System.Resources.ResourceManager("GEE_Web.Resource", this.GetType().Assembly);

                var entry =
                    rm.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentCulture, true, true)
                    .OfType <DictionaryEntry>();

                for (int i = 0; i < splkeys.Length; i++)
                {
                    var value = entry.Where(a => a.Key.ToString() == splkeys[i].ToString()).FirstOrDefault();
                    if (value.Value != null)
                    {
                        keyValue += value.Value.ToString() + ",";
                    }
                    else
                    {
                        keyValue += splkeys[i].ToString() + ",";
                    }
                }

                return(keyValue.Remove(keyValue.Length - 1));
            }
            catch (Exception ex)
            {
                throw;
            }
        }