protected internal virtual void OnGetDataStream(GetDataStreamEventArgs e) { var handler = (GetDataStreamEventHandler)base.Events[getDataStream]; if (handler != null) { handler(this, e); } }
public override Stream GetData() { GetDataStreamEventArgs e = new GetDataStreamEventArgs(this); if (base.Owner != null) { base.Owner.OnGetDataSourceStream(e); } if (e.Stream == null) { return(Stream.Null); } e.Stream.Seek(0L, SeekOrigin.Begin); return(e.Stream); }
protected internal override void AddData(byte[] data, int index, int length) { if (base.Owner != null) { if (base.Owner.dataStream == null) { GetDataStreamEventArgs e = new GetDataStreamEventArgs(this); base.Owner.OnGetDataStream(e); base.Owner.dataStream = e.Stream; } if (base.Owner.dataStream != null) { base.Owner.dataStream.Write(data, index, length); } } }
public override Stream GetData() { Stream stream2; if ((base.Owner == null) || !base.Owner.IsMultiPart()) { return(Stream.Null); } MultiStream stream = new MultiStream(); try { stream.AddStream(new StringStream("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n", new object[] { base.GetCanonicalizedValue(this.FieldName), base.GetCanonicalizedValue(Utils.ExtractFileName(this.FileName)), this.ContentType })); GetDataStreamEventArgs e = new GetDataStreamEventArgs(this); base.Owner.OnGetDataSourceStream(e); if (e.Stream == null) { if (bytes == null) { stream.AddStream(new FileStream(this.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)); } else { stream.AddStream(new MemoryStream(bytes)); } } else { stream.AddStream(e.Stream); } stream2 = stream; } catch (Exception exception) { stream.Close(); throw exception; } return(stream2); }