mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
added schema generation
This commit is contained in:
parent
e8c832ac18
commit
a66d43b806
11 changed files with 150 additions and 15 deletions
|
@ -45,5 +45,16 @@ namespace NzbDrone.Common.Reflection
|
|||
return propertyInfo.CanWrite && propertyInfo.GetSetMethod(false) != null;
|
||||
}
|
||||
|
||||
public static T GetAttribute<T>(this MemberInfo member, bool isRequired = true) where T : Attribute
|
||||
{
|
||||
var attribute = member.GetCustomAttributes(typeof(T), false).SingleOrDefault();
|
||||
|
||||
if (attribute == null && isRequired)
|
||||
{
|
||||
throw new ArgumentException(String.Format("The {0} attribute must be defined on member {1}", typeof(T).Name, member.Name));
|
||||
}
|
||||
|
||||
return (T)attribute;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue