[EXaml] Add code for load EXaml
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / EXaml / Block / GatherTypesBlock.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
4 using System.Text;
5
6 namespace Tizen.NUI.EXaml
7 {
8     internal class GatherTypesBlock : Action
9     {
10         public GatherTypesBlock(Action parent)
11         {
12             this.parent = parent;
13         }
14
15         private Action parent;
16
17         public Action DealChar(char c)
18         {
19             switch (c)
20             {
21                 case ' ':
22                 case '\n':
23                 case '\r':
24                     break;
25
26                 case '(':
27                     childOp = new GetValueListAction(')', this);
28                     return childOp;
29
30                 case '>':
31                     parent?.OnActive();
32                     return parent;
33             }
34
35             return this;
36         }
37
38         private GetValueListAction childOp;
39
40         public void Init()
41         {
42             childOp = null;
43         }
44
45         public void OnActive()
46         {
47             LoadEXaml.Operations.Add(GatherType(childOp.ValueList));
48             childOp = null;
49         }
50
51         private GatherType GatherType(List<object> valueList)
52         {
53             int assemblyIndex = int.Parse(valueList[0] as string);
54             string typeName = valueList[valueList.Count - 1] as string;
55
56             if (valueList.Count > 2)
57             {
58                 List<int> genericTypeIndexs = new List<int>();
59                 var genericTypeIndexList = valueList[1] as List<object>;
60                 foreach (var index in genericTypeIndexList)
61                 {
62                     genericTypeIndexs.Add((int)index);
63                 }
64
65                 return new GatherType(assemblyIndex, typeName, genericTypeIndexs);
66             }
67             else
68             {
69                 return new GatherType(assemblyIndex, typeName);
70             }
71         }
72     }
73 }