[NUI] Add Tizen.NUI.XamlBuild module
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.XamlBuild / src / public / EXamlBuild / EXaml / EXamlValueConverterFromString.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  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using Mono.Cecil;
18 using System;
19 using System.Collections.Generic;
20 using System.Text;
21 using Tizen.NUI.EXaml.Build.Tasks;
22
23 namespace Tizen.NUI.EXaml
24 {
25     internal class EXamlValueConverterFromString
26     {
27         private EXamlContext context;
28
29         internal string GetString()
30         {
31             string ret = "";
32             ret += String.Format("{0} {1}", context.GetValueString(converterInstance), context.GetValueString(Value));
33             return ret;
34         }
35
36         internal EXamlValueConverterFromString(EXamlContext context, TypeDefinition converterType, string value)
37         {
38             this.context = context;
39
40             ConverterType = converterType;
41             Value = value;
42
43             if (!context.typeToInstance.ContainsKey(converterType))
44             {
45                 converterInstance = new EXamlCreateObject(context, null, converterType);
46                 context.typeToInstance.Add(converterType, converterInstance);
47             }
48             else
49             {
50                 converterInstance = context.typeToInstance[converterType];
51             }
52         }
53
54         internal TypeDefinition ConverterType
55         {
56             get;
57             private set;
58         }
59
60         internal string Value
61         {
62             get;
63             private set;
64         }
65
66         private EXamlCreateObject converterInstance;
67     }
68 }