Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Framework / Configuration / DefaultUrl.cs
blobc9dd5de5a565e8d9107af987f6c54d401dd19fd0
1 namespace Castle.MonoRail.Framework.Configuration
3 using System;
4 using System.Configuration;
5 using System.Xml;
7 /// <summary>
8 /// Represents a url mapping
9 /// </summary>
10 public class DefaultUrl : ISerializedConfig
12 private string url, controller, action, area;
14 /// <summary>
15 /// Initializes a new instance of the <see cref="DefaultUrl"/> class.
16 /// </summary>
17 public DefaultUrl()
21 /// <summary>
22 /// Initializes a new instance of the <see cref="DefaultUrl"/> class.
23 /// </summary>
24 /// <param name="url">The URL.</param>
25 /// <param name="controller">The controller.</param>
26 /// <param name="action">The action.</param>
27 /// <param name="area">The area.</param>
28 public DefaultUrl(string url, string controller, string action, string area)
30 this.url = url;
31 this.controller = controller;
32 this.action = action;
33 this.area = area;
36 #region ISerializedConfig implementation
38 /// <summary>
39 /// Deserializes the specified section.
40 /// </summary>
41 /// <param name="section">The section.</param>
42 public void Deserialize(XmlNode section)
44 XmlAttribute urlAtt = section.Attributes["url"];
45 XmlAttribute controllerAtt = section.Attributes["controller"];
46 XmlAttribute actionAtt = section.Attributes["action"];
47 XmlAttribute areaAtt = section.Attributes["area"];
49 if ((urlAtt == null || urlAtt.Value == String.Empty) ||
50 (controllerAtt == null || controllerAtt.Value == String.Empty) ||
51 (actionAtt == null || actionAtt.Value == String.Empty))
53 String message = "To add a default url rule, please specify the 'url', 'controller', 'action' and optionally 'area' attributes. " +
54 "Check the documentation for more information";
55 throw new ConfigurationErrorsException(message);
58 url = urlAtt.Value;
59 action = actionAtt.Value;
60 controller = controllerAtt.Value;
62 if (areaAtt != null)
64 area = areaAtt.Value;
68 #endregion
70 /// <summary>
71 /// Gets the URL.
72 /// </summary>
73 /// <value>The URL.</value>
74 public string Url
76 get { return url; }
79 /// <summary>
80 /// Gets the controller.
81 /// </summary>
82 /// <value>The controller.</value>
83 public string Controller
85 get { return controller; }
88 /// <summary>
89 /// Gets the action.
90 /// </summary>
91 /// <value>The action.</value>
92 public string Action
94 get { return action; }
97 /// <summary>
98 /// Gets the area.
99 /// </summary>
100 /// <value>The area.</value>
101 public string Area
103 get { return area; }