Added RedirectUsingNamedRoute
[castle.git] / InversionOfControl / Castle.Windsor / Configuration / Interpreters / XmlProcessor / ElementProcessors / DefaultElementProcessor.cs
blob808e7c129d94679ee3a7fc0fd76c3b827b5220e5
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.Windsor.Configuration.Interpreters.XmlProcessor.ElementProcessors
17 using System;
18 using System.Xml;
20 public class DefaultElementProcessor : AbstractXmlNodeProcessor
22 private static readonly String IncludeAttrName = "includeUri";
23 private static readonly DefaultTextNodeProcessor textProcessor = new DefaultTextNodeProcessor();
24 private static readonly IncludeElementProcessor includeProcessor = new IncludeElementProcessor();
26 public DefaultElementProcessor()
30 public override String Name
32 get { return ""; }
35 public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine)
37 XmlElement element = nodeList.Current as XmlElement;
39 ProcessAttributes(element, engine);
41 engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(element.ChildNodes));
44 /// <summary>
45 /// Processes element attributes.
46 /// if the attribute is include will append to the element
47 /// all contents from the file.
48 /// if the attribute has a property reference the reference will be
49 /// expanded
50 /// </summary>
51 /// <param name="element">The element.</param>
52 /// <param name="engine"></param>
53 private void ProcessAttributes(XmlElement element, IXmlProcessorEngine engine)
55 ProcessIncludeAttribute(element, engine);
57 foreach(XmlAttribute att in element.Attributes)
59 textProcessor.ProcessString(att, att.Value, engine);
63 private void ProcessIncludeAttribute(XmlElement element, IXmlProcessorEngine engine)
65 XmlAttribute include = element.Attributes[IncludeAttrName] as XmlAttribute;
67 if (include != null)
69 // removing the include attribute from the element
70 element.Attributes.RemoveNamedItem(IncludeAttrName);
72 XmlNode includeContent = includeProcessor.ProcessInclude(element, include.Value, engine);
74 if (includeContent != null)
76 element.PrependChild(includeContent);