1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
.Configuration
18 using System
.Collections
;
19 using System
.Configuration
;
23 /// Represents the controller node configuration
25 public class ControllersConfig
: ISerializedConfig
27 private String
[] assemblies
;
28 private Type customControllerFactory
;
30 #region ISerializedConfig implementation
33 /// Deserializes the specified section.
35 /// <param name="section">The section.</param>
36 public void Deserialize(XmlNode section
)
38 XmlNode customFactoryNode
= section
.SelectSingleNode("customControllerFactory");
40 if (customFactoryNode
!= null)
42 XmlAttribute typeAtt
= customFactoryNode
.Attributes
["type"];
44 if (typeAtt
== null || typeAtt
.Value
== String
.Empty
)
46 String message
= "If the node customControllerFactory is " +
47 "present, you must specify the 'type' attribute";
48 throw new ConfigurationErrorsException(message
);
51 String typeName
= typeAtt
.Value
;
53 customControllerFactory
= TypeLoadUtil
.GetType(typeName
);
56 XmlNodeList nodeList
= section
.SelectNodes("controllers/assembly");
58 ArrayList items
= new ArrayList();
60 foreach(XmlNode node
in nodeList
)
62 items
.Add(node
.ChildNodes
[0].Value
);
65 assemblies
= (String
[]) items
.ToArray(typeof(String
));
71 /// Gets or sets the assemblies.
73 /// <value>The assemblies.</value>
74 public string[] Assemblies
76 get { return assemblies; }
77 set { assemblies = value; }
81 /// Gets or sets the custom controller factory.
83 /// <value>The custom controller factory.</value>
84 public Type CustomControllerFactory
86 get { return customControllerFactory; }
87 set { customControllerFactory = value; }