/// <summary>
 /// Gets and initialises a code-first attribute applied to a member. The member must be a type or property.
 /// </summary>
 /// <typeparam name="T">The type of <see cref="CodeFirstAttribute"/> to get</typeparam>
 /// <param name="type">The type to get the attribute from</param>
 /// <param name="initialise">True to initialse the attribute if it is a IInitialisableAttribute</param>
 /// <returns></returns>
 public static T GetCodeFirstAttribute <T>(this MemberInfo member, bool initialise = true) where T : CodeFirstAttribute
 {
     if (member is Type)
     {
         return(CodeFirstAttributeCache.Get <T>(member as Type, initialise));
     }
     else if (member is PropertyInfo)
     {
         return(CodeFirstAttributeCache.Get <T>(member as PropertyInfo, initialise));
     }
     else
     {
         throw new AttributeInitialisationException("Code-first attributes only support Type and Property member types, and cannot be applied to or retrieved from " + member.MemberType.ToString());
     }
 }
 /// <summary>
 /// Gets a collection of attributes of type T if any are applied to the given property
 /// </summary>
 /// <param name="info">The property to inspect</param>
 /// <param name="initialise">True to initialise the attribute if it is initialisable</param>
 /// <returns>The attributes, or an empty collection if none is found</returns>
 internal static IEnumerable <T> GetCodeFirstAttributesWithInheritance <T>(this PropertyInfo info, bool initialise = true) where T : MultipleCodeFirstAttribute
 {
     return(CodeFirstAttributeCache.GetManyWithInheritance <T>(info, initialise));
 }
 /// <summary>
 /// Gets a collection of attributes of type T if any are applied to the given property
 /// </summary>
 /// <param name="info">The property to inspect</param>
 /// <param name="initialise">True to initialise the attribute if it is initialisable</param>
 /// <returns>The attributes, or an empty collection if none is found</returns>
 public static IEnumerable <T> GetCodeFirstAttributes <T>(this PropertyInfo info, bool initialise = true) where T : MultipleCodeFirstAttribute
 {
     return(CodeFirstAttributeCache.GetMany <T>(info, initialise));
 }
 /// <summary>
 /// Gets an attribute of type T if one is applied to the given property
 /// </summary>
 /// <param name="info">The property to inspect</param>
 /// <param name="initialise">True to initialise the attribute if it is initialisable</param>
 /// <returns>The attribute, or null if none is found</returns>
 public static T GetCodeFirstAttribute <T>(this PropertyInfo info, bool initialise = true) where T : CodeFirstAttribute
 {
     return(CodeFirstAttributeCache.Get <T>(info, initialise));
 }
 /// <summary>
 /// Gets attributes of type T if any are applied to the given type
 /// </summary>
 /// <param name="type">The type to inspect</param>
 /// <param name="initialise">True to initialise the attribute if it is initialisable</param>
 /// <returns>The attribute, or null if none is found</returns>
 public static IEnumerable <T> GetCodeFirstAttributes <T>(this Type type, bool initialise = true) where T : MultipleCodeFirstAttribute
 {
     return(CodeFirstAttributeCache.GetMany <T>(type, initialise));
 }
 /// <summary>
 /// Gets and initialises a code-first attribute applied to a type
 /// </summary>
 /// <typeparam name="T">The type of <see cref="CodeFirstAttribute"/> to get</typeparam>
 /// <param name="type">The type to get the attribute from</param>
 /// <param name="initialise">True to initialse the attribute if it is a IInitialisableAttribute</param>
 /// <returns></returns>
 public static T GetCodeFirstAttribute <T>(this Type type, bool initialise = true) where T : CodeFirstAttribute
 {
     return(CodeFirstAttributeCache.Get <T>(type, initialise));
 }