Some code cleanup
This commit is contained in:
Родитель
f690ec2cf0
Коммит
5f183bad19
|
@ -49,11 +49,11 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
private WeakAction _onSourceUpdate;
|
||||
private WeakReference _propertySource;
|
||||
private WeakReference _propertyTarget;
|
||||
private bool _resolveTopField;
|
||||
private bool _settingSourceToTarget;
|
||||
private bool _settingTargetToSource;
|
||||
private PropertyInfo _sourceProperty;
|
||||
private PropertyInfo _targetProperty;
|
||||
private bool _resolveTopField;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value to use when the binding is unable to return a value. This can happen if one of the
|
||||
|
@ -1040,7 +1040,6 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
}
|
||||
catch (TargetException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -80,8 +80,10 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Binding{TSource, TSource}"/> with a source property but without a target.
|
||||
/// This type of bindings is useful for the <see cref="SetCommand{TIn, TOut}"/>
|
||||
/// and <see cref="SetCommand{T, TEventArgs}"/> methods, to use as CommandParameter
|
||||
/// This type of bindings is useful for the <see cref="SetCommand{T}(object, string, RelayCommand{T}, Binding)"/>,
|
||||
/// <see cref="SetCommand{T}(object, RelayCommand{T}, Binding)"/>,
|
||||
/// <see cref="SetCommand{T, TEventArgs}(object, string, RelayCommand{T}, Binding)"/>
|
||||
/// and <see cref="SetCommand{T, TEventArgs}(object, RelayCommand{T}, Binding)"/> methods, to use as CommandParameter
|
||||
/// binding.
|
||||
/// </summary>
|
||||
/// <param name="source">The source of the binding. If this object implements INotifyPropertyChanged and the
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
// ****************************************************************************
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace System.Windows
|
||||
// ReSharper restore CheckNamespace
|
||||
// ReSharper restore CheckNamespace
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides event listening support for classes that expect to receive events
|
||||
|
@ -24,6 +25,14 @@ namespace System.Windows
|
|||
////[ClassInfo(typeof(Binding))]
|
||||
public interface IWeakEventListener
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the WeakReference holding the instance that raised the event.
|
||||
/// </summary>
|
||||
WeakReference InstanceReference
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Receives events from the centralized event manager.
|
||||
/// </summary>
|
||||
|
@ -36,13 +45,5 @@ namespace System.Windows
|
|||
/// an event that it does not recognize or handle.
|
||||
/// </returns>
|
||||
bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the WeakReference holding the instance that raised the event.
|
||||
/// </summary>
|
||||
WeakReference InstanceReference
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -170,7 +170,9 @@ namespace System.Windows
|
|||
}
|
||||
|
||||
var checkInstance =
|
||||
_list.Any(l => l.Value.Any(i => i.InstanceReference != null
|
||||
_list.Any(
|
||||
l => l.Value.Any(
|
||||
i => i.InstanceReference != null
|
||||
&& i.InstanceReference.IsAlive
|
||||
&& i.InstanceReference.Target != null
|
||||
&& i.InstanceReference.Target.Equals(toRemove.InstanceReference.Target)));
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
////using GalaSoft.Utilities.Attributes;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
////using GalaSoft.Utilities.Attributes;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Threading
|
||||
{
|
||||
|
@ -49,18 +48,6 @@ namespace GalaSoft.MvvmLight.Threading
|
|||
ActivityBase.CurrentActivity.RunOnUiThread(action);
|
||||
}
|
||||
|
||||
private static void CheckDispatcher()
|
||||
{
|
||||
if (ActivityBase.CurrentActivity == null)
|
||||
{
|
||||
var error = new StringBuilder("The DispatcherHelper cannot be called.");
|
||||
error.AppendLine();
|
||||
error.Append("Make sure that your main Activity derives from ActivityBase.");
|
||||
|
||||
throw new InvalidOperationException(error.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is only here for compatibility with
|
||||
/// other platforms but it doesn't do anything.
|
||||
|
@ -76,5 +63,17 @@ namespace GalaSoft.MvvmLight.Threading
|
|||
public static void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
private static void CheckDispatcher()
|
||||
{
|
||||
if (ActivityBase.CurrentActivity == null)
|
||||
{
|
||||
var error = new StringBuilder("The DispatcherHelper cannot be called.");
|
||||
error.AppendLine();
|
||||
error.Append("Make sure that your main Activity derives from ActivityBase.");
|
||||
|
||||
throw new InvalidOperationException(error.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,6 +33,18 @@ namespace GalaSoft.MvvmLight.Views
|
|||
private set;
|
||||
}
|
||||
|
||||
internal string ActivityKey
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
internal static string NextPageKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If possible, discards the current page and displays the previous page
|
||||
/// on the navigation stack.
|
||||
|
@ -63,17 +75,5 @@ namespace GalaSoft.MvvmLight.Views
|
|||
|
||||
base.OnResume();
|
||||
}
|
||||
|
||||
internal string ActivityKey
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
internal static string NextPageKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -233,7 +233,9 @@ namespace GalaSoft.MvvmLight.Views
|
|||
|
||||
AlertDialog dialog = null;
|
||||
|
||||
builder.SetPositiveButton(okText ?? "OK", (d, index) =>
|
||||
builder.SetPositiveButton(
|
||||
okText ?? "OK",
|
||||
(d, index) =>
|
||||
{
|
||||
tcs.TrySetResult(true);
|
||||
|
||||
|
@ -253,7 +255,9 @@ namespace GalaSoft.MvvmLight.Views
|
|||
|
||||
if (cancelText != null)
|
||||
{
|
||||
builder.SetNegativeButton(cancelText, (d, index) =>
|
||||
builder.SetNegativeButton(
|
||||
cancelText,
|
||||
(d, index) =>
|
||||
{
|
||||
tcs.TrySetResult(false);
|
||||
|
||||
|
@ -272,7 +276,9 @@ namespace GalaSoft.MvvmLight.Views
|
|||
});
|
||||
}
|
||||
|
||||
builder.SetOnDismissListener(new OnDismissListener(() =>
|
||||
builder.SetOnDismissListener(
|
||||
new OnDismissListener(
|
||||
() =>
|
||||
{
|
||||
tcs.TrySetResult(false);
|
||||
|
||||
|
|
|
@ -50,76 +50,6 @@ namespace GalaSoft.MvvmLight.Views
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If possible, discards the current page and displays the previous page
|
||||
/// on the navigation stack.
|
||||
/// </summary>
|
||||
public void GoBack()
|
||||
{
|
||||
ActivityBase.GoBack();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a new page corresponding to the given key.
|
||||
/// Make sure to call the <see cref="Configure"/>
|
||||
/// method first.
|
||||
/// </summary>
|
||||
/// <param name="pageKey">The key corresponding to the page
|
||||
/// that should be displayed.</param>
|
||||
/// <exception cref="ArgumentException">When this method is called for
|
||||
/// a key that has not been configured earlier.</exception>
|
||||
public void NavigateTo(string pageKey)
|
||||
{
|
||||
NavigateTo(pageKey, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a new page corresponding to the given key,
|
||||
/// and passes a parameter to the new page.
|
||||
/// Make sure to call the <see cref="Configure"/>
|
||||
/// method first.
|
||||
/// </summary>
|
||||
/// <param name="pageKey">The key corresponding to the page
|
||||
/// that should be displayed.</param>
|
||||
/// <param name="parameter">The parameter that should be passed
|
||||
/// to the new page.</param>
|
||||
/// <exception cref="ArgumentException">When this method is called for
|
||||
/// a key that has not been configured earlier.</exception>
|
||||
public void NavigateTo(string pageKey, object parameter)
|
||||
{
|
||||
if (ActivityBase.CurrentActivity == null)
|
||||
{
|
||||
throw new InvalidOperationException("No CurrentActivity found");
|
||||
}
|
||||
|
||||
lock (_pagesByKey)
|
||||
{
|
||||
if (!_pagesByKey.ContainsKey(pageKey))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
string.Format(
|
||||
"No such page: {0}. Did you forget to call NavigationService.Configure?",
|
||||
pageKey),
|
||||
"pageKey");
|
||||
}
|
||||
|
||||
var intent = new Intent(ActivityBase.CurrentActivity, _pagesByKey[pageKey]);
|
||||
|
||||
if (parameter != null)
|
||||
{
|
||||
lock (_parametersByKey)
|
||||
{
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
_parametersByKey.Add(guid, parameter);
|
||||
intent.PutExtra(ParameterKeyName, guid);
|
||||
}
|
||||
}
|
||||
|
||||
ActivityBase.CurrentActivity.StartActivity(intent);
|
||||
ActivityBase.NextPageKey = pageKey;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a key/page pair to the navigation service.
|
||||
/// </summary>
|
||||
|
@ -192,5 +122,75 @@ namespace GalaSoft.MvvmLight.Views
|
|||
{
|
||||
return (T)GetAndRemoveParameter(intent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If possible, discards the current page and displays the previous page
|
||||
/// on the navigation stack.
|
||||
/// </summary>
|
||||
public void GoBack()
|
||||
{
|
||||
ActivityBase.GoBack();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a new page corresponding to the given key.
|
||||
/// Make sure to call the <see cref="Configure"/>
|
||||
/// method first.
|
||||
/// </summary>
|
||||
/// <param name="pageKey">The key corresponding to the page
|
||||
/// that should be displayed.</param>
|
||||
/// <exception cref="ArgumentException">When this method is called for
|
||||
/// a key that has not been configured earlier.</exception>
|
||||
public void NavigateTo(string pageKey)
|
||||
{
|
||||
NavigateTo(pageKey, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a new page corresponding to the given key,
|
||||
/// and passes a parameter to the new page.
|
||||
/// Make sure to call the <see cref="Configure"/>
|
||||
/// method first.
|
||||
/// </summary>
|
||||
/// <param name="pageKey">The key corresponding to the page
|
||||
/// that should be displayed.</param>
|
||||
/// <param name="parameter">The parameter that should be passed
|
||||
/// to the new page.</param>
|
||||
/// <exception cref="ArgumentException">When this method is called for
|
||||
/// a key that has not been configured earlier.</exception>
|
||||
public void NavigateTo(string pageKey, object parameter)
|
||||
{
|
||||
if (ActivityBase.CurrentActivity == null)
|
||||
{
|
||||
throw new InvalidOperationException("No CurrentActivity found");
|
||||
}
|
||||
|
||||
lock (_pagesByKey)
|
||||
{
|
||||
if (!_pagesByKey.ContainsKey(pageKey))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
string.Format(
|
||||
"No such page: {0}. Did you forget to call NavigationService.Configure?",
|
||||
pageKey),
|
||||
"pageKey");
|
||||
}
|
||||
|
||||
var intent = new Intent(ActivityBase.CurrentActivity, _pagesByKey[pageKey]);
|
||||
|
||||
if (parameter != null)
|
||||
{
|
||||
lock (_parametersByKey)
|
||||
{
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
_parametersByKey.Add(guid, parameter);
|
||||
intent.PutExtra(ParameterKeyName, guid);
|
||||
}
|
||||
}
|
||||
|
||||
ActivityBase.CurrentActivity.StartActivity(intent);
|
||||
ActivityBase.NextPageKey = pageKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,15 +55,6 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
private INotifyCollectionChanged _notifier;
|
||||
private ObservableTableSource<T> _tableSource;
|
||||
|
||||
/// <summary>
|
||||
/// A reuse identifier for the TableView's cells.
|
||||
/// </summary>
|
||||
public string ReuseId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When set, specifies which animation should be used when rows change.
|
||||
/// </summary>
|
||||
|
@ -183,6 +174,15 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A reuse identifier for the TableView's cells.
|
||||
/// </summary>
|
||||
public string ReuseId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TableView's selected item.
|
||||
/// Changes to that property's value raise the PropertyChanged event.
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
////using GalaSoft.Utilities.Attributes;
|
||||
using Foundation;
|
||||
////using GalaSoft.Utilities.Attributes;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Threading
|
||||
{
|
||||
|
@ -62,18 +61,6 @@ namespace GalaSoft.MvvmLight.Threading
|
|||
MainThreadContext.InvokeOnMainThread(action);
|
||||
}
|
||||
|
||||
private static void CheckDispatcher()
|
||||
{
|
||||
if (MainThreadContext == null)
|
||||
{
|
||||
var error = new StringBuilder("The DispatcherHelper is not initialized.");
|
||||
error.AppendLine();
|
||||
error.Append("Call DispatcherHelper.Initialize(app) at the end of AppDelegate.FinishedLaunching.");
|
||||
|
||||
throw new InvalidOperationException(error.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method should be called once on the UI thread to ensure that
|
||||
/// the <see cref="MainThreadContext" /> property is initialized.
|
||||
|
@ -95,5 +82,17 @@ namespace GalaSoft.MvvmLight.Threading
|
|||
{
|
||||
MainThreadContext = null;
|
||||
}
|
||||
|
||||
private static void CheckDispatcher()
|
||||
{
|
||||
if (MainThreadContext == null)
|
||||
{
|
||||
var error = new StringBuilder("The DispatcherHelper is not initialized.");
|
||||
error.AppendLine();
|
||||
error.Append("Call DispatcherHelper.Initialize(app) at the end of AppDelegate.FinishedLaunching.");
|
||||
|
||||
throw new InvalidOperationException(error.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,17 +21,6 @@ namespace GalaSoft.MvvmLight.Views
|
|||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A constructor used when creating managed representations of unmanaged objects;
|
||||
/// Called by the runtime.
|
||||
/// </summary>
|
||||
/// <param name="handle">Pointer (handle) to the unmanaged object.</param>
|
||||
/// <remarks>Check the remarks on <see cref="UIViewController(IntPtr)"/></remarks>
|
||||
protected internal ControllerBase(IntPtr handle)
|
||||
: base(handle)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A constructor that initializes the object from the data stored in the unarchiver
|
||||
/// object.
|
||||
|
@ -74,5 +63,16 @@ namespace GalaSoft.MvvmLight.Views
|
|||
public ControllerBase()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A constructor used when creating managed representations of unmanaged objects;
|
||||
/// Called by the runtime.
|
||||
/// </summary>
|
||||
/// <param name="handle">Pointer (handle) to the unmanaged object.</param>
|
||||
/// <remarks>Check the remarks on <see cref="UIViewController(IntPtr)"/></remarks>
|
||||
protected internal ControllerBase(IntPtr handle)
|
||||
: base(handle)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,20 @@
|
|||
using GalaSoft.MvvmLight.Helpers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if ANDROID
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
|
||||
#elif __IOS__
|
||||
using UIKit;
|
||||
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class BindingAccountTest
|
||||
{
|
||||
private Binding<string, string> _binding1;
|
||||
|
|
|
@ -3,12 +3,13 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if ANDROID
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
|
||||
#elif __IOS__
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
|
|
|
@ -3,12 +3,13 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if ANDROID
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
|
||||
#elif __IOS__
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
|
|
|
@ -3,13 +3,14 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if ANDROID
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
|
||||
#elif __IOS__
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using UIKit;
|
||||
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
|
@ -99,6 +100,7 @@ namespace GalaSoft.MvvmLight.Test.Binding
|
|||
[Test]
|
||||
public void
|
||||
Binding_MultipleLevelsOfNullWithConverter_ShouldCallConverterWithNullThenTargetNullValueButNotFallbackValue(
|
||||
|
||||
)
|
||||
{
|
||||
var vmSource = new TestViewModel();
|
||||
|
|
|
@ -4,13 +4,13 @@ using System.Globalization;
|
|||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if ANDROID
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
|
||||
#elif __IOS__
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using UIKit;
|
||||
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
|
|
Загрузка…
Ссылка в новой задаче