Merged branch back to the trunk. Build is passing with no changes.
[castle.git] / MonoRail / Castle.MonoRail.Framework / Configuration / ExtensionEntry.cs
blobde6c3cd6a33e374e8297266e76b0482286cc8607
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.Configuration
17 using System;
18 using System.Configuration;
19 using System.Xml;
20 using Castle.Core.Configuration;
21 using Castle.Core.Configuration.Xml;
23 /// <summary>
24 /// Represents a MonoRail extension configuration entry
25 /// </summary>
26 public class ExtensionEntry : ISerializedConfig
28 private Type extensionType;
29 private IConfiguration extensionNode;
31 /// <summary>
32 /// Initializes a new instance of the <see cref="ExtensionEntry"/> class.
33 /// </summary>
34 public ExtensionEntry()
38 /// <summary>
39 /// Initializes a new instance of the <see cref="ExtensionEntry"/> class.
40 /// </summary>
41 /// <param name="extensionType">Type of the extension.</param>
42 /// <param name="extensionNode">The extension node.</param>
43 public ExtensionEntry(Type extensionType, IConfiguration extensionNode)
45 this.extensionType = extensionType;
46 this.extensionNode = extensionNode;
49 #region ISerializedConfig implementation
51 /// <summary>
52 /// Deserializes the specified section.
53 /// </summary>
54 /// <param name="section">The section.</param>
55 public void Deserialize(XmlNode section)
57 XmlAttribute typeAtt = section.Attributes["type"];
59 if (typeAtt == null || typeAtt.Value == String.Empty)
61 String message = "To add a service, please specify the 'type' attribute. " +
62 "Check the documentation for more information";
63 throw new ConfigurationErrorsException(message);
66 extensionType = TypeLoadUtil.GetType(typeAtt.Value);
68 extensionNode = XmlConfigurationDeserializer.GetDeserializedNode(section);
71 #endregion
73 /// <summary>
74 /// Gets or sets the type of the extension.
75 /// </summary>
76 /// <value>The type of the extension.</value>
77 public Type ExtensionType
79 get { return extensionType; }
80 set { extensionType = value; }
83 /// <summary>
84 /// Gets or sets the extension node.
85 /// </summary>
86 /// <value>The extension node.</value>
87 public IConfiguration ExtensionNode
89 get { return extensionNode; }
90 set { extensionNode = value; }