1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-21 22:05:43 -04:00

added schema generation

This commit is contained in:
kay.one
2013-04-30 23:43:14 -07:00
committed by Keivan Beigi
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;
}
}
}