• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Schema.XmlSchemaElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XmlSchemaElement类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddElementToSchema

        void AddElementToSchema(XmlSchemaElement element, string elementNs, XmlSchemaSet schemaSet)
        {
            OperationDescription parentOperation = this.operation;
            if (parentOperation.OperationMethod != null)
            {
                XmlQualifiedName qname = new XmlQualifiedName(element.Name, elementNs);

                OperationElement existingElement;
                if (ExportedMessages.ElementTypes.TryGetValue(qname, out existingElement))
                {
                    if (existingElement.Operation.OperationMethod == parentOperation.OperationMethod)
                        return;
                    if (!SchemaHelper.IsMatch(element, existingElement.Element))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotHaveTwoOperationsWithTheSameElement5, parentOperation.OperationMethod.DeclaringType, parentOperation.OperationMethod.Name, qname, existingElement.Operation.OperationMethod.DeclaringType, existingElement.Operation.Name)));
                    }
                    return;
                }
                else
                {
                    ExportedMessages.ElementTypes.Add(qname, new OperationElement(element, parentOperation));
                }
            }
            SchemaHelper.AddElementToSchema(element, SchemaHelper.GetSchema(elementNs, schemaSet), schemaSet);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:MessageContractExporter.cs


示例2: ReplaceThisWith

 public static void ReplaceThisWith(this XmlSchemaElement that, XmlSchemaElement with) 
 {
     var gr = that.Parent as XmlSchemaGroupBase;
     int idx = gr.Items.IndexOf(that);
     gr.Items.Insert(idx, with);
     gr.Items.Remove(that);
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:7,代码来源:DmlExtensions.cs


示例3: Bug360541

		public void Bug360541 ()
		{
			XmlSchemaComplexType stype = GetStype ();
			
			XmlSchemaElement selem1 = new XmlSchemaElement ();
			selem1.Name = "schema";
			selem1.SchemaType = stype;

			XmlSchema schema = new XmlSchema ();
			schema.Items.Add (selem1);

			XmlSchemas xs = new XmlSchemas ();
			xs.Add (schema);

			xs.Find (XmlQualifiedName.Empty, typeof (XmlSchemaElement));

			selem1 = new XmlSchemaElement ();
			selem1.Name = "schema1";
			selem1.SchemaType = stype;

			schema = new XmlSchema ();
			schema.Items.Add (selem1);

			xs = new XmlSchemas ();
			xs.Add (schema);
			xs.Find (XmlQualifiedName.Empty, typeof (XmlSchemaElement));
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:XmlSchemasTests.cs


示例4: TestAdd

		public void TestAdd ()
		{
			XmlSchemaCollection col = new XmlSchemaCollection ();
			XmlSchema schema = new XmlSchema ();
			XmlSchemaElement elem = new XmlSchemaElement ();
			elem.Name = "foo";
			schema.Items.Add (elem);
			schema.TargetNamespace = "urn:foo";
			col.Add (schema);
			col.Add (schema);	// No problem !?

			XmlSchema schema2 = new XmlSchema ();
			schema2.Items.Add (elem);
			schema2.TargetNamespace = "urn:foo";
			col.Add (schema2);	// No problem !!

			schema.Compile (null);
			col.Add (schema);
			col.Add (schema);	// Still no problem !!!

			schema2.Compile (null);
			col.Add (schema2);

			schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
			schema.Compile (null);
			col.Add (schema);

			schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
			schema2.Compile (null);
			col.Add (schema2);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:31,代码来源:XmlSchemaCollectionTests.cs


示例5: DescriptrosCollector

            public DescriptrosCollector(XmlSchemaElement element)
            {
                if (element == null) throw new ArgumentNullException("element");
                this.element = element;

                Collect();
            }
开发者ID:willrawls,项目名称:arp,代码行数:7,代码来源:SchemaParameterDescriptorProvider.cs


示例6: SchemaObjectInfo

 internal SchemaObjectInfo(XmlSchemaType type, XmlSchemaElement element, XmlSchema schema, List<XmlSchemaType> knownTypes)
 {
     this.type = type;
     this.element = element;
     this.schema = schema;
     this.knownTypes = knownTypes;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:SchemaHelper.cs


示例7: CheckDuplicateElement

 internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs)
 {
     if ((element != null) && ((element.Parent != null) && (element.Parent is XmlSchema)))
     {
         XmlSchemaObjectTable elements = null;
         if ((this.Schema != null) && (this.Schema.TargetNamespace == elementNs))
         {
             XmlSchemas.Preprocess(this.Schema);
             elements = this.Schema.Elements;
         }
         else if (this.Schemas != null)
         {
             elements = this.Schemas.GlobalElements;
         }
         else
         {
             return;
         }
         foreach (XmlSchemaElement element2 in elements.Values)
         {
             if ((element2.Name == element.Name) && (element2.QualifiedName.Namespace == elementNs))
             {
                 if (!this.Match(element2, element))
                 {
                     throw new InvalidOperationException(Res.GetString("XmlSerializableRootDupName", new object[] { this.getSchemaMethod.DeclaringType.FullName, element2.Name, elementNs }));
                 }
                 break;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:SerializableMapping.cs


示例8: AddElementForm

 internal static void AddElementForm(XmlSchemaElement element, System.Xml.Schema.XmlSchema schema)
 {
     if (schema.ElementFormDefault != XmlSchemaForm.Qualified)
     {
         element.Form = XmlSchemaForm.Qualified;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:SchemaHelper.cs


示例9: GetXmlSchema

        /// <summary>
        /// Gets the XML schema.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="schemaSet">The schema set.</param>
        /// <param name="generateFlatSchema">A value indicating whether the schema should be generated as flat schema.</param>
        /// <returns>The qualified name of the type.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="schemaSet"/> is <c>null</c>.</exception>
        public static XmlQualifiedName GetXmlSchema(Type type, XmlSchemaSet schemaSet, bool generateFlatSchema)
        {
            Argument.IsNotNull("schemaSet", schemaSet);

            var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
            var serializationManager = dependencyResolver.Resolve<ISerializationManager>();

            string typeNs = GetTypeNamespaceForSchema(type);
            var schema = GetOrCreateSchema(typeNs, schemaSet, serializationManager);

            // Check if it already exists
            string typeName = GetTypeNameForSchema(type);
            var existingType = (from x in schema.Items.Cast<object>()
                                where x is XmlSchemaComplexType && ((XmlSchemaComplexType)x).Name == typeName
                                select (XmlSchemaComplexType)x).FirstOrDefault();
            if (existingType != null)
            {
                return new XmlQualifiedName(existingType.Name, typeNs);
            }

            var typeSchema = CreateSchemaComplexType(type, schema, schemaSet, serializationManager, generateFlatSchema);

            var root = new XmlSchemaElement();
            root.Name = string.Format("{0}", typeSchema.Name);
            root.SchemaTypeName = new XmlQualifiedName(typeSchema.Name, typeNs);
            root.IsNillable = true;
            schema.Items.Add(root);

            return new XmlQualifiedName(typeSchema.Name, typeNs);
        }
开发者ID:JaysonJG,项目名称:Catel,代码行数:38,代码来源:XmlSchemaHelper.cs


示例10: GenerateTypedDataSet

 internal string GenerateTypedDataSet(XmlSchemaElement element, XmlSchemas schemas, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeDomProvider codeProvider)
 {
     if (element == null)
     {
         return null;
     }
     if (this.importedTypes[element.SchemaType] != null)
     {
         return (string) this.importedTypes[element.SchemaType];
     }
     IList list = schemas.GetSchemas(element.QualifiedName.Namespace);
     if (list.Count != 1)
     {
         return null;
     }
     XmlSchema schema = list[0] as XmlSchema;
     if (schema == null)
     {
         return null;
     }
     MemoryStream stream = new MemoryStream();
     schema.Write(stream);
     stream.Position = 0L;
     DesignDataSource designDS = new DesignDataSource();
     designDS.ReadXmlSchema(stream, null);
     stream.Close();
     string str = TypedDataSetGenerator.GenerateInternal(designDS, compileUnit, mainNamespace, codeProvider, this.dataSetGenerateOptions, null);
     this.importedTypes.Add(element.SchemaType, str);
     return str;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:TypedDataSetSchemaImporterExtension.cs


示例11: GenerateTypedDataSet

 internal string GenerateTypedDataSet(XmlSchemaElement element, XmlSchemas schemas, CodeNamespace codeNamespace, StringCollection references, CodeDomProvider codeProvider)
 {
     if (element == null)
     {
         return null;
     }
     if (this.importedTypes[element.SchemaType] != null)
     {
         return (string) this.importedTypes[element.SchemaType];
     }
     IList list = schemas.GetSchemas(element.QualifiedName.Namespace);
     if (list.Count != 1)
     {
         return null;
     }
     XmlSchema schema = list[0] as XmlSchema;
     if (schema == null)
     {
         return null;
     }
     DataSet dataSet = new DataSet();
     using (MemoryStream stream = new MemoryStream())
     {
         schema.Write(stream);
         stream.Position = 0L;
         dataSet.ReadXmlSchema(stream);
     }
     string name = new TypedDataSetGenerator().GenerateCode(dataSet, codeNamespace, codeProvider.CreateGenerator()).Name;
     this.importedTypes.Add(element.SchemaType, name);
     references.Add("System.Data.dll");
     return name;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:DataSetSchemaImporterExtension.cs


示例12: Visit

        protected override void Visit(XmlSchemaElement element)
        {
            var sameNamespace = element.QualifiedName.Namespace == _targetNamespace ||
                                string.IsNullOrEmpty(element.QualifiedName.Namespace) && string.IsNullOrEmpty(_targetNamespace);
            if (!sameNamespace)
                return;

            var isGlobal = (element.Parent is XmlSchema);

            if (isGlobal)
            {
                _elements.Add(element);
                base.Visit(element);
            }
            else if (element.RefName.IsEmpty)
            {
                base.Visit(element);
            }
            else
            {
                var elementParent = FindOuterMostElement(element);
                var referencedElement = (XmlSchemaElement)_schemaSet.GlobalElements[element.RefName];
                if (referencedElement != elementParent)
                    _referencedElements.Add(referencedElement);
            }
        }
开发者ID:sergey-steinvil,项目名称:xsddoc,代码行数:26,代码来源:NamespaceRootElementFinder.cs


示例13: TestSimpleValidation

		public void TestSimpleValidation ()
		{
			string xml = "<root/>";
			xvr = PrepareXmlReader (xml);
			Assert.AreEqual (ValidationType.Auto, xvr.ValidationType);
			XmlSchema schema = new XmlSchema ();
			XmlSchemaElement elem = new XmlSchemaElement ();
			elem.Name = "root";
			schema.Items.Add (elem);
			xvr.Schemas.Add (schema);
			xvr.Read ();	// root
			Assert.AreEqual (ValidationType.Auto, xvr.ValidationType);
			xvr.Read ();	// EOF

			xml = "<hoge/>";
			xvr = PrepareXmlReader (xml);
			xvr.Schemas.Add (schema);
			try {
				xvr.Read ();
				Assert.Fail ("element mismatch is incorrectly allowed");
			} catch (XmlSchemaException) {
			}

			xml = "<hoge xmlns='urn:foo' />";
			xvr = PrepareXmlReader (xml);
			xvr.Schemas.Add (schema);
			try {
				xvr.Read ();
				Assert.Fail ("Element in different namespace is incorrectly allowed.");
			} catch (XmlSchemaException) {
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:32,代码来源:XsdValidatingReaderTests.cs


示例14: DocUIList

        public DocUIList(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm, bool horizontal = true)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            _optlist = new List<ListItemComponent>();
            _parent = xmlNode;
            _listpanel = new StackPanel();
            _listpanel.Orientation = horizontal ? Orientation.Horizontal : Orientation.Vertical;
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null && seq.Items.Count == 1 && seq.Items[0] is XmlSchemaElement)
                {
                    _el = seq.Items[0] as XmlSchemaElement;
                    //get all elements from current node
                    foreach (XmlNode node in xmlNode.ChildNodes)
                    {
                        ListItemComponent lio = new ListItemComponent(node, _el, _listpanel, overlaypanel, _optlist, parentForm);
                        _optlist.Add(lio);
                    }
                }

                Button add = new Button();
                add.Content = "Add item";
                add.Click += AddItem;
                _listpanel.Children.Add(add);
                contentpanel.Children.Add(_listpanel);
            }
        }
开发者ID:00Green27,项目名称:DocUI,代码行数:29,代码来源:DocUIList.cs


示例15: IsXmlSchemaNamespaceElement

 /// <summary>
 /// Checks whether the element belongs to the XSD namespace.
 /// </summary>
 static bool IsXmlSchemaNamespaceElement(XmlSchemaElement element)
 {
     XmlQualifiedName qualifiedName = element.QualifiedName;
     if (qualifiedName != null) {
         return IsXmlSchemaNamespace(qualifiedName.Namespace);
     }
     return false;
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:11,代码来源:XmlSchemaDefinition.cs


示例16: FixtureInit

 public override void FixtureInit()
 {
     XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
     schemas.Add(SchemaCompletionData);
     XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, SchemaCompletionData, String.Empty);
     string xml = "<note xmlns='http://www.w3schools.com'></note>";
     schemaElement = (XmlSchemaElement)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("note xmlns"), provider);
 }
开发者ID:BackupTheBerlios,项目名称:nantgui,代码行数:8,代码来源:ElementSelectedTestFixture.cs


示例17: CreateProtoElement

 public XElement CreateProtoElement(XmlSchemaElement schemaElement) {
     if (schemaElement.ElementSchemaType != null) {
         var nodes = CreateProtoAnyType(schemaElement.ElementSchemaType);
         return new XElement(schemaElement.QualifiedName.ToXName(), nodes);
     } else {
         throw new Exception("invalid schema type");
     }
 }
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:8,代码来源:XmlParser.cs


示例18: VisitXmlSchemaElement

 public virtual void VisitXmlSchemaElement(XmlSchemaElement element)
 {
     if (element.Name != null)
         VisitXmlSchemaElementNamed(element);
     else
     {
         VisitXmlSchemaElementNested(element);
     }
 }
开发者ID:willrawls,项目名称:arp,代码行数:9,代码来源:XsdVisitor.cs


示例19: Visit

        protected override void Visit(XmlSchemaElement element)
        {
            if (!element.RefName.IsEmpty)
                return;

            PushNamedObject(element);
            base.Visit(element);
            PopNamedObject();
        }
开发者ID:sergey-steinvil,项目名称:xsddoc,代码行数:9,代码来源:TypeUsageFinder.cs


示例20: CreateXmlSchemaForIndicatorsInGroup

        /// <summary>
        /// Формируем XmlSchema для правильного отображения индикаторов группы в VGridControl
        /// </summary>
        /// <param name="elmList">названия всех по</param>
        /// <returns>Возвращаем поток в который записана XmlSchema</returns>
        public static MemoryStream CreateXmlSchemaForIndicatorsInGroup(List<string[]> elmList)
        {
            var xmlSchema = new XmlSchema();

            // <xs:element name="root">
            var elementRoot = new XmlSchemaElement();
            xmlSchema.Items.Add(elementRoot);
            elementRoot.Name = "root";
            // <xs:complexType>
            var complexType = new XmlSchemaComplexType();
            elementRoot.SchemaType = complexType;

            // <xs:choice minOccurs="0" maxOccurs="unbounded">
            var choice = new XmlSchemaChoice();
            complexType.Particle = choice;
            choice.MinOccurs = 0;
            choice.MaxOccursString = "unbounded";

            // <xs:element name="record">
            var elementRecord = new XmlSchemaElement();
            choice.Items.Add(elementRecord);
            elementRecord.Name = "record";
            // <xs:complexType>
            var complexType2 = new XmlSchemaComplexType();
            elementRecord.SchemaType = complexType2;

            // <xs:sequence>
            var sequence = new XmlSchemaSequence();
            complexType2.Particle = sequence;

            foreach (var el in elmList)
            {
                var element = new XmlSchemaElement();
                sequence.Items.Add(element);
                element.Name = el[0];
                element.SchemaTypeName = new XmlQualifiedName(el[1], "http://www.w3.org/2001/XMLSchema");
            }

            var schemaSet = new XmlSchemaSet();
            schemaSet.Add(xmlSchema);
            schemaSet.Compile();

            XmlSchema compiledSchema = null;

            foreach (XmlSchema schema1 in schemaSet.Schemas())
                compiledSchema = schema1;

            var nsmgr = new XmlNamespaceManager(new NameTable());
            nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");

            var ms = new MemoryStream();
            if (compiledSchema != null) compiledSchema.Write(ms, nsmgr);
            ms.Position = 0;

            return ms;
        }
开发者ID:Biskup,项目名称:GOATApplication,代码行数:61,代码来源:StaticData.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Schema.XmlSchemaException类代码示例发布时间:2022-05-26
下一篇:
C# Schema.XmlSchemaDatatype类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap