Exemple #1
0
        /// <summary>
        /// Populates blobs from an existing <see cref="BlobStream"/> (eg. to preserve
        /// blob offsets)
        /// </summary>
        /// <param name="blobStream">The #Blob stream with the original content</param>
        public void Populate(BlobStream blobStream)
        {
            if (isReadOnly)
            {
                throw new ModuleWriterException("Trying to modify #Blob when it's read-only");
            }
            if (originalData != null)
            {
                throw new InvalidOperationException("Can't call method twice");
            }
            if (nextOffset != 1)
            {
                throw new InvalidOperationException("Add() has already been called");
            }
            if (blobStream == null || blobStream.ImageStreamLength == 0)
            {
                return;
            }

            using (var reader = blobStream.GetClonedImageStream())
            {
                originalData = reader.ReadAllBytes();
                nextOffset   = (uint)originalData.Length;
                Populate(reader);
            }
        }