Exemple #1
0
        //==============================================================================================================================
        // Helper for the GetCustomAttribute() family.
        //==============================================================================================================================
        private static T OneOrNull <T> (this IEnumerable <CustomAttributeData> results) where T : Attribute
        {
            IEnumerator <CustomAttributeData> enumerator = results.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                return(null);
            }
            CustomAttributeData result = enumerator.Current;

            if (enumerator.MoveNext())
            {
                throw new AmbiguousMatchException("", null);
            }
            return((T)(result.Instantiate()));
        }