-
Notifications
You must be signed in to change notification settings - Fork 3
/
ViewBehaviourObjectDefinitionParser.cs
48 lines (42 loc) · 1.7 KB
/
ViewBehaviourObjectDefinitionParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Xml;
using Spring.Objects.Factory.Support;
using Spring.Objects.Factory.Xml;
namespace Inversion.Spring {
/// <summary>
/// Implements a parser that is able to parse view behaviour definitions
/// in a Spring XML object config.
/// </summary>
public class ViewBehaviourObjectDefinitionParser : AbstractSimpleObjectDefinitionParser {
/// <summary>
/// Gets a value indicating whether an ID should be generated instead
/// if the passed in XmlElement does not specify an "id" attribute explicitly.
/// </summary>
protected override bool ShouldGenerateIdAsFallback {
get { return true; }
}
/// <summary>
/// Obtains the fully qualified type name of the object represented
/// by the XML element.
/// </summary>
/// <param name="element">The object representation in XML.</param>
/// <returns>
/// Returns the fully qualified type name for the object being described.
/// </returns>
protected override string GetObjectTypeName(XmlElement element) {
return element.GetAttribute("type");
}
/// <summary>
/// Parse the supplied XmlElement and populate the supplied ObjectDefinitionBuilder as required.
/// </summary>
/// <param name="xml">The obejct representation in XML.</param>
/// <param name="builder">The builder used to build the object definition in Spring.</param>
protected override void DoParse(XmlElement xml, ObjectDefinitionBuilder builder) {
// all behaviours with config being parsed have @respondsTo
string respondsTo = xml.GetAttribute("responds-to");
builder.AddConstructorArg(respondsTo);
// all view behaviours have @content-type
string contentType = xml.GetAttribute("content-type");
builder.AddConstructorArg(contentType);
}
}
}