Exemple #1
0
 /// <summary>
 /// Gets the attributes on the entity.
 /// </summary>
 /// <param name="entity">The entity on which the attributes are declared.</param>
 /// <param name="inherit">
 /// Specifies whether attributes inherited from base classes and base members
 /// (if the given <paramref name="entity"/> in an <c>override</c>)
 /// should be returned.
 /// </param>
 /// <returns>
 /// Returns the list of attributes that were found.
 /// If inherit is true, attributes from the entity itself are returned first;
 /// followed by attributes inherited from the base entity.
 /// </returns>
 public static IEnumerable <IAttribute> GetAttributes(this IEntity entity, bool inherit)
 {
     if (inherit)
     {
         if (entity is ITypeDefinition td)
         {
             return(InheritanceHelper.GetAttributes(td));
         }
         else if (entity is IMember m)
         {
             return(InheritanceHelper.GetAttributes(m));
         }
         else
         {
             throw new NotSupportedException("Unknown entity type");
         }
     }
     else
     {
         return(entity.GetAttributes());
     }
 }