Skip to content

Commit

Permalink
chore: improved ObservedChangedMixin xml documentation (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
olevett authored and ghuntley committed Mar 14, 2017
1 parent df8636e commit d5135dd
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions src/ReactiveUI/ObservedChangedMixin.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reactive.Linq;
using System.Reflection;

namespace ReactiveUI
{
/// <summary>
/// A collection of helpers for <see cref="IObservedChange{TSender, TValue}"/>.
/// </summary>
public static class ObservedChangedMixin
{
/// <summary>
/// Returns the name of a property which has been changed.
/// </summary>
/// <returns>The name of the property which has change</returns>
/// <returns>
/// The name of the property which has changed.
/// </returns>
public static string GetPropertyName<TSender, TValue>(this IObservedChange<TSender, TValue> This)
{
return Reflection.ExpressionToPropertyNames(This.Expression);
Expand All @@ -22,7 +25,12 @@ public static class ObservedChangedMixin
/// Returns the current value of a property given a notification that
/// it has changed.
/// </summary>
/// <returns>The current value of the property</returns>
/// <param name="This">
/// The <see cref="IObservedChange{TSender, TValue}"/> instance to get the value of.
/// </param>
/// <returns>
/// The current value of the property
/// </returns>
public static TValue GetValue<TSender, TValue>(this IObservedChange<TSender, TValue> This)
{
TValue ret;
Expand All @@ -37,10 +45,15 @@ public static class ObservedChangedMixin
/// notification that it has changed. If any property in the
/// property expression is null, false is returned.
/// </summary>
/// <param name="changeValue">The value of the property
/// expression.</param>
/// <returns>True if the entire expression was able to be followed,
/// false otherwise</returns>
/// <param name="This">
/// The <see cref="IObservedChange{TSender, TValue}"/> instance to get the value of
/// </param>
/// <param name="changeValue">
/// The value of the property expression.
/// </param>
/// <returns>
/// True if the entire expression was able to be followed, false otherwise.
/// </returns>
internal static bool TryGetValue<TSender, TValue>(this IObservedChange<TSender, TValue> This, out TValue changeValue)
{
if (!Equals(This.Value, default(TValue))) {
Expand All @@ -55,12 +68,20 @@ public static class ObservedChangedMixin
/// Given a fully filled-out IObservedChange object, SetValueToProperty
/// will apply it to the specified object (i.e. it will ensure that
/// target.property == This.GetValue() and "replay" the observed change
/// onto another object)
/// onto another object).
/// </summary>
/// <param name="target">The target object to apply the change to.</param>
/// <param name="property">The target property to apply the change to.</param>
/// <param name="This">
/// The <see cref="IObservedChange{TSender, TValue}"/> instance to use as a
/// value to apply.
/// </param>
/// <param name="target">
/// The target object to apply the change to.
/// </param>
/// <param name="property">
/// The target property to apply the change to.
/// </param>
internal static void SetValueToProperty<TSender, TValue, TTarget>(
this IObservedChange<TSender, TValue> This,
this IObservedChange<TSender, TValue> This,
TTarget target,
Expression<Func<TTarget, TValue>> property)
{
Expand All @@ -71,10 +92,15 @@ public static class ObservedChangedMixin
/// Given a stream of notification changes, this method will convert
/// the property changes to the current value of the property.
/// </summary>
/// <returns>An Observable representing the stream of current values of
/// the given change notification stream.</returns>
/// <param name="This">
/// The change notification stream to get the values of.
/// </param>
/// <returns>
/// An Observable representing the stream of current values of
/// the given change notification stream.
/// </returns>
public static IObservable<TValue> Value<TSender, TValue>(
this IObservable<IObservedChange<TSender, TValue>> This)
this IObservable<IObservedChange<TSender, TValue>> This)
{
return This.Select(GetValue);
}
Expand Down

0 comments on commit d5135dd

Please sign in to comment.