public TypeData (Type type, string elementName, bool isPrimitive, TypeData mappedType, XmlSchemaPatternFacet facet)
{
#if NET_2_0
if (type.IsGenericTypeDefinition)
throw new InvalidOperationException ("Generic type definition cannot be used in serialization. Only specific generic types can be used.");
#endif
this.mappedType = mappedType;
this.facet = facet;
this.type = type;
this.typeName = type.Name;
this.fullTypeName = type.FullName.Replace ('+', '.');
if (isPrimitive)
sType = SchemaTypes.Primitive;
else
{
if (type.IsEnum)
sType = SchemaTypes.Enum;
else if (typeof(IXmlSerializable).IsAssignableFrom (type))
sType = SchemaTypes.XmlSerializable;
else if (typeof (System.Xml.XmlNode).IsAssignableFrom (type))
sType = SchemaTypes.XmlNode;
else if (type.IsArray || typeof(IEnumerable).IsAssignableFrom (type))
sType = SchemaTypes.Array;
else
sType = SchemaTypes.Class;
}
if (IsListType)
this.elementName = TypeTranslator.GetArrayName (ListItemTypeData.XmlType);
else
this.elementName = elementName;
if (sType == SchemaTypes.Array || sType == SchemaTypes.Class) {
hasPublicConstructor = !type.IsInterface && (type.IsArray || type.GetConstructor (Type.EmptyTypes) != null || type.IsAbstract || type.IsValueType);
}
}