Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="FileChunkReader"/> instance.
        /// </summary>
        /// <param name="container">Must not be null.</param>
        /// <returns>Never returns null.</returns>
        public static FileChunkReader CreateFileChunkReader(this CompositionContainer container)
        {
            Contract.Requires(container != null);
            Contract.Ensures(Contract.Result <FileChunkReader>() != null);

            var context = container.GetService <ChunkFileContext>();

            if (context == null)
            {
                throw new InvalidOperationException("File Context export was not found in the Composition Container.");
            }

            if (context.CompositionContainer == null)
            {
                context.CompositionContainer = container;
            }

            var reader = new FileChunkReader(context);

            return(reader);
        }