本文整理汇总了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));
}
}