System.Runtime.Serialization.XsdDataContractImporter.ImportSimpleType C# (CSharp) Method

ImportSimpleType() private method

private ImportSimpleType ( CodeTypeDeclaration td, XmlSchemaSet schemas, XmlSchemaSimpleType type, XmlQualifiedName qname ) : void
td System.CodeDom.CodeTypeDeclaration
schemas System.Xml.Schema.XmlSchemaSet
type System.Xml.Schema.XmlSchemaSimpleType
qname System.Xml.XmlQualifiedName
return void
		void ImportSimpleType (CodeTypeDeclaration td, XmlSchemaSet schemas, XmlSchemaSimpleType type, XmlQualifiedName qname)
		{
			var scl = type.Content as XmlSchemaSimpleTypeList;
			if (scl != null) {
				if (scl.ItemType == null)
					throw new InvalidDataContractException (String.Format ("simple type list is allowed only with an anonymous simple type with enumeration restriction content as its item type definition (type is {0})", type.QualifiedName));
				var itemType = scl.ItemType as XmlSchemaSimpleType;
				var ir = itemType.Content as XmlSchemaSimpleTypeRestriction;
				if (ir == null)
					throw new InvalidDataContractException (String.Format ("simple type list is allowed only with an anonymous simple type with enumeration restriction content as its item type definition (type is {0})", type.QualifiedName));
				ImportEnum (td, schemas, ir, type, qname, true);
				return;
			}
			var scr = type.Content as XmlSchemaSimpleTypeRestriction;
			if (scr != null) {
				ImportEnum (td, schemas, scr, type, qname, false);
				return;
			}

			throw new InvalidDataContractException (String.Format ("simple type is supported only if it has enumeration or list of an anonymous simple type with enumeration restriction content as its item type definition (type is {0})", qname));
		}