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


C# XmlSchemaParticle.GetType方法代码示例

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


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

示例1: GetParticleDesc

 private string GetParticleDesc(XmlSchemaParticle particle)
 {
     var desc = particle.GetType().Name.Replace("XmlSchema", "");
       if (particle is XmlSchemaElement)
       {
     desc += "(" + ((XmlSchemaElement)particle).QualifiedName + ")";
       }
       if (particle.SourceUri == null)
       {
     if (particle.Id != null)
       return string.Format("{0}:id:{1}", desc, particle.Id);
     return string.Format("{0}:{1}:{2}", desc, particle.LineNumber, particle.LinePosition);
       }
       else
       {
     string[] segments = new Uri(particle.SourceUri).Segments;
     return string.Format("{0}:{1}:{2}:{3}", segments[segments.Length - 1], desc, particle.LineNumber, particle.LinePosition);
       }
 }
开发者ID:q42jaap,项目名称:xsd2codemirror,代码行数:19,代码来源:SchemaParser.cs

示例2: IndexParticle

        /// <summary>
        /// Index a particle. This finds the parents for all elements.
        /// </summary>
        /// <param name="parentElement">The parent element of the particle to index.</param>
        /// <param name="particle">The particle to index.</param>
        private void IndexParticle(XmlSchemaElement parentElement, XmlSchemaParticle particle)
        {
            if (particle is XmlSchemaAny)
            {
                // ignore
            }
            else if (particle is XmlSchemaChoice)
            {
                XmlSchemaChoice choice = (XmlSchemaChoice)particle;

                foreach (XmlSchemaParticle childParticle in choice.Items)
                {
                    this.IndexParticle(parentElement, childParticle);
                }
            }
            else if (particle is XmlSchemaElement)
            {
                XmlSchemaElement element = (XmlSchemaElement)particle;

                // locally defined elements are not supported
                if (element.QualifiedName.Namespace.Length == 0)
                {
                    throw new ApplicationException(String.Format("Locally defined element '{0}' is not supported.  Please define at a global scope.", element.QualifiedName.Name));
                }

                this.IndexElement(parentElement, element);
            }
            else if (particle is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef groupRef = (XmlSchemaGroupRef)particle;

                if (null != groupRef.Particle)
                {
                    foreach (XmlSchemaParticle childParticle in groupRef.Particle.Items)
                    {
                        this.IndexParticle(parentElement, childParticle);
                    }
                }
            }
            else if (particle is XmlSchemaSequence)
            {
                XmlSchemaSequence sequence = (XmlSchemaSequence)particle;

                foreach (XmlSchemaParticle childParticle in sequence.Items)
                {
                    this.IndexParticle(parentElement, childParticle);
                }
            }
            else
            {
                throw new ApplicationException(String.Format("Unknown particle type: {0}.", particle.GetType().ToString()));
            }
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:58,代码来源:XmlSchemaCompiler.cs

示例3: WriteParticle


//.........这里部分代码省略.........
            }
            else if (particle is XmlSchemaChoice)
            {
                XmlSchemaChoice choice = (XmlSchemaChoice)particle;

                // sort element children
                SortedList children = new SortedList();
                foreach (XmlSchemaParticle childParticle in choice.Items)
                {
                    if (childParticle is XmlSchemaElement)
                    {
                        children.Add(((XmlSchemaElement)childParticle).QualifiedName.Name, childParticle);
                    }
                    else if (childParticle is XmlSchemaAny)
                    {
                        children.Add("ZZZ", childParticle);
                    }
                    else // sort non-element children by their line number
                    {
                        children.Add(String.Concat("Z", childParticle.LineNumber.ToString(CultureInfo.InvariantCulture)), childParticle);
                    }
                }

                writer.WriteString(String.Format("Choice of elements (min: {0}, max: {1})", (choice.MinOccurs == Decimal.MaxValue ? "unbounded" : choice.MinOccurs.ToString(CultureInfo.InvariantCulture)), (choice.MaxOccurs == Decimal.MaxValue ? "unbounded" : choice.MaxOccurs.ToString(CultureInfo.InvariantCulture))));

                writer.WriteStartElement("ul");
                foreach (XmlSchemaParticle childParticle in children.Values)
                {
                    writer.WriteStartElement("li");
                    this.WriteParticle(ownerElementInfo, particle, childParticle, writer);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else if (particle is XmlSchemaElement)
            {
                XmlSchemaElement element = (XmlSchemaElement)particle;

                this.WriteElementLink(element.QualifiedName, writer);
                writer.WriteString(" (min: ");
                if (element.MinOccursString != null)
                {
                    writer.WriteString(element.MinOccursString);
                }
                else if (parentParticle != null)
                {
                    if (parentParticle.MinOccursString != null)
                    {
                        writer.WriteString(parentParticle.MinOccursString);
                    }
                    else
                    {
                        writer.WriteString(parentParticle.MinOccurs.ToString(CultureInfo.InvariantCulture));
                    }
                }
                writer.WriteString(", max: ");
                if (element.MaxOccursString != null)
                {
                    writer.WriteString(element.MaxOccursString);
                }
                else if (parentParticle != null)
                {
                    if (parentParticle.MaxOccursString != null)
                    {
                        writer.WriteString(parentParticle.MaxOccursString);
                    }
                    else
                    {
                        writer.WriteString(parentParticle.MaxOccurs.ToString(CultureInfo.InvariantCulture));
                    }
                }
                writer.WriteString(")");

                string description = GetDescription(element);
                if (description != null && description.Length > 0)
                {
                    writer.WriteString(": ");
                    writer.WriteString(description);
                }
            }
            else if (particle is XmlSchemaSequence)
            {
                XmlSchemaSequence sequence = (XmlSchemaSequence)particle;

                writer.WriteString(String.Format("Sequence (min: {0}, max: {1})", (sequence.MinOccurs == Decimal.MaxValue ? "unbounded" : sequence.MinOccurs.ToString(CultureInfo.InvariantCulture)), (sequence.MaxOccurs == Decimal.MaxValue ? "unbounded" : sequence.MaxOccurs.ToString(CultureInfo.InvariantCulture))));

                writer.WriteStartElement("ol");
                foreach (XmlSchemaParticle childParticle in sequence.Items)
                {
                    writer.WriteStartElement("li");
                    this.WriteParticle(ownerElementInfo, particle, childParticle, writer);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else
            {
                throw new ApplicationException(String.Format("Unknown particle type: {0}.", particle.GetType().ToString()));
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:101,代码来源:XmlSchemaCompiler.cs

示例4: WriteParticle


//.........这里部分代码省略.........
                SortedList children = new SortedList();
                foreach (XmlSchemaParticle childParticle in choice.Items)
                {
                    if (childParticle is XmlSchemaElement)
                    {
                        children.Add(((XmlSchemaElement)childParticle).QualifiedName.Name, childParticle);
                    }
                    else if (childParticle is XmlSchemaAny)
                    {
                        children.Add("ZZZ", childParticle);
                    }
                    else // sort non-element children by their line number
                    {
                        children.Add(String.Concat("Z", childParticle.LineNumber.ToString(CultureInfo.InvariantCulture)), childParticle);
                    }
                }

                writer.WriteString(String.Format("Choice of elements (min: {0}, max: {1})", (choice.MinOccurs == Decimal.MaxValue ? "unbounded" : choice.MinOccurs.ToString(CultureInfo.InvariantCulture)), (choice.MaxOccurs == Decimal.MaxValue ? "unbounded" : choice.MaxOccurs.ToString(CultureInfo.InvariantCulture))));

                writer.WriteStartElement("ul");
                foreach (XmlSchemaParticle childParticle in children.Values)
                {
                    writer.WriteStartElement("li");
                    this.WriteParticle(ownerElementInfo, particle, childParticle, writer);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else if (particle is XmlSchemaElement)
            {
                XmlSchemaElement element = (XmlSchemaElement)particle;

                this.WriteElementLink(element.QualifiedName, writer);
                writer.WriteString(" (min: ");
                if (element.MinOccursString != null)
                {
                    writer.WriteString(element.MinOccursString);
                }
                else if (parentParticle != null)
                {
                    if (parentParticle.MinOccursString != null)
                    {
                        writer.WriteString(parentParticle.MinOccursString);
                    }
                    else
                    {
                        writer.WriteString(parentParticle.MinOccurs.ToString(CultureInfo.InvariantCulture));
                    }
                }
                writer.WriteString(", max: ");
                if (element.MaxOccursString != null)
                {
                    writer.WriteString(element.MaxOccursString);
                }
                else if (parentParticle != null)
                {
                    if (parentParticle.MaxOccursString != null)
                    {
                        writer.WriteString(parentParticle.MaxOccursString);
                    }
                    else
                    {
                        writer.WriteString(parentParticle.MaxOccurs.ToString(CultureInfo.InvariantCulture));
                    }
                }
                writer.WriteString(")");

                string description = GetDescription(element);
                if (description != null && description.Length > 0)
                {
                    writer.WriteString(": ");
                    writer.WriteRaw(htmlPrefix.Replace(description.Trim().Replace("\t", String.Empty).Replace(Environment.NewLine, " "), String.Empty));
                }
            }
            else if (particle is XmlSchemaSequence)
            {
                XmlSchemaSequence sequence = (XmlSchemaSequence)particle;

                writer.WriteString(String.Format("Sequence (min: {0}, max: {1})", (sequence.MinOccurs == Decimal.MaxValue ? "unbounded" : sequence.MinOccurs.ToString(CultureInfo.InvariantCulture)), (sequence.MaxOccurs == Decimal.MaxValue ? "unbounded" : sequence.MaxOccurs.ToString(CultureInfo.InvariantCulture))));

                writer.WriteStartElement("ol");
                foreach (XmlSchemaParticle childParticle in sequence.Items)
                {
                    writer.WriteStartElement("li");
                    this.WriteParticle(ownerElementInfo, particle, childParticle, writer);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else if (particle is XmlSchemaGroupRef)
            {
                // Document the group's children as particles of our parent.
                XmlSchemaGroupRef groupRef = (XmlSchemaGroupRef)particle;
                this.WriteParticle(ownerElementInfo, particle, groupRef.Particle, writer);
            }
            else
            {
                throw new ApplicationException(String.Format("Unknown particle type: {0}.", particle.GetType().ToString()));
            }
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:101,代码来源:XmlSchemaCompiler.cs

示例5: GetXmlSchemaElementFromParticle

 /// <summary>
 ///     Returns the XmlSchemaElement specified by the given qname defined in the given particle.
 /// </summary>
 /// <param name="particle"></param>
 /// <param name="qname"></param>
 /// <returns></returns>
 private XmlSchemaElement GetXmlSchemaElementFromParticle(XmlSchemaParticle particle, XmlQualifiedName qname)
 {
     XmlSchemaElement xe = null;
     var xsgb = particle as XmlSchemaGroupBase;
     var xsgr = particle as XmlSchemaGroupRef;
     if (xsgb != null)
     {
         xe = GetXmlElementFromXmlSchemaGroupBase(xsgb, qname);
     }
     else if (xsgr != null)
     {
         xe = GetXmlElementFromXmlSchemaGroupBase(xsgr.Particle, qname);
     }
     else if (particle != null)
     {
         Debug.Fail("Unable to handle case where particle type is " + particle.GetType());
     }
     return xe;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:AttributeContentValidator.cs


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