Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Experiments / SubversionHooks / Hooks / ReadOnlyStreamWrapper.cs
bloba47578271a9d6b789891c165683e0ea56e1dd150
1 // Copyright 2004-2008 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.SvnHooks
17 using System;
18 using System.IO;
20 /// <summary>
21 /// Summary description for ReadOnlyStreamWrapper.
22 /// </summary>
23 public class ReadOnlyStreamWrapper : Stream
25 public ReadOnlyStreamWrapper(Stream source)
27 if (!source.CanRead)
28 throw new ArgumentException("Source stream must be readable", "source");
30 this.Source = source;
34 public override int Read(byte[] buffer, int offset, int count)
36 return Source.Read(buffer, offset, count);
39 public override long Seek(long offset, SeekOrigin origin)
41 return Source.Seek(offset, origin);
45 public override long Length
47 get
49 return Source.Length;
53 public override long Position
55 get
57 return Source.Position;
59 set
61 Source.Position = value;
65 public override bool CanSeek
67 get
69 return Source.CanSeek;
74 public override bool CanRead
76 get
78 return true;
82 public override bool CanWrite
84 get
86 return false;
91 #region Write related overrides
93 public override void Flush()
97 public override void SetLength(long value)
99 throw new InvalidOperationException();
102 public override void Write(byte[] buffer, int offset, int count)
104 throw new InvalidOperationException();
108 #endregion
110 private readonly Stream Source;