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


C# Serialization.TypeDesc类代码示例

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


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

示例1: 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

示例2: FieldModel

 internal FieldModel(string name, Type fieldType, TypeDesc fieldTypeDesc, bool checkSpecified, bool checkShouldPersist, bool readOnly)
 {
     this.fieldTypeDesc = fieldTypeDesc;
     this.name = name;
     this.fieldType = fieldType;
     this.checkSpecified = checkSpecified ? SpecifiedAccessor.ReadWrite : SpecifiedAccessor.None;
     this.checkShouldPersist = checkShouldPersist;
     this.readOnly = readOnly;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:FieldModel.cs

示例3: TypeDesc

 public TypeDesc(string name, string fullName, TypeKind kind, TypeDesc baseTypeDesc, TypeFlags flags) {
     this.name = name.Replace('+', '.');
     this.fullName = fullName.Replace('+', '.');
     this.kind = kind;
     if (baseTypeDesc != null) {
         this.baseTypeDesc = baseTypeDesc;
     }
     this.flags = flags;
     this.isXsdType = kind == TypeKind.Primitive;
 }
开发者ID:ArildF,项目名称:masters,代码行数:10,代码来源:types.cs

示例4: GetStringForArrayMember

 internal string GetStringForArrayMember(string arrayName, string subscript, TypeDesc arrayTypeDesc)
 {
     if (!arrayTypeDesc.UseReflection)
     {
         return (arrayName + "[" + subscript + "]");
     }
     string typeFullName = arrayTypeDesc.IsCollection ? arrayTypeDesc.CSharpName : typeof(Array).FullName;
     string reflectionVariable = this.GetReflectionVariable(typeFullName, "0");
     return (reflectionVariable + "[" + arrayName + ", " + subscript + "]");
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ReflectionAwareCodeGen.cs

示例5: XmlSerializationCodeGen

 internal XmlSerializationCodeGen(IndentedWriter writer, TypeScope[] scopes, string access, string className) {
     this.writer = writer;
     this.scopes = scopes;
     if (scopes.Length > 0) {
         stringTypeDesc = scopes[0].GetTypeDesc(typeof(string));
         qnameTypeDesc = scopes[0].GetTypeDesc(typeof(XmlQualifiedName));
     }
     this.raCodeGen = new ReflectionAwareCodeGen(writer);
     this.className = className;
     this.access = access;
 }
开发者ID:uQr,项目名称:referencesource,代码行数:11,代码来源:XmlSerializationGeneratedCode.cs

示例6: XmlSerializationILGen

 internal XmlSerializationILGen(TypeScope[] scopes, string access, string className) {
     this.scopes = scopes;
     if (scopes.Length > 0) {
         stringTypeDesc = scopes[0].GetTypeDesc(typeof(string));
         qnameTypeDesc = scopes[0].GetTypeDesc(typeof(XmlQualifiedName));
     }
     this.raCodeGen = new ReflectionAwareILGen();
     this.className = className;
     System.Diagnostics.Debug.Assert(access == "public");
     this.typeAttributes = TypeAttributes.Public;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:11,代码来源:XmlSerializationILGen.cs

示例7: GetNullableType

 private string GetNullableType(TypeDesc td)
 {
     if (td.IsMappedType || (!td.IsValueType && (base.Elements[0].IsSoap || (td.ArrayElementTypeDesc == null))))
     {
         return td.FullName;
     }
     if (td.ArrayElementTypeDesc != null)
     {
         return (this.GetNullableType(td.ArrayElementTypeDesc) + "[]");
     }
     return ("System.Nullable`1[" + td.FullName + "]");
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:MemberMapping.cs

示例8: AddElementMetadata

 private void AddElementMetadata(CodeAttributeDeclarationCollection metadata, string elementName, TypeDesc typeDesc, bool isNullable)
 {
     CodeAttributeDeclaration declaration = new CodeAttributeDeclaration(typeof(SoapElementAttribute).FullName);
     if (elementName != null)
     {
         declaration.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(elementName)));
     }
     if ((typeDesc != null) && typeDesc.IsAmbiguousDataType)
     {
         declaration.Arguments.Add(new CodeAttributeArgument("DataType", new CodePrimitiveExpression(typeDesc.DataType.Name)));
     }
     if (isNullable)
     {
         declaration.Arguments.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression(true)));
     }
     metadata.Add(declaration);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:SoapCodeExporter.cs

示例9: 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

示例10: WriteArrayLocalDecl

 void WriteArrayLocalDecl(string typeName, string variableName, string initValue, TypeDesc arrayTypeDesc) {
     RaCodeGen.WriteArrayLocalDecl(typeName,  variableName,  initValue,  arrayTypeDesc);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:3,代码来源:XmlSerializationWriter.cs

示例11: WriteArrayItems

        void WriteArrayItems(ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc arrayTypeDesc, string arrayName, string choiceName) {
            TypeDesc arrayElementTypeDesc = arrayTypeDesc.ArrayElementTypeDesc;

            if (arrayTypeDesc.IsEnumerable) {
                Writer.Write(typeof(IEnumerator).FullName);
                Writer.Write(" e = ");
                if (arrayTypeDesc.IsPrivateImplementation) {
                    Writer.Write("((");
                    Writer.Write(typeof(IEnumerable).FullName);
                    Writer.Write(")");
                    Writer.Write(arrayName);
                    Writer.WriteLine(").GetEnumerator();");
                }
                else if(arrayTypeDesc.IsGenericInterface) {
                    if (arrayTypeDesc.UseReflection) {
                        // we use wildcard method name for generic GetEnumerator method, so we cannot use GetStringForMethodInvoke call here
                        Writer.Write("(");
                        Writer.Write(typeof(IEnumerator).FullName);
                        Writer.Write(")");
                        Writer.Write(RaCodeGen.GetReflectionVariable(arrayTypeDesc.CSharpName, "System.Collections.Generic.IEnumerable*"));
                        Writer.Write(".Invoke(");
                        Writer.Write(arrayName);
                        Writer.WriteLine(", new object[0]);");
                    }
                    else {
                        Writer.Write("((System.Collections.Generic.IEnumerable<");
                        Writer.Write(arrayElementTypeDesc.CSharpName);
                        Writer.Write(">)");
                        Writer.Write(arrayName);
                        Writer.WriteLine(").GetEnumerator();");
                    }
                }
                else {
                    if (arrayTypeDesc.UseReflection) {
                        Writer.Write("(");
                        Writer.Write(typeof(IEnumerator).FullName);
                        Writer.Write(")");
                    }
                    Writer.Write(RaCodeGen.GetStringForMethodInvoke(arrayName, arrayTypeDesc.CSharpName, "GetEnumerator", arrayTypeDesc.UseReflection));
                    Writer.WriteLine(";");
                }
                Writer.WriteLine("if (e != null)");
                Writer.WriteLine("while (e.MoveNext()) {");
                Writer.Indent++;
                string arrayTypeFullName = arrayElementTypeDesc.CSharpName;
                WriteLocalDecl(arrayTypeFullName, arrayName+"i", "e.Current", arrayElementTypeDesc.UseReflection);
                WriteElements(arrayName + "i", choiceName + "i", elements, text, choice, arrayName + "a", true, true);
            }
            else {
                Writer.Write("for (int i");
                Writer.Write(arrayName);
                Writer.Write(" = 0; i");
                Writer.Write(arrayName);
                Writer.Write(" < ");
                if (arrayTypeDesc.IsArray) {
                    Writer.Write(arrayName);
                    Writer.Write(".Length");
                }
                else {
                    Writer.Write("((");
                    Writer.Write(typeof(ICollection).FullName);
                    Writer.Write(")");
                    Writer.Write(arrayName);
                    Writer.Write(").Count");
                }
                Writer.Write("; i");
                Writer.Write(arrayName);
                Writer.WriteLine("++) {");
                Writer.Indent++;
                int count = elements.Length + (text == null ? 0 : 1);
                if (count > 1) {
                    string arrayTypeFullName = arrayElementTypeDesc.CSharpName;
                    WriteLocalDecl(arrayTypeFullName, arrayName+"i", RaCodeGen.GetStringForArrayMember(arrayName, "i"+arrayName, arrayTypeDesc), arrayElementTypeDesc.UseReflection);
                    if (choice != null) {
                        string choiceFullName = choice.Mapping.TypeDesc.CSharpName;
                        WriteLocalDecl(choiceFullName, choiceName+"i", RaCodeGen.GetStringForArrayMember(choiceName, "i"+arrayName, choice.Mapping.TypeDesc), choice.Mapping.TypeDesc.UseReflection);
                    }
                    WriteElements(arrayName + "i", choiceName + "i", elements, text, choice, arrayName + "a", true, arrayElementTypeDesc.IsNullable);
                }
                else {
                    WriteElements(RaCodeGen.GetStringForArrayMember(arrayName , "i" + arrayName, arrayTypeDesc), elements, text, choice, arrayName + "a", true, arrayElementTypeDesc.IsNullable);
                }
            }
            Writer.Indent--;
            Writer.WriteLine("}");
        }
开发者ID:uQr,项目名称:referencesource,代码行数:86,代码来源:XmlSerializationWriter.cs

示例12: WriteChoiceTypeCheck

        void WriteChoiceTypeCheck(string source, string fullTypeName, bool useReflection, ChoiceIdentifierAccessor choice, string enumName, TypeDesc typeDesc) {

            Writer.Write("if (((object)");
            Writer.Write(source);
            Writer.Write(") != null && !(");
            WriteInstanceOf(source, fullTypeName, useReflection);
            Writer.Write(")) throw CreateMismatchChoiceException(");
            WriteQuotedCSharpString(typeDesc.FullName);
            Writer.Write(", ");
            WriteQuotedCSharpString(choice.MemberName);
            Writer.Write(", ");
            WriteQuotedCSharpString(enumName);
            Writer.WriteLine(");");
        }
开发者ID:uQr,项目名称:referencesource,代码行数:14,代码来源:XmlSerializationWriter.cs

示例13: WriteMember

 void WriteMember(string source, string choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc memberTypeDesc, bool writeAccessors) {
     if (memberTypeDesc.IsArrayLike && 
         !(elements.Length == 1 && elements[0].Mapping is ArrayMapping))
         WriteArray(source, choiceSource, elements, text, choice, memberTypeDesc);
     else
         WriteElements(source, choiceSource, elements, text, choice, "a", writeAccessors, memberTypeDesc.IsNullable);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:7,代码来源:XmlSerializationWriter.cs

示例14: WriteArray

        void WriteArray(string source, string choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc arrayTypeDesc) {
            if (elements.Length == 0 && text == null) return;
            Writer.WriteLine("{");
            Writer.Indent++;
            string arrayTypeName = arrayTypeDesc.CSharpName;
            WriteArrayLocalDecl(arrayTypeName, "a", source, arrayTypeDesc);
            if (arrayTypeDesc.IsNullable) {
                Writer.WriteLine("if (a != null) {");
                Writer.Indent++;
            }

            if (choice != null) {
                bool choiceUseReflection = choice.Mapping.TypeDesc.UseReflection;
                string choiceFullName = choice.Mapping.TypeDesc.CSharpName;
                WriteArrayLocalDecl(choiceFullName+"[]", "c", choiceSource, choice.Mapping.TypeDesc);
                // write check for the choice identifier array
                Writer.WriteLine("if (c == null || c.Length < a.Length) {");
                Writer.Indent++;
                Writer.Write("throw CreateInvalidChoiceIdentifierValueException(");
                WriteQuotedCSharpString(choice.Mapping.TypeDesc.FullName);
                Writer.Write(", ");
                WriteQuotedCSharpString(choice.MemberName);
                Writer.Write(");");
                Writer.Indent--;
                Writer.WriteLine("}");
            }

            WriteArrayItems(elements, text, choice, arrayTypeDesc, "a", "c");
            if (arrayTypeDesc.IsNullable) {
                Writer.Indent--;
                Writer.WriteLine("}");
            }
            Writer.Indent--;
            Writer.WriteLine("}");
        }
开发者ID:uQr,项目名称:referencesource,代码行数:35,代码来源:XmlSerializationWriter.cs

示例15: CanOptimizeWriteListSequence

        bool CanOptimizeWriteListSequence(TypeDesc listElementTypeDesc) {

            // check to see if we can write values of the attribute sequentially
            // currently we have only one data type (XmlQualifiedName) that we can not write "inline", 
            // because we need to output xmlns:qx="..." for each of the qnames

            return (listElementTypeDesc != null && listElementTypeDesc != QnameTypeDesc);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:XmlSerializationWriter.cs


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