1 // Copyright 2004-2008 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
;
23 /// Represents the Scaffolding support configuration.
24 /// <seealso cref="IScaffoldingSupport"/>
26 public class ScaffoldConfig
: ISerializedConfig
28 private Type scaffoldImplType
;
31 /// Initializes a new instance of the <see cref="ScaffoldConfig"/> class.
33 public ScaffoldConfig()
35 TryLoadDefaultScaffoldingImplementation();
38 #region ISerializedConfig implementation
41 /// Deserializes the configuration section looking
42 /// for a 'scaffold' element with a 'type' attribute
44 /// <param name="section">The section.</param>
45 public void Deserialize(XmlNode section
)
47 section
= section
.SelectSingleNode("scaffold");
49 if (section
== null) return;
51 XmlAttribute typeAtt
= section
.Attributes
["type"];
53 if (typeAtt
== null || typeAtt
.Value
== String
.Empty
)
55 String message
= "Please specify the 'type' attribute to define an implementation for scaffolding support";
56 throw new ConfigurationErrorsException(message
);
59 scaffoldImplType
= TypeLoadUtil
.GetType(typeAtt
.Value
);
65 /// Gets the scaffolding support implementation type.
66 /// <seealso cref="IScaffoldingSupport"/>
68 /// <value>The type of the scaffold impl.</value>
69 public Type ScaffoldImplType
71 get { return scaffoldImplType; }
74 private void TryLoadDefaultScaffoldingImplementation()
76 scaffoldImplType
= Type
.GetType("Castle.MonoRail.ActiveRecordSupport.Scaffold.ScaffoldingSupport, Castle.MonoRail.ActiveRecordSupport", false, false);