Added some documentation and cleaning up.
This commit is contained in:
Родитель
e289bfaa29
Коммит
c4eb36471e
|
@ -1,4 +1,19 @@
|
|||
using System;
|
||||
// ****************************************************************************
|
||||
// <copyright file="ObservableCollectionViewSource.cs" company="GalaSoft Laurent Bugnion">
|
||||
// Copyright © GalaSoft Laurent Bugnion 2009-2016
|
||||
// </copyright>
|
||||
// ****************************************************************************
|
||||
// <author>Laurent Bugnion</author>
|
||||
// <email>laurent@galasoft.ch</email>
|
||||
// <date>17.04.2016</date>
|
||||
// <project>GalaSoft.MvvmLight</project>
|
||||
// <web>http://www.mvvmlight.net</web>
|
||||
// <license>
|
||||
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
|
||||
// </license>
|
||||
// ****************************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
|
@ -118,7 +133,7 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
return _selectedItem;
|
||||
}
|
||||
|
||||
set
|
||||
protected set
|
||||
{
|
||||
if (Equals(_selectedItem, value))
|
||||
{
|
||||
|
@ -177,6 +192,16 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
return cell;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item selected by the NSIndexPath passed as parameter.
|
||||
/// </summary>
|
||||
/// <param name="indexPath">The NSIndexPath pointing to the desired item.</param>
|
||||
/// <returns>The item selected by the NSIndexPath passed as parameter.</returns>
|
||||
public TItem GetItem(NSIndexPath indexPath)
|
||||
{
|
||||
return _dataSource[indexPath.Row];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the <see cref="UICollectionViewSource.GetItemsCount"/> method.
|
||||
/// Gets the number of items in the data source.
|
||||
|
@ -278,16 +303,6 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
BindCellDelegate((TCell)cell, (TItem)item, indexPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item selected by the NSIndexPath passed as parameter.
|
||||
/// </summary>
|
||||
/// <param name="indexPath">The NSIndexPath pointing to the desired item.</param>
|
||||
/// <returns>The item selected by the NSIndexPath passed as parameter.</returns>
|
||||
protected TItem GetItem(NSIndexPath indexPath)
|
||||
{
|
||||
return _dataSource[indexPath.Row];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="PropertyChanged"/> event.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
using System;
|
||||
// ****************************************************************************
|
||||
// <copyright file="ObservableTableViewSource.cs" company="GalaSoft Laurent Bugnion">
|
||||
// Copyright © GalaSoft Laurent Bugnion 2009-2016
|
||||
// </copyright>
|
||||
// ****************************************************************************
|
||||
// <author>Laurent Bugnion</author>
|
||||
// <email>laurent@galasoft.ch</email>
|
||||
// <date>17.04.2016</date>
|
||||
// <project>GalaSoft.MvvmLight</project>
|
||||
// <web>http://www.mvvmlight.net</web>
|
||||
// <license>
|
||||
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
|
||||
// </license>
|
||||
// ****************************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
|
@ -175,7 +190,7 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
return _selectedItem;
|
||||
}
|
||||
|
||||
set
|
||||
protected set
|
||||
{
|
||||
if (Equals(_selectedItem, value))
|
||||
{
|
||||
|
@ -276,6 +291,16 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item selected by the NSIndexPath passed as parameter.
|
||||
/// </summary>
|
||||
/// <param name="indexPath">The NSIndexPath pointing to the desired item.</param>
|
||||
/// <returns>The item selected by the NSIndexPath passed as parameter.</returns>
|
||||
public TItem GetItem(NSIndexPath indexPath)
|
||||
{
|
||||
return _dataSource[indexPath.Row];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When called, checks if the <see cref="GetViewForFooterDelegate"/>
|
||||
/// delegate has been set. If yes, calls that delegate to get the TableView's footer.
|
||||
|
@ -400,16 +425,6 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
return CreateCellDelegate(reuseId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item selected by the NSIndexPath passed as parameter.
|
||||
/// </summary>
|
||||
/// <param name="indexPath">The NSIndexPath pointing to the desired item.</param>
|
||||
/// <returns>The item selected by the NSIndexPath passed as parameter.</returns>
|
||||
protected TItem GetItem(NSIndexPath indexPath)
|
||||
{
|
||||
return _dataSource[indexPath.Row];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="PropertyChanged"/> event.
|
||||
/// </summary>
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace GalaSoft.MvvmLight.Views
|
|||
////[ClassInfo(typeof(INavigationService))]
|
||||
public class NavigationService : INavigationService
|
||||
{
|
||||
private readonly Dictionary<WeakReference, object> _parametersByController = new Dictionary<WeakReference, object>();
|
||||
|
||||
/// <summary>
|
||||
/// The key that is returned by the <see cref="CurrentPageKey"/> property
|
||||
/// when the current UIViewController is the root controller.
|
||||
|
@ -49,43 +47,8 @@ namespace GalaSoft.MvvmLight.Views
|
|||
|
||||
private readonly Dictionary<string, TypeActionOrKey> _pagesByKey = new Dictionary<string, TypeActionOrKey>();
|
||||
|
||||
/// <summary>
|
||||
/// Allows a caller to get the navigation parameter corresponding
|
||||
/// to the Intent parameter.
|
||||
/// </summary>
|
||||
/// <param name="controller">The <see cref="UIViewController"/> that was navigated to.</param>
|
||||
/// <returns>The navigation parameter. If no parameter is found,
|
||||
/// returns null.</returns>
|
||||
public object GetAndRemoveParameter(UIViewController controller)
|
||||
{
|
||||
if (controller == null)
|
||||
{
|
||||
throw new ArgumentNullException("controller", "This method must be called with a valid UIViewController");
|
||||
}
|
||||
|
||||
lock (_parametersByController)
|
||||
{
|
||||
object value = null;
|
||||
WeakReference key = null;
|
||||
|
||||
foreach (var pair in _parametersByController)
|
||||
{
|
||||
if (Equals(pair.Key.Target, controller))
|
||||
{
|
||||
key = pair.Key;
|
||||
value = pair.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (key != null)
|
||||
{
|
||||
_parametersByController.Remove(key);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
private readonly Dictionary<WeakReference, object> _parametersByController =
|
||||
new Dictionary<WeakReference, object>();
|
||||
|
||||
/// <summary>
|
||||
/// The key corresponding to the currently displayed page.
|
||||
|
@ -188,6 +151,46 @@ namespace GalaSoft.MvvmLight.Views
|
|||
SaveConfigurationItem(key, item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows a caller to get the navigation parameter corresponding
|
||||
/// to the Intent parameter.
|
||||
/// </summary>
|
||||
/// <param name="controller">The <see cref="UIViewController"/> that was navigated to.</param>
|
||||
/// <returns>The navigation parameter. If no parameter is found,
|
||||
/// returns null.</returns>
|
||||
public object GetAndRemoveParameter(UIViewController controller)
|
||||
{
|
||||
if (controller == null)
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
"controller",
|
||||
"This method must be called with a valid UIViewController");
|
||||
}
|
||||
|
||||
lock (_parametersByController)
|
||||
{
|
||||
object value = null;
|
||||
WeakReference key = null;
|
||||
|
||||
foreach (var pair in _parametersByController)
|
||||
{
|
||||
if (Equals(pair.Key.Target, controller))
|
||||
{
|
||||
key = pair.Key;
|
||||
value = pair.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (key != null)
|
||||
{
|
||||
_parametersByController.Remove(key);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If possible, discards the current page and displays the previous page
|
||||
/// on the navigation stack.
|
||||
|
|
|
@ -6,6 +6,9 @@ using Android.Widget;
|
|||
|
||||
namespace GalaSoft.MvvmLight.Test.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Extending the Button control for unit test purposes (triggering events).
|
||||
/// </summary>
|
||||
public class ButtonEx : Button
|
||||
{
|
||||
public ButtonEx(IntPtr javaReference, JniHandleOwnership transfer)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;ANDROID</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Test class used for Unit test purposes.
|
||||
/// </summary>
|
||||
public class AccountModel : ObservableObject
|
||||
{
|
||||
private string _name = "Account name";
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Test class used for Unit test purposes.
|
||||
/// </summary>
|
||||
public class AccountViewModel : ViewModelBase
|
||||
{
|
||||
public const string EmptyText = "Empty";
|
||||
|
|
|
@ -3,6 +3,9 @@ using System.Windows.Input;
|
|||
|
||||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Test class used for Unit test purposes.
|
||||
/// </summary>
|
||||
public class CommandImpl : ICommand
|
||||
{
|
||||
private readonly string _initialValue;
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
|
||||
#if __IOS__
|
||||
using Foundation;
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Test class used for Unit test purposes.
|
||||
/// </summary>
|
||||
public class TestItem
|
||||
{
|
||||
public TestItem(string title)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Test class used for Unit test purposes.
|
||||
/// </summary>
|
||||
public class TestModel : ObservableObject
|
||||
{
|
||||
private string _myProperty;
|
||||
|
|
|
@ -6,19 +6,20 @@ using GalaSoft.MvvmLight.Command;
|
|||
|
||||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Test class used for Unit test purposes.
|
||||
/// </summary>
|
||||
public class TestViewModel : ViewModelBase
|
||||
{
|
||||
public const string ValueForCommand = "Command value";
|
||||
|
||||
private bool _boolProperty;
|
||||
|
||||
private DateTime _date;
|
||||
private TestModel _model;
|
||||
private TestViewModel _nested;
|
||||
private string _propertyValue;
|
||||
private RelayCommand<string> _setPropertyCommand;
|
||||
private RelayCommand _setPropertyWithoutValueCommand;
|
||||
|
||||
private string _targetPropertyObservable;
|
||||
private ICommand _testCommandImpl;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче