public void GZipMemberEntry_Serialize_ThrowsNotSupportedException() { var bogusEntry = new GZipMemberEntry(); INTV.Core.Utility.BinaryWriter bogusWriter = null; Assert.Throws <NotSupportedException>(() => bogusEntry.Serialize(bogusWriter)); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { if (_presentationOrder.Count != FileSystemConstants.MaxItemCount) { throw new System.InvalidOperationException(); } foreach (var entry in _presentationOrder) { writer.Write(entry); } return(SerializeByteCount); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { // NOTE: The StartingVirtualBlock, Size, and UID are already included in the command to create // a Fork from RAM, so all we need to include is the actual file data. ////writer.Write(StartingVirtualBlock); ////writer.Write(System.BitConverter.GetBytes(Size), 0, 3); ////writer.Write(System.BitConverter.GetBytes(Crc24), 0, 3); using (var file = FileUtilities.OpenFileStream(FilePath)) { file.CopyTo(writer.BaseStream); } return(SerializeByteCount); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { if (FileType != FileType.None) { writer.Write((byte)FileType); writer.Write((byte)Color); byte[] shortNameBuffer = new byte[FileSystemConstants.MaxShortNameLength]; var bufferFillStart = 1; if (!string.IsNullOrEmpty(ShortName)) { bufferFillStart = ShortName.Length + 1; System.Text.Encoding.ASCII.GetBytes(ShortName, 0, System.Math.Min(ShortName.Length, FileSystemConstants.MaxShortNameLength), shortNameBuffer, 0); } for (int i = bufferFillStart; i < FileSystemConstants.MaxShortNameLength; ++i) { shortNameBuffer[i] = 0xFF; } writer.Write(shortNameBuffer, 0, FileSystemConstants.MaxShortNameLength); byte[] longNameBuffer = new byte[FileSystemConstants.MaxLongNameLength]; bufferFillStart = 1; if (!string.IsNullOrEmpty(LongName)) { bufferFillStart = LongName.Length + 1; System.Text.Encoding.ASCII.GetBytes(LongName, 0, System.Math.Min(LongName.Length, FileSystemConstants.MaxLongNameLength), longNameBuffer, 0); } for (int i = bufferFillStart; i < FileSystemConstants.MaxLongNameLength; ++i) { longNameBuffer[i] = 0xFF; } writer.Write(longNameBuffer, 0, FileSystemConstants.MaxLongNameLength); writer.Write(GlobalDirectoryNumber); writer.Write(Reserved); foreach (var globalForkNumber in _forks) { writer.Write(globalForkNumber); } } else { for (var i = 0; i < SerializeByteCount; ++i) { writer.Write((byte)0xFF); } } return(SerializeByteCount); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { var protocolCommandBuffer = new byte[CommandRecordSize + ArgumentRecordSize]; // The try/finally pattern avoids potential double-dispose issues with the memory stream. System.IO.MemoryStream commandWithArgsStream = null; try { commandWithArgsStream = new System.IO.MemoryStream(protocolCommandBuffer); using (var tempBinaryWriter = new INTV.Shared.Utility.ASCIIBinaryWriter(commandWithArgsStream)) { commandWithArgsStream = null; tempBinaryWriter.Write(CommandRecordHeadByte); tempBinaryWriter.Write((byte)Command); tempBinaryWriter.Write((byte)(((int)Command) ^ 0xFF)); tempBinaryWriter.Write(CommandRecordTailByte); tempBinaryWriter.Write(Arg0); tempBinaryWriter.Write(Arg1); tempBinaryWriter.Write(Arg2); tempBinaryWriter.Write(Arg3); tempBinaryWriter.Seek(0, SeekOrigin.Begin); Crc = INTV.Core.Utility.Crc32.OfStream(tempBinaryWriter.BaseStream); writer.Write(protocolCommandBuffer, 0, protocolCommandBuffer.Length); #if LOG_COMMAND_DATA var dataSent = new System.Text.StringBuilder(); foreach (var value in protocolCommandBuffer) { dataSent.AppendFormat("{0} ", value.ToString("X2")); } dataSent.AppendFormat("CRC: {0}", Crc.ToString("X8")); _dataSent = dataSent.ToString(); #endif // LOG_COMMAND_DATA } } finally { if (commandWithArgsStream != null) { commandWithArgsStream.Dispose(); } } writer.Write(Crc); return(ProtocolCommandRecordSize); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { throw new System.NotImplementedException(); }
/// <summary> /// Serializes the error log in a fashion suitable for a text file. /// </summary> /// <param name="currentFirmwareVersion">Version of firmware at time the error log was collected.</param> /// <param name="writer">The binary writer to use to serialize the data.</param> public void SerializeToTextFile(int currentFirmwareVersion, INTV.Core.Utility.BinaryWriter writer) { var reportText = GetDetailedErrorReport(currentFirmwareVersion); writer.Write(reportText.ToCharArray()); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { writer.Write(GetDetailedErrorReport(FirmwareRevisions.UnavailableFirmwareVersion)); return(SerializeByteCount); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { writer.Write(ParentDirectoryGlobalFileNumber); _presentationOrder.Serialize(writer); return(SerializeByteCount); }
/// <inheritdoc /> public override int Serialize(INTV.Core.Utility.BinaryWriter writer) { writer.Write(_crashBuffer); return(SerializeByteCount); }