Пример #1
0
        //==============================================================================================================================
        // Helper for the GetCustomAttribute() family.
        //==============================================================================================================================
        private static Attribute OneOrNull(IEnumerable <CustomAttributeData> results)
        {
            IEnumerator <CustomAttributeData> enumerator = results.GetEnumerator();

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

            if (enumerator.MoveNext())
            {
                throw new AmbiguousMatchException();
            }
            return(result.Instantiate());
        }
Пример #2
0
        public static T UnprojectAndInstantiate <T>(this CustomAttributeData cad) where T : Attribute
        {
            CustomAttributeData runtimeCad = cad.ProjectBackToRuntime();

            return(runtimeCad.Instantiate <T>());
        }