public Array ReadEncodeableArray(string fieldName, System.Type systemType)
{
if (systemType == null) throw new ArgumentNullException("systemType");
bool isNil = false;
IEncodeableCollection encodeables = new IEncodeableCollection();
if (BeginField(fieldName, true, out isNil))
{
XmlQualifiedName xmlName = EncodeableFactory.GetXmlName(systemType);
PushNamespace(xmlName.Namespace);
while (MoveToElement(xmlName.Name))
{
encodeables.Add(ReadEncodeable(xmlName.Name, systemType));
}
// check the length.
if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < encodeables.Count)
{
throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
}
PopNamespace();
EndField(fieldName);
// convert to an array of the specified type.
Array values = Array.CreateInstance(systemType, encodeables.Count);
for (int ii = 0; ii < encodeables.Count; ii++)
{
values.SetValue(encodeables[ii], ii);
}
return values;
}
if (isNil)
{
return null;
}
return Array.CreateInstance(systemType, 0);
}