Fixing an issue where setting a custom property on a handler will not propagate it...
[castle.git] / MonoRail / Castle.MonoRail.Framework / Configuration / DefaultUrl.cs
blob878778b089807ff59b16f1c8275c8b11da127126
1 namespace Castle.MonoRail.Framework.Configuration
3 using System;
4 using System.Configuration;
5 using System.Xml;
7 public class DefaultUrl : ISerializedConfig
9 private string url, controller, action, area;
11 /// <summary>
12 /// Initializes a new instance of the <see cref="DefaultUrl"/> class.
13 /// </summary>
14 public DefaultUrl()
18 /// <summary>
19 /// Initializes a new instance of the <see cref="DefaultUrl"/> class.
20 /// </summary>
21 /// <param name="url">The URL.</param>
22 /// <param name="controller">The controller.</param>
23 /// <param name="action">The action.</param>
24 /// <param name="area">The area.</param>
25 public DefaultUrl(string url, string controller, string action, string area)
27 this.url = url;
28 this.controller = controller;
29 this.action = action;
30 this.area = area;
33 #region ISerializedConfig implementation
35 public void Deserialize(XmlNode section)
37 XmlAttribute urlAtt = section.Attributes["url"];
38 XmlAttribute controllerAtt = section.Attributes["controller"];
39 XmlAttribute actionAtt = section.Attributes["action"];
40 XmlAttribute areaAtt = section.Attributes["area"];
42 if ((urlAtt == null || urlAtt.Value == String.Empty) ||
43 (controllerAtt == null || controllerAtt.Value == String.Empty) ||
44 (actionAtt == null || actionAtt.Value == String.Empty))
46 String message = "To add a default url rule, please specify the 'url', 'controller', 'action' and optionally 'area' attributes. " +
47 "Check the documentation for more information";
48 throw new ConfigurationErrorsException(message);
51 url = urlAtt.Value;
52 action = actionAtt.Value;
53 controller = controllerAtt.Value;
55 if (areaAtt != null)
57 area = areaAtt.Value;
61 #endregion
63 /// <summary>
64 /// Gets the URL.
65 /// </summary>
66 /// <value>The URL.</value>
67 public string Url
69 get { return url; }
72 /// <summary>
73 /// Gets the controller.
74 /// </summary>
75 /// <value>The controller.</value>
76 public string Controller
78 get { return controller; }
81 /// <summary>
82 /// Gets the action.
83 /// </summary>
84 /// <value>The action.</value>
85 public string Action
87 get { return action; }
90 /// <summary>
91 /// Gets the area.
92 /// </summary>
93 /// <value>The area.</value>
94 public string Area
96 get { return area; }