/// <summary> /// Reads attributes of <paramref name="memberInfo"/> and tries to create metadata for each one. /// </summary> /// <param name="memberInfo">Reflection source.</param> /// <returns>Collection of metadata values.</returns> protected virtual MetadataCollection BuildMetadata(MemberInfo memberInfo) { MetadataCollection collection = new MetadataCollection(); foreach (Attribute attribute in memberInfo.GetCustomAttributes(true)) { IMetadataReader reader = attribute as IMetadataReader; if (reader != null) { reader.Apply(collection); } else { IAttributeMetadataReader attributeReader; if (MetadataReaderCollection.TryGet(attribute.GetType(), out attributeReader)) { attributeReader.Apply(attribute, collection); } } } return(collection); }