コード例 #1
0
ファイル: Document.cs プロジェクト: motherwaym/Wyam
        private Document(Pipeline pipeline, Metadata metadata, string source, Stream stream, object streamLock, string content, IEnumerable <KeyValuePair <string, object> > items, bool disposeStream)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            Source    = source;
            _metadata = items == null ? metadata : metadata.Clone(items);
            _content  = content;

            _pipeline = pipeline;
            _pipeline.AddClonedDocument(this);

            if (stream != null)
            {
                if (!stream.CanRead)
                {
                    throw new ArgumentException("Document stream must support reading.", nameof(stream));
                }

                if (!stream.CanSeek)
                {
                    _stream        = new SeekableStream(stream, disposeStream);
                    _disposeStream = true;
                }
                else
                {
                    _stream        = stream;
                    _disposeStream = disposeStream;
                }
            }
            _streamLock = stream != null && streamLock != null ? streamLock : new object();
        }