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
{
// FIXME: We should consider TV and Common (Desktop) profiles also.
Device.Idiom = TargetIdiom.Phone;
-
+ ExpressionSearch.Default = new TizenExpressionSearch();
IsInitialized = true;
}
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