Esempio n. 1
0
            internal static UInt32 GetInlineField(byte *pFields, EETypeOptionalFieldTag eTag, UInt32 uiDefaultValue)
            {
                if (pFields == null)
                {
                    return(uiDefaultValue);
                }

                bool isLastField = false;

                while (!isLastField)
                {
                    byte fieldHeader = NativePrimitiveDecoder.ReadUInt8(ref pFields);
                    isLastField = (fieldHeader & 0x80) != 0;
                    EETypeOptionalFieldTag eCurrentTag = (EETypeOptionalFieldTag)(fieldHeader & 0x7f);
                    UInt32 uiCurrentValue = NativePrimitiveDecoder.DecodeUnsigned(ref pFields);

                    // If we found a tag match return the current value.
                    if (eCurrentTag == eTag)
                    {
                        return(uiCurrentValue);
                    }
                }

                // Reached end of stream without getting a match. Field is not present so return default value.
                return(uiDefaultValue);
            }
Esempio n. 2
0
        internal OptionalFieldsRuntimeBuilder(byte *pInitializeFromOptionalFields = null)
        {
            if (pInitializeFromOptionalFields == null)
            {
                return;
            }

            bool isLastField = false;

            while (!isLastField)
            {
                byte fieldHeader = NativePrimitiveDecoder.ReadUInt8(ref pInitializeFromOptionalFields);
                isLastField = (fieldHeader & 0x80) != 0;
                EETypeOptionalFieldTag eCurrentTag = (EETypeOptionalFieldTag)(fieldHeader & 0x7f);
                UInt32 uiCurrentValue = NativePrimitiveDecoder.DecodeUnsigned(ref pInitializeFromOptionalFields);

                _rgFields[(int)eCurrentTag].m_fPresent = true;
                _rgFields[(int)eCurrentTag].m_uiValue  = uiCurrentValue;
            }
        }