sdk/dotnet/src/Microsoft.Datasync.Client/Utils/StdLibExtensions.cs
/// <summary>
/// Determines if the type has an attribute on it.  If it does, then return
/// the first attribute.
/// </summary>
/// <typeparam name="T">The type of the attribute to check for.</typeparam>
/// <param name="type">The subject type.</param>
/// <param name="attr">On return, the first attribute that is set on the subject type.</param>
/// <returns><c>true</c> if the subject type has an attribute of type <typeparamref name="T"/>, <c>false</c> otherwise.</returns>
Determines if the type has an attribute on it.  If it does, then return
the first attribute.
Determines if the type has an attribute on it . If it does then return the first attribute .
internal static bool HasAttribute<T>(this Type type, out T attr)
        {
            if (type.GetTypeInfo().GetCustomAttributes(typeof(T), true).FirstOrDefault() is T requiredAttr)
            {
                attr = requiredAttr;
                return true;
            }
            attr = default;
            return false;
        }
internal static bool HasAttribute < T > ( this Type type , out T attr ) { if ( type . GetTypeInfo ( ) . GetCustomAttributes ( typeof ( T ) , true ) . FirstOrDefault ( ) is T requiredAttr ) { attr = requiredAttr ; return true ; } attr = default ; return false ; }
Determines if the type has an attribute on it.
Determines if the type has an attribute on it .
None
Type
this
T
out
type
The subject type.
The subject type .
attr
On return, the first attribute that is set on the subject type.
On return the first attribute that is set on the subject type .
typeparam
The type of the attribute to check for.
The type of the attribute to check for .