Browse Source

Use ObservableBase, IDescription for Binding.

pull/58/head
Steven Kirk 11 years ago
parent
commit
8b18504e5e
  1. 16
      Perspex.Base/Binding.cs
  2. 3
      Perspex.Base/PriorityBindingEntry.cs

16
Perspex.Base/Binding.cs

@ -7,7 +7,7 @@
namespace Perspex
{
using System;
using System.Reactive.Linq;
using System.Reactive;
public enum BindingMode
{
@ -18,7 +18,7 @@ namespace Perspex
OneWayToSource,
}
public class Binding : IObservable<object>
public class Binding : ObservableBase<object>, IDescription
{
public BindingMode Mode
{
@ -44,6 +44,8 @@ namespace Perspex
set;
}
public string Description => string.Format("{0}.{1}", this.Source.GetType().Name, this.Property.Name);
public static Binding operator !(Binding binding)
{
return binding.WithMode(BindingMode.TwoWay);
@ -54,11 +56,6 @@ namespace Perspex
return binding.WithMode(BindingMode.TwoWay);
}
public IDisposable Subscribe(IObserver<object> observer)
{
return this.Source.GetObservable(this.Property).Subscribe(observer);
}
public Binding WithMode(BindingMode mode)
{
this.Mode = mode;
@ -70,5 +67,10 @@ namespace Perspex
this.Priority = priority;
return this;
}
protected override IDisposable SubscribeCore(IObserver<object> observer)
{
return this.Source.GetObservable(this.Property).Subscribe(observer);
}
}
}

3
Perspex.Base/PriorityBindingEntry.cs

@ -24,6 +24,8 @@ namespace Perspex
this.Index = index;
}
public IObservable<object> Observable { get; private set; }
/// <summary>
/// Gets a description of the binding.
/// </summary>
@ -67,6 +69,7 @@ namespace Perspex
throw new Exception("PriorityValue.Entry.Start() called more than once.");
}
this.Observable = binding;
this.Value = PerspexProperty.UnsetValue;
if (binding is IDescription)

Loading…
Cancel
Save