Exemplo n.º 1
0
        public static string GetExtName(this Enum e)
        {
            GlobalCodeAttribute globalCodeAttribute = EnumExtensions.GetGlobalCodeAttribute(e);

            if (globalCodeAttribute != null)
            {
                return(globalCodeAttribute.ExtName);
            }
            return(string.Empty);
        }
Exemplo n.º 2
0
        public static SiteSettings DecrySettings(SiteSettings settings)
        {
            PropertyInfo[] properties = settings.GetType().GetProperties();
            Type           type       = settings.GetType();

            PropertyInfo[] array = properties;
            foreach (PropertyInfo propertyInfo in array)
            {
                MethodInfo getMethod = propertyInfo.GetGetMethod();
                if (getMethod != (MethodInfo)null && getMethod.IsPublic && propertyInfo.CanWrite)
                {
                    object[] customAttributes = propertyInfo.GetCustomAttributes(false);
                    if (customAttributes != null && customAttributes.Length != 0)
                    {
                        for (int j = 0; j < customAttributes.Length; j++)
                        {
                            if (customAttributes[j].GetType() == typeof(GlobalCodeAttribute))
                            {
                                GlobalCodeAttribute globalCodeAttribute = (GlobalCodeAttribute)customAttributes[j];
                                if (globalCodeAttribute != null && propertyInfo.PropertyType == typeof(string))
                                {
                                    if (globalCodeAttribute.IsEncryption)
                                    {
                                        propertyInfo.SetValue(settings, HiCryptographer.TryDecypt(getMethod.Invoke(settings, new object[0]).ToNullString()), null);
                                    }
                                    else if (globalCodeAttribute.IsHtmlCode)
                                    {
                                        propertyInfo.SetValue(settings, Globals.HtmlDecode(getMethod.Invoke(settings, new object[0]).ToNullString()), null);
                                    }
                                    else if (globalCodeAttribute.IsUrlEncode)
                                    {
                                        propertyInfo.SetValue(settings, Globals.UrlDecode(getMethod.Invoke(settings, new object[0]).ToNullString()), null);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        propertyInfo.SetValue(settings, getMethod.Invoke(settings, new object[0]), null);
                    }
                }
            }
            return(settings);
        }
Exemplo n.º 3
0
        public static string GetGlobalCode(this Enum e)
        {
            GlobalCodeAttribute globalCodeAttribute = EnumExtensions.GetGlobalCodeAttribute(e);

            return((globalCodeAttribute != null) ? globalCodeAttribute.Description : e.ToString());
        }