mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
added schema generation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user