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


C# Schema.XmlSchemaType類代碼示例

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


XmlSchemaType類屬於System.Xml.Schema命名空間,在下文中一共展示了XmlSchemaType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsSpecialXmlType

 internal static bool IsSpecialXmlType(Type type, out XmlQualifiedName typeName, out XmlSchemaType xsdType, out bool hasRoot)
 {
     xsdType = null;
     hasRoot = true;
     if (type == Globals.TypeOfXmlElement || type == Globals.TypeOfXmlNodeArray)
     {
         string name = null;
         if (type == Globals.TypeOfXmlElement)
         {
             xsdType = CreateAnyElementType();
             name = "XmlElement";
             hasRoot = false;
         }
         else
         {
             xsdType = CreateAnyType();
             name = "ArrayOfXmlNode";
             hasRoot = true;
         }
         typeName = new XmlQualifiedName(name, DataContract.GetDefaultStableNamespace(type));
         return true;
     }
     typeName = null;
     return false;
 }
開發者ID:Profit0004,項目名稱:mono,代碼行數:25,代碼來源:SchemaExporter_mobile.cs

示例2: ImportSchemaType

        //public override string ImportSchemaType(
        //    string name, 
        //    string ns, 
        //    XmlSchemaObject context, 
        //    XmlSchemas schemas, 
        //    XmlSchemaImporter importer,
        //    CodeCompileUnit compileUnit, 
        //    CodeNamespace mainNamespace, 
        //    CodeGenerationOptions options, 
        //    CodeDomProvider codeProvider)
        //{

        //    XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) schemas.Find(new XmlQualifiedName(name, ns), typeof(XmlSchemaSimpleType));
        //    return ImportSchemaType(
        //        simpleType, 
        //        context, 
        //        schemas, 
        //        importer, 
        //        compileUnit, 
        //        mainNamespace, 
        //        options, 
        //        codeProvider);
        //}

        public override string ImportSchemaType(
            XmlSchemaType type, 
            XmlSchemaObject context, 
            XmlSchemas schemas, 
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit, 
            CodeNamespace mainNamespace, 
            CodeGenerationOptions options, 
            CodeDomProvider codeProvider)
        {

            XmlSchemaAnnotated annotatedType  = type as XmlSchemaAnnotated;
            if (annotatedType == null)
                return null;

            if (annotatedType.Annotation == null)
                return null;

            // create the comments and add them to the hash table under the namespace of the object
            CreateComments(annotatedType);

            //mainNamespace.Types.

            return null;

        }
開發者ID:nujmail,項目名稱:xsd-to-classes,代碼行數:50,代碼來源:AnnotationTypeExtension.cs

示例3: ImportSchemaType

		public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) {
			if (type == null) {
				return null;
			}

			if (importedTypes[type] != null) {
				mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataSet).Namespace));
				compileUnit.ReferencedAssemblies.Add("System.Data.dll");
				return (string)importedTypes[type];
			}
			if (!(context is XmlSchemaElement))
				return null;

			if (type is XmlSchemaComplexType) {
				XmlSchemaComplexType ct = (XmlSchemaComplexType)type;
				if (ct.Particle is XmlSchemaSequence) {
					XmlSchemaObjectCollection items = ((XmlSchemaSequence)ct.Particle).Items;
					if (items.Count == 2 && items[0] is XmlSchemaAny && items[1] is XmlSchemaAny) {
						XmlSchemaAny any0 = (XmlSchemaAny)items[0];
						XmlSchemaAny any1 = (XmlSchemaAny)items[1];
						if (any0.Namespace == XmlSchema.Namespace && any1.Namespace == "urn:schemas-microsoft-com:xml-diffgram-v1") {
							string typeName = typeof(DataTable).FullName;
							importedTypes.Add(type, typeName);
							mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataTable).Namespace));
							compileUnit.ReferencedAssemblies.Add("System.Data.dll");
							return typeName;
						}
					}
				}
			}
			return null;
		}
開發者ID:GodLesZ,項目名稱:svn-dump,代碼行數:32,代碼來源:DataTableSchemaImporterExtension.cs

示例4: TypeDesc

 internal TypeDesc(string name, string fullName, XmlSchemaType dataType, TypeKind kind, TypeDesc baseTypeDesc, TypeFlags flags, string formatterName)
 {
     this.name = name.Replace('+', '.');
     this.fullName = fullName.Replace('+', '.');
     this.kind = kind;
     this.baseTypeDesc = baseTypeDesc;
     this.flags = flags;
     this.isXsdType = kind == TypeKind.Primitive;
     if (this.isXsdType)
     {
         this.weight = 1;
     }
     else if (kind == TypeKind.Enum)
     {
         this.weight = 2;
     }
     else if (this.kind == TypeKind.Root)
     {
         this.weight = -1;
     }
     else
     {
         this.weight = (baseTypeDesc == null) ? 0 : (baseTypeDesc.Weight + 1);
     }
     this.dataType = dataType;
     this.formatterName = formatterName;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:27,代碼來源:TypeDesc.cs

示例5: XmlAtomicValue

        //-----------------------------------------------
        // XmlAtomicValue constructors and methods
        //-----------------------------------------------

        internal XmlAtomicValue(XmlSchemaType xmlType, bool value)
        {
            if (xmlType == null) throw new ArgumentNullException(nameof(xmlType));
            _xmlType = xmlType;
            _clrType = TypeCode.Boolean;
            _unionVal.boolVal = value;
        }
開發者ID:Corillian,項目名稱:corefx,代碼行數:11,代碼來源:XmlAtomicValue.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: Init

		private void Init (bool value, XmlSchemaType xmlType)
		{
			if (xmlType == null)
				throw new ArgumentNullException ("xmlType");
			xmlTypeCode = XmlTypeCode.Boolean;
			this.booleanValue = value;
			schemaType = xmlType;
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:8,代碼來源:XmlAtomicValue.cs

示例8: Init

		private void Init (byte [] value, XmlSchemaType xmlType)
		{
			if (xmlType == null)
				throw new ArgumentNullException ("xmlType");
			xmlTypeCode = XmlTypeCode.Base64Binary;
			this.bytesValue = value;
			schemaType = xmlType;
		}
開發者ID:nobled,項目名稱:mono,代碼行數:8,代碼來源:XmlAtomicValue.cs

示例9: CreateClassDeclaration

        internal static CodeTypeDeclaration CreateClassDeclaration(XmlSchemaType type)
        {
            string className = CodeIdentifier.MakeValid(type.QualifiedName.Name);
            CodeTypeDeclaration codeClass = new CodeTypeDeclaration(className);
            codeClass.TypeAttributes |= TypeAttributes.Public;

            return codeClass;
        }
開發者ID:nujmail,項目名稱:xsd-to-classes,代碼行數:8,代碼來源:codeDomHelper.cs

示例10: GetXmlTypeInfo

 internal static void GetXmlTypeInfo(Type type, out XmlQualifiedName stableName, out XmlSchemaType xsdType, out bool hasRoot)
 {
     if (IsSpecialXmlType(type, out stableName, out xsdType, out hasRoot))
         return;
     XmlSchemaSet schemas = null;
     InvokeSchemaProviderMethod(type, schemas, out stableName, out xsdType, out hasRoot);
     if (stableName.Name == null || stableName.Name.Length == 0)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.InvalidXmlDataContractName, DataContract.GetClrTypeFullName(type))));
 }
開發者ID:dotnet,項目名稱:corefx,代碼行數:9,代碼來源:SchemaExporter.cs

示例11: XmlAtomicValue

 internal XmlAtomicValue(XmlSchemaType xmlType, long value)
 {
     if (xmlType == null)
     {
         throw new ArgumentNullException("xmlType");
     }
     this.xmlType = xmlType;
     this.clrType = TypeCode.Int64;
     this.unionVal.i64Val = value;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:10,代碼來源:XmlAtomicValue.cs

示例12: GetXmlTypeInfo

 internal static void GetXmlTypeInfo(Type type, out XmlQualifiedName stableName, out XmlSchemaType xsdType, out bool hasRoot)
 {
     if (IsSpecialXmlType(type, out stableName, out xsdType, out hasRoot))
         return;
     XmlSchemaSet schemas = new XmlSchemaSet();
     schemas.XmlResolver = null;
     InvokeSchemaProviderMethod(type, schemas, out stableName, out xsdType, out hasRoot);
     if (stableName.Name == null || stableName.Name.Length == 0)
         throw Fx.Exception.AsError(new InvalidDataContractException(SR.InvalidXmlDataContractName(DataContract.GetClrTypeFullName(type))));
 }
開發者ID:nuxleus,項目名稱:WCFWeb,代碼行數:10,代碼來源:SchemaExporter.cs

示例13: CreateProtoAnyType

 XObject[] CreateProtoAnyType(XmlSchemaType schemaType) {
     if ((schemaType as XmlSchemaComplexType) != null) {
         return CreateProtoComplexType(schemaType as XmlSchemaComplexType);
     } else if ((schemaType as XmlSchemaSimpleType) != null) {
         var value = CreateProtoSimpleType(schemaType as XmlSchemaSimpleType);
         return new XObject[] { new XText(value) };
     } else {
         throw new Exception("invalid schema type");
     }
 }
開發者ID:zzilla,項目名稱:ONVIF-Device-Manager,代碼行數:10,代碼來源:XmlParser.cs

示例14: GetFacets

 private static CompiledFacets GetFacets(XmlSchemaType type)
 {
     CompiledFacets compiledFacets = new CompiledFacets(type.Datatype);
     XmlSchemaSimpleType simpleType = type as XmlSchemaSimpleType;
     
     if(simpleType != null)
     {
         compiledFacets.compileFacets(simpleType);
     }
     return compiledFacets;
 }
開發者ID:pusp,項目名稱:o2platform,代碼行數:11,代碼來源:ClrSimpleTypeInfo.cs

示例15: InvokeSchemaProviderMethod

        private static bool InvokeSchemaProviderMethod(Type clrType, XmlSchemaSet schemas, out XmlQualifiedName stableName, out XmlSchemaType xsdType, out bool hasRoot)
        {
            xsdType = null;
            hasRoot = true;
            object[] attrs = clrType.GetTypeInfo().GetCustomAttributes(Globals.TypeOfXmlSchemaProviderAttribute, false).ToArray();
            if (attrs == null || attrs.Length == 0)
            {
                stableName = DataContract.GetDefaultStableName(clrType);
                return false;
            }

            XmlSchemaProviderAttribute provider = (XmlSchemaProviderAttribute)attrs[0];
            if (provider.IsAny)
            {
                xsdType = CreateAnyElementType();
                hasRoot = false;
            }
            string methodName = provider.MethodName;
            if (methodName == null || methodName.Length == 0)
            {
                if (!provider.IsAny)
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.InvalidGetSchemaMethod, DataContract.GetClrTypeFullName(clrType))));
                stableName = DataContract.GetDefaultStableName(clrType);
            }
            else
            {
                MethodInfo getMethod = clrType.GetMethod(methodName,  /*BindingFlags.DeclaredOnly |*/ BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, new Type[] { typeof(XmlSchemaSet) });
                if (getMethod == null)
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.MissingGetSchemaMethod, DataContract.GetClrTypeFullName(clrType), methodName)));

                if (!(Globals.TypeOfXmlQualifiedName.IsAssignableFrom(getMethod.ReturnType)))
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.InvalidReturnTypeOnGetSchemaMethod, DataContract.GetClrTypeFullName(clrType), methodName, DataContract.GetClrTypeFullName(getMethod.ReturnType), DataContract.GetClrTypeFullName(Globals.TypeOfXmlQualifiedName))));

                object typeInfo = getMethod.Invoke(null, new object[] { schemas });

                if (provider.IsAny)
                {
                    if (typeInfo != null)
                        throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.InvalidNonNullReturnValueByIsAny, DataContract.GetClrTypeFullName(clrType), methodName)));
                    stableName = DataContract.GetDefaultStableName(clrType);
                }
                else if (typeInfo == null)
                {
                    xsdType = CreateAnyElementType();
                    hasRoot = false;
                    stableName = DataContract.GetDefaultStableName(clrType);
                }
                else
                {
                    stableName = (XmlQualifiedName)typeInfo;
                }
            }
            return true;
        }
開發者ID:dotnet,項目名稱:corefx,代碼行數:54,代碼來源:SchemaExporter.cs


注:本文中的System.Xml.Schema.XmlSchemaType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。