System.Xml.Serialization.TypeScope.GetTypeDesc C# (CSharp) Method

GetTypeDesc() private method

private GetTypeDesc ( Type type ) : TypeDesc
type System.Type
return TypeDesc
        internal TypeDesc GetTypeDesc(Type type)
        {
            return GetTypeDesc(type, null, true, true);
        }

Same methods

TypeScope::GetTypeDesc ( Type type, MemberInfo source ) : TypeDesc
TypeScope::GetTypeDesc ( Type type, MemberInfo source, bool directReference ) : TypeDesc
TypeScope::GetTypeDesc ( Type type, MemberInfo source, bool directReference, bool throwOnError ) : TypeDesc
TypeScope::GetTypeDesc ( XmlSchemaSimpleType dataType ) : TypeDesc
TypeScope::GetTypeDesc ( string name, string ns ) : TypeDesc
TypeScope::GetTypeDesc ( string name, string ns, TypeFlags flags ) : TypeDesc

Usage Example

Example #1
0
        private string WriteTypeInfo(TypeScope scope, TypeDesc typeDesc, Type type)
        {
            this.InitTheFirstTime();
            string cSharpName = typeDesc.CSharpName;
            string str2       = (string)this.reflectionVariables[cSharpName];

            if (str2 == null)
            {
                if (type.IsArray)
                {
                    str2 = this.GenerateVariableName("array", typeDesc.CSharpName);
                    TypeDesc arrayElementTypeDesc = typeDesc.ArrayElementTypeDesc;
                    if (arrayElementTypeDesc.UseReflection)
                    {
                        string str3 = this.WriteTypeInfo(scope, arrayElementTypeDesc, scope.GetTypeFromTypeDesc(arrayElementTypeDesc));
                        this.writer.WriteLine("static " + typeof(Type).FullName + " " + str2 + " = " + str3 + ".MakeArrayType();");
                    }
                    else
                    {
                        string str4 = this.WriteAssemblyInfo(type);
                        this.writer.Write("static " + typeof(Type).FullName + " " + str2 + " = " + str4 + ".GetType(");
                        this.WriteQuotedCSharpString(type.FullName);
                        this.writer.WriteLine(");");
                    }
                }
                else
                {
                    str2 = this.GenerateVariableName("type", typeDesc.CSharpName);
                    Type underlyingType = Nullable.GetUnderlyingType(type);
                    if (underlyingType != null)
                    {
                        string str5 = this.WriteTypeInfo(scope, scope.GetTypeDesc(underlyingType), underlyingType);
                        this.writer.WriteLine("static " + typeof(Type).FullName + " " + str2 + " = typeof(System.Nullable<>).MakeGenericType(new " + typeof(Type).FullName + "[] {" + str5 + "});");
                    }
                    else
                    {
                        string str6 = this.WriteAssemblyInfo(type);
                        this.writer.Write("static " + typeof(Type).FullName + " " + str2 + " = " + str6 + ".GetType(");
                        this.WriteQuotedCSharpString(type.FullName);
                        this.writer.WriteLine(");");
                    }
                }
                this.reflectionVariables.Add(cSharpName, str2);
                TypeMapping typeMappingFromTypeDesc = scope.GetTypeMappingFromTypeDesc(typeDesc);
                if (typeMappingFromTypeDesc != null)
                {
                    this.WriteMappingInfo(typeMappingFromTypeDesc, str2, type);
                }
                if (typeDesc.IsCollection || typeDesc.IsEnumerable)
                {
                    TypeDesc desc2 = typeDesc.ArrayElementTypeDesc;
                    if (desc2.UseReflection)
                    {
                        this.WriteTypeInfo(scope, desc2, scope.GetTypeFromTypeDesc(desc2));
                    }
                    this.WriteCollectionInfo(str2, typeDesc, type);
                }
            }
            return(str2);
        }
All Usage Examples Of System.Xml.Serialization.TypeScope::GetTypeDesc