// --------------------------------------------------------------------
//
// Copyright 2014 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Diagnostics
{
///
/// Defines diagnostic extensions on s.
///
public static class PerspexObjectExtensions
{
///
/// Gets a diagnostic for a on a .
///
/// The object.
/// The property.
///
/// A that can be used to diagnose the state of the
/// property on the object.
///
public static PerspexPropertyValue GetDiagnostic(this PerspexObject o, PerspexProperty property)
{
var set = o.GetSetValues();
PriorityValue value;
if (set.TryGetValue(property, out value))
{
return new PerspexPropertyValue(
property,
value.Value,
(BindingPriority)value.ValuePriority,
value.GetDiagnostic());
}
else
{
return new PerspexPropertyValue(
property,
o.GetValue(property),
BindingPriority.Unset,
"Unset");
}
}
}
}