예제 #1
0
        /// <summary>
        /// Vrati iso kod pre pozadovany typ jazyka
        /// </summary>
        /// <param name="type">LanguageTypes</param>
        /// <returns>Iso code alebo null</returns>
        public static String GetIsoCodeFromValue(LanguageTypes type)
        {
            FieldInfo fieldInfo = type.GetType().GetField(type.ToString());

            LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
            if (attributes != null && attributes.Length > 0)
            {
                foreach (LanguageAttribute attribute in attributes)
                {
                    return(attribute.IsoCode);
                }
            }
            return(String.Empty);
        }
예제 #2
0
        /// <summary>
        /// Vrati aktualnu kulturu requestu
        /// </summary>
        /// <param name="language">Jazyk ktoreho kulturu chceme ziskat</param>
        /// <returns>Kultura alebo null</returns>
        private CultureInfo InternalGetCurrentCulture(LanguageTypes language)
        {
            FieldInfo fieldInfo = language.GetType().GetField(language.ToString());

            LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
            if (attributes != null && attributes.Length > 0)
            {
                foreach (LanguageAttribute attribute in attributes)
                {
                    if (!String.IsNullOrWhiteSpace(attribute.Culture))
                    {
                        return(new CultureInfo(attribute.Culture));
                    }
                }
            }
            return(null);
        }
예제 #3
0
 /// <summary>
 /// Vrati iso kod pre pozadovany typ jazyka
 /// </summary>
 /// <param name="type">LanguageTypes</param>
 /// <returns>Iso code alebo null</returns>
 public static String GetIsoCodeFromValue(LanguageTypes type)
 {
     FieldInfo fieldInfo = type.GetType().GetField(type.ToString());
     LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
     if (attributes != null && attributes.Length > 0)
     {
         foreach (LanguageAttribute attribute in attributes)
         {
             return attribute.IsoCode;
         }
     }
     return String.Empty;
 }
 /// <summary>
 /// Vrati aktualnu kulturu requestu
 /// </summary>
 /// <param name="language">Jazyk ktoreho kulturu chceme ziskat</param>
 /// <returns>Kultura alebo null</returns>
 private CultureInfo InternalGetCurrentCulture(LanguageTypes language)
 {
     FieldInfo fieldInfo = language.GetType().GetField(language.ToString());
     LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
     if (attributes != null && attributes.Length > 0)
     {
         foreach (LanguageAttribute attribute in attributes)
         {
             if (!String.IsNullOrWhiteSpace(attribute.Culture))
             {
                 return new CultureInfo(attribute.Culture);
             }
         }
     }
     return null;
 }