|
1
|
|
#region Copyright
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
|
21
|
|
|
|
22
|
|
#endregion
|
|
23
|
|
|
|
24
|
|
using System;
|
|
25
|
|
using System.Reflection;
|
|
26
|
|
using ShowX.Config;
|
|
27
|
|
using ShowX.Session;
|
|
28
|
|
using log4net;
|
|
29
|
|
|
|
30
|
|
namespace ShowX.Model.XmlModel
|
|
31
|
|
{
|
|
32
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
public class XmlObjectHandlerMethodCaller : ObjectHandlerMethodCaller
|
|
36
|
|
{
|
|
37
|
|
private static readonly ILog log = LogManager.GetLogger(
|
|
38
|
|
typeof(XmlObjectHandlerMethodCaller));
|
|
39
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
|
|
44
|
|
|
|
45
|
|
|
|
46
|
144
|
protected override IObjectHandler BuildObjectHandlerFromType(Type t)
|
|
47
|
|
{
|
|
48
|
144
|
XmlSession session = Configuration.Session as XmlSession;
|
|
49
|
|
|
|
50
|
144
|
if (session[t] == null) {
|
|
51
|
|
|
|
52
|
1
|
string errorMsg = string.Format(
|
|
53
|
|
"Attempt to use non registered type '{0}'",t.FullName);
|
|
54
|
|
|
|
55
|
1
|
log.Fatal(errorMsg);
|
|
56
|
1
|
throw new ModelException(errorMsg);
|
|
57
|
|
}
|
|
58
|
|
|
|
59
|
143
|
Type handler = session[t].HandlerType as Type;
|
|
60
|
|
|
|
61
|
143
|
if (handler == null) {
|
|
62
|
|
|
|
63
|
0
|
string errorMsg = string.Format(
|
|
64
|
|
"No object handler defined for type '{0}'",t.FullName);
|
|
65
|
|
|
|
66
|
0
|
log.Fatal(errorMsg);
|
|
67
|
0
|
throw new ModelException(errorMsg);
|
|
68
|
|
}
|
|
69
|
|
|
|
70
|
143
|
IObjectHandler objectHandler = handler.InvokeMember("",
|
|
71
|
|
BindingFlags.CreateInstance,null,null,null) as IObjectHandler;
|
|
72
|
|
|
|
73
|
143
|
if (objectHandler == null) {
|
|
74
|
|
|
|
75
|
0
|
string errorMsg = string.Format(
|
|
76
|
|
"Object handler for type {0} cannot be loaded",t.Name);
|
|
77
|
|
|
|
78
|
0
|
log.Fatal(errorMsg);
|
|
79
|
0
|
throw new ModelException(errorMsg);
|
|
80
|
|
}
|
|
81
|
|
|
|
82
|
143
|
return objectHandler;
|
|
83
|
|
}
|
|
84
|
|
}
|
|
85
|
|
}
|
|
86
|
|
|