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


C# Schema.XmlSchemaSimpleType类代码示例

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


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

示例1: GetSchema

        public XmlSchemaElement GetSchema()
        {
            var type = new XmlSchemaComplexType();

            type.Attributes.Add(new XmlSchemaAttribute
                                    {
                                        Name = "refValue",
                                        Use = XmlSchemaUse.Required,
                                        SchemaTypeName =
                                            new XmlQualifiedName("positiveInteger", "http://www.w3.org/2001/XMLSchema")
                                    });

            type.Attributes.Add(new XmlSchemaAttribute
                                    {
                                        Name = "test",
                                        Use = XmlSchemaUse.Optional,
                                        SchemaTypeName =
                                            new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
                                    });

            
            var restriction = new XmlSchemaSimpleTypeRestriction
                                  {
                                      BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
                                  };

            restriction.Facets.Add(new XmlSchemaEnumerationFacet {Value = "years"});
            restriction.Facets.Add(new XmlSchemaEnumerationFacet {Value = "weeks"});
            restriction.Facets.Add(new XmlSchemaEnumerationFacet {Value = "days"});

            var simpleType = new XmlSchemaSimpleType {Content = restriction};


            type.Attributes.Add(new XmlSchemaAttribute
                                    {
                                        Name = "units",
                                        Use = XmlSchemaUse.Required,
                                        SchemaType = simpleType
                                    });


            type.Attributes.Add(new XmlSchemaAttribute
                                    {
                                        Name = "expressionLanguage",
                                        Use = XmlSchemaUse.Optional,
                                        SchemaTypeName =
                                            new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
                                    });

            var element = new XmlSchemaElement
                              {
                                  Name = "dicom-age-less-than",
                                  SchemaType = type
                              };

            return element;
        }
开发者ID:nhannd,项目名称:Xian,代码行数:57,代码来源:DicomAgeLessThanSpecification.cs

示例2: CreateSimpletypeLength

    private void CreateSimpletypeLength(string length, string minLength, string maxLength, bool expected) {
      passed = true;

      XmlSchema schema = new XmlSchema();

      XmlSchemaSimpleType testType = new XmlSchemaSimpleType();
      testType.Name = "TestType";

      XmlSchemaSimpleTypeRestriction testTypeRestriction = new XmlSchemaSimpleTypeRestriction();
      testTypeRestriction.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

      if (length != "-") {
        XmlSchemaLengthFacet _length = new XmlSchemaLengthFacet();
        _length.Value = length;
        testTypeRestriction.Facets.Add(_length);
      }
      if (minLength != "-") {
        XmlSchemaMinLengthFacet _minLength = new XmlSchemaMinLengthFacet();
        _minLength.Value = minLength;
        testTypeRestriction.Facets.Add(_minLength);
      }
      if (maxLength != "-") {
        XmlSchemaMaxLengthFacet _maxLength = new XmlSchemaMaxLengthFacet();
        _maxLength.Value = maxLength;
        testTypeRestriction.Facets.Add(_maxLength);
      }

      testType.Content = testTypeRestriction;
      schema.Items.Add(testType);
      schema.Compile(new ValidationEventHandler(ValidationCallbackOne));

      Assert.IsTrue (expected == passed, (passed ? "Test passed, should have failed" : "Test failed, should have passed") + ": " + length + " " + minLength + " " + maxLength);
      
    }
开发者ID:nobled,项目名称:mono,代码行数:34,代码来源:XmlSchemaLengthFacetTests.cs

示例3: Visit

 protected override void Visit(XmlSchemaSimpleType type)
 {
     if (type.QualifiedName.IsEmpty)
         Traverse(type.Content);
     else
         AddLeaf(SimpleTypeStructureNodeType.NamedType, type);
 }
开发者ID:sergey-steinvil,项目名称:xsddoc,代码行数:7,代码来源:SimpleTypeStructureBuilder.cs

示例4: Type

        /// <summary>
        /// Create an XmlQueryType from an Xsd simple type (where variety can be Atomic, List, or Union).
        /// </summary>
        /// <param name="schemaType">the simple Xsd schema type of the atomic value</param>
        /// <param name="isStrict">true if the dynamic type is guaranteed to match the static type exactly</param>
        /// <returns>the atomic value type</returns>
        public static XmlQueryType Type(XmlSchemaSimpleType schemaType, bool isStrict) {
            if (schemaType.Datatype.Variety == XmlSchemaDatatypeVariety.Atomic) {
                // We must special-case xs:anySimpleType because it is broken in Xsd and is sometimes treated as
                // an atomic value and sometimes as a list value.  In XQuery, it always maps to xdt:anyAtomicType*.
                if (schemaType == DatatypeImplementation.AnySimpleType)
                    return AnyAtomicTypeS;

                return ItemType.Create(schemaType, isStrict);
            }

            // Skip restrictions. It is safe to do that because this is a list or union, so it's not a build in type
            while (schemaType.DerivedBy == XmlSchemaDerivationMethod.Restriction)
                schemaType = (XmlSchemaSimpleType) schemaType.BaseXmlSchemaType;

            // Convert Xsd list
            if (schemaType.DerivedBy == XmlSchemaDerivationMethod.List)
                return PrimeProduct(Type(((XmlSchemaSimpleTypeList) schemaType.Content).BaseItemType, isStrict), XmlQueryCardinality.ZeroOrMore);

            // Convert Xsd union
            Debug.Assert(schemaType.DerivedBy == XmlSchemaDerivationMethod.Union);
            XmlSchemaSimpleType[] baseMemberTypes = ((XmlSchemaSimpleTypeUnion) schemaType.Content).BaseMemberTypes;
            XmlQueryType[] queryMemberTypes = new XmlQueryType[baseMemberTypes.Length];

            for (int i = 0; i < baseMemberTypes.Length; i++)
                queryMemberTypes[i] = Type(baseMemberTypes[i], isStrict);

            return Choice(queryMemberTypes);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:34,代码来源:XmlQueryTypeFactory.cs

示例5: CreateGuidType

        private XmlSchemaSimpleType CreateGuidType()
        {
            var type = new XmlSchemaSimpleType { Name = "Guid" };

            var restriction = new XmlSchemaSimpleTypeRestriction { BaseType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String) };
            restriction.Facets.Add(new XmlSchemaPatternFacet
            {
                Value =
                    @"[{(]?[0-9A-Fa-f]{8}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{12}[})]?|([!$])(\(var|\(loc|\(wix)\.[_A-Za-z][0-9A-Za-z_.]*\)"
            });
            type.Content = restriction;
            return type;
        }
开发者ID:kayanme,项目名称:Dataspace,代码行数:13,代码来源:DataSchemaBuilder.cs

示例6: FixtureInit

        public override void FixtureInit()
        {
            XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
            schemas.Add(SchemaCompletion);
            XmlSchemaCompletion xsdSchemaCompletionData = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
            schemas.Add(xsdSchemaCompletionData);

            string xml = GetSchema();
            int index = xml.IndexOf("type=\"dir\"/>");
            index = xml.IndexOf("dir", index);
            XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
            schemaSimpleType = (XmlSchemaSimpleType)schemaDefinition.GetSelectedSchemaObject(xml, index);
        }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:13,代码来源:AttributeTypeSelectedTestFixture.cs

示例7: FixtureInit

        public override void FixtureInit()
        {
            XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
            schemas.Add(SchemaCompletionData);
            XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
            schemas.Add(xsdSchemaCompletionData);
            XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty);

            string xml = GetSchema();
            int index = xml.IndexOf("type=\"dir\"/>");
            index = xml.IndexOf("dir", index);
            schemaSimpleType = (XmlSchemaSimpleType)XmlView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
        }
开发者ID:BackupTheBerlios,项目名称:nantgui,代码行数:13,代码来源:AttributeTypeSelectedTestFixture.cs

示例8: Visit

        protected override void Visit(XmlSchemaSimpleType type)
        {
            if (type.QualifiedName.IsEmpty)
                base.Visit(type);
            else
            {
                if (!AddUsage(type))
                    return;

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

示例9: ResolveType

        public static XmlSchemaSimpleType ResolveType(this XmlSchemaSet schemaSet, XmlSchemaSimpleType type, XmlQualifiedName typeName)
        {
            if (type != null)
                return type;

            var resolvedType = schemaSet.GlobalTypes[typeName] as XmlSchemaSimpleType;
            if (resolvedType != null)
                return resolvedType;

            var builtInSimpleType = XmlSchemaType.GetBuiltInSimpleType(typeName);
            if (builtInSimpleType != null)
                return builtInSimpleType;

            return null;
        }
开发者ID:sergey-steinvil,项目名称:xsddoc,代码行数:15,代码来源:XmlSchemaSetExtensions.cs

示例10: GetDataTypeSource

 private TypeDesc GetDataTypeSource(XmlSchemaSimpleType dataType)
 {
     if ((dataType.Name != null) && (dataType.Name.Length != 0))
     {
         TypeDesc typeDesc = base.Scope.GetTypeDesc(dataType);
         if (typeDesc != null)
         {
             return typeDesc;
         }
     }
     if (!dataType.DerivedFrom.IsEmpty)
     {
         return this.GetDataTypeSource(this.FindDataType(dataType.DerivedFrom));
     }
     return base.Scope.GetTypeDesc(typeof(string));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:SoapSchemaImporter.cs

示例11: SimpleType

 internal SimpleType(XmlSchemaSimpleType node)
 {
     this.name = "";
     this.length = -1;
     this.minLength = -1;
     this.maxLength = -1;
     this.pattern = "";
     this.ns = "";
     this.maxExclusive = "";
     this.maxInclusive = "";
     this.minExclusive = "";
     this.minInclusive = "";
     this.enumeration = "";
     this.name = node.Name;
     this.ns = (node.QualifiedName != null) ? node.QualifiedName.Namespace : "";
     this.LoadTypeValues(node);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:SimpleType.cs

示例12: AddNonXsdPrimitive

 private static void AddNonXsdPrimitive(Type type, string dataTypeName, string ns, string formatterName, XmlQualifiedName baseTypeName, XmlSchemaFacet[] facets, TypeFlags flags)
 {
     XmlSchemaSimpleType dataType = new XmlSchemaSimpleType {
         Name = dataTypeName
     };
     XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
         BaseTypeName = baseTypeName
     };
     foreach (XmlSchemaFacet facet in facets)
     {
         restriction.Facets.Add(facet);
     }
     dataType.Content = restriction;
     TypeDesc desc = new TypeDesc(type, false, dataType, formatterName, flags);
     if (primitiveTypes[type] == null)
     {
         primitiveTypes.Add(type, desc);
     }
     primitiveDataTypes.Add(dataType, desc);
     primitiveNames.Add(dataTypeName, ns, desc);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:TypeScope.cs

示例13: CreateProtoSimpleType

 string CreateProtoSimpleType(XmlSchemaSimpleType simpleType) {
     if (simpleType.QualifiedName.Namespace == XmlSchema.Namespace) {
         return CreateProtoXsdType(simpleType.QualifiedName.Name);
     } else if ((simpleType.Content as XmlSchemaSimpleTypeRestriction) != null) {
         var facets = (simpleType.Content as XmlSchemaSimpleTypeRestriction).Facets.OfType<XmlSchemaFacet>();
         foreach (var facet in facets) {
             if ((facet as XmlSchemaEnumerationFacet) != null) {
                 return (facet as XmlSchemaEnumerationFacet).Value;
             } else if ((facet as XmlSchemaMinInclusiveFacet) != null) {
                 return (facet as XmlSchemaMinInclusiveFacet).Value;
             } else if ((facet as XmlSchemaMaxLengthFacet) != null) {
                 return (facet as XmlSchemaMaxLengthFacet).Value;
             }
         }
         throw new Exception("not implemented");
     } else if ((simpleType.Content as XmlSchemaSimpleTypeUnion) != null) {
         return CreateProtoSimpleType((simpleType.Content as XmlSchemaSimpleTypeUnion).BaseMemberTypes.First());
     } else {
         throw new Exception("not implemented");
     }
 }
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:21,代码来源:XmlParser.cs

示例14: GetSimpleType

        /// <summary>
        ///     Returns a SimpleType restricted by the datatype only
        /// </summary>
        public override XmlSchemaSimpleType GetSimpleType(string attributeDataType)
        {
            var retVal = new XmlSchemaSimpleType();

            // <xs:restriction base="<whatever xs:datatype is required>" />
            var dataTypeRestriction = new XmlSchemaSimpleTypeRestriction
            {
                BaseTypeName = new XmlQualifiedName(attributeDataType)
            };
            retVal.Content = dataTypeRestriction;

            //  if the property type is an enum then add an enumeration facet to the simple type
            if (Property.PropertyType.IsEnum)
            {
                // <xs:enumeration value="123" />
                foreach (var enumValue in Enum.GetNames(Property.PropertyType))
                {
                    var enumFacet = new XmlSchemaEnumerationFacet { Value = enumValue };
                    dataTypeRestriction.Facets.Add(enumFacet);
                }
            }

            return retVal;
        }
开发者ID:flcdrg,项目名称:XSDExtractor,代码行数:27,代码来源:NoValidatorParser.cs

示例15: SetAttributeType

 internal void SetAttributeType(XmlSchemaSimpleType value) { 
     attributeType = value;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:3,代码来源:XmlSchemaAttribute.cs


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