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


C# XmlSchemaComplexType.ContainsName方法代碼示例

本文整理匯總了C#中System.Xml.Schema.XmlSchemaComplexType.ContainsName方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlSchemaComplexType.ContainsName方法的具體用法?C# XmlSchemaComplexType.ContainsName怎麽用?C# XmlSchemaComplexType.ContainsName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Schema.XmlSchemaComplexType的用法示例。


在下文中一共展示了XmlSchemaComplexType.ContainsName方法的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.XmlSchemaComplexType.ContainsName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。