Added non-generic registration interface to IKernel and IWindsor to accommodate dynam...
[castle.git] / MonoRail / Castle.MonoRail.Framework / Attributes / LayoutAttribute.cs
blob3d4d7b6ea266476b3eed4d858c6e07157445cedf
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 Castle.MonoRail.Framework.Descriptors;
20 /// <summary>
21 /// Associates a layout name with a controller.
22 /// The layout can later be changed using the LayoutName
23 /// property of the <see cref="IController"/>.
24 /// </summary>
25 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple=false), Serializable]
26 public class LayoutAttribute : Attribute, ILayoutDescriptorBuilder
28 private readonly string[] layoutNames;
30 /// <summary>
31 /// Constructs a LayoutAttribute with the
32 /// layout names.
33 /// </summary>
34 public LayoutAttribute(string layoutName)
36 if (string.IsNullOrEmpty(layoutName))
38 throw new ArgumentNullException("layoutName", "Invalid layout name");
41 layoutNames = new string[] { layoutName };
44 /// <summary>
45 /// Constructs a LayoutAttribute with the
46 /// layout names.
47 /// </summary>
48 public LayoutAttribute(params string[] layoutNames)
50 if (layoutNames.Length == 0)
52 throw new ArgumentNullException("layoutNames", "Invalid layout name");
55 this.layoutNames = layoutNames;
58 /// <summary>
59 /// Gets the layout name
60 /// </summary>
61 public String LayoutName
63 get { return layoutNames[0]; }
66 /// <summary>
67 /// <see cref="ILayoutDescriptorBuilder"/> implementation.
68 /// Gets the descriptor that describes the layout.
69 /// </summary>
70 public LayoutDescriptor BuildLayoutDescriptor()
72 return new LayoutDescriptor(layoutNames);