src/Microsoft/Windows/ComponentObjectModel/_Library/ComponentAttributeCollection.cs
/// <summary>
/// Tries to get a typed attribute from this collection.
/// </summary>
/// <typeparam name="T">The type of the attribute.</typeparam>
/// <param name="attribute">[Out] parameter, containing the attribute, or null, when not found in the collection.</param>
/// <returns>true, if the attribute was found. Otherwise, false.</returns>
Tries to get a typed attribute from this collection.
Tries to get a typed attribute from this collection .
public bool TryGet<T>( out T attribute ) where T : Attribute {
            if ( false == _attributes.TryGetValue( typeof( T ).FullName, out List<Attribute> list ) ) {
                attribute = default;
                return false;
            }
            if ( list.Count == 0 ) {
                attribute = default;
                return false;
            }
            if ( list.Count > 1 ) {
                throw new InvalidOperationException();
            }
            attribute = (T)list[0];
            return true;
        }
public bool TryGet < T > ( out T attribute ) where T : Attribute { if ( false == _attributes . TryGetValue ( typeof ( T ) . FullName , out List < Attribute > list ) ) { attribute = default ; return false ; } if ( list . Count == 0 ) { attribute = default ; return false ; } if ( list . Count > 1 ) { throw new InvalidOperationException ( ) ; } attribute = ( T ) list [ 0 ] ; return true ; }
Tries to get a typed attribute from this collection.
Tries to get a typed attribute from this collection .
true, if the attribute was found. Otherwise, false.
true if the attribute was found . Otherwise false .
T
out
attribute
[Out] parameter, containing the attribute, or null, when not found in the collection.
[ Out ] parameter containing the attribute or null when not found in the collection .
typeparam
The type of the attribute.
The type of the attribute .