- simplified the code to get the map value from placdeholder property using TextMapHelper
- reduce memory waste by calling Dispose() or using Add() from PropertyMapSetterHelper class
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
get
{
PropertyMap map = (PropertyMap)GetValue(PlaceholderProperty);
- PropertyValue value = null;
+ string defalutText = "";
- // text
- value = map.Find(0);
- if (null != value)
- {
- value.Get(out string text);
- map.Add("text", new PropertyValue(text));
- }
-
- // textFocused
- value = map.Find(1);
- if (null != value)
- {
- value.Get(out string textFocused);
- map.Add("textFocused", new PropertyValue(textFocused));
- }
-
- // color
- value = map.Find(2);
- if (null != value)
- {
- Color color = new Color();
- value.Get(color);
- map.Add("color", new PropertyValue(color));
- }
-
- // fontFamily
- value = map.Find(3);
- if (null != value)
- {
- value.Get(out string fontFamily);
- map.Add("fontFamily", new PropertyValue(fontFamily));
- }
+ if (TextMapHelper.IsValue(map, 0))
+ map.Add("text", TextMapHelper.GetStringFromMap(map, 0, defalutText));
- // fontStyle
- value = map.Find(4);
- if (null != value)
- {
- PropertyMap fontStyle = new PropertyMap();
- value.Get(fontStyle);
- map.Add("fontStyle", new PropertyValue(fontStyle));
- }
+ if (TextMapHelper.IsValue(map, 1))
+ map.Add("textFocused", TextMapHelper.GetStringFromMap(map, 1, defalutText));
+
+ if (TextMapHelper.IsValue(map, 2))
+ map.Add("color", TextMapHelper.GetColorFromMap(map, 2, Color.Black));
+
+ if (TextMapHelper.IsValue(map, 3))
+ map.Add("fontFamily", TextMapHelper.GetStringFromMap(map, 3, defalutText));
- // pointSize
- value = map.Find(5);
- if (null != value)
+ if (TextMapHelper.IsValue(map, 4))
{
- value.Get(out float pointSize);
- map.Add("pointSize", new PropertyValue(pointSize));
+ var fontStyle = new PropertyMap();
+ map.Find(4).Get(fontStyle);
+ var fontStyleValue = new PropertyValue(fontStyle);
+ map.Add("fontStyle", fontStyleValue);
+ fontStyleValue.Dispose();
+ fontStyle.Dispose();
}
- // pixelSize
- value = map.Find(6);
- if (null != value)
- {
- value.Get(out float pixelSize);
- map.Add("pixelSize", new PropertyValue(pixelSize));
- }
-
- // ellipsis
- value = map.Find(7);
- if (null != value)
- {
- value.Get(out bool ellipsis);
- map.Add("ellipsis", new PropertyValue(ellipsis));
- }
+ if (TextMapHelper.IsValue(map, 5))
+ map.Add("pointSize", TextMapHelper.GetNullableFloatFromMap(map, 5));
+
+ if (TextMapHelper.IsValue(map, 6))
+ map.Add("pixelSize", TextMapHelper.GetNullableFloatFromMap(map, 6));
+
+ if (TextMapHelper.IsValue(map, 7))
+ map.Add("ellipsis", TextMapHelper.GetBoolFromMap(map, 7, false));
return map;
}
get
{
PropertyMap map = (PropertyMap)GetValue(PlaceholderProperty);
- PropertyValue value = null;
+ string defalutText = "";
- // text
- value = map.Find(0);
- if (null != value)
- {
- value.Get(out string text);
- map.Add("text", new PropertyValue(text));
- }
-
- // textFocused
- value = map.Find(1);
- if (null != value)
- {
- value.Get(out string textFocused);
- map.Add("textFocused", new PropertyValue(textFocused));
- }
-
- // color
- value = map.Find(2);
- if (null != value)
- {
- Color color = new Color();
- value.Get(color);
- map.Add("color", new PropertyValue(color));
- }
-
- // fontFamily
- value = map.Find(3);
- if (null != value)
- {
- value.Get(out string fontFamily);
- map.Add("fontFamily", new PropertyValue(fontFamily));
- }
+ if (TextMapHelper.IsValue(map, 0))
+ map.Add("text", TextMapHelper.GetStringFromMap(map, 0, defalutText));
- // fontStyle
- value = map.Find(4);
- if (null != value)
- {
- PropertyMap fontStyle = new PropertyMap();
- value.Get(fontStyle);
- map.Add("fontStyle", new PropertyValue(fontStyle));
- }
+ if (TextMapHelper.IsValue(map, 1))
+ map.Add("textFocused", TextMapHelper.GetStringFromMap(map, 1, defalutText));
+
+ if (TextMapHelper.IsValue(map, 2))
+ map.Add("color", TextMapHelper.GetColorFromMap(map, 2, Color.Black));
+
+ if (TextMapHelper.IsValue(map, 3))
+ map.Add("fontFamily", TextMapHelper.GetStringFromMap(map, 3, defalutText));
- // pointSize
- value = map.Find(5);
- if (null != value)
+ if (TextMapHelper.IsValue(map, 4))
{
- value.Get(out float pointSize);
- map.Add("pointSize", new PropertyValue(pointSize));
+ var fontStyle = new PropertyMap();
+ map.Find(4).Get(fontStyle);
+ var fontStyleValue = new PropertyValue(fontStyle);
+ map.Add("fontStyle", fontStyleValue);
+ fontStyleValue.Dispose();
+ fontStyle.Dispose();
}
- // pixelSize
- value = map.Find(6);
- if (null != value)
- {
- value.Get(out float pixelSize);
- map.Add("pixelSize", new PropertyValue(pixelSize));
- }
-
- // ellipsis
- value = map.Find(7);
- if (null != value)
- {
- value.Get(out bool ellipsis);
- map.Add("ellipsis", new PropertyValue(ellipsis));
- }
+ if (TextMapHelper.IsValue(map, 5))
+ map.Add("pointSize", TextMapHelper.GetNullableFloatFromMap(map, 5));
+
+ if (TextMapHelper.IsValue(map, 6))
+ map.Add("pixelSize", TextMapHelper.GetNullableFloatFromMap(map, 6));
+
+ if (TextMapHelper.IsValue(map, 7))
+ map.Add("ellipsis", TextMapHelper.GetBoolFromMap(map, 7, false));
return map;
}
return selectionHandleImage;
}
- private static string GetCamelCase(string pascalCase)
+ internal static string GetCamelCase(string pascalCase)
{
if (!string.IsNullOrEmpty(pascalCase))
{
return pascalCase;
}
- private static string GetStringFromMap(PropertyMap map, string key, string defaultValue)
+ internal static string GetStringFromMap(PropertyMap map, string key, string defaultValue)
{
string value = defaultValue;
map.Find(0, key)?.Get(out value);
return value;
}
- private static string GetStringFromMap(PropertyMap map, int key, string defaultValue)
+ internal static string GetStringFromMap(PropertyMap map, int key, string defaultValue)
{
string value = defaultValue;
map.Find(key)?.Get(out value);
return value;
}
- private static bool GetBoolFromMap(PropertyMap map, string key, bool defaultValue)
+ internal static bool GetBoolFromMap(PropertyMap map, string key, bool defaultValue)
{
bool value = defaultValue;
map.Find(0, key)?.Get(out value);
return value;
}
- private static bool GetBoolFromMap(PropertyMap map, int key, bool defaultValue)
+ internal static bool GetBoolFromMap(PropertyMap map, int key, bool defaultValue)
{
bool value = defaultValue;
map.Find(key)?.Get(out value);
return value;
}
- private static int GetIntFromMap(PropertyMap map, int key, int defaultValue)
+ internal static int GetIntFromMap(PropertyMap map, int key, int defaultValue)
{
int value = defaultValue;
map.Find(key)?.Get(out value);
return value;
}
- private static float GetFloatFromMap(PropertyMap map, string key, float defaultValue)
+ internal static float GetFloatFromMap(PropertyMap map, string key, float defaultValue)
{
float value = defaultValue;
map.Find(0, key)?.Get(out value);
return value;
}
- private static Color GetColorFromMap(PropertyMap map, string key, Color defaultValue)
+ internal static Color GetColorFromMap(PropertyMap map, string key, Color defaultValue)
{
Color value = new Color(defaultValue);
map.Find(0, key)?.Get(value);
return value;
}
- private static Color GetColorFromMap(PropertyMap map, int key, Color defaultValue)
+ internal static Color GetColorFromMap(PropertyMap map, int key, Color defaultValue)
{
Color value = new Color(defaultValue);
map.Find(key)?.Get(value);
return value;
}
- private static Vector2 GetVector2FromMap(PropertyMap map, string key, Vector2 defaultValue)
+ internal static Vector2 GetVector2FromMap(PropertyMap map, string key, Vector2 defaultValue)
{
Vector2 value = new Vector2(defaultValue);
map.Find(0, key)?.Get(value);
return value;
}
- private static PropertyMap GetMapFromMap(PropertyMap map, int key, PropertyMap defaultValue)
+ internal static PropertyMap GetMapFromMap(PropertyMap map, int key, PropertyMap defaultValue)
{
PropertyMap value = new PropertyMap(defaultValue);
map.Find(key)?.Get(value);
return value;
}
- private static int? GetNullableIntFromMap(PropertyMap map, int key)
+ internal static int? GetNullableIntFromMap(PropertyMap map, int key)
{
PropertyValue propertyValue = map.Find(key);
if (propertyValue == null)
return value;
}
- private static float? GetNullableFloatFromMap(PropertyMap map, int key)
+ internal static float? GetNullableFloatFromMap(PropertyMap map, int key)
{
PropertyValue propertyValue = map.Find(key);
if (propertyValue == null)
propertyValue.Get(out float value);
return value;
}
+
+ internal static bool IsValue(PropertyMap map, int key)
+ {
+ PropertyValue propertyValue = map.Find(key);
+ if (propertyValue == null)
+ return false;
+
+ return true;
+ }
}
}
\ No newline at end of file