[NUI] remove build warning messages
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextMapHelper.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
18 using System;
19 using System.ComponentModel;
20 using Tizen.NUI.Text;
21
22 namespace Tizen.NUI.BaseComponents
23 {
24     /// <summary>
25     /// TextMapHelper converts PropertyMap to struct and struct to PropertyMap.
26     /// </summary>
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public static class TextMapHelper
29     {
30         /// <summary>
31         /// It returns a string value according to FontWidthType.
32         /// The returned value can be used for FontStyle PropertyMap.
33         /// <param name="fontWidthType">The FontWidthType enum value.</param>
34         /// <returns> A string value for FontStyle.Width property. </returns>
35         /// </summary>
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         public static string GetFontWidthString(FontWidthType fontWidthType)
38         {
39             string value = GetCamelCase(fontWidthType.ToString());
40             return string.IsNullOrEmpty(value) ? "none" : value;
41         }
42
43         /// <summary>
44         /// It returns a string value according to FontWeightType.
45         /// The returned value can be used for FontStyle PropertyMap.
46         /// <param name="fontWeightType">The FontWeightType enum value.</param>
47         /// <returns> A string value for FontStyle.Weight property. </returns>
48         /// </summary>
49         [EditorBrowsable(EditorBrowsableState.Never)]
50         public static string GetFontWeightString(FontWeightType fontWeightType)
51         {
52             string value = GetCamelCase(fontWeightType.ToString());
53             return string.IsNullOrEmpty(value) ? "none" : value;
54         }
55
56         /// <summary>
57         /// It returns a string value according to FontSlantType.
58         /// The returned value can be used for FontStyle PropertyMap.
59         /// <param name="fontSlantType">The FontSlantType enum value.</param>
60         /// <returns> A string value for FontStyle.Slant property. </returns>
61         /// </summary>
62         [EditorBrowsable(EditorBrowsableState.Never)]
63         public static string GetFontSlantString(FontSlantType fontSlantType)
64         {
65             string value = GetCamelCase(fontSlantType.ToString());
66             return string.IsNullOrEmpty(value) ? "none" : value;
67         }
68
69         /// <summary>
70         /// It returns a string value according to FontSizeType.
71         /// The returned value can be used for TextFit PropertyMap.
72         /// <param name="fontSizeType">The FontSizeType enum value.</param>
73         /// <returns> A string value for TextFit.FontSizeType property. </returns>
74         /// </summary>
75         [EditorBrowsable(EditorBrowsableState.Never)]
76         public static string GetFontSizeString(FontSizeType fontSizeType)
77         {
78             string value = GetCamelCase(fontSizeType.ToString());
79             return string.IsNullOrEmpty(value) ? "pointSize" : value;
80         }
81
82         /// <summary>
83         /// It returns a FontWidthType value according to fontWidthString.
84         /// The returned value can be used for FontStyle PropertyMap.
85         /// <param name="fontWidthString">The FontWidth string value.</param>
86         /// <returns> A FontWidthType value for FontStyle.Width property. </returns>
87         /// </summary>
88         [EditorBrowsable(EditorBrowsableState.Never)]
89         public static FontWidthType GetFontWidthType(string fontWidthString)
90         {
91             FontWidthType value;
92             if (!(Enum.TryParse(fontWidthString, true, out value) && Enum.IsDefined(typeof(FontWidthType), value)))
93             {
94                 value = FontWidthType.None; // If parsing fails, set a default value.
95             }
96
97             return value;
98         }
99
100         /// <summary>
101         /// It returns a FontWeightType value according to fontWeightString.
102         /// The returned value can be used for FontStyle PropertyMap.
103         /// <param name="fontWeightString">The FontWeight string value.</param>
104         /// <returns> A FontWeightType value for FontStyle.Weight property. </returns>
105         /// </summary>
106         [EditorBrowsable(EditorBrowsableState.Never)]
107         public static FontWeightType GetFontWeightType(string fontWeightString)
108         {
109             FontWeightType value;
110             if (!(Enum.TryParse(fontWeightString, true, out value) && Enum.IsDefined(typeof(FontWeightType), value)))
111             {
112                 value = FontWeightType.None; // If parsing fails, set a default value.
113             }
114
115             return value;
116         }
117
118         /// <summary>
119         /// It returns a FontSlantType value according to fontSlantString.
120         /// The returned value can be used for FontStyle PropertyMap.
121         /// <param name="fontSlantString">The FontSlant string value.</param>
122         /// <returns> A FontSlantType value for FontStyle.Slant property. </returns>
123         /// </summary>
124         [EditorBrowsable(EditorBrowsableState.Never)]
125         public static FontSlantType GetFontSlantType(string fontSlantString)
126         {
127             FontSlantType value;
128             if (!(Enum.TryParse(fontSlantString, true, out value) && Enum.IsDefined(typeof(FontSlantType), value)))
129             {
130                 value = FontSlantType.None; // If parsing fails, set a default value.
131             }
132
133             return value;
134         }
135
136         /// <summary>
137         /// It returns a FontSizeType value according to fontSizeString.
138         /// The returned value can be used for FontStyle PropertyMap.
139         /// <param name="fontSizeString">The FontSizeType string value.</param>
140         /// <returns> A FontSizeType value for TextFit.FontSizeType property. </returns>
141         /// </summary>
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public static FontSizeType GetFontSizeType(string fontSizeString)
144         {
145             FontSizeType value;
146             if (!(Enum.TryParse(fontSizeString, true, out value) && Enum.IsDefined(typeof(FontSizeType), value)))
147             {
148                 value = FontSizeType.PointSize; // If parsing fails, set a default value.
149             }
150
151             return value;
152         }
153
154         /// <summary>
155         /// This method converts a FontStyle struct to a PropertyMap and returns it.
156         /// The returned map can be used for set FontStyle PropertyMap in the SetFontStyle method.
157         /// <param name="fontStyle">The FontStyle struct value.</param>
158         /// <returns> A PropertyMap for FontStyle property. </returns>
159         /// </summary>
160         [EditorBrowsable(EditorBrowsableState.Never)]
161         public static PropertyMap GetFontStyleMap(FontStyle fontStyle)
162         {
163             var map = new PropertyMap();
164             map.Add("width", GetFontWidthString(fontStyle.Width));
165             map.Add("weight", GetFontWeightString(fontStyle.Weight));
166             map.Add("slant", GetFontSlantString(fontStyle.Slant));
167
168             return map;
169         }
170
171         /// <summary>
172         /// This method converts a FontStyle map to a struct and returns it.
173         /// The returned struct can be returned to the user as a FontStyle in the GetFontStyle method.
174         /// <param name="map">The FontStyle PropertyMap.</param>
175         /// <returns> A FontStyle struct. </returns>
176         /// </summary>
177         [EditorBrowsable(EditorBrowsableState.Never)]
178         public static FontStyle GetFontStyleStruct(PropertyMap map)
179         {
180             var fontStyle = new FontStyle();
181             if (null != map)
182             {
183                 var defaultValue = "none";
184                 fontStyle.Width = GetFontWidthType(GetStringFromMap(map, "width", defaultValue));
185                 fontStyle.Weight = GetFontWeightType(GetStringFromMap(map, "weight", defaultValue));
186                 fontStyle.Slant = GetFontSlantType(GetStringFromMap(map, "slant", defaultValue));
187             }
188
189             return fontStyle;
190         }
191
192         /// <summary>
193         /// This method converts a InputFilter struct to a PropertyMap and returns it. <br />
194         /// The returned map can be used for set InputFilter PropertyMap in the SetInputFilter method. <br />
195         /// <param name="inputFilter">The InputFilter struct value.</param>
196         /// <returns> A PropertyMap for InputFilter property. </returns>
197         /// </summary>
198         [EditorBrowsable(EditorBrowsableState.Never)]
199         public static PropertyMap GetInputFilterMap(InputFilter inputFilter)
200         {
201             var defaultValue = "";
202
203             var map = new PropertyMap();
204             var accepted = inputFilter.Accepted == null ? defaultValue : inputFilter.Accepted;
205             var rejected = inputFilter.Rejected == null ? defaultValue : inputFilter.Rejected;
206             map.Add(0, accepted);
207             map.Add(1, rejected);
208
209             return map;
210         }
211
212         /// <summary>
213         /// This method converts a InputFilter map to a struct and returns it. <br />
214         /// The returned struct can be returned to the user as a InputFilter in the GetInputFilter method. <br />
215         /// <param name="map">The InputFilter PropertyMap.</param>
216         /// <returns> A InputFilter struct. </returns>
217         /// </summary>
218         [EditorBrowsable(EditorBrowsableState.Never)]
219         public static InputFilter GetInputFilterStruct(PropertyMap map)
220         {
221             var inputFilter = new InputFilter();
222             if (null != map)
223             {
224                 var defaultValue = "";
225                 inputFilter.Accepted = GetStringFromMap(map, 0, defaultValue);
226                 inputFilter.Rejected = GetStringFromMap(map, 1, defaultValue);
227             }
228
229             return inputFilter;
230         }
231
232         /// <summary>
233         /// This method converts a Underline struct to a PropertyMap and returns it.
234         /// The returned map can be used for set Underline PropertyMap in the SetUnderline method.
235         /// <param name="underline">The Underline struct value.</param>
236         /// <returns> A PropertyMap for Underline property. </returns>
237         /// </summary>
238         [EditorBrowsable(EditorBrowsableState.Never)]
239         public static PropertyMap GetUnderlineMap(Underline underline)
240         {
241             var map = new PropertyMap();
242
243             map.Add("enable", underline.Enable);
244
245             if (underline.Color != null)
246                 map.Add("color", underline.Color);
247
248             if (underline.Height != null)
249                 map.Add("height", (float)underline.Height);
250
251             return map;
252         }
253
254         /// <summary>
255         /// This method converts a Underline map to a struct and returns it.
256         /// The returned struct can be returned to the user as a Underline in the GetUnderline method.
257         /// <param name="map">The Underline PropertyMap.</param>
258         /// <returns> A Underline struct. </returns>
259         /// </summary>
260         [EditorBrowsable(EditorBrowsableState.Never)]
261         public static Underline GetUnderlineStruct(PropertyMap map)
262         {
263             var underline = new Underline();
264             if (null != map)
265             {
266                 underline.Enable = GetBoolFromMap(map, "enable", false);
267                 underline.Color = GetColorFromMap(map, "color");
268                 underline.Height = GetFloatFromMap(map, "height", 0.0f);
269             }
270
271             return underline;
272         }
273
274         /// <summary>
275         /// This method converts a Shadow struct to a PropertyMap and returns it.
276         /// The returned map can be used for set Shadow PropertyMap in the SetShadow method.
277         /// <param name="shadow">The Shadow struct value.</param>
278         /// <returns> A PropertyMap for Shadow property. </returns>
279         /// </summary>
280         [EditorBrowsable(EditorBrowsableState.Never)]
281         public static PropertyMap GetShadowMap(Tizen.NUI.Text.Shadow shadow)
282         {
283             var map = new PropertyMap();
284
285             if (shadow.Offset != null)
286                 map.Add("offset", shadow.Offset);
287
288             if (shadow.Color != null)
289                 map.Add("color", shadow.Color);
290
291             if (shadow.BlurRadius != null)
292                 map.Add("blurRadius", (float)shadow.BlurRadius);
293
294             return map;
295         }
296
297         /// <summary>
298         /// This method converts a Shadow map to a struct and returns it.
299         /// The returned struct can be returned to the user as a Shadow in the GetShadow method.
300         /// <param name="map">The Shadow PropertyMap.</param>
301         /// <returns> A Shadow struct. </returns>
302         /// </summary>
303         [EditorBrowsable(EditorBrowsableState.Never)]
304         public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map)
305         {
306             var shadow = new Tizen.NUI.Text.Shadow();
307             if (null != map)
308             {
309                 shadow.Offset = GetVector2FromMap(map, "offset");
310                 shadow.Color = GetColorFromMap(map, "color");
311                 shadow.BlurRadius = GetFloatFromMap(map, "blurRadius", 0.0f);
312             }
313
314             return shadow;
315         }
316
317         /// <summary>
318         /// This method converts a Outline struct to a PropertyMap and returns it.
319         /// The returned map can be used for set Outline PropertyMap in the SetOutline method.
320         /// <param name="outline">The Outline struct value.</param>
321         /// <returns> A PropertyMap for Outline property. </returns>
322         /// </summary>
323         [EditorBrowsable(EditorBrowsableState.Never)]
324         public static PropertyMap GetOutlineMap(Outline outline)
325         {
326             var map = new PropertyMap();
327
328             if (outline.Color != null)
329                 map.Add("color", outline.Color);
330
331             if (outline.Width != null)
332                 map.Add("width", (float)outline.Width);
333
334             return map;
335         }
336
337         /// <summary>
338         /// This method converts a Outline map to a struct and returns it.
339         /// The returned struct can be returned to the user as a Outline in the GetOutline method.
340         /// <param name="map">The Outline PropertyMap.</param>
341         /// <returns> A Outline struct. </returns>
342         /// </summary>
343         [EditorBrowsable(EditorBrowsableState.Never)]
344         public static Outline GetOutlineStruct(PropertyMap map)
345         {
346             var outline = new Outline();
347             if (null != map)
348             {
349                 outline.Color = GetColorFromMap(map, "color");
350                 outline.Width = GetFloatFromMap(map, "width", 0.0f);
351             }
352
353             return outline;
354         }
355
356         /// <summary>
357         /// This method converts a TextFit struct to a PropertyMap and returns it.
358         /// The returned map can be used for set TextFit PropertyMap in the SetTextFit method.
359         /// <param name="textFit">The TextFit struct value.</param>
360         /// <returns> A PropertyMap for TextFit property. </returns>
361         /// </summary>
362         [EditorBrowsable(EditorBrowsableState.Never)]
363         public static PropertyMap GetTextFitMap(TextFit textFit)
364         {
365             var map = new PropertyMap();
366             map.Add("enable", textFit.Enable);
367             map.Add("fontSizeType", GetFontSizeString(textFit.FontSizeType));
368
369             if (textFit.MinSize != null)
370                 map.Add("minSize", (float)textFit.MinSize);
371
372             if (textFit.MaxSize != null)
373                 map.Add("maxSize", (float)textFit.MaxSize);
374
375             if (textFit.StepSize != null)
376                 map.Add("stepSize", (float)textFit.StepSize);
377
378             return map;
379         }
380
381         /// <summary>
382         /// This method converts a TextFit map to a struct and returns it.
383         /// The returned struct can be returned to the user as a TextFit in the GetTextFit method.
384         /// <param name="map">The TextFit PropertyMap.</param>
385         /// <returns> A TextFit struct. </returns>
386         /// </summary>
387         [EditorBrowsable(EditorBrowsableState.Never)]
388         public static TextFit GetTextFitStruct(PropertyMap map)
389         {
390             var textFit = new TextFit();
391             if (null != map)
392             {
393                 var defaultValue = "PointSize";
394                 textFit.Enable = GetBoolFromMap(map, "enable", false);
395                 textFit.MinSize = GetFloatFromMap(map, "minSize", 0.0f);
396                 textFit.MaxSize = GetFloatFromMap(map, "maxSize", 0.0f);
397                 textFit.StepSize = GetFloatFromMap(map, "stepSize", 0.0f);
398                 textFit.FontSize = GetFloatFromMap(map, "fontSize", 0.0f);
399                 textFit.FontSizeType = GetFontSizeType(GetStringFromMap(map, "fontSizeType", defaultValue));
400             }
401
402             return textFit;
403         }
404
405         /// <summary>
406         /// This method converts a Placeholder struct to a PropertyMap and returns it.
407         /// The returned map can be used for set Placeholder PropertyMap in the SetPlaceholder method.
408         /// <param name="placeholder">The Placeholder struct value.</param>
409         /// <returns> A PropertyMap for Placeholder property. </returns>
410         /// </summary>
411         [EditorBrowsable(EditorBrowsableState.Never)]
412         public static PropertyMap GetPlaceholderMap(Placeholder placeholder)
413         {
414             var map = new PropertyMap();
415
416             if (placeholder.Text != null)
417                 map.Add("text", placeholder.Text);
418
419             if (placeholder.TextFocused != null)
420                 map.Add("textFocused", placeholder.TextFocused);
421
422             if (placeholder.Color != null)
423                 map.Add("color", placeholder.Color);
424
425             if (placeholder.FontFamily != null)
426                 map.Add("fontFamily", placeholder.FontFamily);
427
428             if (placeholder.FontStyle != null)
429             {
430                 using (var fontStyleMap = GetFontStyleMap((FontStyle)placeholder.FontStyle))
431                 using (var fontStyleValue = new PropertyValue(fontStyleMap))
432                 {
433                     map.Add("fontStyle", fontStyleValue);
434                 }
435             }
436
437             if (placeholder.PointSize != null && placeholder.PixelSize != null)
438                 map.Add("pointSize", (float)placeholder.PointSize);
439
440             else if (placeholder.PointSize != null)
441                 map.Add("pointSize", (float)placeholder.PointSize);
442
443             else if (placeholder.PixelSize != null)
444                 map.Add("pixelSize", (float)placeholder.PixelSize);
445
446             map.Add("ellipsis", placeholder.Ellipsis);
447
448             return map;
449         }
450
451         /// <summary>
452         /// This method converts a Placeholder map to a struct and returns it.
453         /// The returned struct can be returned to the user as a Placeholder in the GetPlaceholder method.
454         /// <param name="map">The Placeholder PropertyMap.</param>
455         /// <returns> A Placeholder struct. </returns>
456         /// </summary>
457         [EditorBrowsable(EditorBrowsableState.Never)]
458         public static Placeholder GetPlaceholderStruct(PropertyMap map)
459         {
460             var placeholder = new Placeholder();
461             if (null != map)
462             {
463                 var defaultText = "";
464                 placeholder.Text = GetStringFromMap(map, 0, defaultText);
465                 placeholder.TextFocused = GetStringFromMap(map, 1, defaultText);
466                 placeholder.Color = GetColorFromMap(map, 2);
467                 placeholder.FontFamily = GetStringFromMap(map, 3, defaultText);
468                 using (var fontStyleMap = GetMapFromMap(map, 4))
469                 {
470                     placeholder.FontStyle = GetFontStyleStruct(fontStyleMap);
471                 }
472                 placeholder.PointSize = GetNullableFloatFromMap(map, 5);
473                 placeholder.PixelSize = GetNullableFloatFromMap(map, 6);
474                 placeholder.Ellipsis = GetBoolFromMap(map, 7, false);
475             }
476
477             return placeholder;
478         }
479
480         /// <summary>
481         /// This method converts a HiddenInput struct to a PropertyMap and returns it.
482         /// The returned map can be used for set HiddenInputSettings PropertyMap in the SetHiddenInput method.
483         /// <param name="hiddenInput">The HiddenInput struct value.</param>
484         /// <returns> A PropertyMap for HiddenInput property. </returns>
485         /// </summary>
486         [EditorBrowsable(EditorBrowsableState.Never)]
487         public static PropertyMap GetHiddenInputMap(HiddenInput hiddenInput)
488         {
489             var map = new PropertyMap();
490
491             map.Add(0, (int)hiddenInput.Mode);
492
493             if (hiddenInput.SubstituteCharacter != null)
494                 map.Add(1, Convert.ToInt32(hiddenInput.SubstituteCharacter));
495
496             if (hiddenInput.SubstituteCount != null)
497                 map.Add(2, (int)hiddenInput.SubstituteCount);
498
499             if (hiddenInput.ShowLastCharacterDuration != null)
500                 map.Add(3, (int)hiddenInput.ShowLastCharacterDuration);
501
502             return map;
503         }
504
505         /// <summary>
506         /// This method converts a HiddenInputSettings map to a struct and returns it.
507         /// The returned struct can be returned to the user as a HiddenInput in the GetHiddenInput method.
508         /// <param name="map">The HiddenInput PropertyMap.</param>
509         /// <returns> A HiddenInput struct. </returns>
510         /// </summary>
511         [EditorBrowsable(EditorBrowsableState.Never)]
512         public static HiddenInput GetHiddenInputStruct(PropertyMap map)
513         {
514             var hiddenInput = new HiddenInput();
515             if (null != map)
516             {
517                 int defaultVlaue = 0;
518                 hiddenInput.Mode = (HiddenInputModeType)GetIntFromMap(map, 0, defaultVlaue);
519
520                 int? substituteCharacter = GetNullableIntFromMap(map, 1);
521                 if (substituteCharacter != null)
522                     hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
523
524                 hiddenInput.SubstituteCount = GetNullableIntFromMap(map, 2);
525                 hiddenInput.ShowLastCharacterDuration = GetNullableIntFromMap(map, 3);
526             }
527
528             return hiddenInput;
529         }
530
531         /// <summary>
532         /// This method converts a fileName string to a PropertyMap and returns it.
533         /// The returned map can be used for set SelectionHandleImageLeft, SelectionHandleImageRight PropertyMap in the SetSelectionHandleImage method.
534         /// <param name="fileName">The file path string value for SelectionHandleImage.</param>
535         /// <returns> A PropertyMap for SelectionHandleImageLeft, SelectionHandleImageRight properties. </returns>
536         /// </summary>
537         [EditorBrowsable(EditorBrowsableState.Never)]
538         public static PropertyMap GetFileNameMap(string fileName)
539         {
540             return new PropertyMap().Add("filename", fileName);
541         }
542
543         /// <summary>
544         /// This method converts a SelectionHandleImageLeft, SelectionHandleImageRight map to a struct and returns it.
545         /// The returned struct can be returned to the user as a SelectionHandleImage in the GetSelectionHandleImage method.
546         /// <param name="leftImageMap">The SelectionHandleImageLeft PropertyMap.</param>
547         /// <param name="rightImageMap">The SelectionHandleImageRight PropertyMap.</param>
548         /// <returns> A SelectionHandleImage struct. </returns>
549         /// </summary>
550         [EditorBrowsable(EditorBrowsableState.Never)]
551         public static SelectionHandleImage GetSelectionHandleImageStruct(PropertyMap leftImageMap, PropertyMap rightImageMap)
552         {
553             var defaultValue = "";
554
555             var selectionHandleImage = new SelectionHandleImage();
556             if (null != leftImageMap)
557                 selectionHandleImage.LeftImageUrl = GetStringFromMap(leftImageMap, "filename", defaultValue);
558             
559             if (null != rightImageMap)
560                 selectionHandleImage.RightImageUrl = GetStringFromMap(rightImageMap, "filename", defaultValue);
561
562             return selectionHandleImage;
563         }
564
565         internal static string GetCamelCase(string pascalCase)
566         {
567             if (!string.IsNullOrEmpty(pascalCase))
568             {
569                 char[] charArray = pascalCase.ToCharArray();
570                 charArray[0] = Char.ToLower(charArray[0]);
571                 pascalCase = new string(charArray);
572             }
573
574             return pascalCase;
575         }
576
577         internal static string GetStringFromMap(PropertyMap map, string key, string defaultValue)
578         {
579             string value = defaultValue;
580             using (var propertyValue = map.Find(0, key))
581             {
582                 if (null != propertyValue) propertyValue.Get(out value);
583             }
584             return value;
585         }
586
587         internal static string GetStringFromMap(PropertyMap map, int key, string defaultValue)
588         {
589             string value = defaultValue;
590             using (var propertyValue = map.Find(key))
591             {
592                 if (null != propertyValue) propertyValue.Get(out value);
593             }
594             return value;
595         }
596
597         internal static bool GetBoolFromMap(PropertyMap map, string key, bool defaultValue)
598         {
599             bool value = defaultValue;
600             using (var propertyValue = map.Find(0, key))
601             {
602                 if (null != propertyValue) propertyValue.Get(out value);
603             }
604             return value;
605         }
606
607         internal static bool GetBoolFromMap(PropertyMap map, int key, bool defaultValue)
608         {
609             bool value = defaultValue;
610             using (var propertyValue = map.Find(key))
611             {
612                 if (null != propertyValue) propertyValue.Get(out value);
613             }
614             return value;
615         }
616
617         internal static int GetIntFromMap(PropertyMap map, int key, int defaultValue)
618         {
619             int value = defaultValue;
620             using (var propertyValue = map.Find(key))
621             {
622                 if (null != propertyValue) propertyValue.Get(out value);
623             }
624             return value;
625         }
626
627         internal static float GetFloatFromMap(PropertyMap map, string key, float defaultValue)
628         {
629             float value = defaultValue;
630             using (var propertyValue = map.Find(0, key))
631             {
632                 if (null != propertyValue) propertyValue.Get(out value);
633             }
634             return value;
635         }
636
637         internal static Color GetColorFromMap(PropertyMap map, string key)
638         {
639             Color value = new Color();
640             using (var propertyValue = map.Find(0, key))
641             {
642                 if (null != propertyValue) propertyValue.Get(value);
643             }
644             return value;
645         }
646
647         internal static Color GetColorFromMap(PropertyMap map, int key)
648         {
649             Color value = new Color();
650             using (var propertyValue = map.Find(key))
651             {
652                 if (null != propertyValue) propertyValue.Get(value);
653             }
654             return value;
655         }
656
657         internal static Vector2 GetVector2FromMap(PropertyMap map, string key)
658         {
659             Vector2 value = new Vector2();
660             using (var propertyValue = map.Find(0, key))
661             {
662                 if (null != propertyValue) propertyValue.Get(value);
663             }
664             return value;
665         }
666
667         internal static PropertyMap GetMapFromMap(PropertyMap map, int key)
668         {
669             PropertyMap value = new PropertyMap();
670             using (var propertyValue = map.Find(key))
671             {
672                 if (null != propertyValue) propertyValue.Get(value);
673             }
674             return value;
675         }
676
677         internal static int? GetNullableIntFromMap(PropertyMap map, int key)
678         {
679             using (var propertyValue = map.Find(key))
680             {
681                 if (propertyValue == null)
682                     return null;
683
684                 propertyValue.Get(out int value);
685                 return value;
686             }
687         }
688
689         internal static float? GetNullableFloatFromMap(PropertyMap map, int key)
690         {
691             using (var propertyValue = map.Find(key))
692             {
693                 if (propertyValue == null)
694                     return null;
695
696                 propertyValue.Get(out float value);
697                 return value;
698             }
699         }
700
701         internal static bool IsValue(PropertyMap map, int key)
702         {
703             using (var propertyValue = map.Find(key))
704             {
705                 if (propertyValue == null)
706                     return false;
707
708                 return true;
709             }
710         }
711     }
712 }