Browse Source

Change ExpressionValue to struct.

And add some docs.
Steven Kirk 10 years ago
parent
commit
772937ad15

+ 0 - 5
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)

+ 23 - 0
src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs

@@ -9,16 +9,32 @@ using System.Reactive.Disposables;
 
 namespace Perspex.Markup.Binding
 {
+    /// <summary>
+    /// Observes the value of an expression on a root object.
+    /// </summary>
     public class ExpressionObserver : ObservableBase<ExpressionValue>
     {
         private int _count;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ExpressionObserver"/> class.
+        /// </summary>
+        /// <param name="root">The root object.</param>
+        /// <param name="expression">The expression.</param>
         public ExpressionObserver(object root, string expression)
         {
             Root = root;
             Nodes = ExpressionNodeBuilder.Build(expression);
         }
 
+        /// <summary>
+        /// Attempts to set the value of a property expression.
+        /// </summary>
+        /// <param name="value">The value to set.</param>
+        /// <returns>
+        /// True if the value could be set; false if the expression does not evaluate to a 
+        /// property.
+        /// </returns>
         public bool SetValue(object value)
         {
             var last = Nodes.Last() as PropertyAccessorNode;
@@ -39,10 +55,17 @@ namespace Perspex.Markup.Binding
             return false;
         }
 
+        /// <summary>
+        /// Gets the root object that the expression is being observed on.
+        /// </summary>
         public object Root { get; }
 
+        /// <summary>
+        /// Gets a list of nodes representing the parts of the expression.
+        /// </summary>
         public IList<ExpressionNode> Nodes { get; }
 
+        /// <inheritdoc/>
         protected override IDisposable SubscribeCore(IObserver<ExpressionValue> observer)
         {
             IncrementCount();

+ 18 - 6
src/Markup/Perspex.Markup/Binding/ExpressionValue.cs

@@ -5,22 +5,34 @@ using System;
 
 namespace Perspex.Markup.Binding
 {
-    public class ExpressionValue
+    /// <summary>
+    /// Holds the value for an <see cref="ExpressionObserver"/>.
+    /// </summary>
+    public struct ExpressionValue
     {
+        /// <summary>
+        /// An <see cref="ExpressionValue"/> that has no value.
+        /// </summary>
         public static readonly ExpressionValue None = new ExpressionValue();
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ExpressionValue"/> struct.
+        /// </summary>
+        /// <param name="value"></param>
         public ExpressionValue(object value)
         {
             HasValue = true;
             Value = value;
         }
 
-        private ExpressionValue()
-        {
-            HasValue = false;
-        }
-
+        /// <summary>
+        /// Gets a value indicating whether the evaluated expression resulted in a value.
+        /// </summary>
         public bool HasValue { get; }
+
+        /// <summary>
+        /// Gets a the result of the expression.
+        /// </summary>
         public object Value { get; }
     }
 }