Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail / BrailConfigurationSection.cs
blobad81d416ee9c1194b3c68a8efd9e442b27aa6295
1 // Copyright 2004-2008 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.Views.Brail
17 using System;
18 using System.Configuration;
19 using System.Reflection;
20 using System.Xml;
22 public class BrailConfigurationSection : IConfigurationSectionHandler
24 #region IConfigurationSectionHandler Members
26 public object Create(object parent, object configContext, XmlNode section)
28 BooViewEngineOptions options = new BooViewEngineOptions();
29 if (section.Attributes["batch"] != null)
30 options.BatchCompile = bool.Parse(section.Attributes["batch"].Value);
31 if (section.Attributes["saveToDisk"] != null)
32 options.SaveToDisk = bool.Parse(section.Attributes["saveToDisk"].Value);
33 if (section.Attributes["debug"] != null)
34 options.Debug = bool.Parse(section.Attributes["debug"].Value);
35 if (section.Attributes["saveDirectory"] != null)
36 options.SaveDirectory = section.Attributes["saveDirectory"].Value;
37 if (section.Attributes["commonScriptsDirectory"] != null)
38 options.CommonScriptsDirectory = section.Attributes["commonScriptsDirectory"].Value;
39 foreach(XmlNode refence in section.SelectNodes("reference"))
41 XmlAttribute attribute = refence.Attributes["assembly"];
42 if (attribute == null)
43 throw GetConfigurationException("Attribute 'assembly' is mandatory for <reference/> tags");
44 Assembly asm = Assembly.Load(attribute.Value);
45 options.AssembliesToReference.Add(asm);
48 foreach(XmlNode import in section.SelectNodes("import"))
50 XmlAttribute attribute = import.Attributes["namespace"];
51 if (attribute == null)
52 throw GetConfigurationException("Attribute 'namespace' is mandatory for <import/> tags");
53 string name = attribute.Value;
54 options.NamespacesToImport.Add(name);
56 return options;
59 #endregion
61 private static Exception GetConfigurationException(string error)
63 return new ConfigurationErrorsException(error);