Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
37 additions and
4 deletions
-
.travis.yml
-
build.cake
-
src/Markup/Avalonia.Markup/Data/MultiBinding.cs
-
tests/Avalonia.Markup.UnitTests/Data/MultiBindingTests.cs
-
tools/packages.config
|
|
|
@ -11,6 +11,8 @@ mono: |
|
|
|
- 5.2.0 |
|
|
|
dotnet: 2.1.200 |
|
|
|
script: |
|
|
|
- sudo apt-get update |
|
|
|
- sudo apt-get install castxml |
|
|
|
- ./build.sh --target "Travis" --configuration "Release" |
|
|
|
notifications: |
|
|
|
email: false |
|
|
|
|
|
|
|
@ -3,8 +3,8 @@ |
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
#addin "nuget:?package=NuGet.Core&version=2.14.0" |
|
|
|
#tool "nuget:?package=NuGet.CommandLine&version=4.3.0" |
|
|
|
#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2017.1.20170613.162720" |
|
|
|
#tool "nuget:?package=NuGet.CommandLine&version=4.7.1" |
|
|
|
#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.2.3" |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
// TOOLS |
|
|
|
|
|
|
|
@ -61,7 +61,7 @@ namespace Avalonia.Data |
|
|
|
|
|
|
|
var targetType = targetProperty?.PropertyType ?? typeof(object); |
|
|
|
var children = Bindings.Select(x => x.Initiate(target, null)); |
|
|
|
var input = children.Select(x => x.Subject).CombineLatest().Select(x => ConvertValue(x, targetType)); |
|
|
|
var input = children.Select(x => x.Observable).CombineLatest().Select(x => ConvertValue(x, targetType)); |
|
|
|
var mode = Mode == BindingMode.Default ? |
|
|
|
targetProperty?.GetMetadata(target.GetType()).DefaultBindingMode : Mode; |
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +41,37 @@ namespace Avalonia.Markup.UnitTests.Data |
|
|
|
Assert.Equal("1,2,3", result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Nested_MultiBinding_Should_Be_Set_Up() |
|
|
|
{ |
|
|
|
var source = new { A = 1, B = 2, C = 3 }; |
|
|
|
var binding = new MultiBinding |
|
|
|
{ |
|
|
|
Converter = new ConcatConverter(), |
|
|
|
Bindings = |
|
|
|
{ |
|
|
|
new Binding { Path = "A" }, |
|
|
|
new MultiBinding |
|
|
|
{ |
|
|
|
Converter = new ConcatConverter(), |
|
|
|
Bindings = |
|
|
|
{ |
|
|
|
new Binding { Path = "B"}, |
|
|
|
new Binding { Path = "C"} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var target = new Mock<IAvaloniaObject>().As<IControl>(); |
|
|
|
target.Setup(x => x.GetValue(Control.DataContextProperty)).Returns(source); |
|
|
|
|
|
|
|
var observable = binding.Initiate(target.Object, null).Observable; |
|
|
|
var result = await observable.Take(1); |
|
|
|
|
|
|
|
Assert.Equal("1,2,3", result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Return_FallbackValue_When_Converter_Returns_UnsetValue() |
|
|
|
{ |
|
|
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
<?xml version="1.0" encoding="utf-8"?> |
|
|
|
<packages> |
|
|
|
<package id="Cake" version="0.28.0" /> |
|
|
|
<package id="Cake" version="0.30.0" /> |
|
|
|
</packages> |
|
|
|
|