private IList <System.Reflection.PropertyInfo> GetGetPropertiesByAttrSkipFiliter(Type type) { var props = TypePropertiesCacheHelper.GetTypePropertiesCache(type); _customAttributes = CustomAttributeHelper.GetCustomAttributes(type); if (_customAttributes.FirstOrDefault() != null) { _customAttributes = _customAttributes.Where(attr => attr.Skip == false); var notSkipAttrsName = _customAttributes.Select(attr => attr.memberInfo.Name); props = props.Where(prop => notSkipAttrsName.Contains(prop.Name)).ToArray(); } return(props); }
public static IEnumerable <TableColumnAttribute> GetCustomAttributes(System.Type type) { var props = TypePropertiesCacheHelper.GetTypePropertiesCache(type); foreach (var prop in props) { var data = GetCustomAttribute(prop); if (data != null) { data.memberInfo = prop; } yield return(data); } }
private static Dictionary <string, string> AttributeToHtml <T>(T tableAttributes) { if (tableAttributes == null) { return(null); } var type = tableAttributes.GetType(); var dic = TypePropertiesCacheHelper.GetTypePropertiesCache(type) //.Select(prop => new { Key = prop.Name, Value = TypePropertiesCacheHelper.GetValueFromExpressionCache(type, prop, tableAttributes).ToString() }) #if !NET40 .Select(prop => new { Key = prop.Name, Value = prop.GetValue(tableAttributes).ToString() }) #endif #if NET40 .Select(prop => new { Key = prop.Name, Value = prop.GetValue(tableAttributes, null).ToString() }) #endif .ToDictionary(key => key.Key, value => value.Value); return(dic); }