当前位置: 首页>>代码示例>>C#>>正文


C# XmlSchemaParticle.GetParticleType方法代码示例

本文整理汇总了C#中System.Xml.Schema.XmlSchemaParticle.GetParticleType方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaParticle.GetParticleType方法的具体用法?C# XmlSchemaParticle.GetParticleType怎么用?C# XmlSchemaParticle.GetParticleType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Schema.XmlSchemaParticle的用法示例。


在下文中一共展示了XmlSchemaParticle.GetParticleType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TraverseParticle

        private void TraverseParticle(XmlSchemaParticle particle, XmlSchemaComplexType baseType, ClrContentTypeInfo typeInfo, XmlSchemaDerivationMethod derivationMethod)
        {
            if (particleStack == null)
            {
                particleStack = new Stack<ParticleData>();
            }
            else
            {
                particleStack.Clear();
            }
            if (propertyNameTypeTable == null)
            {
                propertyNameTypeTable = new Dictionary<string, ClrPropertyInfo>();
            }
            else
            {
                propertyNameTypeTable.Clear();
            }

            XmlSchemaParticle baseParticle = baseType.ContentTypeParticle;
            ParticleData particleData;
            GroupingInfo parentGroupInfo = null;
            StringBuilder regEx = new StringBuilder();

            XmlSchemaGroupBase currentGroupBase = null;
            GroupingInfo currentGroupingInfo = null;

            int currentIndex = 0;

            while (true)
            {

                // dont interrogate a particle if we are past the end of the list
                if (currentGroupBase == null || currentIndex <= currentGroupBase.Items.Count)
                {
                    ParticleType particleType = particle.GetParticleType();
                    switch (particleType)
                    {
                        case ParticleType.Element:
                            {
                                XmlSchemaElement elem = particle as XmlSchemaElement;
                                ClrPropertyInfo propertyInfo = null;
                                bool fromBaseType = false;
                                if (derivationMethod == XmlSchemaDerivationMethod.Extension && typeInfo.IsDerived)
                                {
                                    if (baseParticle.ContainsElement(elem))
                                    {
                                        fromBaseType = true;
                                    }
                                    else if (!typeInfo.InlineBaseType && baseType.ContainsName(elem.QualifiedName))
                                    {
                                        typeInfo.InlineBaseType = true;
                                    }

                                }
                                propertyInfo = BuildProperty(elem, fromBaseType);
                                regEx.Append(propertyInfo.PropertyName);
                                AppendOccurenceToRegex(propertyInfo, regEx);
                                //Add to parent
                                if (currentGroupingInfo == null)
                                {
                                    //Not adding property to propertyNameTypeTable as this case will occur only for pointless groups, so they have just one property
                                    BuildAnnotationInformation(propertyInfo, elem, false, false);
                                    typeInfo.AddMember(propertyInfo);
                                }
                                else
                                {
                                    BuildAnnotationInformation(propertyInfo, elem, currentGroupingInfo.ContentModelType == ContentModelType.Choice, currentGroupingInfo.IsNested);
                                    currentGroupingInfo.AddChild(propertyInfo);
                                    SetPropertyFlags(propertyInfo, currentGroupingInfo, elem.ElementSchemaType);
                                }
                                break;

                            }
                        case ParticleType.Any:
                            {
                                regEx.Append("any");
                                XmlSchemaAny any = particle as XmlSchemaAny;

                                if (derivationMethod == XmlSchemaDerivationMethod.Extension && typeInfo.IsDerived)
                                {
                                    if (baseParticle.ContainsWildCard(any))
                                    {
                                        typeInfo.HasElementWildCard = true;//ANY property in the base type will be reused
                                    }
                                }

                                //Note we always create a property info object to keep the original nesting structure in the schema
                                //so it can be used to create a correct FSM; on the other hand, typeInfo.HasElementWildCard will indicate whether
                                //we need to create a property in the resulting object type.
                                ClrWildCardPropertyInfo wcPropertyInfo = BuildAnyProperty(any, !typeInfo.HasElementWildCard);

                                //Add to parent
                                if (currentGroupingInfo == null)
                                {
                                    typeInfo.AddMember(wcPropertyInfo);
                                }
                                else
                                {
                                    currentGroupingInfo.AddChild(wcPropertyInfo);
//.........这里部分代码省略.........
开发者ID:dipdapdop,项目名称:linqtoxsd,代码行数:101,代码来源:XsdToTypesConverter.cs


注:本文中的System.Xml.Schema.XmlSchemaParticle.GetParticleType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。