Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document all the methods with missing VSDocs #316

Merged
merged 5 commits into from
Jun 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ReactiveUI.Mobile/AutoSuspendAppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public void SetupDefaultSuspendResume(ISuspensionDriver driver = null)
}
}

/// <summary>
/// AutoSuspend-based App Delegate. To use AutoSuspend with iOS, change your
/// AppDelegate to inherit from this class, then call:
///
/// RxApp.DependencyResolver.GetService<ISuspensionHost>().SetupDefaultSuspendResume();
/// </summary>
public abstract class AutoSuspendAppDelegate : UIApplicationDelegate, IEnableLogger
{
readonly Subject<UIApplication> _finishedLaunching = new Subject<UIApplication>();
Expand Down Expand Up @@ -132,7 +138,6 @@ internal void setupDefaultSuspendResume(ISuspensionDriver driver)
.LoggedCatch(this, Observable.Return(Unit.Default), "Tried to persist app state")
.Subscribe(_ => this.Log().Info("Persisted application state"));


SuspensionHost.IsResuming
.SelectMany(x => driver.LoadState<IApplicationRootState>())
.LoggedCatch(this,
Expand Down
18 changes: 17 additions & 1 deletion ReactiveUI.Mobile/Geolocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

namespace ReactiveUI.Mobile
{
/// <summary>
/// ReactiveGeolocator is an API to convert Xamarin Geolocation into
/// something Rx-friendly.
/// </summary>
public static class ReactiveGeolocator
{
[ThreadStatic] static IReactiveGeolocator _UnitTestImplementation;
Expand All @@ -34,6 +38,14 @@ internal static IReactiveGeolocator Implementation {
}
}

/// <summary>
/// Returns an IObservable that continuously updates as the user's
/// physical location changes. It is super important to make sure to
/// dispose all subscriptions to this IObservable.
/// </summary>
/// <param name="minUpdateTime">Minimum update time.</param>
/// <param name="minUpdateDist">Minimum update dist.</param>
/// <param name="includeHeading">If set to <c>true</c> include heading.</param>
public static IObservable<Position> Listen(int minUpdateTime, double minUpdateDist, bool includeHeading = false)
{
if (Implementation != null) {
Expand Down Expand Up @@ -73,6 +85,11 @@ public static IObservable<Position> Listen(int minUpdateTime, double minUpdateDi
return ret.Multicast(new Subject<Position>()).RefCount();
}

/// <summary>
/// Returns a single lookup of the user's current physical position
/// </summary>
/// <returns>The current physical location.</returns>
/// <param name="includeHeading">If set to <c>true</c> include heading.</param>
public static IObservable<Position> GetPosition(bool includeHeading = false)
{
if (Implementation != null) {
Expand Down Expand Up @@ -114,7 +131,6 @@ public static IObservable<Position> GetPosition(bool includeHeading = false)
}).Multicast(new AsyncSubject<Position>());
#endif


return ret.RefCount();
}

Expand Down
67 changes: 67 additions & 0 deletions ReactiveUI.Mobile/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@ namespace ReactiveUI.Mobile
{
public interface IReactiveGeolocator
{
/// <summary>
/// Returns an IObservable that continuously updates as the user's
/// physical location changes. It is super important to make sure to
/// dispose all subscriptions to this IObservable.
/// </summary>
/// <param name="minUpdateTime">Minimum update time.</param>
/// <param name="minUpdateDist">Minimum update dist.</param>
/// <param name="includeHeading">If set to <c>true</c> include heading.</param>
IObservable<Position> Listen(int minUpdateTime, double minUpdateDist, bool includeHeading = false);

/// <summary>
/// Returns a single lookup of the user's current physical position
/// </summary>
/// <returns>The current physical location.</returns>
/// <param name="includeHeading">If set to <c>true</c> include heading.</param>
IObservable<Position> GetPosition(bool includeHeading = false);
}

Expand All @@ -23,21 +37,74 @@ public interface IReactiveGeolocator
* Resurrected - Occurs after the app has "resurrected" from a tombstoned state.
*/

/// <summary>
/// ISuspensionHost represents a standardized version of the events that the
/// host operating system publishes. Subscribe to these events in order to
/// handle app suspend / resume.
/// </summary>
public interface ISuspensionHost
{
/// <summary>
/// Signals when the application is launching new. This can happen when
/// an app has recently crashed, as well as the firs time the app has
/// been launched. Apps should create their state from scratch.
/// </summary>
IObservable<Unit> IsLaunchingNew { get; }

/// <summary>
/// Signals when the application is resuming from suspended state (i.e.
/// it was previously running but its process was destroyed).
/// </summary>
IObservable<Unit> IsResuming { get; }

/// <summary>
/// Signals when the application is activated. Note that this may mean
/// that your process was not actively running before this signal.
/// </summary>
IObservable<Unit> IsUnpausing { get; }

/// <summary>
/// Signals when the application should persist its state to disk.
/// </summary>
/// <value>Returns an IDisposable that should be disposed once the
/// application finishes persisting its state</value>
IObservable<IDisposable> ShouldPersistState { get; }

/// <summary>
/// Signals that the saved application state should be deleted, this
/// usually is called after an app has crashed
/// </summary>
IObservable<Unit> ShouldInvalidateState { get; }

/// <summary>
/// Sets up the default suspend resume behavior, which is to use the
/// ISuspensionDriver to save / reload application state. Using this also
/// requires you to register an IApplicationRootState that will create a
/// new application root state from scratch.
/// </summary>
void SetupDefaultSuspendResume(ISuspensionDriver driver = null);
}

/// <summary>
/// ISuspensionDriver represents a class that can load/save state to persistent
/// storage. Most platforms have a basic implementation of this class, but you
/// probably want to write your own.
/// </summary>
public interface ISuspensionDriver
{
/// <summary>
/// Loads the application state from persistent storage
/// </summary>
IObservable<T> LoadState<T>() where T : class, IApplicationRootState;

/// <summary>
/// Saves the application state to disk.
/// </summary>
IObservable<Unit> SaveState<T>(T state) where T : class, IApplicationRootState;

/// <summary>
/// Invalidates the application state (i.e. deletes it from disk)
/// </summary>
IObservable<Unit> InvalidateState();
}

Expand Down
7 changes: 7 additions & 0 deletions ReactiveUI.Platforms/Android/AndroidUIScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

namespace ReactiveUI.Android
{
/// <summary>
/// AndroidUIScheduler is a scheduler that schedules items on a running
/// Activity's main thread. This is the moral equivalent of
/// DispatcherScheduler, but since every Activity runs separately, you must
/// assign RxApp.MainThreadScheduler to an instance of this at the start of
/// every activity.
/// </summary>
public class AndroidUIScheduler : IScheduler, IEnableLogger
{
Activity activity;
Expand Down
3 changes: 3 additions & 0 deletions ReactiveUI.Platforms/Cocoa/CocoaDefaultPropertyBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// Provides default property bindings for a number of common Cocoa controls.
/// </summary>
public class CocoaDefaultPropertyBinding : IDefaultPropertyBindingProvider
{
public Tuple<string, int> GetPropertyForControl(object control)
Expand Down
16 changes: 10 additions & 6 deletions ReactiveUI.Platforms/Cocoa/KVOObservableForProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// This class provides notifications for Cocoa Framework objects based on
/// Key-Value Observing. Unfortunately, this class is a bit Tricky™, because
/// of the caveat mentioned below - there is no way up-front to be able to
/// tell whether a given property on an object is Key-Value Observable, we
/// only have to hope for the best :-/
/// </summary>
public class KVOObservableForProperty : ICreatesObservableForProperty
{
public KVOObservableForProperty ()
{
}

public int GetAffinityForObject(Type type, string propertyName, bool beforeChanged = false)
{
// NB: There is no way to know up-front whether a given property is
Expand All @@ -46,6 +49,7 @@ public IObservable<IObservedChange<object, object>> GetNotificationForProperty(o
var keyPath = (NSString)findCocoaNameFromNetName(sender.GetType(), propertyName);

obj.AddObserver(bobs, keyPath, beforeChanged ? NSKeyValueObservingOptions.Old : NSKeyValueObservingOptions.New, IntPtr.Zero);

return Disposable.Create(() => {
obj.RemoveObserver(bobs, keyPath);
pin.Free();
Expand All @@ -57,7 +61,7 @@ string findCocoaNameFromNetName(Type senderType, string propertyName)
{
bool propIsBoolean = false;

var pi = Reflection.GetSafeProperty (senderType, propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
var pi = Reflection.GetSafeProperty(senderType, propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
if (pi == null) goto attemptGuess;

if (pi.DeclaringType == typeof(bool)) propIsBoolean = true;
Expand All @@ -75,7 +79,7 @@ string findCocoaNameFromNetName(Type senderType, string propertyName)
}
}

internal class BlockObserveValueDelegate : NSObject
class BlockObserveValueDelegate : NSObject
{
Action<string, NSObject, NSDictionary> _block;
public BlockObserveValueDelegate(Action<string, NSObject, NSDictionary> block)
Expand Down
4 changes: 4 additions & 0 deletions ReactiveUI.Platforms/Cocoa/NSRunloopScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// Provides a scheduler which will use the Cocoa main loop to schedule
/// work on. This is the Cocoa equivalent of DispatcherScheduler.
/// </summary>
public class NSRunloopScheduler : IScheduler
{
NSObject theApp;
Expand Down
3 changes: 3 additions & 0 deletions ReactiveUI.Platforms/Cocoa/PlatformOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// Returns the current orientation of the device on iOS.
/// </summary>
public class PlatformOperations : IPlatformOperations
{
public string GetOrientation()
Expand Down
19 changes: 15 additions & 4 deletions ReactiveUI.Platforms/Cocoa/RoutedViewHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// RoutedViewHost is a helper class that will connect a RoutingState
/// to an arbitrary NSView and attempt to load the View for the latest
/// ViewModel as a child view of the target. Usually the target view will
/// be the NSWindow.
///
/// This is a bit different than the XAML's RoutedViewHost in the sense
/// that this isn't a Control itself, it only manipulates other Views.
/// </summary>
public class RoutedViewHost : ReactiveObject
{
IRoutingState _Router;
Expand Down Expand Up @@ -46,10 +55,12 @@ public RoutedViewHost(NSView targetView)
(vm, contract) => new { ViewModel = vm, Contract = contract, });

vmAndContract.Subscribe(x => {
if (viewLastAdded != null) viewLastAdded.RemoveFromSuperview();
if (viewLastAdded != null)
viewLastAdded.RemoveFromSuperview();

if (x.ViewModel == null) {
if (DefaultContent != null) targetView.AddSubview(DefaultContent.View);
if (DefaultContent != null)
targetView.AddSubview(DefaultContent.View);
return;
}

Expand All @@ -59,14 +70,14 @@ public RoutedViewHost(NSView targetView)

if (view is NSViewController) {
viewLastAdded = ((NSViewController)view).View;
} else if (view is NSView) {
} else if (view is NSView) {
viewLastAdded = (NSView)view;
} else {
throw new Exception(String.Format("'{0}' must be an NSViewController or NSView", view.GetType().FullName));
}

targetView.AddSubview(viewLastAdded);
}, ex => RxApp.DefaultExceptionHandler.OnNext(ex));
}, RxApp.DefaultExceptionHandler.OnNext);
}
}
}
6 changes: 6 additions & 0 deletions ReactiveUI.Platforms/Cocoa/TargetActionCommandBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// TargetActionCommandBinder is an implementation of command binding that
/// understands Cocoa's Target / Action Framework. Many controls in Cocoa
/// that are effectively command sources (i.e. Buttons, Menus, etc),
/// participate in this framework.
/// </summary>
public class TargetActionCommandBinder : ICreatesCommandBinding
{
readonly Type[] validTypes;
Expand Down
8 changes: 8 additions & 0 deletions ReactiveUI.Platforms/Cocoa/ViewModelViewHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

namespace ReactiveUI.Cocoa
{
/// <summary>
/// ViewModelViewHost is a helper class that will connect a ViewModel
/// to an arbitrary NSView and attempt to load the View for the current
/// ViewModel as a child view of the target.
///
/// This is a bit different than the XAML's ViewModelViewHost in the sense
/// that this isn't a Control itself, it only manipulates other Views.
/// </summary>
public class ViewModelViewHost : ReactiveObject
{
public ViewModelViewHost(NSView targetView)
Expand Down
5 changes: 5 additions & 0 deletions ReactiveUI.Platforms/ComponentModelTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

namespace ReactiveUI
{
/// <summary>
/// This binding type converter uses the built-in WPF component model
/// conversions to get a whole bunch of conversions for free. Unfortunately,
/// these are pretty gutted on some other platforms like Silverlight.
/// </summary>
public class ComponentModelTypeConverter : IBindingTypeConverter
{
readonly MemoizingMRUCache<Tuple<Type, Type>, TypeConverter> typeConverterCache = new MemoizingMRUCache<Tuple<Type, Type>, TypeConverter>((types, _) =>
Expand Down
7 changes: 6 additions & 1 deletion ReactiveUI.Platforms/PlatformUnitTestDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

namespace ReactiveUI
{
internal static class PlatformUnitTestDetector
/// <summary>
/// Because RxUI.dll is in a PLib, it doesn't have the SuperPowers it needs
/// to be able to really detect whether it's in a unit test runner. This class
/// is much better at it.
/// </summary>
static class PlatformUnitTestDetector
{
public static bool InUnitTestRunner(string[] testAssemblies, string[] designEnvironments)
{
Expand Down
1 change: 0 additions & 1 deletion ReactiveUI.Platforms/ReactiveUI.Xaml_WP8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
<Compile Include="Xaml\PlatformOperations.cs" />
<Compile Include="Xaml\Properties\AssemblyInfo.cs" />
<Compile Include="Xaml\RoutedViewHost.cs" />
<Compile Include="Xaml\SampleDataBinder.cs" />
<Compile Include="Xaml\TransitioningContentControl.cs" />
<Compile Include="Xaml\ViewModelViewHost.cs" />
<Compile Include="Xaml\XamlDefaultPropertyBinding.cs" />
Expand Down
12 changes: 6 additions & 6 deletions ReactiveUI.Platforms/Xaml/AutoDataTemplateBindingHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

namespace ReactiveUI.Xaml
{
/// <summary>
/// AutoDataTemplateBindingHook is a binding hook that checks ItemsControls
/// that don't have DataTemplates, and assigns a default DataTemplate that
/// loads the View associated with each ViewModel.
/// </summary>
public class AutoDataTemplateBindingHook : IPropertyBindingHook
{
public static Lazy<DataTemplate> DefaultItemTemplate = new Lazy<DataTemplate>(() => {
Expand Down Expand Up @@ -43,11 +48,6 @@ public class AutoDataTemplateBindingHook : IPropertyBindingHook

public bool ExecuteHook(object source, object target, Func<IObservedChange<object, object>[]> getCurrentViewModelProperties, Func<IObservedChange<object, object>[]> getCurrentViewProperties, BindingDirection direction)
{
// NB: If ReactiveUI.Routing is registered but they're not actually
// using it, we don't want to help them out here.
//TODO: figure out if this is still needed
//if (!RxApp.IsServiceLocationConfigured()) return true;

var viewProperties = getCurrentViewProperties();
var lastViewProperty = viewProperties.LastOrDefault();
if (lastViewProperty == null) return true;
Expand All @@ -67,4 +67,4 @@ public bool ExecuteHook(object source, object target, Func<IObservedChange<objec
return true;
}
}
}
}
Loading