private IAWArray UnrollArray(ArrayList arr) { IAWArray iSFSArray = AWArray.NewInstance(); IEnumerator enumerator = arr.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; AWDataWrapper sFSDataWrapper = this.WrapField(current); if (sFSDataWrapper == null) { throw new AWCodecError("Cannot serialize field of array: " + current + " -- unsupported type!"); } iSFSArray.Add(sFSDataWrapper); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } return(iSFSArray); }
private IAWArray DecodeSFSArray(ByteArray buffer) { IAWArray iSFSArray = AWArray.NewInstance(); AWDataType sFSDataType = (AWDataType)Convert.ToInt32(buffer.ReadByte()); if (sFSDataType != AWDataType.SFS_ARRAY) { throw new AWCodecError(string.Concat(new object[] { "Invalid AWDataType. Expected: ", AWDataType.SFS_ARRAY, ", found: ", sFSDataType })); } int num = (int)buffer.ReadShort(); if (num < 0) { throw new AWCodecError("Can't decode AWArray. Size is negative: " + num); } try { for (int i = 0; i < num; i++) { AWDataWrapper sFSDataWrapper = this.DecodeObject(buffer); if (sFSDataWrapper == null) { throw new AWCodecError("Could not decode AWArray item at index: " + i); } iSFSArray.Add(sFSDataWrapper); } } catch (AWCodecError sFSCodecError) { throw sFSCodecError; } return(iSFSArray); }