예제 #1
0
        public void Deserialize <TInput>(ref global::Hagar.Buffers.Reader <TInput> reader, global::Benchmarks.Models.IntClass instance)
        {
            uint fieldId = 0;

            while (true)
            {
                var header = reader.ReadFieldHeader();
                if (header.IsEndBaseOrEndObject)
                {
                    break;
                }

                fieldId += header.FieldIdDelta;
                switch ((fieldId))
                {
                case 0U:
                    instance.MyProperty1 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 1U:
                    instance.MyProperty2 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 2U:
                    instance.MyProperty3 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 3U:
                    instance.MyProperty4 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 4U:
                    instance.MyProperty5 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 5U:
                    instance.MyProperty6 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 6U:
                    instance.MyProperty7 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 7U:
                    instance.MyProperty8 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                case 8U:
                    instance.MyProperty9 = (int)global::Hagar.Codecs.Int32Codec.ReadValue(ref reader, header);
                    break;

                default:
                    reader.ConsumeUnknownField(header);
                    break;
                }
            }
        }
예제 #2
0
        public void DeserializeNew <TInput>(ref global::Hagar.Buffers.Reader <TInput> reader, global::Benchmarks.Models.IntClass instance)
        {
            int   id     = 0;
            Field header = default;

            while (true)
            {
                id = ReadHeader(ref reader, ref header, id);

                if (id == 0)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty1 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 1)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty2 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 2)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty3 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 3)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty4 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 4)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty5 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 5)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty6 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 6)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty7 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 7)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty8 = reader.ReadInt32(header.WireType);
                    id = ReadHeader(ref reader, ref header, id);
                }

                if (id == 8)
                {
                    ReferenceCodec.MarkValueField(reader.Session);
                    instance.MyProperty9 = reader.ReadInt32(header.WireType);
                    id = ReadHeaderExpectingEndBaseOrEndObject(ref reader, ref header, id);
                }

                if (id == -1)
                {
                    break;
                }

                reader.ConsumeUnknownField(header);
            }
        }