Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework / Views / FileViewSource.cs
blobebe664edd41af4525fa257b7aeb44c1a47d6111e
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.MonoRail.Framework.Views
17 using System.IO;
19 /// <summary>
20 /// Represents a view template source on the file system.
21 /// </summary>
22 public class FileViewSource : IViewSource
24 private readonly FileInfo fileInfo;
25 private readonly bool enableCache;
26 private long lastUpdated;
28 /// <summary>
29 /// Initializes a new instance of the <see cref="FileViewSource"/> class.
30 /// </summary>
31 /// <param name="fileInfo">The file info.</param>
32 /// <param name="enableCache">if set to <c>true</c> [enable cache].</param>
33 public FileViewSource(FileInfo fileInfo, bool enableCache)
35 this.fileInfo = fileInfo;
36 this.enableCache = enableCache;
38 lastUpdated = LastModified;
41 /// <summary>
42 /// Opens the view stream.
43 /// </summary>
44 /// <returns></returns>
45 public Stream OpenViewStream()
47 lastUpdated = LastModified;
49 return fileInfo.OpenRead();
52 /// <summary>
53 /// Gets a value indicating whether cache is enabled for it.
54 /// </summary>
55 /// <value><c>true</c> if cache is enabled for it; otherwise, <c>false</c>.</value>
56 public bool EnableCache
58 get { return enableCache; }
61 /// <summary>
62 /// Gets or sets the last updated.
63 /// </summary>
64 /// <value>The last updated.</value>
65 public long LastUpdated
67 get { return lastUpdated; }
68 set { lastUpdated = value; }
71 /// <summary>
72 /// Gets the last modified.
73 /// </summary>
74 /// <value>The last modified.</value>
75 public long LastModified
77 get { return File.GetLastWriteTime(fileInfo.FullName).Ticks; }