Ejemplo n.º 1
0
        /// <summary>
        /// Deserializes the metadata (footer, properties, etc.) for this checkpoint file.
        /// </summary>
        private async Task ReadMetadataAsync()
        {
            Stream filestream = null;

            try
            {
                filestream = this.ReaderPool.AcquireStream();

                // Read and validate the Footer section.  The footer is always at the end of the stream, minus space for the checksum.
                var footerHandle = new BlockHandle(filestream.Length - FileFooter.SerializedSize - sizeof(ulong), FileFooter.SerializedSize);
                this.Footer =
                    await FileBlock.ReadBlockAsync(filestream, footerHandle, (sectionReader, sectionHandle) => FileFooter.Read(sectionReader, sectionHandle)).ConfigureAwait(false);

                // Verify we know how to deserialize this version of the checkpoint file.
                if (this.Footer.Version != FileVersion)
                {
                    throw new InvalidDataException(SR.Error_KeyCheckpointFile_Deserialized);
                }

                // Read and validate the Properties section.
                var propertiesHandle = this.Footer.PropertiesHandle;
                this.Properties =
                    await
                    FileBlock.ReadBlockAsync(
                        filestream,
                        propertiesHandle,
                        (sectionReader, sectionHandle) => FilePropertySection.Read <KeyCheckpointFileProperties>(sectionReader, sectionHandle)).ConfigureAwait(false);
            }
            finally
            {
                this.ReaderPool.ReleaseStream(filestream, true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new key checkpoint file with the given filename.
        /// </summary>
        /// <param name="filename">Path to the checkpoint file.</param>
        /// <param name="fileId">File Id of the checkpoint file.</param>
        /// <param name="isValueAReferenceType"></param>
        public KeyCheckpointFile(string filename, uint fileId, bool isValueAReferenceType)
            : this(filename, isValueAReferenceType)
        {
            this.Properties = new KeyCheckpointFileProperties()
            {
                FileId = fileId,
            };

            this.isValueAReferenceType = isValueAReferenceType;
        }