Exemplo n.º 1
0
        void IPinchable.Decode(IPinchDecoder decoder)
        {
            int remainingFields = decoder.OpenSequence();

            // Decode members for version 1:
            if (remainingFields >= 9)
            {
                _optPointer = (string)decoder.DecodeOptionalString(_optPointerProperties);
                _optScalar = (byte?)decoder.DecodeOptionalInt8(_optScalarProperties);
                _optStructure = (SmallStructure)decoder.DecodeOptionalStructure(SmallStructureFactory.Instance, _optStructureProperties);
                _removedOptPointer = (string)decoder.DecodeOptionalString(_removedOptPointerProperties);
                _removedOptScalar = (byte?)decoder.DecodeOptionalInt8(_removedOptScalarProperties);
                _removedOptStructure = (SmallStructure)decoder.DecodeOptionalStructure(SmallStructureFactory.Instance, _removedOptStructureProperties);
                _reqPointer = (string)decoder.DecodeRequiredString(_reqPointerProperties);
                _reqScalar = (byte)decoder.DecodeRequiredInt8(_reqScalarProperties);
                _reqStructure = (SmallStructure)decoder.DecodeRequiredStructure(SmallStructureFactory.Instance, _reqStructureProperties);

                remainingFields -= 9;
            }
            else
            {
                if (remainingFields != 0) throw new PinchInvalidCodingException();
            }

            if (remainingFields > 0)
            {
                OnAdditionalFutureFields(decoder);

                decoder.SkipFields(remainingFields);
            }

            decoder.CloseSequence();
        }
Exemplo n.º 2
0
 public ChoiceStructure(SmallStructure value)
 {
     _value = value;
     _valueKind = ChoiceStructureKind.Small;
 }
Exemplo n.º 3
0
        void IPinchable.Decode(IPinchDecoder decoder)
        {
            int remainingFields = decoder.OpenSequence();

            // Decode members for version 1:
            if (remainingFields >= 26)
            {
                _optBool = (bool?)decoder.DecodeOptionalBool(_optBoolProperties);
                _optBytes = (byte[])decoder.DecodeOptionalBytes(_optBytesProperties);
                _optDecimal = (decimal?)decoder.DecodeOptionalDecimal(_optDecimalProperties);
                _optEnumeration = (TypesEnumeration?)decoder.DecodeOptionalEnumeration(_optEnumerationProperties);
                _optFloat32 = (float?)decoder.DecodeOptionalFloat32(_optFloat32Properties);
                _optFloat64 = (double?)decoder.DecodeOptionalFloat64(_optFloat64Properties);
                _optInt16 = (short?)decoder.DecodeOptionalInt16(_optInt16Properties);
                _optInt32 = (int?)decoder.DecodeOptionalInt32(_optInt32Properties);
                _optInt64 = (long?)decoder.DecodeOptionalInt64(_optInt64Properties);
                _optInt8 = (byte?)decoder.DecodeOptionalInt8(_optInt8Properties);
                int optListOfEnumCount = decoder.OpenSequence();

                _optListOfEnum = new List<SmallStructure>();

                for (int i = 0; i < optListOfEnumCount; i++)
                {
                    _optListOfEnum.Add((SmallStructure)decoder.DecodeOptionalStructure(SmallStructureFactory.Instance, _optListOfEnumProperties));
                }

                decoder.CloseSequence();
                _optString = (string)decoder.DecodeOptionalString(_optStringProperties);
                _optStructure = (SmallStructure)decoder.DecodeOptionalStructure(SmallStructureFactory.Instance, _optStructureProperties);
                _reqBool = (bool)decoder.DecodeRequiredBool(_reqBoolProperties);
                _reqBytes = (byte[])decoder.DecodeRequiredBytes(_reqBytesProperties);
                _reqDecimal = (decimal)decoder.DecodeRequiredDecimal(_reqDecimalProperties);
                _reqEnumeration = (TypesEnumeration)decoder.DecodeRequiredEnumeration(_reqEnumerationProperties);
                _reqFloat32 = (float)decoder.DecodeRequiredFloat32(_reqFloat32Properties);
                _reqFloat64 = (double)decoder.DecodeRequiredFloat64(_reqFloat64Properties);
                _reqInt16 = (short)decoder.DecodeRequiredInt16(_reqInt16Properties);
                _reqInt32 = (int)decoder.DecodeRequiredInt32(_reqInt32Properties);
                _reqInt64 = (long)decoder.DecodeRequiredInt64(_reqInt64Properties);
                _reqInt8 = (byte)decoder.DecodeRequiredInt8(_reqInt8Properties);
                int reqListOfEnumCount = decoder.OpenSequence();

                _reqListOfEnum = new List<SmallStructure>();

                for (int i = 0; i < reqListOfEnumCount; i++)
                {
                    _reqListOfEnum.Add((SmallStructure)decoder.DecodeRequiredStructure(SmallStructureFactory.Instance, _reqListOfEnumProperties));
                }

                decoder.CloseSequence();
                _reqString = (string)decoder.DecodeRequiredString(_reqStringProperties);
                _reqStructure = (SmallStructure)decoder.DecodeRequiredStructure(SmallStructureFactory.Instance, _reqStructureProperties);

                remainingFields -= 26;
            }
            else
            {
                if (remainingFields != 0) throw new PinchInvalidCodingException();
            }

            if (remainingFields > 0)
            {
                OnAdditionalFutureFields(decoder);

                decoder.SkipFields(remainingFields);
            }

            decoder.CloseSequence();
        }