ProtocolBuffers.FieldCode.GenerateFieldTypeReaderPrimitive C# (CSharp) Method

GenerateFieldTypeReaderPrimitive() static private method

static private GenerateFieldTypeReaderPrimitive ( Field f, string stream, string instance ) : string
f Field
stream string
instance string
return string
        static string GenerateFieldTypeReaderPrimitive(Field f, string stream, string instance)
        {
            switch (f.ProtoType) {
            case ProtoTypes.Double:
                return "br.ReadDouble ()";
            case ProtoTypes.Float:
                return "br.ReadSingle ()";
            case ProtoTypes.Fixed32:
                return "br.ReadUInt32 ()";
            case ProtoTypes.Fixed64:
                return "br.ReadUInt64 ()";
            case ProtoTypes.Sfixed32:
                return "br.ReadInt32 ()";
            case ProtoTypes.Sfixed64:
                return "br.ReadInt64 ()";
            case ProtoTypes.Int32:
                return "(int)ProtocolParser.ReadUInt32(" + stream + ")";
            case ProtoTypes.Int64:
                return "(long)ProtocolParser.ReadUInt64(" + stream + ")";
            case ProtoTypes.Uint32:
                return "ProtocolParser.ReadUInt32(" + stream + ")";
            case ProtoTypes.Uint64:
                return "ProtocolParser.ReadUInt64(" + stream + ");";
            case ProtoTypes.Sint32:
                return "ProtocolParser.ReadSInt32(" + stream + ");";
            case ProtoTypes.Sint64:
                return "ProtocolParser.ReadSInt64(" + stream + ");";
            case ProtoTypes.Bool:
                return "ProtocolParser.ReadBool(" + stream + ")";
            case ProtoTypes.String:
                return "ProtocolParser.ReadString(" + stream + ")";
            case ProtoTypes.Bytes:
                return "ProtocolParser.ReadBytes(" + stream + ")";
            case ProtoTypes.Enum:
                return "(" + f.PropertyItemType + ")ProtocolParser.ReadUInt32(" + stream + ")";
            case ProtoTypes.Message:
                if (f.Rule == FieldRule.Repeated)
                    return f.FullPath + ".Deserialize(ProtocolParser.ReadBytes(" + stream + "))";
                else {
                    if (instance == null)
                        return f.FullPath + ".Deserialize(ProtocolParser.ReadBytes(" + stream + "))";
                    else
                        return f.FullPath + ".Deserialize(ProtocolParser.ReadBytes(" + stream + "), " + instance + ")";
                }
            default:
                throw new NotImplementedException ();
            }
        }