private TypeMapping GetTypeMapping(string typeName, string ns, TypeDesc typeDesc, NameTable typeLib, Type type)
{
TypeMapping mapping;
if (typeName == null || typeName.Length == 0)
mapping = type == null ? null : (TypeMapping)_anonymous[type];
else
mapping = (TypeMapping)typeLib[typeName, ns];
if (mapping == null) return null;
if (!mapping.IsAnonymousType && mapping.TypeDesc != typeDesc)
throw new InvalidOperationException(SR.Format(SR.XmlTypesDuplicate, typeDesc.FullName, mapping.TypeDesc.FullName, typeName, ns));
return mapping;
}