1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.Framework
21 /// Abstract base class for HttpFilters.
23 public abstract class TransformFilter
: Stream
, ITransformFilter
25 private Stream baseStream
;
29 /// Base class holds the underlying stream.
31 /// <param name="baseStream">The stream to write to after filtering.</param>
32 public TransformFilter(Stream baseStream
)
34 this.baseStream
= baseStream
;
39 /// The stream to the filter can use to write write to
41 protected Stream BaseStream
43 get { return baseStream; }
47 /// This method is not supported for an HttpFilter
49 /// <exception cref="NotSupportedException">Always thrown</exception>
50 public override int Read(byte[] buffer
, int offset
, int count
)
52 throw new NotSupportedException();
56 /// This method is not supported for an HttpFilter
58 public override bool CanRead
64 /// This method is not supported for an HttpFilter
66 public override bool CanSeek
72 /// Indicates if the Stream is closed or open
74 public override bool CanWrite
76 get { return !closed; }
80 /// Close implementation.
83 /// Don't forget to call base.Close is you override this function.
85 public override void Close()
92 /// Indicates if the Stream is closed or open
95 /// Implementors should always check Closed before writing anything to the BaseStream.
99 get { return closed; }
103 /// This method is not supported for an HttpFilter
105 /// <exception cref="NotSupportedException">Always thrown</exception>
106 public override long Length
108 get { throw new NotSupportedException(); }
112 /// This method is not supported for an HttpFilter
114 /// <exception cref="NotSupportedException">Always thrown</exception>
115 public override long Position
117 get { throw new NotSupportedException(); }
118 set { throw new NotSupportedException(); }
122 /// Flushes the base stream
124 public override void Flush()
130 /// This method is not supported for an HttpFilter
132 /// <exception cref="NotSupportedException">Always thrown</exception>
133 public override long Seek(long offset
, SeekOrigin origin
)
135 throw new NotSupportedException();
139 /// This method is not supported for an HttpFilter
141 /// <exception cref="NotSupportedException">Always thrown</exception>
142 public override void SetLength(long value)
144 throw new NotSupportedException();