[EXaml] Add code for load EXaml
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / EXaml / Action / SetBindingAction.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
4 using System.Text;
5 using Tizen.NUI.Binding;
6 using Tizen.NUI.Binding.Internals;
7
8 namespace Tizen.NUI.EXaml
9 {
10     internal class SetBindingAction : Action
11     {
12         public SetBindingAction(Action parent)
13         {
14             this.parent = parent;
15         }
16
17         private Action parent;
18
19         public Action DealChar(char c)
20         {
21             switch (c)
22             {
23                 case ' ':
24                 case '\n':
25                 case '\r':
26                     break;
27
28                 case '(':
29                     childOp = new GetValueListAction(')', this);
30                     return childOp;
31
32                 case '%':
33                     parent?.OnActive();
34                     return parent;
35             }
36
37             return this;
38         }
39
40         private GetValueListAction childOp;
41
42         public void Init()
43         {
44             childOp = null;
45         }
46
47         public void OnActive()
48         {
49             if (null != childOp)
50             {
51                 int instanceIndex = (childOp.ValueList[0] as Instance).Index;
52                 var propertyIndex = (int)childOp.ValueList[1];
53                 int valueIndex = (childOp.ValueList[2] as Instance).Index;
54
55                 LoadEXaml.Operations.Add(new SetBinding(instanceIndex, propertyIndex, valueIndex));
56             }
57         }
58     }
59 }