public static bool TryGetAttributeValues <T>(IEnumerable attributes, ITypeId attributeType, string propertyName, out List <T> results) { results = new List <T>(); if (attributes != null) { foreach (object attribute in attributes) { if (!PlatformNeutralAttributeHelper.IsAssignableFrom(attributeType, attribute)) { continue; } results.Add(PlatformNeutralAttributeHelper.GetValue <T>(attribute, propertyName)); } } return(results.Count > 0); }
public static bool TryGetAttributeValue <T>(IEnumerable attributes, ITypeId attributeType, string propertyName, out T result) { bool flag; if (attributes != null) { IEnumerator enumerator = attributes.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; if (!PlatformNeutralAttributeHelper.IsAssignableFrom(attributeType, current)) { continue; } result = PlatformNeutralAttributeHelper.GetValue <T>(current, propertyName); flag = true; return(flag); } result = default(T); return(false); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } return(flag); } result = default(T); return(false); }