private MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc, bool openModel, RecursionLimiter limiter)
{
MembersMapping members = new MembersMapping();
members.TypeDesc = _typeScope.GetTypeDesc(typeof(object[]));
MemberMapping[] mappings = new MemberMapping[xmlReflectionMembers.Length];
NameTable elements = new NameTable();
NameTable attributes = new NameTable();
TextAccessor textAccessor = null;
bool isSequence = false;
for (int i = 0; i < mappings.Length; i++)
{
try
{
MemberMapping mapping = ImportMemberMapping(xmlReflectionMembers[i], ns, xmlReflectionMembers, rpc, openModel, limiter);
if (!hasWrapperElement)
{
if (mapping.Attribute != null)
{
if (rpc)
{
throw new InvalidOperationException(SR.XmlRpcLitAttributeAttributes);
}
else
{
throw new InvalidOperationException(SR.Format(SR.XmlInvalidAttributeType, "XmlAttribute"));
}
}
}
if (rpc && xmlReflectionMembers[i].IsReturnValue)
{
if (i > 0) throw new InvalidOperationException(SR.XmlInvalidReturnPosition);
mapping.IsReturnValue = true;
}
mappings[i] = mapping;
isSequence |= mapping.IsSequence;
if (!xmlReflectionMembers[i].XmlAttributes.XmlIgnore)
{
// add All memeber accessors to the scope accessors
AddUniqueAccessor(mapping, elements, attributes, isSequence);
}
mappings[i] = mapping;
if (mapping.Text != null)
{
if (textAccessor != null)
{
throw new InvalidOperationException(SR.XmlIllegalMultipleTextMembers);
}
textAccessor = mapping.Text;
}
if (mapping.Xmlns != null)
{
if (members.XmlnsMember != null)
throw new InvalidOperationException(SR.XmlMultipleXmlnsMembers);
members.XmlnsMember = mapping;
}
}
catch (Exception e)
{
if (e is OutOfMemoryException)
{
throw;
}
throw CreateReflectionException(xmlReflectionMembers[i].MemberName, e);
}
}
if (isSequence)
{
throw new InvalidOperationException(SR.Format(SR.XmlSequenceMembers, "Order"));
}
members.Members = mappings;
members.HasWrapperElement = hasWrapperElement;
return members;
}