Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / MVC / Castle.MVC / Configuration / CommandsSetting.cs
blob104ea5400d904d644031babd3dc1759e592f87cd
1 #region Apache Notice
2 /*****************************************************************************
3 *
4 * Castle.MVC
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ********************************************************************************/
19 #endregion
21 #region Autors
23 /************************************************
24 * Gilles Bayon
25 *************************************************/
26 #endregion
28 #region Using
30 using System;
31 using System.Collections.Specialized;
32 using System.Xml;
33 #endregion
35 namespace Castle.MVC.Configuration
37 /// <summary>
38 /// Represents a commands configuration file.
39 /// </summary>
40 public class CommandsSetting
42 /// <summary>
43 /// Key used to retrieve command configuation element.
44 /// </summary>
45 internal const string NODE_COMMAND_XPATH = "command";
46 /// <summary>
47 /// Key used to retrieve id view attribute.
48 /// </summary>
49 internal const string ATTRIBUTE_VIEW = "view";
50 /// <summary>
51 /// Key used to retrieve id command attribute.
52 /// </summary>
53 internal const string ATTRIBUTE_ID = "id";
55 #region Fields
57 private string _view = string.Empty;
58 private StringDictionary _commands = new StringDictionary();
59 #endregion
61 #region Properties
62 /// <summary>
63 /// Gets the specifed view id to navigate.
64 /// </summary>
65 public string this[ string commandId ]
67 get{ return _commands[ commandId ]; }
70 /// <summary>
71 /// Gets the view name.
72 /// </summary>
73 public string View
75 get{ return _view; }
77 #endregion
79 /// <summary>
80 /// Initializes an instance of the NodeSettings class using the specified configNode.
81 /// </summary>
82 /// <param name="configNode">The XmlNode from the configuration file.</param>
83 public CommandsSetting(XmlNode configNode)
85 XmlNode currentAttribute = configNode.Attributes[ATTRIBUTE_VIEW];
86 if( currentAttribute.Value.Trim().Length > 0 )
87 _view = currentAttribute.Value;
89 foreach(XmlNode commandNode in configNode.SelectNodes( NODE_COMMAND_XPATH ) )
91 string id = commandNode.Attributes[ATTRIBUTE_ID].Value;
92 string view = commandNode.Attributes[ATTRIBUTE_VIEW].Value;
93 _commands.Add( id, view );