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); }
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; } }