private void Scan(SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
{
XmlSerializationAttribute[] attribs;
var attributes = new List<Attribute>();
// Get the ElementType attributes specified on the type itself as long
// as we're not the type itself!
if (memberInfo.MemberInfo != memberInfo.ReturnType)
{
var smi = new SerializationMemberInfo(memberInfo.ReturnType, options, cache);
attribs = smi.GetApplicableAttributes(typeof(XmlDictionaryElementTypeAttribute));
foreach (XmlSerializationAttribute a in attribs)
{
attributes.Add(a);
}
}
// Get the ElementType attributes specified on the member.
attribs = memberInfo.GetApplicableAttributes(typeof(XmlDictionaryElementTypeAttribute));
foreach (var a in attribs)
{
attributes.Add(a);
}
foreach (XmlDictionaryElementTypeAttribute attribute in attributes)
{
var dictionaryItem = new DictionaryItem();
var smi2 = new SerializationMemberInfo(attribute.ElementType, options, cache);
if (attribute.TypeAlias == null)
{
attribute.TypeAlias = smi2.SerializedName;
}
dictionaryItem.attribute = attribute;
dictionaryItem.typeAlias = attribute.TypeAlias;
// Check if a specific type of serializer is specified.
if (attribute.SerializerType == null)
{
// Figure out the serializer based on the type of the element.
dictionaryItem.serializer = cache.GetTypeSerializerBySupportedType(attribute.ElementType, smi2);
}
else
{
// Get the type of serializer they specify.
dictionaryItem.serializer = cache.GetTypeSerializerBySerializerType(attribute.SerializerType, smi2);
}
primaryDictionaryItem = dictionaryItem;
typeToItemMap[attribute.ElementType] = dictionaryItem;
aliasToItemMap[attribute.TypeAlias] = dictionaryItem;
}
if (aliasToItemMap.Count != 1)
{
primaryDictionaryItem = null;
}
}