public void VisitReadTwoDimArray(string variable, string reader, TwoDimArrayTypeNode node, TextBuilder builder) { builder.WriteLine("int size0 = {0}.ReadInt32();", reader); builder.WriteLine("{0} = new {1}(size0);", variable, node.TypeName); builder.WriteLine("for(int i = 0; i < size0; ++i)"); builder.LeftPar(); builder.Indent(); builder.WriteLine("int size1 = {0}.ReadInt32();", reader); builder.WriteLine("{0}[i] = new {1}[size1];", variable, node.ParameterNodes[0].TypeName); builder.WriteLine("for(int j = 0; j < size1; ++j)"); builder.LeftPar(); builder.Indent(); string target = variable + "[i, j]"; builder.WriteIndents(); builder.Write(target + " = "); VisitDeserialization(target, reader, node.Serialize, builder); builder.Write(";"); builder.NextLine(); builder.UnIndent(); builder.RightPar(); builder.UnIndent(); builder.RightPar(); }
public void VisitWriteTwoDimArray(string variable, string writer, TwoDimArrayTypeNode node, TextBuilder builder) { builder.WriteLine("int size0 = {0}.Length;", variable); builder.WriteLine("{0}.Write(size0);", writer); builder.WriteLine("for(int i = 0; i < size0; ++i)"); builder.LeftPar(); builder.Indent(); builder.WriteLine("int size1 = {0}[i] != null ? {0}[i].Count : 0;", variable); builder.WriteLine("{0}.Write(size1);", writer); builder.WriteLine("for(int j = 0; j < size1; ++j)"); builder.LeftPar(); builder.Indent(); builder.WriteIndents(); VisitSerialization(variable + "[i, j]", writer, node.Serialize, builder); builder.Write(";"); builder.NextLine(); builder.UnIndent(); builder.RightPar(); builder.UnIndent(); builder.RightPar(); }