From 93f63fd8ff2413dfe8c762804bfe3d071f99ade0 Mon Sep 17 00:00:00 2001 From: grokys Date: Sun, 2 Feb 2014 05:29:31 +0100 Subject: [PATCH] Moved SetterSubject. --- Perspex/Setter.cs | 70 +++++++++++++++++++++++------------------------ Perspex/Style.cs | 6 ++-- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Perspex/Setter.cs b/Perspex/Setter.cs index f86a7d5a89..cfc4ca8488 100644 --- a/Perspex/Setter.cs +++ b/Perspex/Setter.cs @@ -12,39 +12,6 @@ namespace Perspex using System.Reactive.Disposables; using Perspex.Controls; - internal class SetterSubject : IObservable - { - private Control control; - - private object onValue; - - private object offValue; - - private List> observers; - - public SetterSubject(Control control, object onValue, object offValue) - { - this.control = control; - this.onValue = onValue; - this.offValue = offValue; - this.observers = new List>(); - } - - public IDisposable Subscribe(IObserver observer) - { - observers.Add(observer); - return Disposable.Create(() => this.observers.Remove(observer)); - } - - public void Push(bool on) - { - foreach (IObserver o in this.observers) - { - o.OnNext(on ? this.onValue : this.offValue); - } - } - } - public class Setter { private object oldValue; @@ -61,10 +28,43 @@ namespace Perspex set; } - internal SetterSubject CreateSubject(Control control) + internal Subject CreateSubject(Control control) { object oldValue = control.GetValue(this.Property); - return new SetterSubject(control, this.Value, oldValue); + return new Subject(control, this.Value, oldValue); + } + + internal class Subject : IObservable + { + private Control control; + + private object onValue; + + private object offValue; + + private List> observers; + + public Subject(Control control, object onValue, object offValue) + { + this.control = control; + this.onValue = onValue; + this.offValue = offValue; + this.observers = new List>(); + } + + public IDisposable Subscribe(IObserver observer) + { + observers.Add(observer); + return Disposable.Create(() => this.observers.Remove(observer)); + } + + public void Push(bool on) + { + foreach (IObserver o in this.observers) + { + o.OnNext(on ? this.onValue : this.offValue); + } + } } } } diff --git a/Perspex/Style.cs b/Perspex/Style.cs index f56e8ba25a..70ec45bd32 100644 --- a/Perspex/Style.cs +++ b/Perspex/Style.cs @@ -52,11 +52,11 @@ namespace Perspex match = match.Previous; } - List subjects = new List(); + List subjects = new List(); foreach (Setter setter in this.Setters) { - SetterSubject subject = setter.CreateSubject(control); + Setter.Subject subject = setter.CreateSubject(control); subjects.Add(subject); control.SetValue(setter.Property, subject); } @@ -65,7 +65,7 @@ namespace Perspex { bool on = x.All(y => y); - foreach (SetterSubject subject in subjects) + foreach (Setter.Subject subject in subjects) { subject.Push(on); }