// -----------------------------------------------------------------------
//
// Copyright 2014 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Subjects;
using System.Reflection;
using System.Text;
using Perspex.Utilities;
///
/// Maintains a list of prioritised bindings together with a current value.
///
///
/// Bindings, in the form of s are added to the object using
/// the method. With the observable is passed a priority, where lower values
/// represent higher priorites. The current is selected from the highest
/// priority binding that doesn't return . Where there
/// are multiple bindings registered with the same priority, the most recently added binding
/// has a higher priority. Each time the value changes, the observable is
/// fired with the old and new values.
///
internal class PriorityValue
{
///
/// The name of the property.
///
private string name;
///
/// The value type.
///
private Type valueType;
///
/// The currently registered bindings organised by priority.
///
private Dictionary levels = new Dictionary();
///
/// The changed observable.
///
private Subject> changed = new Subject>();
///
/// The current value.
///
private object value;
///
/// The function used to validate the value, if any.
///
private Func