コード例 #1
0
ファイル: MemoryMessage.cs プロジェクト: hmoriya/smtp4dev
            public Stream WriteData()
            {
                CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream();

                stream.Closing += (s, ea) =>
                {
                    _message.Data = stream.ToArray();
                };

                return(stream);
            }
コード例 #2
0
        /// <inheritdoc/>
        public Task <Stream> WriteData()
        {
            CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream();

            stream.Closing += (s, ea) =>
            {
                this.message.Data = stream.ToArray();
            };

            return(Task.FromResult <Stream>(stream));
        }
コード例 #3
0
        public override Stream GetData(DataAccessMode dataAccessMode)
        {
            if (dataAccessMode == DataAccessMode.ForWriting)
            {
                CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream();
                stream.Closing += (s, ea) =>
                {
                    _data           = new byte[stream.Length];
                    stream.Position = 0;
                    stream.Read(_data, 0, _data.Length);
                };

                return(stream);
            }
            else
            {
                return(new MemoryStream(_data, false));
            }
        }
コード例 #4
0
        public Stream GetData(bool forWriting)
        {
            if (forWriting)
            {
                CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream();
                stream.Closing += (s, ea) =>
                {
                    _data           = new byte[stream.Length];
                    stream.Position = 0;
                    stream.Read(_data, 0, _data.Length);
                };

                return(stream);
            }
            else
            {
                return(new MemoryStream(_data, false));
            }
        }