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


C# XmlSchemaComplexType.CreateSchemaSequenceParticle方法代码示例

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


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

示例1: GenerateSchemaTypeObjects

        /// <summary>
        /// </summary>
        public override void GenerateSchemaTypeObjects(PropertyInfo property, XmlSchemaType type, int level)
        {
            var atts = GetAttributes<ConfigurationPropertyAttribute>(property);
            if (atts.Length == 0)
                return;

            XmlSchemaComplexType ct;
            if (Generator.ComplexMap.ContainsKey(property.PropertyType))
            {
                //already done the work
                ct = Generator.ComplexMap[property.PropertyType];
            }
            else
            {
                //  got to generate a new one
                ct = new XmlSchemaComplexType { Name = atts[0].Name + "CT" };
                ct.AddAnnotation(property, null);
                ct.CreateSchemaSequenceParticle();

                Generator.ComplexMap.Add(property.PropertyType, ct);
                Generator.Schema.Items.Add(ct);

                //  get all properties from the configuration object
                var propertyInfos = GetProperties<ConfigurationPropertyAttribute>(property.PropertyType);

                foreach (var pi in propertyInfos)
                {
                    var parser = TypeParserFactory.GetParser(Generator, pi);
                    parser.GenerateSchemaTypeObjects(pi, ct, level + 1);
                }
            }

            var element = new XmlSchemaElement
            {
                Name = atts[0].Name, // property.PropertyType.Name + "CT",
                MinOccurs = atts[0].IsRequired ? 1 : 0,
                SchemaTypeName = new XmlQualifiedName(XmlHelper.PrependNamespaceAlias(ct.Name))
            };
            var pct = (XmlSchemaComplexType) type;
            ((XmlSchemaGroupBase) pct.Particle).Items.Add(element);

            //  add the documentation
            element.AddAnnotation(property, atts[0]);
        }
开发者ID:flcdrg,项目名称:XSDExtractor,代码行数:46,代码来源:ConfigurationElementParser.cs

示例2: AddCollectionChildren

        /// <summary>
        ///     Adds the child elements of the collection
        /// </summary>
        protected void AddCollectionChildren(XmlSchemaGroupBase parentParticle, ConfigurationCollectionAttribute configCollAttribute, int level)
        {
            Debug.IndentLevel = level;

            XmlSchemaComplexType ct;
            if (Generator.ComplexMap.ContainsKey(configCollAttribute.ItemType))
            {
                //already done the work
                ct = Generator.ComplexMap[configCollAttribute.ItemType];
            }
            else
            {
                //  got to generate a new one for the collection
                ct = new XmlSchemaComplexType { Name = configCollAttribute.ItemType.Name + "CT" };
                ct.CreateSchemaSequenceParticle();

                Generator.ComplexMap.Add(configCollAttribute.ItemType, ct);
                Generator.Schema.Items.Add(ct);
            }

            //  add method
            var addElement = new XmlSchemaElement
            {
                Name = configCollAttribute.AddItemName,
                MinOccurs = 0,
                SchemaTypeName = new XmlQualifiedName(XmlHelper.PrependNamespaceAlias(ct.Name))
            };

            //  ok we now have the child element as a complextype object
            //  but we need to add three elements to the parent complex type
            //  which support the add / remove / clear methods of the collection
            //  if we must add a clear method then it has to come first

            //  the basic map types do not include the clear and remove methods
            if (configCollAttribute.CollectionType == ConfigurationElementCollectionType.AddRemoveClearMap ||
                configCollAttribute.CollectionType == ConfigurationElementCollectionType.AddRemoveClearMapAlternate)
            {
                //  clear method (which is a simple element)
                var element = new XmlSchemaElement
                {
                    Name = configCollAttribute.ClearItemsName,
                    MinOccurs = 0,
                    MaxOccurs = 1,
                    //SchemaType = new XmlSchemaComplexType()
                };

                parentParticle.Items.Add(element);

                //  remove method
                element = new XmlSchemaElement
                {
                    MinOccurs = 0,
                    Name = configCollAttribute.RemoveItemName
                };

                var removeCt = new XmlSchemaComplexType();
                element.SchemaType = removeCt;

                //  get the type contained in the collection and work out
                //  what the key property is
                var childElementType = configCollAttribute.ItemType;
                var found = false;
                foreach (var pi in childElementType.GetProperties())
                {
                    if (found)
                        break;

                    Debug.WriteLine("Child property: " + pi.Name);

                    var cpAtts = GetAttributes<ConfigurationPropertyAttribute>(pi);

                    // this should return a standardtypeparser object, if it doesnt
                    //  then it means that the key of the element was an element
                    //  itself and I don't think that is possible!

                    if (cpAtts.Any(att => att.IsKey))
                    {
                        var parser = TypeParserFactory.GetParser(Generator, pi);
                        parser.GenerateSchemaTypeObjects(pi, removeCt, level + 1);
                        found = true;
                    }
                }

                parentParticle.Items.Add(element);
                SetMaxOccurs(element, parentParticle);
            }

            SetMaxOccurs(addElement, parentParticle);

            parentParticle.Items.Add(addElement);

            //  get all properties from the configuration object
            var propertyInfos = GetProperties<ConfigurationPropertyAttribute>(configCollAttribute.ItemType);
            foreach (var pi in propertyInfos)
            {
                var parser = TypeParserFactory.GetParser(Generator, pi);
                Debug.WriteLine("\tConfigurationProperty: {0} {1}", pi.Name, parser.GetType());
//.........这里部分代码省略.........
开发者ID:flcdrg,项目名称:XSDExtractor,代码行数:101,代码来源:ConfigurationCollectionParser.cs


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