[NUI] Add Tizen.NUI.XamlBuild module
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.XamlBuild / src / public / EXamlBuild / EXaml / EXamlCreateObject / EXamlCreateArrayObject.cs
1 using Mono.Cecil;
2 using System;
3 using System.Collections.Generic;
4 using System.Text;
5 using Tizen.NUI.EXaml.Build.Tasks;
6
7 namespace Tizen.NUI.EXaml
8 {
9     internal class EXamlCreateArrayObject : EXamlCreateObject
10     {
11         public EXamlCreateArrayObject(EXamlContext context, TypeReference type, List<object> items) : base(context, null, type)
12         {
13             this.items = items;
14         }
15
16         internal override string Write()
17         {
18             if (false == IsValid)
19             {
20                 return "";
21             }
22
23             string itemsString = "";
24             if (0 < items.Count)
25             {
26                 itemsString += "(";
27
28                 foreach (var item in items)
29                 {
30                     itemsString += $"{eXamlContext.GetValueString(item)} ";
31                 }
32
33                 itemsString += ")";
34             }
35
36             string ret = String.Format("({0} ({1} {2}))\n",
37                          eXamlContext.GetValueString((int)EXamlOperationType.CreateArrayObject),
38                          eXamlContext.GetValueString(eXamlContext.GetTypeIndex(Type)),
39                          itemsString);
40
41             return ret;
42         }
43
44         private List<object> items;
45     }
46 }