Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteHashtable()

string System.Xml.Serialization.XmlSerializationReaderCodeGen.WriteHashtable ( EnumMapping mapping,
string typeName )
inlineprivate

Definition at line 932 of file XmlSerializationReaderCodeGen.cs.

933 {
934 CodeIdentifier.CheckValidIdentifier(typeName);
935 string text = MakeUnique(mapping, typeName + "Values");
936 if (text == null)
937 {
938 return CodeIdentifier.GetCSharpName(typeName);
939 }
940 string s = MakeUnique(mapping, "_" + text);
941 text = CodeIdentifier.GetCSharpName(text);
942 base.Writer.WriteLine();
943 base.Writer.Write(typeof(Hashtable).FullName);
944 base.Writer.Write(" ");
945 base.Writer.Write(s);
946 base.Writer.WriteLine(";");
947 base.Writer.WriteLine();
948 base.Writer.Write("internal ");
949 base.Writer.Write(typeof(Hashtable).FullName);
950 base.Writer.Write(" ");
951 base.Writer.Write(text);
952 base.Writer.WriteLine(" {");
953 base.Writer.Indent++;
954 base.Writer.WriteLine("get {");
955 base.Writer.Indent++;
956 base.Writer.Write("if ((object)");
957 base.Writer.Write(s);
958 base.Writer.WriteLine(" == null) {");
959 base.Writer.Indent++;
960 base.Writer.Write(typeof(Hashtable).FullName);
961 base.Writer.Write(" h = new ");
962 base.Writer.Write(typeof(Hashtable).FullName);
963 base.Writer.WriteLine("();");
964 ConstantMapping[] constants = mapping.Constants;
965 for (int i = 0; i < constants.Length; i++)
966 {
967 base.Writer.Write("h.Add(");
969 if (!mapping.TypeDesc.UseReflection)
970 {
971 base.Writer.Write(", (long)");
972 base.Writer.Write(mapping.TypeDesc.CSharpName);
973 base.Writer.Write(".@");
974 CodeIdentifier.CheckValidIdentifier(constants[i].Name);
975 base.Writer.Write(constants[i].Name);
976 }
977 else
978 {
979 base.Writer.Write(", ");
980 IndentedWriter writer = base.Writer;
983 handler.AppendFormatted(constants[i].Value);
984 handler.AppendLiteral("L");
985 writer.Write(string.Create(invariantCulture, ref handler));
986 }
987 base.Writer.WriteLine(");");
988 }
989 base.Writer.Write(s);
990 base.Writer.WriteLine(" = h;");
991 base.Writer.Indent--;
992 base.Writer.WriteLine("}");
993 base.Writer.Write("return ");
994 base.Writer.Write(s);
995 base.Writer.WriteLine(";");
996 base.Writer.Indent--;
997 base.Writer.WriteLine("}");
998 base.Writer.Indent--;
999 base.Writer.WriteLine("}");
1000 return text;
1001 }
static CultureInfo InvariantCulture

References System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(), System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendLiteral(), System.Xml.Serialization.CodeIdentifier.CheckValidIdentifier(), System.IO.Create, System.Xml.Dictionary, System.FullName, System.Xml.Serialization.CodeIdentifier.GetCSharpName(), System.Globalization.CultureInfo.InvariantCulture, System.Xml.Serialization.XmlSerializationReaderCodeGen.MakeUnique(), System.Xml.Name, System.s, System.text, System.Xml.Serialization.XmlSerializationCodeGen.WriteQuotedCSharpString(), and System.writer.

Referenced by System.Xml.Serialization.XmlSerializationReaderCodeGen.WriteEnumMethod().