summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen
diff options
context:
space:
mode:
authorchungryeol lim <cdark.lim@samsung.com>2016-12-26 18:50:44 +0900
committerchungryeol lim <cdark.lim@samsung.com>2016-12-26 21:32:27 +0900
commit4678bcda9ae352c0b7fdaaf10e87eef40900369f (patch)
tree67f89e24913600873cf69ee14c594e691657e254 /Xamarin.Forms.Platform.Tizen
parentaa0cf74ac39c66c43c7440c2cde88461ab7b196f (diff)
downloadxamarin-forms-4678bcda9ae352c0b7fdaaf10e87eef40900369f.tar.gz
xamarin-forms-4678bcda9ae352c0b7fdaaf10e87eef40900369f.tar.bz2
xamarin-forms-4678bcda9ae352c0b7fdaaf10e87eef40900369f.zip
implement ExpressionSearch for RelativeLayout.FromExpression
Change-Id: Id2fdeea22736d08844d8552015dbb895ae2fa28a Signed-off-by: chungryeol lim <cdark.lim@samsung.com>
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen')
-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 6aa0e62b..f5989e05 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