- Implemented support for view component caching. Just use the attribute
[castle.git] / MonoRail / Castle.MonoRail.Framework / Internal / Descriptors / ViewComponentDescriptor.cs
blobf9439367fcbb91e511eb5f7ff81652b2c5de9859
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.Internal
17 using Castle.MonoRail.Framework;
18 using Castle.MonoRail.Framework.ViewComponents;
20 /// <summary>
21 /// Represents a <see cref="ViewComponent"/> cache configuration.
22 /// </summary>
23 public class ViewComponentDescriptor
25 /// <summary>
26 /// Represents an empty descriptor
27 /// </summary>
28 public static readonly ViewComponentDescriptor Empty = new ViewComponentDescriptor(false, ViewComponentCache.Disabled, null);
30 private readonly bool isCacheable;
31 private readonly ViewComponentCache cacheStrategy;
32 private readonly IViewComponentCacheKeyGenerator cacheKeyGenerator;
34 /// <summary>
35 /// Initializes a new instance of the <see cref="ViewComponentDescriptor"/> class.
36 /// </summary>
37 /// <param name="isCacheable">if set to <c>true</c> [is cacheable].</param>
38 /// <param name="cacheStrategy">The cache strategy.</param>
39 /// <param name="cacheKeyGenerator">The cache key generator.</param>
40 public ViewComponentDescriptor(bool isCacheable, ViewComponentCache cacheStrategy, IViewComponentCacheKeyGenerator cacheKeyGenerator)
42 this.isCacheable = isCacheable;
43 this.cacheStrategy = cacheStrategy;
44 this.cacheKeyGenerator = cacheKeyGenerator;
47 /// <summary>
48 /// Gets a value indicating whether the view component is cacheable.
49 /// </summary>
50 /// <value>
51 /// <c>true</c> if the View Component is cacheable; otherwise, <c>false</c>.
52 /// </value>
53 public bool IsCacheable
55 get { return isCacheable; }
58 /// <summary>
59 /// Gets the cache strategy.
60 /// </summary>
61 /// <value>The cache strategy.</value>
62 public ViewComponentCache CacheStrategy
64 get { return cacheStrategy; }
67 /// <summary>
68 /// Gets the cache key generator.
69 /// </summary>
70 /// <value>The cache key generator.</value>
71 public IViewComponentCacheKeyGenerator CacheKeyGenerator
73 get { return cacheKeyGenerator; }