summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-23 09:21:30 (GMT)
committerGitHub <noreply@github.com>2016-12-23 09:21:30 (GMT)
commitc34016dc84a30a351d9323285b68ce6cb02af969 (patch)
tree1c223684896b460d13a0fe84f4d91926f540f922 /Xamarin.Forms.Core
parentb96df000db76ba3490589c37e93224271249bc88 (diff)
downloadxamarin-forms-c34016dc84a30a351d9323285b68ce6cb02af969.zip
xamarin-forms-c34016dc84a30a351d9323285b68ce6cb02af969.tar.gz
xamarin-forms-c34016dc84a30a351d9323285b68ce6cb02af969.tar.bz2
Xamlc compile data triggers (#648)
* [Xaml] DataTrigger and PropertyCondition no longer use a ServiceProvider * [XamlC] avoid generating ServiceProvider for unused ProvideValue * fix tests
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/Interactivity/BindingCondition.cs15
-rw-r--r--Xamarin.Forms.Core/Interactivity/DataTrigger.cs5
2 files changed, 8 insertions, 12 deletions
diff --git a/Xamarin.Forms.Core/Interactivity/BindingCondition.cs b/Xamarin.Forms.Core/Interactivity/BindingCondition.cs
index 1d11185..ccf55e5 100644
--- a/Xamarin.Forms.Core/Interactivity/BindingCondition.cs
+++ b/Xamarin.Forms.Core/Interactivity/BindingCondition.cs
@@ -3,6 +3,7 @@ using Xamarin.Forms.Xaml;
namespace Xamarin.Forms
{
+ [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
public sealed class BindingCondition : Condition, IValueProvider
{
readonly BindableProperty _boundProperty;
@@ -41,15 +42,9 @@ namespace Xamarin.Forms
}
}
- internal IServiceProvider ServiceProvider { get; set; }
-
- internal IValueConverterProvider ValueConverter { get; set; }
-
object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
{
- ValueConverter = serviceProvider.GetService(typeof(IValueConverterProvider)) as IValueConverterProvider;
- ServiceProvider = serviceProvider;
-
+ //This is no longer required
return this;
}
@@ -71,14 +66,16 @@ namespace Xamarin.Forms
bindable.ClearValue(_boundProperty);
}
+ static IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>();
+
bool EqualsToValue(object other)
{
if ((other == Value) || (other != null && other.Equals(Value)))
return true;
object converted = null;
- if (ValueConverter != null)
- converted = ValueConverter.Convert(Value, other != null ? other.GetType() : typeof(object), null, ServiceProvider);
+ if (s_valueConverter != null)
+ converted = s_valueConverter.Convert(Value, other != null ? other.GetType() : typeof(object), null, null);
else
return false;
diff --git a/Xamarin.Forms.Core/Interactivity/DataTrigger.cs b/Xamarin.Forms.Core/Interactivity/DataTrigger.cs
index e27ec13..d90cf44 100644
--- a/Xamarin.Forms.Core/Interactivity/DataTrigger.cs
+++ b/Xamarin.Forms.Core/Interactivity/DataTrigger.cs
@@ -5,6 +5,7 @@ using Xamarin.Forms.Xaml;
namespace Xamarin.Forms
{
[ContentProperty("Setters")]
+ [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
public sealed class DataTrigger : TriggerBase, IValueProvider
{
public DataTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new BindingCondition(), targetType)
@@ -48,9 +49,7 @@ namespace Xamarin.Forms
object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
{
- var valueconverter = serviceProvider.GetService(typeof(IValueConverterProvider)) as IValueConverterProvider;
- (Condition as BindingCondition).ValueConverter = valueconverter;
-
+ //This is no longer required
return this;
}
}