summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Platform.Tizen/Forms.cs36
1 files changed, 33 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Forms.cs b/Xamarin.Forms.Platform.Tizen/Forms.cs
index 6aa0e62..f5989e0 100644
--- a/Xamarin.Forms.Platform.Tizen/Forms.cs
+++ b/Xamarin.Forms.Platform.Tizen/Forms.cs
@@ -1,7 +1,10 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
using System.Reflection;
-using Tizen.Applications;
using ElmSharp;
+using Tizen.Applications;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -155,7 +158,7 @@ namespace Xamarin.Forms.Platform.Tizen
// FIXME: We should consider TV and Common (Desktop) profiles also.
Device.Idiom = TargetIdiom.Phone;
-
+ ExpressionSearch.Default = new TizenExpressionSearch();
IsInitialized = true;
}
@@ -170,4 +173,31 @@ namespace Xamarin.Forms.Platform.Tizen
return Color.Black;
}
}
-}
+
+ class TizenExpressionSearch : ExpressionVisitor, IExpressionSearch
+ {
+ List<object> _results;
+ Type _targetType;
+
+ public List<T> FindObjects<T>(Expression expression) where T : class
+ {
+ _results = new List<object>();
+ _targetType = typeof(T);
+ Visit(expression);
+ return _results.Select(o => o as T).ToList();
+ }
+
+ protected override Expression VisitMember(MemberExpression node)
+ {
+ if (node.Expression is ConstantExpression && node.Member is FieldInfo)
+ {
+ var container = ((ConstantExpression)node.Expression).Value;
+ var value = ((FieldInfo)node.Member).GetValue(container);
+
+ if (_targetType.IsInstanceOfType(value))
+ _results.Add(value);
+ }
+ return base.VisitMember(node);
+ }
+ }
+} \ No newline at end of file