private void CheckAmbiguousChoice(XmlAttributes a, Type accessorType, string accessorName)
{
Hashtable choiceTypes = new Hashtable();
XmlElementAttributes elements = a.XmlElements;
if (elements != null && elements.Count >= 2 && a.XmlChoiceIdentifier == null)
{
for (int i = 0; i < elements.Count; i++)
{
Type type = elements[i].Type == null ? accessorType : elements[i].Type;
if (choiceTypes.Contains(type))
{
// You need to add {0} to the '{1}'.
throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdentiferMissing, typeof(XmlChoiceIdentifierAttribute).Name, accessorName));
}
else
{
choiceTypes.Add(type, false);
}
}
}
if (choiceTypes.Contains(typeof(XmlElement)) && a.XmlAnyElements.Count > 0)
{
// You need to add {0} to the '{1}'.
throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdentiferMissing, typeof(XmlChoiceIdentifierAttribute).Name, accessorName));
}
XmlArrayItemAttributes items = a.XmlArrayItems;
if (items != null && items.Count >= 2)
{
NameTable arrayTypes = new NameTable();
for (int i = 0; i < items.Count; i++)
{
Type type = items[i].Type == null ? accessorType : items[i].Type;
string ns = items[i].NestingLevel.ToString(CultureInfo.InvariantCulture);
XmlArrayItemAttribute item = (XmlArrayItemAttribute)arrayTypes[type.FullName, ns];
if (item != null)
{
throw new InvalidOperationException(SR.Format(SR.XmlArrayItemAmbiguousTypes, accessorName, item.ElementName, items[i].ElementName, typeof(XmlElementAttribute).Name, typeof(XmlChoiceIdentifierAttribute).Name, accessorName));
}
else
{
arrayTypes[type.FullName, ns] = items[i];
}
}
}
}