[EditorBrowsable(EditorBrowsableState.Never)]
public static FontStyle GetFontStyleStruct(PropertyMap map)
{
- var defaultValue = "none";
-
var fontStyle = new FontStyle();
- fontStyle.Width = GetFontWidthType(GetStringFromMap(map, "width", defaultValue));
- fontStyle.Weight = GetFontWeightType(GetStringFromMap(map, "weight", defaultValue));
- fontStyle.Slant = GetFontSlantType(GetStringFromMap(map, "slant", defaultValue));
+ if (null != map)
+ {
+ var defaultValue = "none";
+ fontStyle.Width = GetFontWidthType(GetStringFromMap(map, "width", defaultValue));
+ fontStyle.Weight = GetFontWeightType(GetStringFromMap(map, "weight", defaultValue));
+ fontStyle.Slant = GetFontSlantType(GetStringFromMap(map, "slant", defaultValue));
+ }
return fontStyle;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static InputFilter GetInputFilterStruct(PropertyMap map)
{
- var defaultValue = "";
-
var inputFilter = new InputFilter();
- inputFilter.Accepted = GetStringFromMap(map, 0, defaultValue);
- inputFilter.Rejected = GetStringFromMap(map, 1, defaultValue);
+ if (null != map)
+ {
+ var defaultValue = "";
+ inputFilter.Accepted = GetStringFromMap(map, 0, defaultValue);
+ inputFilter.Rejected = GetStringFromMap(map, 1, defaultValue);
+ }
return inputFilter;
}
public static Underline GetUnderlineStruct(PropertyMap map)
{
var underline = new Underline();
- underline.Enable = GetBoolFromMap(map, "enable", false);
- underline.Color = GetColorFromMap(map, "color", Color.Black);
- underline.Height = GetFloatFromMap(map, "height", 0.0f);
+ if (null != map)
+ {
+ underline.Enable = GetBoolFromMap(map, "enable", false);
+ underline.Color = GetColorFromMap(map, "color");
+ underline.Height = GetFloatFromMap(map, "height", 0.0f);
+ }
return underline;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map)
{
- var defaultValue = new Vector2(0, 0);
-
var shadow = new Tizen.NUI.Text.Shadow();
- shadow.Offset = GetVector2FromMap(map, "offset", defaultValue);
- defaultValue.Dispose();
- shadow.Color = GetColorFromMap(map, "color", Color.Black);
- shadow.BlurRadius = GetFloatFromMap(map, "blurRadius", 0.0f);
+ if (null != map)
+ {
+ shadow.Offset = GetVector2FromMap(map, "offset");
+ shadow.Color = GetColorFromMap(map, "color");
+ shadow.BlurRadius = GetFloatFromMap(map, "blurRadius", 0.0f);
+ }
return shadow;
}
public static Outline GetOutlineStruct(PropertyMap map)
{
var outline = new Outline();
- outline.Color = GetColorFromMap(map, "color", Color.Black);
- outline.Width = GetFloatFromMap(map, "width", 0.0f);
+ if (null != map)
+ {
+ outline.Color = GetColorFromMap(map, "color");
+ outline.Width = GetFloatFromMap(map, "width", 0.0f);
+ }
return outline;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static TextFit GetTextFitStruct(PropertyMap map)
{
- var defaultValue = "PointSize";
-
var textFit = new TextFit();
- textFit.Enable = GetBoolFromMap(map, "enable", false);
- textFit.MinSize = GetFloatFromMap(map, "minSize", 0.0f);
- textFit.MaxSize = GetFloatFromMap(map, "maxSize", 0.0f);
- textFit.StepSize = GetFloatFromMap(map, "stepSize", 0.0f);
- textFit.FontSize = GetFloatFromMap(map, "fontSize", 0.0f);
- textFit.FontSizeType = GetFontSizeType(GetStringFromMap(map, "fontSizeType", defaultValue));
+ if (null != map)
+ {
+ var defaultValue = "PointSize";
+ textFit.Enable = GetBoolFromMap(map, "enable", false);
+ textFit.MinSize = GetFloatFromMap(map, "minSize", 0.0f);
+ textFit.MaxSize = GetFloatFromMap(map, "maxSize", 0.0f);
+ textFit.StepSize = GetFloatFromMap(map, "stepSize", 0.0f);
+ textFit.FontSize = GetFloatFromMap(map, "fontSize", 0.0f);
+ textFit.FontSizeType = GetFontSizeType(GetStringFromMap(map, "fontSizeType", defaultValue));
+ }
return textFit;
}
if (placeholder.FontStyle != null)
{
- var fontStyleValue = new PropertyValue(GetFontStyleMap((FontStyle)placeholder.FontStyle));
- map.Add("fontStyle", fontStyleValue);
- fontStyleValue.Dispose();
+ using (var fontStyleMap = GetFontStyleMap((FontStyle)placeholder.FontStyle))
+ using (var fontStyleValue = new PropertyValue(fontStyleMap))
+ {
+ map.Add("fontStyle", fontStyleValue);
+ }
}
if (placeholder.PointSize != null && placeholder.PixelSize != null)
[EditorBrowsable(EditorBrowsableState.Never)]
public static Placeholder GetPlaceholderStruct(PropertyMap map)
{
- var defaultText = "";
- var defaultFontStyle = new PropertyMap();
-
var placeholder = new Placeholder();
- placeholder.Text = GetStringFromMap(map, 0, defaultText);
- placeholder.TextFocused = GetStringFromMap(map, 1, defaultText);
- placeholder.Color = GetColorFromMap(map, 2, Color.Black);
- placeholder.FontFamily = GetStringFromMap(map, 3, defaultText);
- placeholder.FontStyle = GetFontStyleStruct(GetMapFromMap(map, 4, defaultFontStyle));
- defaultFontStyle.Dispose();
- placeholder.PointSize = GetNullableFloatFromMap(map, 5);
- placeholder.PixelSize = GetNullableFloatFromMap(map, 6);
- placeholder.Ellipsis = GetBoolFromMap(map, 7, false);
+ if (null != map)
+ {
+ var defaultText = "";
+ placeholder.Text = GetStringFromMap(map, 0, defaultText);
+ placeholder.TextFocused = GetStringFromMap(map, 1, defaultText);
+ placeholder.Color = GetColorFromMap(map, 2);
+ placeholder.FontFamily = GetStringFromMap(map, 3, defaultText);
+ using (var fontStyleMap = GetMapFromMap(map, 4))
+ {
+ placeholder.FontStyle = GetFontStyleStruct(fontStyleMap);
+ }
+ placeholder.PointSize = GetNullableFloatFromMap(map, 5);
+ placeholder.PixelSize = GetNullableFloatFromMap(map, 6);
+ placeholder.Ellipsis = GetBoolFromMap(map, 7, false);
+ }
return placeholder;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static HiddenInput GetHiddenInputStruct(PropertyMap map)
{
- int defaultVlaue = 0;
-
var hiddenInput = new HiddenInput();
- hiddenInput.Mode = (HiddenInputModeType)GetIntFromMap(map, 0, defaultVlaue);
+ if (null != map)
+ {
+ int defaultVlaue = 0;
+ hiddenInput.Mode = (HiddenInputModeType)GetIntFromMap(map, 0, defaultVlaue);
- int? substituteCharacter = GetNullableIntFromMap(map, 1);
- if (substituteCharacter != null)
- hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
+ int? substituteCharacter = GetNullableIntFromMap(map, 1);
+ if (substituteCharacter != null)
+ hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
- hiddenInput.SubstituteCount = GetNullableIntFromMap(map, 2);
- hiddenInput.ShowLastCharacterDuration = GetNullableIntFromMap(map, 3);
+ hiddenInput.SubstituteCount = GetNullableIntFromMap(map, 2);
+ hiddenInput.ShowLastCharacterDuration = GetNullableIntFromMap(map, 3);
+ }
return hiddenInput;
}
var defaultValue = "";
var selectionHandleImage = new SelectionHandleImage();
- selectionHandleImage.LeftImageUrl = GetStringFromMap(leftImageMap, "filename", defaultValue);
- selectionHandleImage.RightImageUrl = GetStringFromMap(rightImageMap, "filename", defaultValue);
+ if (null != leftImageMap)
+ selectionHandleImage.LeftImageUrl = GetStringFromMap(leftImageMap, "filename", defaultValue);
+
+ if (null != rightImageMap)
+ selectionHandleImage.RightImageUrl = GetStringFromMap(rightImageMap, "filename", defaultValue);
return selectionHandleImage;
}
internal static string GetStringFromMap(PropertyMap map, string key, string defaultValue)
{
string value = defaultValue;
- map.Find(0, key)?.Get(out value);
+ using (var propertyValue = map.Find(0, key))
+ {
+ if (null != propertyValue) propertyValue.Get(out value);
+ }
return value;
}
internal static string GetStringFromMap(PropertyMap map, int key, string defaultValue)
{
string value = defaultValue;
- map.Find(key)?.Get(out value);
+ using (var propertyValue = map.Find(key))
+ {
+ if (null != propertyValue) propertyValue.Get(out value);
+ }
return value;
}
internal static bool GetBoolFromMap(PropertyMap map, string key, bool defaultValue)
{
bool value = defaultValue;
- map.Find(0, key)?.Get(out value);
+ using (var propertyValue = map.Find(0, key))
+ {
+ if (null != propertyValue) propertyValue.Get(out value);
+ }
return value;
}
internal static bool GetBoolFromMap(PropertyMap map, int key, bool defaultValue)
{
bool value = defaultValue;
- map.Find(key)?.Get(out value);
+ using (var propertyValue = map.Find(key))
+ {
+ if (null != propertyValue) propertyValue.Get(out value);
+ }
return value;
}
internal static int GetIntFromMap(PropertyMap map, int key, int defaultValue)
{
int value = defaultValue;
- map.Find(key)?.Get(out value);
+ using (var propertyValue = map.Find(key))
+ {
+ if (null != propertyValue) propertyValue.Get(out value);
+ }
return value;
}
internal static float GetFloatFromMap(PropertyMap map, string key, float defaultValue)
{
float value = defaultValue;
- map.Find(0, key)?.Get(out value);
+ using (var propertyValue = map.Find(0, key))
+ {
+ if (null != propertyValue) propertyValue.Get(out value);
+ }
return value;
}
- internal static Color GetColorFromMap(PropertyMap map, string key, Color defaultValue)
+ internal static Color GetColorFromMap(PropertyMap map, string key)
{
- Color value = new Color(defaultValue);
- map.Find(0, key)?.Get(value);
+ Color value = new Color();
+ using (var propertyValue = map.Find(0, key))
+ {
+ if (null != propertyValue) propertyValue.Get(value);
+ }
return value;
}
- internal static Color GetColorFromMap(PropertyMap map, int key, Color defaultValue)
+ internal static Color GetColorFromMap(PropertyMap map, int key)
{
- Color value = new Color(defaultValue);
- map.Find(key)?.Get(value);
+ Color value = new Color();
+ using (var propertyValue = map.Find(key))
+ {
+ if (null != propertyValue) propertyValue.Get(value);
+ }
return value;
}
- internal static Vector2 GetVector2FromMap(PropertyMap map, string key, Vector2 defaultValue)
+ internal static Vector2 GetVector2FromMap(PropertyMap map, string key)
{
- Vector2 value = new Vector2(defaultValue);
- map.Find(0, key)?.Get(value);
+ Vector2 value = new Vector2();
+ using (var propertyValue = map.Find(0, key))
+ {
+ if (null != propertyValue) propertyValue.Get(value);
+ }
return value;
}
- internal static PropertyMap GetMapFromMap(PropertyMap map, int key, PropertyMap defaultValue)
+ internal static PropertyMap GetMapFromMap(PropertyMap map, int key)
{
- PropertyMap value = new PropertyMap(defaultValue);
- map.Find(key)?.Get(value);
+ PropertyMap value = new PropertyMap();
+ using (var propertyValue = map.Find(key))
+ {
+ if (null != propertyValue) propertyValue.Get(value);
+ }
return value;
}
internal static int? GetNullableIntFromMap(PropertyMap map, int key)
{
- PropertyValue propertyValue = map.Find(key);
- if (propertyValue == null)
- return null;
+ using (var propertyValue = map.Find(key))
+ {
+ if (propertyValue == null)
+ return null;
- propertyValue.Get(out int value);
- return value;
+ propertyValue.Get(out int value);
+ return value;
+ }
}
internal static float? GetNullableFloatFromMap(PropertyMap map, int key)
{
- PropertyValue propertyValue = map.Find(key);
- if (propertyValue == null)
- return null;
+ using (var propertyValue = map.Find(key))
+ {
+ if (propertyValue == null)
+ return null;
- propertyValue.Get(out float value);
- return value;
+ 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;
+ using (var propertyValue = map.Find(key))
+ {
+ if (propertyValue == null)
+ return false;
- return true;
+ return true;
+ }
}
}
}
\ No newline at end of file
var stringKey = "color";
var stringInvalidKey = "invalidKey";
var intKey = 1;
- var intInvalidKey = 10;
var value = new Color(1.0f, 0.2f, 0.5f, 1.0f);
- var defaultValue = Color.Black;
var map = new PropertyMap();
map.Add(stringKey, new PropertyValue(value));
map.Add(intKey, new PropertyValue(value));
- var result = TextMapHelper.GetColorFromMap(map, stringKey, defaultValue);
+ var result = TextMapHelper.GetColorFromMap(map, stringKey);
Assert.AreEqual(value.R, result.R, "Should be equal!");
Assert.AreEqual(value.G, result.G, "Should be equal!");
Assert.AreEqual(value.B, result.B, "Should be equal!");
Assert.AreEqual(value.A, result.A, "Should be equal!");
- result = TextMapHelper.GetColorFromMap(map, stringInvalidKey, defaultValue);
- Assert.AreEqual(defaultValue.R, result.R, "Should be equal!");
- Assert.AreEqual(defaultValue.G, result.G, "Should be equal!");
- Assert.AreEqual(defaultValue.B, result.B, "Should be equal!");
- Assert.AreEqual(defaultValue.A, result.A, "Should be equal!");
-
- result = TextMapHelper.GetColorFromMap(map, intKey, defaultValue);
+ result = TextMapHelper.GetColorFromMap(map, intKey);
Assert.AreEqual(value.R, result.R, "Should be equal!");
Assert.AreEqual(value.G, result.G, "Should be equal!");
Assert.AreEqual(value.B, result.B, "Should be equal!");
Assert.AreEqual(value.A, result.A, "Should be equal!");
- result = TextMapHelper.GetColorFromMap(map, intInvalidKey, defaultValue);
- Assert.AreEqual(defaultValue.R, result.R, "Should be equal!");
- Assert.AreEqual(defaultValue.G, result.G, "Should be equal!");
- Assert.AreEqual(defaultValue.B, result.B, "Should be equal!");
- Assert.AreEqual(defaultValue.A, result.A, "Should be equal!");
-
tlog.Debug(tag, $"TextMapHelperGetColorFromMap END (OK)");
}
var stringKey = "position";
var stringInvalidKey = "invalidKey";
var value = new Vector2(3, 10);
- var defaultValue = new Vector2(0, 0);
var map = new PropertyMap();
map.Add(stringKey, new PropertyValue(value));
- var result = TextMapHelper.GetVector2FromMap(map, stringKey, defaultValue);
+ var result = TextMapHelper.GetVector2FromMap(map, stringKey);
Assert.AreEqual(value.X, result.X, "Should be equal!");
Assert.AreEqual(value.Y, result.Y, "Should be equal!");
- result = TextMapHelper.GetVector2FromMap(map, stringInvalidKey, defaultValue);
- Assert.AreEqual(defaultValue.X, result.X, "Should be equal!");
- Assert.AreEqual(defaultValue.Y, result.Y, "Should be equal!");
-
tlog.Debug(tag, $"TextMapHelperGetVector2FromMap END (OK)");
}
tlog.Debug(tag, $"TextMapHelperGetMapFromMap START");
var intKey = 1;
- var intInvalidKey = 10;
var value = new PropertyMap();
value.Add("width", new PropertyValue(10));
value.Add("height", new PropertyValue(20));
- var defaultValue = new PropertyMap();
- defaultValue.Add("width", new PropertyValue(0));
- defaultValue.Add("height", new PropertyValue(0));
var map = new PropertyMap();
map.Add(intKey, new PropertyValue(value));
- var result = TextMapHelper.GetMapFromMap(map, intKey, defaultValue);
+ var result = TextMapHelper.GetMapFromMap(map, intKey);
result.Find(0, "width").Get(out int width);
result.Find(0, "height").Get(out int height);
Assert.AreEqual(10, width, "Should be equal!");
Assert.AreEqual(20, height, "Should be equal!");
- result = TextMapHelper.GetMapFromMap(map, intInvalidKey, defaultValue);
- result.Find(0, "width").Get(out int defaultWidth);
- result.Find(0, "height").Get(out int defaultHeight);
- Assert.AreEqual(0, defaultWidth, "Should be equal!");
- Assert.AreEqual(0, defaultHeight, "Should be equal!");
-
tlog.Debug(tag, $"TextMapHelperGetMapFromMap END (OK)");
}