static internal T GetRequiredSingleAttribute <T>(CustomAttributeProvider attrProvider, Type[] attrTypeGroup) where T : class { T result = GetSingleAttribute <T>(attrProvider, attrTypeGroup); if (result == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.couldnTFindRequiredAttributeOfTypeOn2, typeof(T), attrProvider.ToString()))); } return(result); }
static internal T GetSingleAttribute <T>(CustomAttributeProvider attrProvider) where T : class { Type attrType = typeof(T); object[] attrs = GetCustomAttributes(attrProvider, attrType); if (attrs == null || attrs.Length == 0) { return(null); } else if (attrs.Length > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.tooManyAttributesOfTypeOn2, attrType, attrProvider.ToString()))); } else { return(attrs[0] as T); } }