[NUI] Fix BindableObject.SetValue to allow Selector types flexibly
authorJiyun Yang <ji.yang@samsung.com>
Tue, 25 May 2021 08:26:10 +0000 (17:26 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 26 May 2021 01:00:09 +0000 (10:00 +0900)
When the flag isCreateByXaml is true, the BindableObject.SetValue is comparing types strictly.
But some bindable properties, such as BackgroundColor, are designed to allow both types: Color and Selector<Color>.
Hence this patch allows BindableObject.SetValue to take both types.

Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/public/XamlBinding/BindableProperty.cs

index 896f1bf..5129ec6 100755 (executable)
@@ -622,6 +622,12 @@ namespace Tizen.NUI.Binding
             Type valueType = value.GetType();
             Type type = ReturnType;
 
+            // TODO This is temporary fix before deleting CreateByXaml flag in BindableProperty.
+            if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Tizen.NUI.BaseComponents.Selector<>) && valueType.GetGenericArguments()[0] == ReturnType)
+            {
+                return true;
+            }
+
             // Dont support arbitrary IConvertible by limiting which types can use this
             Type[] convertableTo;
             TypeConverter typeConverterTo;