Commit 6f86f0a0 authored by Uladzimir Makarevich's avatar Uladzimir Makarevich

MAKE !

parent c04f5c14
......@@ -47,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Adapters\RoutedCommandsAdapter.cs" />
<Compile Include="Converters\AggregateConverter.cs" />
<Compile Include="Converters\AnyConverter.cs" />
<Compile Include="Converters\BooleanConverter.cs" />
<Compile Include="Converters\EqualsConverter.cs" />
......@@ -59,10 +60,12 @@
<Compile Include="Converters\Patterns\IInlineConverter.cs" />
<Compile Include="Converters\Patterns\ICase.cs" />
<Compile Include="Converters\Patterns\ITwoWayConverter.cs" />
<Compile Include="Converters\SplitConverter.cs" />
<Compile Include="Converters\SwitchConverter.cs" />
<Compile Include="Dictionaries\AppConverters.cs" />
<Compile Include="LocalizationSource.cs" />
<Compile Include="Markup\Behaviour.cs" />
<Compile Include="Markup\Converter.cs" />
<Compile Include="Markup\Enum.cs" />
<Compile Include="Markup\NullExtension.cs" />
<Compile Include="Markup\Patterns\ABindingExtension.cs" />
......
using Ace.Converters.Patterns;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using System.Windows.Markup;
#if XAMARIN
using ContentProperty = Xamarin.Forms.ContentPropertyAttribute;
#endif
namespace Ace.Converters
{
[ContentProperty("Converters")]
public class AggregateConverter : AValueConverter
{
public List<IValueConverter> Converters { get; } = new List<IValueConverter>();
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var newValue = Converters.Aggregate(value, (v, c)=> c.Convert(v, targetType, parameter, culture));
return GetDefined(newValue, value);
}
}
}
using System;
using System.Globalization;
using System.Windows.Data;
namespace Ace.Converters
{
public class SplitConverter : IValueConverter
{
public StringSplitOptions SplitOptions { get; set; }
public int Count { get; set; } = int.MaxValue;
public string Separators
{
get => new string(_separators);
set => value.ToCharArray().To(out _separators);
}
private char[] _separators = {(char)0x0A, (char)0x0D, };
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value.As("").Split(_separators, Count, SplitOptions);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
\ No newline at end of file
using System;
using System.Globalization;
using System.Windows.Data;
namespace Ace.Markup
{
public class Converter : IValueConverter
{
public IValueConverter Source { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
Source?.Convert(value, targetType, parameter, culture);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
Source?.ConvertBack(value, targetType, parameter, culture);
}
}
\ No newline at end of file
......@@ -11,12 +11,12 @@ namespace Ace.Markup
public class Enum : MarkupExtension
{
public Enum() => Type = null;
public Enum(Type type) => Type = type;
[TypeConverter(typeof(TypeTypeConverter))]
public Type Type { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider) =>
System.Enum.GetValues(Type);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment