public static string GetExtName(this Enum e) { GlobalCodeAttribute globalCodeAttribute = EnumExtensions.GetGlobalCodeAttribute(e); if (globalCodeAttribute != null) { return(globalCodeAttribute.ExtName); } return(string.Empty); }
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); }
public static string GetGlobalCode(this Enum e) { GlobalCodeAttribute globalCodeAttribute = EnumExtensions.GetGlobalCodeAttribute(e); return((globalCodeAttribute != null) ? globalCodeAttribute.Description : e.ToString()); }