Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / EXaml / Block / GatherMethodsBlock.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8 /*
9  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  */
24 using System;
25 using System.Collections.Generic;
26 using System.Reflection;
27 using System.Text;
28
29 namespace Tizen.NUI.EXaml
30 {
31     internal class GatherMethodsBlock : Action
32     {
33         public GatherMethodsBlock(GlobalDataList globalDataList, Action parent)
34         {
35             this.parent = parent;
36             this.globalDataList = globalDataList;
37         }
38
39         private Action parent;
40         private GlobalDataList globalDataList;
41
42         public Action DealChar(char c)
43         {
44             switch (c)
45             {
46                 case ' ':
47                 case '\n':
48                 case '\r':
49                     break;
50
51                 case '(':
52                     childOp = new GetValueListAction(')', this);
53                     return childOp;
54
55                 case '>':
56                     parent?.OnActive();
57                     return parent;
58             }
59
60             return this;
61         }
62
63         private GetValueListAction childOp;
64
65         public void Init()
66         {
67             childOp = null;
68         }
69
70         public void OnActive()
71         {
72             int typeIndex = int.Parse(childOp.ValueList[0] as string);
73             string name = childOp.ValueList[1] as string;
74             var paramList = childOp.ValueList[2] as List<object>;
75             globalDataList.PreLoadOperations.Add(new GatherMethod(globalDataList, typeIndex, name, paramList));
76         }
77     }
78 }