Added a cleaner way to convert event args in EventToCommand
This commit is contained in:
Родитель
d226f50edb
Коммит
30dc6dca24
|
@ -33,8 +33,8 @@ namespace GalaSoft.MvvmLight.Command
|
|||
/// and leave the CommandParameter and CommandParameterValue empty!</para>
|
||||
/// </summary>
|
||||
////[ClassInfo(typeof(EventToCommand),
|
||||
//// VersionString = "4.1.5",
|
||||
//// DateString = "201212161200",
|
||||
//// VersionString = "4.1.6",
|
||||
//// DateString = "201305182300",
|
||||
//// Description = "A Trigger used to bind any event to an ICommand.",
|
||||
//// UrlContacts = "http://www.galasoft.ch/contact_en.html",
|
||||
//// Email = "laurent@galasoft.ch")]
|
||||
|
@ -54,6 +54,48 @@ namespace GalaSoft.MvvmLight.Command
|
|||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a converter used to convert the EventArgs when using
|
||||
/// <see cref="PassEventArgsToCommand"/>. If PassEventArgsToCommand is false,
|
||||
/// this property is never used.
|
||||
/// </summary>
|
||||
public IEventArgsConverter EventArgsConverter
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="EventArgsConverterParameter" /> dependency property's name.
|
||||
/// </summary>
|
||||
public const string EventArgsConverterParameterPropertyName = "EventArgsConverterParameter";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a parameters for the converter used to convert the EventArgs when using
|
||||
/// <see cref="PassEventArgsToCommand"/>. If PassEventArgsToCommand is false,
|
||||
/// this property is never used. This is a dependency property.
|
||||
/// </summary>
|
||||
public object EventArgsConverterParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetValue(EventArgsConverterParameterProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(EventArgsConverterParameterProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="EventArgsConverterParameter" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty EventArgsConverterParameterProperty = DependencyProperty.Register(
|
||||
EventArgsConverterParameterPropertyName,
|
||||
typeof(object),
|
||||
typeof(EventToCommand),
|
||||
new UIPropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Provides a simple way to invoke this trigger programatically
|
||||
/// without any EventArgs.
|
||||
|
@ -82,7 +124,9 @@ namespace GalaSoft.MvvmLight.Command
|
|||
if (commandParameter == null
|
||||
&& PassEventArgsToCommand)
|
||||
{
|
||||
commandParameter = parameter;
|
||||
commandParameter = EventArgsConverter == null
|
||||
? parameter
|
||||
: EventArgsConverter.Convert(parameter, EventArgsConverterParameter);
|
||||
}
|
||||
|
||||
if (command != null
|
||||
|
@ -133,12 +177,12 @@ namespace GalaSoft.MvvmLight.Command
|
|||
return;
|
||||
}
|
||||
|
||||
var command = this.GetCommand();
|
||||
var command = GetCommand();
|
||||
|
||||
if (this.MustToggleIsEnabledValue
|
||||
if (MustToggleIsEnabledValue
|
||||
&& command != null)
|
||||
{
|
||||
element.IsEnabled = command.CanExecute(this.CommandParameterValue);
|
||||
element.IsEnabled = command.CanExecute(CommandParameterValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
namespace GalaSoft.MvvmLight.Command
|
||||
{
|
||||
/// <summary>
|
||||
/// The definition of the converter used to convert an EventArgs
|
||||
/// in the <see cref="EventToCommand"/> class, if the
|
||||
/// <see cref="EventToCommand.PassEventArgsToCommand"/> property is true.
|
||||
/// Set an instance of this class to the <see cref="EventToCommand.EventArgsConverter"/>
|
||||
/// property of the EventToCommand instance.
|
||||
/// </summary>
|
||||
public interface IEventArgsConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// The method used to convert the EventArgs instance.
|
||||
/// </summary>
|
||||
/// <param name="value">An instance of EventArgs passed by the
|
||||
/// event that the EventToCommand instance is handling.</param>
|
||||
/// <param name="parameter">An optional parameter used for the conversion. Use
|
||||
/// the <see cref="EventToCommand.EventArgsConverterParameter"/> property
|
||||
/// to set this value. This may be null.</param>
|
||||
/// <returns>The converted value.</returns>
|
||||
object Convert(object value, object parameter);
|
||||
}
|
||||
}
|
|
@ -96,6 +96,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Command\EventToCommand.cs" />
|
||||
<Compile Include="Command\EventToCommand.WPF.cs" />
|
||||
<Compile Include="Command\IEventArgsConverter.cs" />
|
||||
<Compile Include="Ioc\ISimpleIoc.cs" />
|
||||
<Compile Include="Ioc\PreferredConstructor.cs" />
|
||||
<Compile Include="Ioc\SimpleIoc.cs" />
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace GalaSoft.MvvmLight.Command
|
|||
/// and leave the CommandParameter and CommandParameterValue empty!</para>
|
||||
/// </summary>
|
||||
////[ClassInfo(typeof(EventToCommand),
|
||||
//// VersionString = "4.1.5",
|
||||
//// DateString = "201212161200",
|
||||
//// VersionString = "4.1.6",
|
||||
//// DateString = "201305182300",
|
||||
//// Description = "A Trigger used to bind any event to an ICommand.",
|
||||
//// UrlContacts = "http://www.galasoft.ch/contact_en.html",
|
||||
//// Email = "laurent@galasoft.ch")]
|
||||
|
@ -257,6 +257,48 @@ namespace GalaSoft.MvvmLight.Command
|
|||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a converter used to convert the EventArgs when using
|
||||
/// <see cref="PassEventArgsToCommand"/>. If PassEventArgsToCommand is false,
|
||||
/// this property is never used.
|
||||
/// </summary>
|
||||
public IEventArgsConverter EventArgsConverter
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="EventArgsConverterParameter" /> dependency property's name.
|
||||
/// </summary>
|
||||
public const string EventArgsConverterParameterPropertyName = "EventArgsConverterParameter";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a parameters for the converter used to convert the EventArgs when using
|
||||
/// <see cref="PassEventArgsToCommand"/>. If PassEventArgsToCommand is false,
|
||||
/// this property is never used. This is a dependency property.
|
||||
/// </summary>
|
||||
public object EventArgsConverterParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetValue(EventArgsConverterParameterProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(EventArgsConverterParameterProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="EventArgsConverterParameter" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty EventArgsConverterParameterProperty = DependencyProperty.Register(
|
||||
EventArgsConverterParameterPropertyName,
|
||||
typeof(object),
|
||||
typeof(EventToCommand),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Provides a simple way to invoke this trigger programatically
|
||||
/// without any EventArgs.
|
||||
|
@ -285,7 +327,9 @@ namespace GalaSoft.MvvmLight.Command
|
|||
if (commandParameter == null
|
||||
&& PassEventArgsToCommand)
|
||||
{
|
||||
commandParameter = parameter;
|
||||
commandParameter = EventArgsConverter == null
|
||||
? parameter
|
||||
: EventArgsConverter.Convert(parameter, EventArgsConverterParameter);
|
||||
}
|
||||
|
||||
if (command != null
|
||||
|
|
|
@ -66,6 +66,9 @@
|
|||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Command\IEventArgsConverter.cs">
|
||||
<Link>Command\IEventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Ioc\ISimpleIoc.cs">
|
||||
<Link>Ioc\ISimpleIoc.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -58,6 +58,9 @@
|
|||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Command\IEventArgsConverter.cs">
|
||||
<Link>Command\IEventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Ioc\ISimpleIoc.cs">
|
||||
<Link>Ioc\ISimpleIoc.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -67,6 +67,9 @@
|
|||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Command\IEventArgsConverter.cs">
|
||||
<Link>Command\IEventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Ioc\ISimpleIoc.cs">
|
||||
<Link>Ioc\ISimpleIoc.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -69,6 +69,9 @@
|
|||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Command\IEventArgsConverter.cs">
|
||||
<Link>Command\IEventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Ioc\ISimpleIoc.cs">
|
||||
<Link>Ioc\ISimpleIoc.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
<Reference Include="mscorlib.extensions" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Command\IEventArgsConverter.cs">
|
||||
<Link>Command\IEventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Ioc\ISimpleIoc.cs">
|
||||
<Link>Ioc\ISimpleIoc.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Command\IEventArgsConverter.cs">
|
||||
<Link>Command\IEventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Extras %28NET35%29\Ioc\ISimpleIoc.cs">
|
||||
<Link>Ioc\ISimpleIoc.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Command
|
||||
{
|
||||
public class TestEventArgsConverter : IEventArgsConverter
|
||||
{
|
||||
public string TestPrefix
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public object Convert(object value, object parameter)
|
||||
{
|
||||
var args = (StringEventArgs)value;
|
||||
|
||||
return TestPrefix
|
||||
+ args.Parameter
|
||||
+ (parameter == null ? string.Empty : parameter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,526 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Interactivity;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Windows.Input;
|
||||
using System;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Command
|
||||
{
|
||||
[TestClass]
|
||||
public class EventToCommandEventArgsTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestInvokeSimpleCommandWithEventArgs()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.SimpleCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(null, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(InvalidCastException))]
|
||||
public void TestInvokeParameterCommandWithEventArgs()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(args.Parameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndNoParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.CommandWithEventArgs
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(args.Parameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndParameterValue()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
const string CommandParameter = "CommandParameter";
|
||||
trigger.CommandParameterValue = CommandParameter;
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(CommandParameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndBoundParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
var textBox = new TextBox
|
||||
{
|
||||
Text = "BoundParameter"
|
||||
};
|
||||
|
||||
var bindingParameter = new Binding
|
||||
{
|
||||
Source = textBox,
|
||||
Path = new PropertyPath("Text")
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
trigger.CommandParameter = bindingParameter;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandParameterProperty, bindingParameter);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(textBox.Text, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeSimpleCommandWithEventArgsAndConverter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.SimpleCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(null, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeParameterCommandWithEventArgsAndConverter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(prefix + args.Parameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndNoParameterAndConverter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.CommandWithEventArgsConverted
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(prefix + args.Parameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndParameterValueAndConverter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
const string commandParameter = "CommandParameter";
|
||||
trigger.CommandParameterValue = commandParameter;
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(commandParameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndBoundParameterAndConverter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
var textBox = new TextBox
|
||||
{
|
||||
Text = "BoundParameter"
|
||||
};
|
||||
|
||||
var bindingParameter = new Binding
|
||||
{
|
||||
Source = textBox,
|
||||
Path = new PropertyPath("Text")
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
trigger.CommandParameter = bindingParameter;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandParameterProperty, bindingParameter);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(textBox.Text, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeSimpleCommandWithEventArgsAndConverterAndConverterParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
trigger.EventArgsConverterParameter = "Suffix";
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.SimpleCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(null, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeParameterCommandWithEventArgsAndConverterAndConverterParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
trigger.EventArgsConverterParameter = "Suffix";
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(prefix + args.Parameter + trigger.EventArgsConverterParameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndNoParameterAndConverterAndConverterParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
trigger.EventArgsConverterParameter = "Suffix";
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.CommandWithEventArgsConverted
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(prefix + args.Parameter + trigger.EventArgsConverterParameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndParameterValueAndConverterAndConverterParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
trigger.EventArgsConverterParameter = "Suffix";
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
const string commandParameter = "CommandParameter";
|
||||
trigger.CommandParameterValue = commandParameter;
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(commandParameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndBoundParameterAndConverterAndConverterParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
const string prefix = "Test";
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
trigger.EventArgsConverter = new TestEventArgsConverter
|
||||
{
|
||||
TestPrefix = prefix
|
||||
};
|
||||
trigger.EventArgsConverterParameter = "Suffix";
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
var textBox = new TextBox
|
||||
{
|
||||
Text = "BoundParameter"
|
||||
};
|
||||
|
||||
var bindingParameter = new Binding
|
||||
{
|
||||
Source = textBox,
|
||||
Path = new PropertyPath("Text")
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
trigger.CommandParameter = bindingParameter;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandParameterProperty, bindingParameter);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(textBox.Text, vm.ParameterReceived);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Command
|
||||
{
|
||||
public class EventToCommandStub : EventToCommand
|
||||
{
|
||||
public void InvokeWithEventArgs(EventArgs args)
|
||||
{
|
||||
base.Invoke(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,12 +2,9 @@
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Interactivity;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Windows.Input;
|
||||
using System;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Command
|
||||
{
|
||||
|
@ -410,263 +407,5 @@ namespace GalaSoft.MvvmLight.Test.Command
|
|||
Assert.IsTrue(vm.CommandExecuted);
|
||||
#endif
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeSimpleCommandWithEventArgs()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.SimpleCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(null, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(InvalidCastException))]
|
||||
public void TestInvokeParameterCommandWithEventArgs()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(args.Parameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndNoParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.CommandWithEventArgs
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(args.Parameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndParameterValue()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
#endif
|
||||
|
||||
const string CommandParameter = "CommandParameter";
|
||||
trigger.CommandParameterValue = CommandParameter;
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(CommandParameter, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestInvokeWithEventArgsAndBoundParameter()
|
||||
{
|
||||
var trigger = new EventToCommandStub();
|
||||
var rectangle = new Rectangle();
|
||||
((IAttachedObject)trigger).Attach(rectangle);
|
||||
|
||||
trigger.PassEventArgsToCommand = true;
|
||||
|
||||
var vm = new TestViewModel();
|
||||
var binding = new Binding
|
||||
{
|
||||
Source = vm.ParameterCommand
|
||||
};
|
||||
|
||||
var textBox = new TextBox
|
||||
{
|
||||
Text = "BoundParameter"
|
||||
};
|
||||
|
||||
var bindingParameter = new Binding
|
||||
{
|
||||
Source = textBox,
|
||||
Path = new PropertyPath("Text")
|
||||
};
|
||||
|
||||
#if SL3
|
||||
trigger.Command = binding;
|
||||
trigger.CommandParameter = bindingParameter;
|
||||
#else
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
|
||||
BindingOperations.SetBinding(trigger, EventToCommand.CommandParameterProperty, bindingParameter);
|
||||
#endif
|
||||
|
||||
var args = new StringEventArgs("StringEventArgs");
|
||||
trigger.InvokeWithEventArgs(args);
|
||||
Assert.IsTrue(vm.CommandExecuted);
|
||||
Assert.AreEqual(textBox.Text, vm.ParameterReceived);
|
||||
}
|
||||
|
||||
private class StringEventArgs : EventArgs
|
||||
{
|
||||
public string Parameter
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public StringEventArgs(string parameter)
|
||||
{
|
||||
Parameter = parameter;
|
||||
}
|
||||
}
|
||||
|
||||
private class EventToCommandStub : EventToCommand
|
||||
{
|
||||
public void InvokeWithEventArgs(EventArgs args)
|
||||
{
|
||||
base.Invoke(args);
|
||||
}
|
||||
}
|
||||
|
||||
private class TestViewModel : ViewModelBase
|
||||
{
|
||||
public bool CommandExecuted
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string ParameterReceived
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand SimpleCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand ParameterCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand ToggledCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand ToggledCommandWithParameter
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public readonly RelayCommand<EventArgs> CommandWithEventArgs;
|
||||
|
||||
private bool _enableToggledCommand;
|
||||
public bool EnableToggledCommand
|
||||
{
|
||||
private get
|
||||
{
|
||||
return _enableToggledCommand;
|
||||
}
|
||||
set
|
||||
{
|
||||
_enableToggledCommand = value;
|
||||
((RelayCommand)ToggledCommand).RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public TestViewModel()
|
||||
{
|
||||
SimpleCommand = new RelayCommand(() => CommandExecuted = true);
|
||||
|
||||
ParameterCommand = new RelayCommand<string>(p =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = p;
|
||||
});
|
||||
|
||||
ToggledCommand = new RelayCommand(
|
||||
() => CommandExecuted = true,
|
||||
() => EnableToggledCommand);
|
||||
|
||||
ToggledCommandWithParameter = new RelayCommand<string>(
|
||||
p =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = p;
|
||||
},
|
||||
p => (p != null && p.StartsWith("Hello")));
|
||||
|
||||
CommandWithEventArgs = new RelayCommand<EventArgs>(e =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = ((StringEventArgs)e).Parameter;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Command
|
||||
{
|
||||
public class StringEventArgs : EventArgs
|
||||
{
|
||||
public string Parameter
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public StringEventArgs(string parameter)
|
||||
{
|
||||
Parameter = parameter;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Parameter;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using System.Windows.Input;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Command
|
||||
{
|
||||
public class TestViewModel : ViewModelBase
|
||||
{
|
||||
public bool CommandExecuted
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string ParameterReceived
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand SimpleCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand ParameterCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand ToggledCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand ToggledCommandWithParameter
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public readonly RelayCommand<EventArgs> CommandWithEventArgs;
|
||||
|
||||
public readonly RelayCommand<string> CommandWithEventArgsConverted;
|
||||
|
||||
private bool _enableToggledCommand;
|
||||
public bool EnableToggledCommand
|
||||
{
|
||||
private get
|
||||
{
|
||||
return _enableToggledCommand;
|
||||
}
|
||||
set
|
||||
{
|
||||
_enableToggledCommand = value;
|
||||
((RelayCommand)ToggledCommand).RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public TestViewModel()
|
||||
{
|
||||
SimpleCommand = new RelayCommand(() => CommandExecuted = true);
|
||||
|
||||
ParameterCommand = new RelayCommand<string>(p =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = p;
|
||||
});
|
||||
|
||||
ToggledCommand = new RelayCommand(
|
||||
() => CommandExecuted = true,
|
||||
() => EnableToggledCommand);
|
||||
|
||||
ToggledCommandWithParameter = new RelayCommand<string>(
|
||||
p =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = p;
|
||||
},
|
||||
p => (p != null && p.StartsWith("Hello")));
|
||||
|
||||
CommandWithEventArgs = new RelayCommand<EventArgs>(e =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = ((StringEventArgs)e).Parameter;
|
||||
});
|
||||
|
||||
CommandWithEventArgsConverted = new RelayCommand<string>(e =>
|
||||
{
|
||||
CommandExecuted = true;
|
||||
ParameterReceived = e;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,10 +57,15 @@
|
|||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Command\EventToCommandEventArgsTest.cs" />
|
||||
<Compile Include="Command\EventArgsConverter.cs" />
|
||||
<Compile Include="Command\EventToCommandStub.cs" />
|
||||
<Compile Include="Command\EventToCommandTest.cs" />
|
||||
<Compile Include="Command\RelayCommandGenericTest.cs" />
|
||||
<Compile Include="Command\RelayCommandTest.cs" />
|
||||
<Compile Include="Command\StringEventArgs.cs" />
|
||||
<Compile Include="Command\TemporaryClass.cs" />
|
||||
<Compile Include="Command\TestViewModel.cs" />
|
||||
<Compile Include="Helpers\PublicTestClassGenericWithResult.cs" />
|
||||
<Compile Include="Helpers\InternalTestClassGenericWithResult.cs" />
|
||||
<Compile Include="Helpers\InternalTestClassWithResult.cs" />
|
||||
|
|
|
@ -57,6 +57,15 @@
|
|||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventArgsConverter.cs">
|
||||
<Link>Command\EventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandEventArgsTest.cs">
|
||||
<Link>Command\EventToCommandEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandStub.cs">
|
||||
<Link>Command\EventToCommandStub.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandTest.cs">
|
||||
<Link>Command\EventToCommandTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -66,9 +75,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\RelayCommandTest.cs">
|
||||
<Link>Command\RelayCommandTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\StringEventArgs.cs">
|
||||
<Link>Command\StringEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TemporaryClass.cs">
|
||||
<Link>Command\TemporaryClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TestViewModel.cs">
|
||||
<Link>Command\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Helpers\InternalTestClassGenericWithResult.cs">
|
||||
<Link>Helpers\InternalTestClassGenericWithResult.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -72,6 +72,15 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventArgsConverter.cs">
|
||||
<Link>Command\EventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandEventArgsTest.cs">
|
||||
<Link>Command\EventToCommandEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandStub.cs">
|
||||
<Link>Command\EventToCommandStub.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandTest.cs">
|
||||
<Link>Command\EventToCommandTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -81,9 +90,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\RelayCommandTest.cs">
|
||||
<Link>Command\RelayCommandTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\StringEventArgs.cs">
|
||||
<Link>Command\StringEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TemporaryClass.cs">
|
||||
<Link>Command\TemporaryClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TestViewModel.cs">
|
||||
<Link>Command\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Helpers\CommonTestClass.cs">
|
||||
<Link>Helpers\CommonTestClass.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -95,6 +95,15 @@
|
|||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventArgsConverter.cs">
|
||||
<Link>Command\EventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandEventArgsTest.cs">
|
||||
<Link>Command\EventToCommandEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandStub.cs">
|
||||
<Link>Command\EventToCommandStub.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandTest.cs">
|
||||
<Link>Command\EventToCommandTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -104,9 +113,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\RelayCommandTest.cs">
|
||||
<Link>Command\RelayCommandTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\StringEventArgs.cs">
|
||||
<Link>Command\StringEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TemporaryClass.cs">
|
||||
<Link>Command\TemporaryClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TestViewModel.cs">
|
||||
<Link>Command\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Helpers\InternalTestClassGenericWithResult.cs">
|
||||
<Link>Helpers\InternalTestClassGenericWithResult.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -95,6 +95,15 @@
|
|||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventArgsConverter.cs">
|
||||
<Link>Command\EventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandEventArgsTest.cs">
|
||||
<Link>Command\EventToCommandEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandStub.cs">
|
||||
<Link>Command\EventToCommandStub.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandTest.cs">
|
||||
<Link>Command\EventToCommandTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -104,9 +113,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\RelayCommandTest.cs">
|
||||
<Link>Command\RelayCommandTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\StringEventArgs.cs">
|
||||
<Link>Command\StringEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TemporaryClass.cs">
|
||||
<Link>Command\TemporaryClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TestViewModel.cs">
|
||||
<Link>Command\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Helpers\InternalTestClassGenericWithResult.cs">
|
||||
<Link>Helpers\InternalTestClassGenericWithResult.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -70,6 +70,15 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventArgsConverter.cs">
|
||||
<Link>Command\EventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandEventArgsTest.cs">
|
||||
<Link>Command\EventToCommandEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandStub.cs">
|
||||
<Link>Command\EventToCommandStub.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandTest.cs">
|
||||
<Link>Command\EventToCommandTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -79,9 +88,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\RelayCommandTest.cs">
|
||||
<Link>Command\RelayCommandTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\StringEventArgs.cs">
|
||||
<Link>Command\StringEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TemporaryClass.cs">
|
||||
<Link>Command\TemporaryClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TestViewModel.cs">
|
||||
<Link>Command\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Helpers\InternalTestClassGenericWithResult.cs">
|
||||
<Link>Helpers\InternalTestClassGenericWithResult.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -90,6 +90,15 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventArgsConverter.cs">
|
||||
<Link>Command\EventArgsConverter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandEventArgsTest.cs">
|
||||
<Link>Command\EventToCommandEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandStub.cs">
|
||||
<Link>Command\EventToCommandStub.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\EventToCommandTest.cs">
|
||||
<Link>Command\EventToCommandTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -99,9 +108,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\RelayCommandTest.cs">
|
||||
<Link>Command\RelayCommandTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\StringEventArgs.cs">
|
||||
<Link>Command\StringEventArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TemporaryClass.cs">
|
||||
<Link>Command\TemporaryClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Command\TestViewModel.cs">
|
||||
<Link>Command\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Helpers\CommonTestClass.cs">
|
||||
<Link>Helpers\CommonTestClass.cs</Link>
|
||||
</Compile>
|
||||
|
@ -246,9 +261,15 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Stubs\ITestClass.cs">
|
||||
<Link>Stubs\ITestClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Stubs\TestBaseClass.cs">
|
||||
<Link>Stubs\TestBaseClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Stubs\TestBindingTarget.cs">
|
||||
<Link>Stubs\TestBindingTarget.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Stubs\TestChildClass.cs">
|
||||
<Link>Stubs\TestChildClass.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Test %28NET35%29\Stubs\TestClass.cs">
|
||||
<Link>Stubs\TestClass.cs</Link>
|
||||
</Compile>
|
||||
|
@ -315,7 +336,6 @@
|
|||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Stubs\Class1.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Stubs
|
||||
{
|
||||
public class TestBaseClass
|
||||
{
|
||||
public void Remove()
|
||||
{
|
||||
SimpleIoc.Default.Unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class TestChildClass : TestBaseClass
|
||||
{
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче