/// <summary> /// Get Name /// </summary> public string GetName() { if (!string.IsNullOrEmpty(this.Name) && !string.IsNullOrWhiteSpace(this.Name)) { if (this.ResourceType != null) { var resourceManager = ResourceManagers.GetResourceManager(this.ResourceType); string value = resourceManager.GetString(this.Name); return(value ?? string.Empty); } else { return(this.Name); } } return(string.Empty); }
public static void CheckDisplayAttributes(Type model) { var properties = model.GetProperties().Where(prop => prop.IsDefined(typeof(DisplayAttribute), false)); var log = string.Empty; foreach (var item in properties) { DisplayAttribute[] attributes = (DisplayAttribute[])item.GetCustomAttributes(typeof(DisplayAttribute), false); if (null != attributes[0].ResourceType) { var resourceManager = ResourceManagers.GetResourceManager(attributes[0].ResourceType); string value = resourceManager.GetString(attributes[0].Name); if (string.IsNullOrEmpty(value)) { throw new Exception("Could not find Display Name for: " + attributes[0].ResourceType.Name + "." + item.Name); } } } }