예제 #1
0
        /// <summary>
        /// Sets the stream of this file.
        /// </summary>
        /// <param name="stream">The stream to set.</param>
        /// <returns>That instance.</returns>
        /// <remarks>
        /// If <paramref name="stream" /> is <see langword="null" />, <see cref="SimpleFile.OpenStreamFunc" />
        /// will also be set to <see langword="null" />.
        /// </remarks>
        public SimpleFile SetStream(Stream stream)
        {
            this.OpenStreamFunc = stream == null ? null : new OpenStreamHandler(delegate()
            {
                return(stream);
            });

            return(this);
        }
예제 #2
0
        /// <summary>
        /// Sets the data of this file.
        /// </summary>
        /// <param name="data">The data to set.</param>
        /// <returns>That instance.</returns>
        /// <remarks>
        /// If <paramref name="data" /> is <see langword="null" /> <see cref="SimpleFile.OpenStreamFunc" />
        /// will also be set to <see langword="null" />.
        /// </remarks>
        public SimpleFile SetData(IEnumerable <byte> data)
        {
            this.OpenStreamFunc = data == null ? null : new OpenStreamHandler(delegate()
            {
                return(new MemoryStream(CollectionHelper.AsArray(data)));
            });

            return(this);
        }