|
|
@ -45,7 +45,7 @@ namespace Avalonia.Data |
|
|
case BindingMode.OneWay: |
|
|
case BindingMode.OneWay: |
|
|
return target.Bind(property, binding.Observable ?? binding.Subject, binding.Priority); |
|
|
return target.Bind(property, binding.Observable ?? binding.Subject, binding.Priority); |
|
|
case BindingMode.TwoWay: |
|
|
case BindingMode.TwoWay: |
|
|
return new CompositeDisposable( |
|
|
return new TwoWayBindingDisposable( |
|
|
target.Bind(property, binding.Subject, binding.Priority), |
|
|
target.Bind(property, binding.Subject, binding.Priority), |
|
|
target.GetObservable(property).Subscribe(binding.Subject)); |
|
|
target.GetObservable(property).Subscribe(binding.Subject)); |
|
|
case BindingMode.OneTime: |
|
|
case BindingMode.OneTime: |
|
|
@ -88,6 +88,32 @@ namespace Avalonia.Data |
|
|
throw new ArgumentException("Invalid binding mode."); |
|
|
throw new ArgumentException("Invalid binding mode."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private sealed class TwoWayBindingDisposable : IDisposable |
|
|
|
|
|
{ |
|
|
|
|
|
private readonly IDisposable _first; |
|
|
|
|
|
private readonly IDisposable _second; |
|
|
|
|
|
private bool _isDisposed; |
|
|
|
|
|
|
|
|
|
|
|
public TwoWayBindingDisposable(IDisposable first, IDisposable second) |
|
|
|
|
|
{ |
|
|
|
|
|
_first = first; |
|
|
|
|
|
_second = second; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
|
|
{ |
|
|
|
|
|
if (_isDisposed) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_first.Dispose(); |
|
|
|
|
|
_second.Dispose(); |
|
|
|
|
|
|
|
|
|
|
|
_isDisposed = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public sealed class DoNothingType |
|
|
public sealed class DoNothingType |
|
|
|