private bool WriteEnumAndArrayTypes(StructMapping structMapping, object o, string n, string ns, XmlMapping parentMapping)
{
if (o is Enum)
{
Writer.WriteStartElement(n, ns);
EnumMapping enumMapping = null;
Type enumType = o.GetType();
foreach (var m in parentMapping.Scope.TypeMappings)
{
var em = m as EnumMapping;
if (em != null && em.TypeDesc.Type == enumType)
{
enumMapping = em;
break;
}
}
Debug.Assert(enumMapping != null);
WriteXsiType(enumMapping.TypeName, ns);
Writer.WriteString(WriteEnumMethod(enumMapping, o));
Writer.WriteEndElement();
return true;
}
if (o is Array)
{
Debug.Assert(parentMapping != null);
Writer.WriteStartElement(n, ns);
ArrayMapping arrayMapping = null;
Type arrayType = o.GetType();
foreach (var m in parentMapping.Scope.TypeMappings)
{
var am = m as ArrayMapping;
if (am != null && am.TypeDesc.Type == arrayType)
{
arrayMapping = am;
break;
}
}
Debug.Assert(arrayMapping != null);
WriteXsiType(arrayMapping.TypeName, ns);
WriteMember(o, null, arrayMapping.ElementsSortedByDerivation, null, null, arrayMapping.TypeDesc, true);
Writer.WriteEndElement();
return true;
}
return false;
}