public static DescriptionAttribute GetDescription(Type attributeType, DescriptionObjectType objectType, string name, bool inherit) { MemberInfo memberInfo = null; object[] array = null; Type typeFromHandle = typeof(DescriptionAttribute); switch (objectType) { case DescriptionObjectType.Event: memberInfo = attributeType.GetEvent(name); break; case DescriptionObjectType.Field: memberInfo = attributeType.GetField(name); break; case DescriptionObjectType.Method: memberInfo = attributeType.GetMethod(name); break; case DescriptionObjectType.Property: memberInfo = attributeType.GetProperty(name); break; } array = ((DescriptionObjectType.Type != objectType) ? memberInfo.GetCustomAttributes(typeFromHandle, inherit) : attributeType.GetCustomAttributes(typeFromHandle, inherit)); if (array != null && array.Length > 0) { return((DescriptionAttribute)array[0]); } return(null); }
public static DescriptionAttribute GetDescription(Type attributeType, DescriptionObjectType objectType, string name) { return(GetDescription(attributeType, objectType, name, inherit: false)); }