public XmlSchemaType WriteArrayType (Type type, MemberInfo member)
{
if (generatedSchemaTypes.Contains (type.FullName)) // Caching
return null;
XmlSchemaComplexType complexType = new XmlSchemaComplexType ();
XmlQualifiedName qname = GetQualifiedName (type);
if (qname == null)
complexType.Name = type.Name;
else
complexType.Name = qname.Name;
XmlSchemaSequence sequence = new XmlSchemaSequence ();
XmlSchemaElement element = new XmlSchemaElement ();
element.MinOccurs = 0;
element.MaxOccursString = "unbounded";
element.IsNillable = true;
element.Name = qname.Name.ToLower ();
object [] attrs = member.GetCustomAttributes (false);
if (attrs.Length > 0) {
foreach (object o in attrs) {
if (o is XmlArrayItemAttribute) {
if (type.IsArray == false)
throw new ArgumentException (
String.Format ("XmlArrayAttribute is not applicable to {0}, because it is not an array.",
member.Name));
XmlArrayItemAttribute attr = (XmlArrayItemAttribute) o;
if (attr.ElementName.Length != 0)
element.Name = attr.ElementName;
continue;
}
if (o is XmlAnyElementAttribute)
return null;
}
}
element.SchemaTypeName = GetQualifiedName (
type.FullName.Substring (0, type.FullName.Length - 2));
sequence.Items.Add (element);
complexType.Particle = sequence;
generatedSchemaTypes.Add (type.FullName, complexType);
return complexType;
}