Exemple #1
0
 /// <summary>
 /// Opens the parser and parses the <see cref="ContainerRecord"/>.
 /// </summary>
 public void Open()
 {
     m_physicalParser.Open();
     m_containerRecord = ContainerRecord.CreateContainerRecord(m_physicalParser.NextRecord());
     m_physicalParser.CompressionAlgorithm = m_containerRecord.CompressionAlgorithm;
     m_physicalParser.CompressionStyle     = m_containerRecord.CompressionStyle;
 }
Exemple #2
0
 /// <summary>
 /// Opens the parser and parses the <see cref="ContainerRecord"/>.
 /// </summary>
 /// <param name="stream">The stream containing the PQDIF file data.</param>
 /// <param name="leaveOpen">True if the stream should be closed when the parser is closed; false otherwise.</param>
 /// <exception cref="ArgumentNullException"><paramref name="stream"/> is null.</exception>
 /// <exception cref="InvalidOperationException"><paramref name="stream"/> is not both readable and seekable.</exception>
 /// <exception cref="NotSupportedException">An unsupported compression mode was defined in the PQDIF file.</exception>
 public void Open(Stream stream, bool leaveOpen = false)
 {
     m_physicalParser.Open(stream, leaveOpen);
     m_containerRecord = ContainerRecord.CreateContainerRecord(m_physicalParser.NextRecord());
     m_physicalParser.CompressionAlgorithm = m_containerRecord.CompressionAlgorithm;
     m_physicalParser.CompressionStyle     = m_containerRecord.CompressionStyle;
 }
Exemple #3
0
 /// <summary>
 /// Opens the parser and parses the <see cref="ContainerRecord"/>.
 /// </summary>
 public void Open()
 {
     m_physicalParser.Open();
     m_containerRecord = ContainerRecord.CreateContainerRecord(m_physicalParser.NextRecord());
     m_physicalParser.CompressionAlgorithm = m_containerRecord.CompressionAlgorithm;
     m_physicalParser.CompressionStyle = m_containerRecord.CompressionStyle;
 }
Exemple #4
0
        private void ValidateContainerRecord(ContainerRecord containerRecord)
        {
            if (!containerRecord.PhysicalRecord.Body.Collection.GetElementsByTag(ContainerRecord.VersionInfoTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.Container, "VersionInfoTag", ContainerRecord.VersionInfoTag));
            }

            if (!containerRecord.PhysicalRecord.Body.Collection.GetElementsByTag(ContainerRecord.FileNameTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.Container, "FileNameTag", ContainerRecord.FileNameTag));
            }

            if (!containerRecord.PhysicalRecord.Body.Collection.GetElementsByTag(ContainerRecord.VersionInfoTag).Any())
            {
                m_missingTags.Add(new MissingTag(RecordType.Container, "CreationTag", ContainerRecord.CreationTag));
            }
        }
Exemple #5
0
        // Static Methods

        /// <summary>
        /// Creates a new container record from scratch.
        /// </summary>
        /// <returns>The new container record.</returns>
        public static ContainerRecord CreateContainerRecord()
        {
            Guid            recordTypeTag   = Record.GetTypeAsTag(RecordType.Container);
            Record          physicalRecord  = new Record(recordTypeTag);
            ContainerRecord containerRecord = new ContainerRecord(physicalRecord);

            DateTime now = DateTime.UtcNow;

            containerRecord.WriterMajorVersion     = 1;
            containerRecord.WriterMinorVersion     = 5;
            containerRecord.CompatibleMajorVersion = 1;
            containerRecord.CompatibleMinorVersion = 0;
            containerRecord.FileName = $"{now:yyyy-MM-dd_HH.mm.ss}.pqd";
            containerRecord.Creation = now;

            return(containerRecord);
        }
Exemple #6
0
        /// <summary>
        /// Writes the given container record to the file stream.
        /// </summary>
        /// <param name="containerRecord">The container record to be written to the PQDIF file.</param>
        public void Write(ContainerRecord containerRecord)
        {
            if ((object)containerRecord == null)
            {
                throw new ArgumentNullException("containerRecord");
            }

            if (m_disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            if ((object)m_containerRecord != null)
            {
                throw new InvalidOperationException("Only one container record can be written to a PQDIF file.");
            }

            ValidateContainerRecord(containerRecord);

            m_containerRecord = containerRecord;
            m_physicalWriter.WriteRecord(containerRecord.PhysicalRecord);
            m_physicalWriter.CompressionAlgorithm = m_containerRecord.CompressionAlgorithm;
            m_physicalWriter.CompressionStyle     = m_containerRecord.CompressionStyle;
        }
Exemple #7
0
        private void ValidateContainerRecord(ContainerRecord containerRecord)
        {
            if (!containerRecord.PhysicalRecord.Body.Collection.GetElementsByTag(ContainerRecord.VersionInfoTag).Any())
                m_missingTags.Add(new MissingTag(RecordType.Container, "VersionInfoTag", ContainerRecord.VersionInfoTag));

            if (!containerRecord.PhysicalRecord.Body.Collection.GetElementsByTag(ContainerRecord.FileNameTag).Any())
                m_missingTags.Add(new MissingTag(RecordType.Container, "FileNameTag", ContainerRecord.FileNameTag));

            if (!containerRecord.PhysicalRecord.Body.Collection.GetElementsByTag(ContainerRecord.VersionInfoTag).Any())
                m_missingTags.Add(new MissingTag(RecordType.Container, "CreationTag", ContainerRecord.CreationTag));
        }
Exemple #8
0
        /// <summary>
        /// Writes the given container record to the file stream.
        /// </summary>
        /// <param name="containerRecord">The container record to be written to the PQDIF file.</param>
        public void Write(ContainerRecord containerRecord)
        {
            if ((object)containerRecord == null)
                throw new ArgumentNullException("containerRecord");

            if (m_disposed)
                throw new ObjectDisposedException(GetType().Name);

            if ((object)m_containerRecord != null)
                throw new InvalidOperationException("Only one container record can be written to a PQDIF file.");

            ValidateContainerRecord(containerRecord);

            m_containerRecord = containerRecord;
            m_physicalWriter.WriteRecord(containerRecord.PhysicalRecord);
            m_physicalWriter.CompressionAlgorithm = m_containerRecord.CompressionAlgorithm;
            m_physicalWriter.CompressionStyle = m_containerRecord.CompressionStyle;
        }