public int CalculateSize() {
     int size = 0;
     if (KeyData.Length != 0) {
         size += 1 + CodedOutputStream.ComputeBytesSize(KeyData);
     }
     if (RollingStartIntervalNumber != 0) {
         size += 1 + CodedOutputStream.ComputeUInt32Size(RollingStartIntervalNumber);
     }
     if (RollingPeriod != 0) {
         size += 1 + CodedOutputStream.ComputeUInt32Size(RollingPeriod);
     }
     if (TransmissionRiskLevel != 0) {
         size += 1 + CodedOutputStream.ComputeInt32Size(TransmissionRiskLevel);
     }
     size += visitedCountries_.CalculateSize(_repeated_visitedCountries_codec);
     if (Origin.Length != 0) {
         size += 1 + CodedOutputStream.ComputeStringSize(Origin);
     }
     if (ReportType != global::Iks.Protobuf.EfgsReportType.Unknown) {
         size += 1 + CodedOutputStream.ComputeEnumSize((int) ReportType);
     }
     if (DaysSinceOnsetOfSymptoms != 0) {
         size += 1 + CodedOutputStream.ComputeSInt32Size(DaysSinceOnsetOfSymptoms);
     }
     if (_unknownFields != null) {
         size += _unknownFields.CalculateSize();
     }
     return size;
 }
        public int CalculateSize()
        {
            int size = 0;

            if (HasKeyData)
            {
                size += 1 + CodedOutputStream.ComputeBytesSize(KeyData);
            }
            if (HasTransmissionRiskLevel)
            {
                size += 1 + CodedOutputStream.ComputeInt32Size(TransmissionRiskLevel);
            }
            if (HasRollingStartIntervalNumber)
            {
                size += 1 + CodedOutputStream.ComputeInt32Size(RollingStartIntervalNumber);
            }
            if (HasRollingPeriod)
            {
                size += 1 + CodedOutputStream.ComputeInt32Size(RollingPeriod);
            }
            if (HasReportType)
            {
                size += 1 + CodedOutputStream.ComputeEnumSize((int)ReportType);
            }
            if (HasDaysSinceOnsetOfSymptoms)
            {
                size += 1 + CodedOutputStream.ComputeSInt32Size(DaysSinceOnsetOfSymptoms);
            }
            if (_unknownFields != null)
            {
                size += _unknownFields.CalculateSize();
            }
            return(size);
        }
        public int CalculateSize()
        {
            int num = 0;

            if (spell_ != null)
            {
                num += 1 + CodedOutputStream.ComputeMessageSize(Spell);
            }
            if (From != 0)
            {
                num += 1 + CodedOutputStream.ComputeEnumSize((int)From);
            }
            if (To != 0)
            {
                num += 1 + CodedOutputStream.ComputeEnumSize((int)To);
            }
            if (discardedBecauseHandWasFull_.HasValue)
            {
                num += _single_discardedBecauseHandWasFull_codec.CalculateSizeWithTag(DiscardedBecauseHandWasFull);
            }
            if (_unknownFields != null)
            {
                num += _unknownFields.CalculateSize();
            }
            return(num);
        }
        public int CalculateSize()
        {
            int num = 0;

            if (Result != 0)
            {
                num += 1 + CodedOutputStream.ComputeEnumSize((int)Result);
            }
            if (_unknownFields != null)
            {
                num += _unknownFields.CalculateSize();
            }
            return(num);
        }
Exemple #5
0
        public void TestNegativeEnumPackedArray()
        {
            int arraySize = 1 + (10 * 5);
            int msgSize   = 1 + 1 + arraySize;

            byte[]            bytes  = new byte[msgSize];
            CodedOutputStream output = new CodedOutputStream(bytes);
            // Length-delimited to show we want the packed representation
            uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited);

            output.WriteTag(tag);
            int size = 0;

            for (int i = 0; i >= -5; i--)
            {
                size += CodedOutputStream.ComputeEnumSize(i);
            }
            output.WriteRawVarint32((uint)size);
            for (int i = 0; i >= -5; i--)
            {
                output.WriteEnum(i);
            }
            Assert.AreEqual(0, output.SpaceLeft);

            CodedInputStream input = new CodedInputStream(bytes);

            tag = input.ReadTag();

            RepeatedField <SampleEnum> values = new RepeatedField <SampleEnum>();

            values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));

            Assert.AreEqual(6, values.Count);
            Assert.AreEqual(SampleEnum.None, values[0]);
            Assert.AreEqual(((SampleEnum)(-1)), values[1]);
            Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
            Assert.AreEqual(((SampleEnum)(-3)), values[3]);
            Assert.AreEqual(((SampleEnum)(-4)), values[4]);
            Assert.AreEqual(((SampleEnum)(-5)), values[5]);
        }
        public int CalculateSize()
        {
            int num = 0;

            if (EventType != 0)
            {
                num += 1 + CodedOutputStream.ComputeEnumSize((int)EventType);
            }
            if (EventId != 0)
            {
                num += 1 + CodedOutputStream.ComputeSInt32Size(EventId);
            }
            if (parentEventId_.HasValue)
            {
                num += _single_parentEventId_codec.CalculateSizeWithTag(ParentEventId);
            }
            if (Int1 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int1);
            }
            if (Int2 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int2);
            }
            if (Int3 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int3);
            }
            if (Int4 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int4);
            }
            if (Int5 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int5);
            }
            if (Int6 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int6);
            }
            if (Int7 != 0)
            {
                num += 1 + CodedOutputStream.ComputeInt32Size(Int7);
            }
            if (String1.Length != 0)
            {
                num += 1 + CodedOutputStream.ComputeStringSize(String1);
            }
            if (Bool1)
            {
                num += 2;
            }
            if (cellCoord1_ != null)
            {
                num += 1 + CodedOutputStream.ComputeMessageSize(CellCoord1);
            }
            if (cellCoord2_ != null)
            {
                num += 1 + CodedOutputStream.ComputeMessageSize(CellCoord2);
            }
            if (CompanionReserveState1 != 0)
            {
                num += 1 + CodedOutputStream.ComputeEnumSize((int)CompanionReserveState1);
            }
            if (CompanionReserveState2 != 0)
            {
                num += 2 + CodedOutputStream.ComputeEnumSize((int)CompanionReserveState2);
            }
            if (DamageReductionType1 != 0)
            {
                num += 2 + CodedOutputStream.ComputeEnumSize((int)DamageReductionType1);
            }
            if (FightResult1 != 0)
            {
                num += 2 + CodedOutputStream.ComputeEnumSize((int)FightResult1);
            }
            if (gameStatistics1_ != null)
            {
                num += 2 + CodedOutputStream.ComputeMessageSize(GameStatistics1);
            }
            if (TeamsScoreModificationReason1 != 0)
            {
                num += 2 + CodedOutputStream.ComputeEnumSize((int)TeamsScoreModificationReason1);
            }
            if (optInt1_.HasValue)
            {
                num += _single_optInt1_codec.CalculateSizeWithTag(OptInt1);
            }
            if (optInt2_.HasValue)
            {
                num += _single_optInt2_codec.CalculateSizeWithTag(OptInt2);
            }
            if (optInt3_.HasValue)
            {
                num += _single_optInt3_codec.CalculateSizeWithTag(OptInt3);
            }
            if (optInt4_.HasValue)
            {
                num += _single_optInt4_codec.CalculateSizeWithTag(OptInt4);
            }
            num += cellCoordList1_.CalculateSize(_repeated_cellCoordList1_codec);
            num += spellMovementList1_.CalculateSize(_repeated_spellMovementList1_codec);
            num += castTargetList1_.CalculateSize(_repeated_castTargetList1_codec);
            num += intList1_.CalculateSize(_repeated_intList1_codec);
            num += intList2_.CalculateSize(_repeated_intList2_codec);
            if (_unknownFields != null)
            {
                num += _unknownFields.CalculateSize();
            }
            return(num);
        }