本文整理匯總了C#中System.Xml.Schema.XmlSchemaType.GetContentType方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlSchemaType.GetContentType方法的具體用法?C# XmlSchemaType.GetContentType怎麽用?C# XmlSchemaType.GetContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Schema.XmlSchemaType
的用法示例。
在下文中一共展示了XmlSchemaType.GetContentType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BuildProperties
private void BuildProperties(XmlSchemaElement parentElement, XmlSchemaType schemaType, ClrContentTypeInfo typeInfo)
{
XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType;
if (ct != null)
{
if (ct.TypeCode == XmlTypeCode.Item)
{
return;
}
XmlSchemaParticle particleToProperties = ct.ContentTypeParticle;
XmlSchemaComplexType baseType = ct.BaseXmlSchemaType as XmlSchemaComplexType;
if (schemaType.GetContentType() == XmlSchemaContentType.TextOnly)
{
//Try to create a text property for the simple content
ClrPropertyInfo property = BuildComplexTypeTextProperty(parentElement, ct);
if (property != null)
{
typeInfo.AddMember(property);
}
if (baseType == null)
{ //Derived from Simple type, first step simpleContent extension
TraverseAttributes(ct.AttributeUses, typeInfo);
}
else
{ //Derived from another complex type simple content, generate the content only if there are additional restrictions
if (!ct.IsDerivedByRestriction()) //process attributes only if not derived by restriction
TraverseAttributes(ct.AttributeUses, baseType.AttributeUses, typeInfo);
}
}
else
{
Debug.Assert(baseType != null); //ComplexType with complexContent is always derived from another complexType
if (ct.IsDerivedByRestriction())
{//Do not handle restrictions on complex content?
return;
}
if (particleToProperties.GetParticleType() != ParticleType.Empty)
{
TraverseParticle(particleToProperties, baseType, typeInfo, ct.DerivedBy);
}
TraverseAttributes(ct.AttributeUses, baseType.AttributeUses, typeInfo);
}
}
else
{
typeInfo.AddMember(BuildSimpleTypeTextProperty(parentElement, schemaType as XmlSchemaSimpleType));
}
}