Added non-generic registration interface to IKernel and IWindsor to accommodate dynam...
[castle.git] / MonoRail / Castle.MonoRail.Framework / TransformFilter.cs
blob32e254269404c7818de06938fd5cc567a85a9c4b
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.IO;
20 /// <summary>
21 /// Abstract base class for HttpFilters.
22 /// </summary>
23 public abstract class TransformFilter : Stream, ITransformFilter
25 private Stream baseStream;
26 private bool closed;
28 /// <summary>
29 /// Base class holds the underlying stream.
30 /// </summary>
31 /// <param name="baseStream">The stream to write to after filtering.</param>
32 public TransformFilter(Stream baseStream)
34 this.baseStream = baseStream;
35 closed = false;
38 /// <summary>
39 /// The stream to the filter can use to write write to
40 /// </summary>
41 protected Stream BaseStream
43 get { return baseStream; }
46 /// <summary>
47 /// This method is not supported for an HttpFilter
48 /// </summary>
49 /// <exception cref="NotSupportedException">Always thrown</exception>
50 public override int Read(byte[] buffer, int offset, int count)
52 throw new NotSupportedException();
55 /// <summary>
56 /// This method is not supported for an HttpFilter
57 /// </summary>
58 public override bool CanRead
60 get { return false; }
63 /// <summary>
64 /// This method is not supported for an HttpFilter
65 /// </summary>
66 public override bool CanSeek
68 get { return false; }
71 /// <summary>
72 /// Indicates if the Stream is closed or open
73 /// </summary>
74 public override bool CanWrite
76 get { return !closed; }
79 /// <summary>
80 /// Close implementation.
81 /// </summary>
82 /// <remarks>
83 /// Don't forget to call base.Close is you override this function.
84 /// </remarks>
85 public override void Close()
87 closed = true;
88 baseStream.Close();
91 /// <summary>
92 /// Indicates if the Stream is closed or open
93 /// </summary>
94 /// <remarks>
95 /// Implementors should always check Closed before writing anything to the BaseStream.
96 /// </remarks>
97 protected bool Closed
99 get { return closed; }
102 /// <summary>
103 /// This method is not supported for an HttpFilter
104 /// </summary>
105 /// <exception cref="NotSupportedException">Always thrown</exception>
106 public override long Length
108 get { throw new NotSupportedException(); }
111 /// <summary>
112 /// This method is not supported for an HttpFilter
113 /// </summary>
114 /// <exception cref="NotSupportedException">Always thrown</exception>
115 public override long Position
117 get { throw new NotSupportedException(); }
118 set { throw new NotSupportedException(); }
121 /// <summary>
122 /// Flushes the base stream
123 /// </summary>
124 public override void Flush()
126 baseStream.Flush();
129 /// <summary>
130 /// This method is not supported for an HttpFilter
131 /// </summary>
132 /// <exception cref="NotSupportedException">Always thrown</exception>
133 public override long Seek(long offset, SeekOrigin origin)
135 throw new NotSupportedException();
138 /// <summary>
139 /// This method is not supported for an HttpFilter
140 /// </summary>
141 /// <exception cref="NotSupportedException">Always thrown</exception>
142 public override void SetLength(long value)
144 throw new NotSupportedException();