private SpecialMapping ImportAnyMapping(XmlSchemaType type, string identifier, string ns, bool repeats)
{
if (type == null) return null;
if (!type.DerivedFrom.IsEmpty) return null;
bool mixed = IsMixed(type);
TypeItems items = GetTypeItems(type);
if (items.Particle == null) return null;
if (!(items.Particle is XmlSchemaAll || items.Particle is XmlSchemaSequence)) return null;
if (items.Attributes != null && items.Attributes.Count > 0) return null;
XmlSchemaGroupBase group = (XmlSchemaGroupBase)items.Particle;
if (group.Items.Count != 1 || !(group.Items[0] is XmlSchemaAny)) return null;
XmlSchemaAny any = (XmlSchemaAny)group.Items[0];
SpecialMapping mapping = new SpecialMapping();
// check for special named any case
if (items.AnyAttribute != null && any.IsMultipleOccurrence && mixed)
{
mapping.NamedAny = true;
mapping.TypeDesc = Scope.GetTypeDesc(typeof(XmlElement));
}
else if (items.AnyAttribute != null || any.IsMultipleOccurrence)
{
// these only work for named any case -- otherwise import as struct
return null;
}
else
{
mapping.TypeDesc = Scope.GetTypeDesc(mixed ? typeof(XmlNode) : typeof(XmlElement));
}
TypeFlags flags = TypeFlags.CanBeElementValue;
if (items.AnyAttribute != null || mixed)
flags |= TypeFlags.CanBeTextValue;
// let the extensions to run
RunSchemaExtensions(mapping, XmlQualifiedName.Empty, null, any, flags);
mapping.TypeName = mapping.TypeDesc.Name;
if (repeats)
mapping.TypeDesc = mapping.TypeDesc.CreateArrayTypeDesc();
return mapping;
}