From 772937ad1543e339b55eb10cadaec0fc9ea1fa6e Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 30 Sep 2015 20:29:35 +0200 Subject: [PATCH] Change ExpressionValue to struct. And add some docs. --- .../Perspex.Markup/Binding/ExpressionNode.cs | 5 ---- .../Binding/ExpressionObserver.cs | 23 ++++++++++++++++++ .../Perspex.Markup/Binding/ExpressionValue.cs | 24 ++++++++++++++----- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/Markup/Perspex.Markup/Binding/ExpressionNode.cs b/src/Markup/Perspex.Markup/Binding/ExpressionNode.cs index 64fbe20873..aec90ee070 100644 --- a/src/Markup/Perspex.Markup/Binding/ExpressionNode.cs +++ b/src/Markup/Perspex.Markup/Binding/ExpressionNode.cs @@ -58,11 +58,6 @@ namespace Perspex.Markup.Binding set { - if (value == null) - { - throw new ArgumentNullException("value"); - } - _value = value; if (Next != null) diff --git a/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs b/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs index 4bc0192c9f..cdbeddda0c 100644 --- a/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs +++ b/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs @@ -9,16 +9,32 @@ using System.Reactive.Disposables; namespace Perspex.Markup.Binding { + /// + /// Observes the value of an expression on a root object. + /// public class ExpressionObserver : ObservableBase { private int _count; + /// + /// Initializes a new instance of the class. + /// + /// The root object. + /// The expression. public ExpressionObserver(object root, string expression) { Root = root; Nodes = ExpressionNodeBuilder.Build(expression); } + /// + /// Attempts to set the value of a property expression. + /// + /// The value to set. + /// + /// True if the value could be set; false if the expression does not evaluate to a + /// property. + /// public bool SetValue(object value) { var last = Nodes.Last() as PropertyAccessorNode; @@ -39,10 +55,17 @@ namespace Perspex.Markup.Binding return false; } + /// + /// Gets the root object that the expression is being observed on. + /// public object Root { get; } + /// + /// Gets a list of nodes representing the parts of the expression. + /// public IList Nodes { get; } + /// protected override IDisposable SubscribeCore(IObserver observer) { IncrementCount(); diff --git a/src/Markup/Perspex.Markup/Binding/ExpressionValue.cs b/src/Markup/Perspex.Markup/Binding/ExpressionValue.cs index 7579f98db4..2441acda73 100644 --- a/src/Markup/Perspex.Markup/Binding/ExpressionValue.cs +++ b/src/Markup/Perspex.Markup/Binding/ExpressionValue.cs @@ -5,22 +5,34 @@ using System; namespace Perspex.Markup.Binding { - public class ExpressionValue + /// + /// Holds the value for an . + /// + public struct ExpressionValue { + /// + /// An that has no value. + /// public static readonly ExpressionValue None = new ExpressionValue(); + /// + /// Initializes a new instance of the struct. + /// + /// public ExpressionValue(object value) { HasValue = true; Value = value; } - private ExpressionValue() - { - HasValue = false; - } - + /// + /// Gets a value indicating whether the evaluated expression resulted in a value. + /// public bool HasValue { get; } + + /// + /// Gets a the result of the expression. + /// public object Value { get; } } }