Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic WithConversion method #1631

Merged
merged 2 commits into from Feb 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,6 +15,8 @@ namespace MvvmCross.Binding.Binders

public interface IMvxNamedInstanceRegistryFiller<out T>
{
string FindName(Type type);

void FillFrom(IMvxNamedInstanceRegistry<T> registry, Type type);

void FillFrom(IMvxNamedInstanceRegistry<T> registry, Assembly assembly);
Expand Down
Expand Up @@ -98,7 +98,7 @@ where type.IsConventional()
}
}

protected virtual string FindName(Type type)
public virtual string FindName(Type type)
{
var name = type.Name;
name = RemoveHead(name, "Mvx");
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class MvxValueConverterRegistryFiller
: MvxNamedInstanceRegistryFiller<IMvxValueConverter>
, IMvxValueConverterRegistryFiller
{
protected override string FindName(Type type)
public override string FindName(Type type)
{
var name = base.FindName(type);
name = RemoveTail(name, "ValueConverter");
Expand Down
Expand Up @@ -10,9 +10,10 @@ namespace MvvmCross.Binding.BindingContext
using System;
using System.Linq;
using System.Linq.Expressions;

using MvvmCross.Binding.Binders;
using MvvmCross.Binding.Bindings;
using MvvmCross.Binding.ValueConverters;
using MvvmCross.Platform;
using MvvmCross.Platform.Converters;

public class MvxFluentBindingDescription<TTarget, TSource>
Expand Down Expand Up @@ -95,6 +96,15 @@ public MvxFluentBindingDescription(IMvxBindingContextOwner bindingContextOwner,
return this;
}

public MvxFluentBindingDescription<TTarget, TSource> WithConversion<TValueConverter>(object converterParameter = null)
where TValueConverter : IMvxValueConverter
{
var filler = Mvx.Resolve<IMvxValueConverterRegistryFiller>();
var converterName = filler.FindName(typeof(TValueConverter));

return WithConversion(converterName, converterParameter);
}

public MvxFluentBindingDescription<TTarget, TSource> WithFallback(object fallback)
{
this.SourceStepDescription.FallbackValue = fallback;
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class MvxValueCombinerRegistryFiller
: MvxNamedInstanceRegistryFiller<IMvxValueCombiner>
, IMvxValueCombinerRegistryFiller
{
protected override string FindName(Type type)
public override string FindName(Type type)
{
var name = base.FindName(type);
name = RemoveTail(name, "ValueCombiner");
Expand Down