예제 #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
파일: TestUtils.cs 프로젝트: zouql/runtime
        public static T UnprojectAndInstantiate <T>(this CustomAttributeData cad) where T : Attribute
        {
            CustomAttributeData runtimeCad = cad.ProjectBackToRuntime();

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