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
.Configuration
;
20 using Castle
.Core
.Configuration
;
21 using Castle
.Core
.Configuration
.Xml
;
24 /// Represents a MonoRail extension configuration entry
26 public class ExtensionEntry
: ISerializedConfig
28 private Type extensionType
;
29 private IConfiguration extensionNode
;
32 /// Initializes a new instance of the <see cref="ExtensionEntry"/> class.
34 public ExtensionEntry()
39 /// Initializes a new instance of the <see cref="ExtensionEntry"/> class.
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
52 /// Deserializes the specified section.
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
);
74 /// Gets or sets the type of the extension.
76 /// <value>The type of the extension.</value>
77 public Type ExtensionType
79 get { return extensionType; }
80 set { extensionType = value; }
84 /// Gets or sets the extension node.
86 /// <value>The extension node.</value>
87 public IConfiguration ExtensionNode
89 get { return extensionNode; }
90 set { extensionNode = value; }