當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlSchemaType.GetContentType方法代碼示例

本文整理匯總了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));
     }
 }
開發者ID:dipdapdop,項目名稱:linqtoxsd,代碼行數:48,代碼來源:XsdToTypesConverter.cs


注:本文中的System.Xml.Schema.XmlSchemaType.GetContentType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。