-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node_patch.cs
92 lines (86 loc) · 3.79 KB
/
Node_patch.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Teamcenter.Schemas.Soa._2011_06.Metamodel;
namespace Teamcenter.Soa.Internal.Client.Parse
{
public abstract class Node_patch
{
private static readonly IDictionary<Type, Type> CDM_TYPES = new Dictionary<Type, Type>()
{
{
typeof (Teamcenter.Soa.Client.Model.ServiceData),
typeof (Teamcenter.Schemas.Soa._2006_03.Base.ServiceData)
},
{
typeof (Teamcenter.Soa.Client.Model.Preferences),
typeof (Teamcenter.Schemas.Soa._2006_03.Base.Preferences)
},
{
typeof (Teamcenter.Soa.Client.Model.PartialErrors),
typeof (Teamcenter.Schemas.Soa._2006_03.Base.PartialErrors)
},
{
typeof (Teamcenter.Schemas.Soa._2006_03.Base.ModelSchema),
typeof (Teamcenter.Schemas.Soa._2006_03.Base.ModelSchema)
},
{
typeof (TypeSchema),
typeof (TypeSchema)
}
};
private static readonly IDictionary<Type, Type> POLICY_TYPES = new Dictionary<Type, Type>()
{
{
typeof (Teamcenter.Soa.Common.ObjectPropertyPolicy),
typeof (Teamcenter.Soa.Common.ObjectPropertyPolicy)
},
{
typeof (Teamcenter.Soa.Common.PolicyType),
typeof (Teamcenter.Soa.Common.PolicyType)
},
{
typeof (Teamcenter.Soa.Common.PolicyProperty),
typeof (Teamcenter.Soa.Common.PolicyProperty)
}
};
private static readonly ISet<Type> ELEMENT_TYPES = (ISet<Type>)new HashSet<Type>()
{
typeof (Teamcenter.Soa.Client.Model.ServiceData),
typeof (Teamcenter.Soa.Client.Model.Preferences),
typeof (Teamcenter.Soa.Client.Model.PartialErrors),
typeof (Teamcenter.Soa.Common.ObjectPropertyPolicy)
};
protected static Node BuildChildNode(Type type, string name, FieldInfo field, Hashtable allNodes)
{
if (allNodes.Contains(type))
{
if (((Node)allNodes[type]).LocalName == name) //Patch
{
return (Node)allNodes[type];
}
}
if (!type.IsArray)
{
return !PrimitiveNode.IsPrimitiveType(type) ?
(!typeof(Hashtable).IsAssignableFrom(type) ?
(!typeof(Teamcenter.Soa.Client.Model.ModelObject).IsAssignableFrom(type) ?
(!CDM_TYPES.ContainsKey(type) ?
(!POLICY_TYPES.ContainsKey(type) ?
(Node)new StructNode(type, name, field, allNodes) :
(Node)new PolicyNode(type, name, allNodes)) :
(Node)new CDMStructNode(type, CDM_TYPES[type], allNodes)) :
(Node)new ModelObjectNode(type, name)) :
(Node)new MapNode(type, name, field, allNodes)) :
(Node)PrimitiveNode.Builder(type, name);
}
Type elementType = type.GetElementType();
return !PrimitiveNode.IsPrimitiveType(elementType) ?
(!typeof(Teamcenter.Soa.Client.Model.ModelObject).IsAssignableFrom(elementType) ?
(Node)new StructArrayNode(type, name, field, allNodes) :
(Node)new ModelObjectArrayNode(type, name, field, allNodes)) :
(Node)new PrimitiveArrayNode(type, name);
}
}
}