private static void ApplyViewModelPropertyAttribute(MemberDefinition prop, ViewModelPropertyAttribute attr) { prop.access = attr.AccessModifier; // the read only setting on an attribute is only relevant if its value is true prop.readOnly = attr.ReadOnly ? attr.ReadOnly : prop.readOnly; prop.summary = attr.Summary; }
public static ViewModelPropertyAttribute GetViewModelProperty <T>(T ViewModel, string property) { bool IsDesc = false; if (property.Contains("DESC")) { IsDesc = true; property = property.Replace("DESC", "").Trim(); } PropertyInfo pi = ViewModel.GetType().GetProperty(property); ViewModelPropertyAttribute attr = (ViewModelPropertyAttribute)System.Attribute.GetCustomAttribute(pi, typeof(ViewModelPropertyAttribute)); if (attr == null) { attr = new ViewModelPropertyAttribute(); attr.SortExpression = pi.Name; } attr.IsDesc = IsDesc; return(attr); }