[Xaml] Provide method so that user can dispose all xaml objects
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / EXaml / Operation / GatherBindableProperties.cs
index f077d7e..f886979 100755 (executable)
@@ -38,13 +38,21 @@ namespace Tizen.NUI.EXaml
         public void Do()
         {
             var type = globalDataList.GatheredTypes[typeIndex];
+            if (null == type)
+            {
+                throw new Exception($"Type of index {typeIndex} is null");
+            }
+
             var field = type.GetField(fi => fi.Name == propertyName && fi.IsStatic && fi.IsPublic);
             if (null == field)
             {
                 field = type.GetField(fi => fi.Name == propertyName && fi.IsStatic && !fi.IsPublic);
             }
 
-            globalDataList.GatheredBindableProperties.Add(field.GetValue(null) as BindableProperty);
+            if (null != field && field.GetValue(null) is BindableProperty value)
+            {
+                globalDataList.GatheredBindableProperties.Add(value);
+            }
         }
 
         private int typeIndex;