2 /*****************************************************************************
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
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 ********************************************************************************/
23 /************************************************
25 *************************************************/
31 using System
.Collections
.Specialized
;
35 namespace Castle
.MVC
.Configuration
38 /// Represents a commands configuration file.
40 public class CommandsSetting
43 /// Key used to retrieve command configuation element.
45 internal const string NODE_COMMAND_XPATH
= "command";
47 /// Key used to retrieve id view attribute.
49 internal const string ATTRIBUTE_VIEW
= "view";
51 /// Key used to retrieve id command attribute.
53 internal const string ATTRIBUTE_ID
= "id";
57 private string _view
= string.Empty
;
58 private StringDictionary _commands
= new StringDictionary();
63 /// Gets the specifed view id to navigate.
65 public string this[ string commandId
]
67 get{ return _commands[ commandId ]; }
71 /// Gets the view name.
80 /// Initializes an instance of the NodeSettings class using the specified configNode.
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
);