Example #1
0
        /// <summary>
        /// Converts file details to an array of bytes.
        /// </summary>
        /// <param name="fileDetails">File details.</param>
        /// <returns>Converted file details to byte array.</returns>
        public static byte[] ConvertToByteArray(FileDetails fileDetails)
        {
            byte[] serializedFileDetails;

            using (var memoryStream = new MemoryStream())
            {
                var xmlSerializer = new XmlSerializer(typeof(FileDetails));
                xmlSerializer.Serialize(memoryStream, fileDetails);

                memoryStream.Position = 0;
                serializedFileDetails = new byte[memoryStream.Length];

                const int memoryStreamOffset = 0;
                memoryStream.Read(serializedFileDetails, memoryStreamOffset,
                                  serializedFileDetails.Length);
            }

            return(serializedFileDetails);
        }
Example #2
0
 /// <summary>
 /// Returns file details as an array of bytes.
 /// </summary>
 /// <returns>file details represented as an array of bytes.</returns>
 public byte[] GetByteArrayFileDetails()
 {
     return(FileDetails.ConvertToByteArray(_fileDetails));
 }
Example #3
0
 /// <summary>
 /// Sets file details.
 /// </summary>
 /// <param name="byteArrayFileDetails">File details represented as an array of bytes.</param>
 public TransmittedFile(byte[] byteArrayFileDetails) : this()
 {
     _fileDetails = FileDetails.ConvertToFileDetails(byteArrayFileDetails);
 }
Example #4
0
 /// <summary>
 /// Initializes a file details information field.
 /// </summary>
 private TransmittedFile()
 {
     _fileDetails = new FileDetails();
 }