private ISFSArray DecodeSFSArray(ByteArray buffer) { //Discarded unreachable code: IL_00c1 ISFSArray iSFSArray = SFSArray.NewInstance(); SFSDataType sFSDataType = (SFSDataType)Convert.ToInt32(buffer.ReadByte()); if (sFSDataType != SFSDataType.SFS_ARRAY) { throw new SFSCodecError(string.Concat("Invalid SFSDataType. Expected: ", SFSDataType.SFS_ARRAY, ", found: ", sFSDataType)); } int num = buffer.ReadShort(); if (num < 0) { throw new SFSCodecError("Can't decode SFSArray. Size is negative: " + num); } try { for (int i = 0; i < num; i++) { SFSDataWrapper sFSDataWrapper = DecodeObject(buffer); if (sFSDataWrapper != null) { iSFSArray.Add(sFSDataWrapper); continue; } throw new SFSCodecError("Could not decode SFSArray item at index: " + i); } return(iSFSArray); } catch (SFSCodecError sFSCodecError) { throw sFSCodecError; } }
public SFSDataWrapper(SFSDataType tp, object data) { type = (int)tp; this.data = data; }
public void WriteByte(SFSDataType tp) { WriteByte(Convert.ToByte((int)tp)); }
private SFSDataWrapper DecodeObject(ByteArray buffer) { SFSDataType sFSDataType = (SFSDataType)Convert.ToInt32(buffer.ReadByte()); switch (sFSDataType) { case SFSDataType.NULL: return(BinDecode_NULL(buffer)); case SFSDataType.BOOL: return(BinDecode_BOOL(buffer)); case SFSDataType.BOOL_ARRAY: return(BinDecode_BOOL_ARRAY(buffer)); case SFSDataType.BYTE: return(BinDecode_BYTE(buffer)); case SFSDataType.BYTE_ARRAY: return(BinDecode_BYTE_ARRAY(buffer)); case SFSDataType.SHORT: return(BinDecode_SHORT(buffer)); case SFSDataType.SHORT_ARRAY: return(BinDecode_SHORT_ARRAY(buffer)); case SFSDataType.INT: return(BinDecode_INT(buffer)); case SFSDataType.INT_ARRAY: return(BinDecode_INT_ARRAY(buffer)); case SFSDataType.LONG: return(BinDecode_LONG(buffer)); case SFSDataType.LONG_ARRAY: return(BinDecode_LONG_ARRAY(buffer)); case SFSDataType.FLOAT: return(BinDecode_FLOAT(buffer)); case SFSDataType.FLOAT_ARRAY: return(BinDecode_FLOAT_ARRAY(buffer)); case SFSDataType.DOUBLE: return(BinDecode_DOUBLE(buffer)); case SFSDataType.DOUBLE_ARRAY: return(BinDecode_DOUBLE_ARRAY(buffer)); case SFSDataType.UTF_STRING: return(BinDecode_UTF_STRING(buffer)); case SFSDataType.TEXT: return(BinDecode_TEXT(buffer)); case SFSDataType.UTF_STRING_ARRAY: return(BinDecode_UTF_STRING_ARRAY(buffer)); case SFSDataType.SFS_ARRAY: buffer.Position--; return(new SFSDataWrapper(17, DecodeSFSArray(buffer))); case SFSDataType.SFS_OBJECT: { buffer.Position--; ISFSObject iSFSObject = DecodeSFSObject(buffer); byte type = Convert.ToByte(18); object data = iSFSObject; if (iSFSObject.ContainsKey(CLASS_MARKER_KEY) && iSFSObject.ContainsKey(CLASS_FIELDS_KEY)) { type = Convert.ToByte(19); data = Sfs2Cs(iSFSObject); } return(new SFSDataWrapper(type, data)); } default: throw new Exception("Unknow SFSDataType ID: " + sFSDataType); } }
private void AddObject(object val, SFSDataType tp) { Add(new SFSDataWrapper((int)tp, val)); }