src/Microsoft/Windows/ComponentObjectModel/_Library/ComponentAttributeCollection.cs
/// <summary>
/// Gets a typed attribute from the collection.
/// </summary>
/// <typeparam name="T">The type of the attribute.</typeparam>
/// <returns>if found within the collection, The typed attribute. Otherwise, default.</returns>
Gets a typed attribute from the collection.
Gets a typed attribute from the collection .
public T Get<T>() where T : Attribute {
            if ( false == _attributes.TryGetValue( typeof( T ).FullName, out List<Attribute> list ) ) {
                return default;
            }
            if ( list.Count == 0 ) {
                return default;
            }
            if ( list.Count > 1 ) {
                throw new InvalidOperationException();
            }
            return (T)list[0];
        }
public T Get < T > ( ) where T : Attribute { if ( false == _attributes . TryGetValue ( typeof ( T ) . FullName , out List < Attribute > list ) ) { return default ; } if ( list . Count == 0 ) { return default ; } if ( list . Count > 1 ) { throw new InvalidOperationException ( ) ; } return ( T ) list [ 0 ] ; }
Gets a typed attribute from the collection.
Gets a typed attribute from the collection .
if found within the collection, The typed attribute. Otherwise, default.
if found within the collection The typed attribute . Otherwise default .
typeparam
The type of the attribute.
The type of the attribute .