//============================================================================================================================== // 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()); }
public static T UnprojectAndInstantiate <T>(this CustomAttributeData cad) where T : Attribute { CustomAttributeData runtimeCad = cad.ProjectBackToRuntime(); return(runtimeCad.Instantiate <T>()); }