protected string GenSerializerStaticClassCodeByTemplate(Type type, Type[] refTypes, string contentRead, string contentWrite)
    {
        StringBuilder code = new StringBuilder(InitStringBuilderCapacity);

        GenHeaderComment(code);
        NamespaceUtility.GenUsingDirectives(code, refTypes, new [] { "System.IO" });

        code.Append(
            string.Format(
                "\n" +
                "public class {0}\n" +
                "{{\n" +
                "	public static void Read(BinaryReader o)\n"+
                "	{{\n"+
                "{1}" +
                "	}}\n"+
                "\n" +
                "	public static void Write(BinaryWriter o)\n"+
                "	{{\n"+
                "{2}" +
                "	}}\n"+
                "}}\n",
                SerializerFileName(type),
                contentRead,
                contentWrite
                ));

        return(code.ToString());
    }
    protected string GenSerializerClassCodeByTemplate(Type type, Type[] refTypes, string construction, string contentRead, string contentWrite)
    {
        StringBuilder code = new StringBuilder(InitStringBuilderCapacity);

        GenHeaderComment(code);
        NamespaceUtility.GenUsingDirectives(code, refTypes, new[] { "System.IO" });

        code.Append(
            string.Format(
                "\n" +
                "public class {0}\n" +
                "{{\n" +
                "	public static {1} Read(BinaryReader o)\n"+
                "	{{\n"+
                (
                    type.IsClass ?
                    "		if(o.ReadBoolean() == false)\n"+
                    "			return {4};\n":""
                ) +
                "		\n"+
                "		{1} d = {5};\n"+
                "{2}" +
                "		return d;\n"+
                "	}}\n"+
                "\n" +
                "	public static void Write(BinaryWriter o, {1} d)\n"+
                "	{{\n"+
                (
                    type.IsClass ?
                    "		o.Write(d != null);\n"+
                    "		if(d == null)\n"+
                    "			return;\n":""
                ) +
                "		\n"+
                "{3}" +
                "	}}\n"+
                "}}\n",
                SerializerFileName(type),
                TypeName(type),
                contentRead,
                contentWrite,
                DefaultValue(type),
                construction
                ));

        return(code.ToString());
    }