Added TargetNullValue for Binding (used when the Source property is null).
Added FallbackValue for Binding (used when there is an error in the binding resolution) Added a SetCommand overload without an eventName parameter: Works for Button.Click (Android), CheckBox.CheckedChange (Android), UIButton.TouchUpInside (iOS), UIBarButtonItem.Clicked (iOS). Added a SetCommand overload with a value for CommandParameter. SetCommand now supports binding for CommandParameter (in case the value changes) and a non changing value. --> public static void SetCommand<T>( this object element, RelayCommand<T> command, T commandParameter) Modified SetCommand (non generic) to support ICommand instead of RelayCommand. Replaced UpdateSourceTrigger with ObserveSourceEvent, and UpdateTargetTrigger with ObserveTargetEvent. The old names were too confusing. UpdateSourceTrigger and UpdateTargetTrigger are still there but marked Obsolete. Cleanup up and refactored the Binding class in partial classes for neatness. Added a bunch of unit tests for iOS and Android (not all features are unit tested yet but it's a good start). Renamed solution Galasoft.MvvmLight (VS2013) in Galasoft.MvvmLight (VS2015).
This commit is contained in:
Родитель
d3a603de38
Коммит
4b51532a31
|
@ -1,572 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight (PCL)", "GalaSoft.MvvmLight (PCL)\GalaSoft.MvvmLight (PCL).csproj", "{6A912701-3BA1-4975-ADBF-160CAF66B640}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (PNET45)", "Tests\PCL\GalaSoft.MvvmLight.Test (PNET45)\GalaSoft.MvvmLight.Test (PNET45).csproj", "{59378F82-F92D-457E-8FB1-B7799A7A919B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestViews", "TestViews", "{B25F0638-578E-4E2A-9783-23EB99B525BE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.TestView (PNET45)", "TestViews\PCL\GalaSoft.MvvmLight.TestView (PNET45)\GalaSoft.MvvmLight.TestView (PNET45).csproj", "{AAE11955-7DF4-4758-9024-C5247BDE0368}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{99D5856E-95ED-49B6-9F0C-0A5878A87009}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (NET45)", "GalaSoft.MvvmLight.Platform (NET45)\GalaSoft.MvvmLight.Platform (NET45).csproj", "{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (WIN81)", "GalaSoft.MvvmLight.Platform (WIN81)\GalaSoft.MvvmLight.Platform (WIN81).csproj", "{8E1FCE57-FD06-44ED-B2BC-6D935329630E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.TestView (PWIN81)", "TestViews\PCL\GalaSoft.MvvmLight.TestView (PWIN81)\GalaSoft.MvvmLight.TestView (PWIN81).csproj", "{2CFF4493-5482-465C-A02C-784435861343}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.TestView (PWPSL81)", "TestViews\PCL\GalaSoft.MvvmLight.TestView (PWPSL81)\GalaSoft.MvvmLight.TestView (PWPSL81).csproj", "{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (WPSL81)", "GalaSoft.MvvmLight.Platform (WPSL81)\GalaSoft.MvvmLight.Platform (WPSL81).csproj", "{588595A3-48D5-4A2C-930A-59C5123A07CD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (PWPSL81)", "Tests\PCL\GalaSoft.MvvmLight.Test (PWPSL81)\GalaSoft.MvvmLight.Test (PWPSL81).csproj", "{29B2A5BA-2E0A-484A-866D-41CCE7144521}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (PWP81)", "Tests\PCL\GalaSoft.MvvmLight.Test (PWP81)\GalaSoft.MvvmLight.Test (PWP81).csproj", "{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (WP81)", "GalaSoft.MvvmLight.Platform (WP81)\GalaSoft.MvvmLight.Platform (WP81).csproj", "{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight (NET4)", "GalaSoft.MvvmLight (NET4)\GalaSoft.MvvmLight (NET4).csproj", "{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (NET4)", "Tests\GalaSoft.MvvmLight.Test (NET4)\GalaSoft.MvvmLight.Test (NET4).csproj", "{30EFC165-77CE-4AC3-B99B-7998D5E39749}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Extras (NET4)", "GalaSoft.MvvmLight.Extras (NET4)\GalaSoft.MvvmLight.Extras (NET4).csproj", "{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight (NET35)", "GalaSoft.MvvmLight (NET35)\GalaSoft.MvvmLight (NET35).csproj", "{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Extras (NET35)", "GalaSoft.MvvmLight.Extras (NET35)\GalaSoft.MvvmLight.Extras (NET35).csproj", "{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (NET35)", "Tests\GalaSoft.MvvmLight.Test (NET35)\GalaSoft.MvvmLight.Test (NET35).csproj", "{0F66F445-5DF0-4064-8214-3D16FF924E88}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.TestView (PWP81)", "TestViews\PCL\GalaSoft.MvvmLight.TestView (PWP81)\GalaSoft.MvvmLight.TestView (PWP81).csproj", "{E924C358-8AFD-4B47-903D-5760221AA05C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Extras (PCL)", "GalaSoft.MvvmLight.Extras (PCL)\GalaSoft.MvvmLight.Extras (PCL).csproj", "{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (PWIN81)", "Tests\PCL\GalaSoft.MvvmLight.Test (PWIN81)\GalaSoft.MvvmLight.Test (PWIN81).csproj", "{DB6CF16F-315E-4BBD-8348-369905645838}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (WPSL80)", "GalaSoft.MvvmLight.Platform (WPSL80)\GalaSoft.MvvmLight.Platform (WPSL80).csproj", "{5E668BEC-ADF7-4F85-AC28-685863160494}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (PWPSL80)", "Tests\PCL\GalaSoft.MvvmLight.Test (PWPSL80)\GalaSoft.MvvmLight.Test (PWPSL80).csproj", "{3620804D-B56B-4C22-B987-AAD7B7F40FC8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (Android)", "GalaSoft.MvvmLight.Platform (Android)\GalaSoft.MvvmLight.Platform (Android).csproj", "{A5B7741D-E331-438C-B3BF-596B048DB622}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight (SL5)", "GalaSoft.MvvmLight (SL5)\GalaSoft.MvvmLight (SL5).csproj", "{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Extras (SL5)", "GalaSoft.MvvmLight.Extras (SL5)\GalaSoft.MvvmLight.Extras (SL5).csproj", "{F0428C63-C7AD-4563-AC05-81EAA4D76D28}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Test (SL5)", "Tests\GalaSoft.MvvmLight.Test (SL5)\GalaSoft.MvvmLight.Test (SL5).csproj", "{0E24C663-BDCB-4702-864B-A850A9C68F03}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalaSoft.MvvmLight.Platform (iOS)", "GalaSoft.MvvmLight.Platform (iOS)\GalaSoft.MvvmLight.Platform (iOS).csproj", "{DE2FB1EC-A248-4980-A5E3-6835231D84CD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6A912701-3BA1-4975-ADBF-160CAF66B640}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0722B3DB-76CD-4562-BEA9-5C5C416B6A39}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|x64.Build.0 = Debug|x64
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Debug|x86.Build.0 = Debug|x86
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|ARM.Build.0 = Release|ARM
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|x64.ActiveCfg = Release|x64
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|x64.Build.0 = Release|x64
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|x86.ActiveCfg = Release|x86
|
||||
{8E1FCE57-FD06-44ED-B2BC-6D935329630E}.Release|x86.Build.0 = Release|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|x64.Build.0 = Debug|x64
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|x86.Build.0 = Debug|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|ARM.Build.0 = Release|ARM
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|x64.ActiveCfg = Release|x64
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|x64.Build.0 = Release|x64
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|x64.Deploy.0 = Release|x64
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|x86.ActiveCfg = Release|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|x86.Build.0 = Release|x86
|
||||
{2CFF4493-5482-465C-A02C-784435861343}.Release|x86.Deploy.0 = Release|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|x86.Build.0 = Debug|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|ARM.Build.0 = Release|ARM
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|x86.ActiveCfg = Release|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|x86.Build.0 = Release|x86
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6}.Release|x86.Deploy.0 = Release|x86
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Debug|x86.Build.0 = Debug|x86
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|ARM.Build.0 = Release|ARM
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|x86.ActiveCfg = Release|x86
|
||||
{588595A3-48D5-4A2C-930A-59C5123A07CD}.Release|x86.Build.0 = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|x86.Build.0 = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|ARM.Build.0 = Release|ARM
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|x64.ActiveCfg = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|x86.ActiveCfg = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|x86.Build.0 = Release|x86
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521}.Release|x86.Deploy.0 = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|x86.Build.0 = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|ARM.Build.0 = Release|ARM
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|x64.ActiveCfg = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|x86.ActiveCfg = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|x86.Build.0 = Release|x86
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E}.Release|x86.Deploy.0 = Release|x86
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Debug|x86.Build.0 = Debug|x86
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|ARM.Build.0 = Release|ARM
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|x86.ActiveCfg = Release|x86
|
||||
{0A0F720A-2A59-4276-93BC-B4BBEC2D187F}.Release|x86.Build.0 = Release|x86
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{36A3299E-5BC9-46D1-8A8F-9D85E3B58529}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DEE82CB5-7C8C-4E00-8F8A-1CC48E033943}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{80BFFA86-0EFF-4B5A-BA81-02EC6B681BE2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B7D2A691-4C0E-4C54-AB1C-1B79559E0B0A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|x86.Build.0 = Debug|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|ARM.Build.0 = Release|ARM
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|x86.ActiveCfg = Release|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|x86.Build.0 = Release|x86
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C}.Release|x86.Deploy.0 = Release|x86
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{39C71A69-4ACE-4B45-9A2C-C274FADA78EF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|x64.Build.0 = Debug|x64
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|x86.Build.0 = Debug|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|ARM.Build.0 = Release|ARM
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|x64.ActiveCfg = Release|x64
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|x64.Build.0 = Release|x64
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|x64.Deploy.0 = Release|x64
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|x86.ActiveCfg = Release|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|x86.Build.0 = Release|x86
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838}.Release|x86.Deploy.0 = Release|x86
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Debug|x86.Build.0 = Debug|x86
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|ARM.Build.0 = Release|ARM
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|x86.ActiveCfg = Release|x86
|
||||
{5E668BEC-ADF7-4F85-AC28-685863160494}.Release|x86.Build.0 = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|x86.Build.0 = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|ARM.Build.0 = Release|ARM
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|x64.ActiveCfg = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|x86.ActiveCfg = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|x86.Build.0 = Release|x86
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8}.Release|x86.Deploy.0 = Release|x86
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A5B7741D-E331-438C-B3BF-596B048DB622}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4A3E7910-7169-4462-B9E4-E7DF8BE6B09E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F0428C63-C7AD-4563-AC05-81EAA4D76D28}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DE2FB1EC-A248-4980-A5E3-6835231D84CD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{59378F82-F92D-457E-8FB1-B7799A7A919B} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{AAE11955-7DF4-4758-9024-C5247BDE0368} = {B25F0638-578E-4E2A-9783-23EB99B525BE}
|
||||
{2CFF4493-5482-465C-A02C-784435861343} = {B25F0638-578E-4E2A-9783-23EB99B525BE}
|
||||
{BEC455D1-BA26-43FB-AC1A-C61FCB55DCC6} = {B25F0638-578E-4E2A-9783-23EB99B525BE}
|
||||
{29B2A5BA-2E0A-484A-866D-41CCE7144521} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{B59BBF25-4D29-4B1F-AB02-588AC4032E9E} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{30EFC165-77CE-4AC3-B99B-7998D5E39749} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{0F66F445-5DF0-4064-8214-3D16FF924E88} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{E924C358-8AFD-4B47-903D-5760221AA05C} = {B25F0638-578E-4E2A-9783-23EB99B525BE}
|
||||
{DB6CF16F-315E-4BBD-8348-369905645838} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{3620804D-B56B-4C22-B987-AAD7B7F40FC8} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
{0E24C663-BDCB-4702-864B-A850A9C68F03} = {99D5856E-95ED-49B6-9F0C-0A5878A87009}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -53,8 +53,12 @@
|
|||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Helpers\Binding.cs" />
|
||||
<Compile Include="Helpers\BindingGenericObsoleteAndroid.cs" />
|
||||
<Compile Include="Helpers\BindingGenericObsolete.cs" />
|
||||
<Compile Include="Helpers\BindingGeneric.cs" />
|
||||
<Compile Include="Helpers\BindingGenericAndroid.cs" />
|
||||
<Compile Include="Helpers\BindingMode.cs" />
|
||||
<Compile Include="Helpers\ExtensionsAndroid.cs" />
|
||||
<Compile Include="Helpers\Extensions.cs" />
|
||||
<Compile Include="Helpers\IWeakEventListener.cs" />
|
||||
<Compile Include="Helpers\ObservableAdapter.cs" />
|
||||
|
|
|
@ -38,11 +38,6 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
/// </summary>
|
||||
protected WeakReference TopTarget;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the value of the databound property changes.
|
||||
/// </summary>
|
||||
public abstract event EventHandler ValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The mode of the binding. OneTime means that the target property will be set once (when the binding is
|
||||
/// created) but that subsequent changes will be ignored. OneWay means that the target property will be set, and
|
||||
|
@ -99,5 +94,10 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
/// be set to the target value.
|
||||
/// </summary>
|
||||
public abstract void ForceUpdateValueFromTargetToSource();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the value of the databound property changes.
|
||||
/// </summary>
|
||||
public abstract event EventHandler ValueChanged;
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,170 @@
|
|||
// ****************************************************************************
|
||||
// <copyright file="BindingGenericAndroid.cs" company="GalaSoft Laurent Bugnion">
|
||||
// Copyright © GalaSoft Laurent Bugnion 2009-2015
|
||||
// </copyright>
|
||||
// ****************************************************************************
|
||||
// <author>Laurent Bugnion</author>
|
||||
// <email>laurent@galasoft.ch</email>
|
||||
// <date>22.01.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 Android.Text;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
// Partial class for Android only.
|
||||
public partial class Binding<TSource, TTarget>
|
||||
{
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's source property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>This method should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveSourceEvent()
|
||||
{
|
||||
return ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound source object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// The PropertyChanged mode should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveSourceEvent(UpdateTriggerMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case UpdateTriggerMode.LostFocus:
|
||||
return ObserveSourceEvent<View.FocusChangeEventArgs>("FocusChange");
|
||||
|
||||
case UpdateTriggerMode.PropertyChanged:
|
||||
return CheckControlSource();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's target property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>This method should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the target object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveTargetEvent()
|
||||
{
|
||||
return ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound target object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// The PropertyChanged mode should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveTargetEvent(UpdateTriggerMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case UpdateTriggerMode.LostFocus:
|
||||
return ObserveTargetEvent<View.FocusChangeEventArgs>("FocusChange");
|
||||
|
||||
case UpdateTriggerMode.PropertyChanged:
|
||||
return CheckControlTarget();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private Binding<TSource, TTarget> CheckControl()
|
||||
{
|
||||
var textBox = _propertySource.Target as EditText;
|
||||
if (textBox != null)
|
||||
{
|
||||
var binding = ObserveSourceEvent<TextChangedEventArgs>("TextChanged");
|
||||
binding._sourceHandlers["TextChanged"].IsDefault = true;
|
||||
return binding;
|
||||
}
|
||||
|
||||
var checkbox = _propertySource.Target as CompoundButton;
|
||||
if (checkbox != null)
|
||||
{
|
||||
var binding = ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
binding._sourceHandlers["CheckedChange"].IsDefault = true;
|
||||
return binding;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private Binding<TSource, TTarget> CheckControlSource()
|
||||
{
|
||||
return CheckControl();
|
||||
}
|
||||
|
||||
private Binding<TSource, TTarget> CheckControlTarget()
|
||||
{
|
||||
if (Mode != BindingMode.TwoWay)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
return CheckControl();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
// These methods are obsoleted and will be removed in a future version.
|
||||
public partial class Binding<TSource, TTarget> : Binding
|
||||
{
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound source object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="eventName">The name of the event that should be observed
|
||||
/// to update the binding's value.</param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
/// <exception cref="ArgumentNullException">When the eventName parameter is null
|
||||
/// or is an empty string.</exception>
|
||||
/// <exception cref="ArgumentException">When the requested event does not exist on the
|
||||
/// source control.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveSourceEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateSourceTrigger(string eventName)
|
||||
{
|
||||
return ObserveSourceEvent(eventName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound source object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <remarks>Use this method when the event requires a specific EventArgs type
|
||||
/// instead of the standard EventHandler.</remarks>
|
||||
/// <typeparam name="TEventArgs">The type of the EventArgs used by this control's event.</typeparam>
|
||||
/// <param name="eventName">The name of the event that should be observed
|
||||
/// to update the binding's value.</param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
/// <exception cref="ArgumentNullException">When the eventName parameter is null
|
||||
/// or is an empty string.</exception>
|
||||
/// <exception cref="ArgumentException">When the requested event does not exist on the
|
||||
/// source control.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveSourceEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateSourceTrigger<TEventArgs>(string eventName)
|
||||
where TEventArgs : EventArgs
|
||||
{
|
||||
return ObserveSourceEvent<TEventArgs>(eventName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound target object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="eventName">The name of the event that should be observed
|
||||
/// to update the binding's value.</param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
/// <exception cref="ArgumentNullException">When the eventName parameter is null
|
||||
/// or is an empty string.</exception>
|
||||
/// <exception cref="ArgumentException">When the requested event does not exist on the
|
||||
/// target control.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveTargetEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateTargetTrigger(string eventName)
|
||||
{
|
||||
return ObserveTargetEvent(eventName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound target object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <remarks>Use this method when the event requires a specific EventArgs type
|
||||
/// instead of the standard EventHandler.</remarks>
|
||||
/// <typeparam name="TEventArgs">The type of the EventArgs used by this control's event.</typeparam>
|
||||
/// <param name="eventName">The name of the event that should be observed
|
||||
/// to update the binding's value.</param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or OneWay binding. This exception can
|
||||
/// also be thrown when the target object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
/// <exception cref="ArgumentNullException">When the eventName parameter is null
|
||||
/// or is an empty string.</exception>
|
||||
/// <exception cref="ArgumentException">When the requested event does not exist on the
|
||||
/// target control.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveTargetEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateTargetTrigger<TEventArgs>(string eventName)
|
||||
where TEventArgs : EventArgs
|
||||
{
|
||||
return ObserveTargetEvent<TEventArgs>(eventName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
// These methods are obsoleted and will be removed in a future version.
|
||||
public partial class Binding<TSource, TTarget>
|
||||
{
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's source property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>This method should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveSourceEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateSourceTrigger()
|
||||
{
|
||||
return ObserveSourceEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound source object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// The PropertyChanged mode should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveSourceEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateSourceTrigger(UpdateTriggerMode mode)
|
||||
{
|
||||
return ObserveSourceEvent(mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's target property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>This method should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the target object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveTargetEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateTargetTrigger()
|
||||
{
|
||||
return ObserveTargetEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound target object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// The PropertyChanged mode should only be used with the following items:
|
||||
/// <para>- an EditText control and its Text property (TextChanged event).</para>
|
||||
/// <para>- a CompoundButton control and its Checked property (CheckedChange event).</para>
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
[Obsolete("This method will be removed in a future version. Please use ObserveTargetEvent instead.")]
|
||||
public Binding<TSource, TTarget> UpdateTargetTrigger(UpdateTriggerMode mode)
|
||||
{
|
||||
return ObserveTargetEvent(mode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,20 +14,11 @@
|
|||
// ****************************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Windows.Input;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
#if ANDROID
|
||||
using Android.Views;
|
||||
#endif
|
||||
|
||||
#if IOS
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
#endif
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -221,14 +212,70 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuate the command when a specific event is raised. This method
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding{T, T}">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
public static void SetCommand<T>(
|
||||
this object element,
|
||||
string eventName,
|
||||
RelayCommand<T> command,
|
||||
Binding commandParameterBinding)
|
||||
{
|
||||
var t = element.GetType();
|
||||
var e = t.GetEventInfoForControl(eventName);
|
||||
|
||||
var castedBinding = (Binding<T, T>)commandParameterBinding;
|
||||
|
||||
EventHandler handler = (s, args) =>
|
||||
{
|
||||
var param = castedBinding == null ? default(T) : castedBinding.Value;
|
||||
|
||||
if (command.CanExecute(param))
|
||||
{
|
||||
command.Execute(param);
|
||||
}
|
||||
};
|
||||
|
||||
e.AddEventHandler(
|
||||
element,
|
||||
handler);
|
||||
|
||||
if (commandParameterBinding == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var enabledProperty = t.GetProperty("Enabled");
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(castedBinding.Value));
|
||||
|
||||
command.CanExecuteChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(castedBinding.Value));
|
||||
|
||||
commandParameterBinding.ValueChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(castedBinding.Value));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding<TSource, TTarget>">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
|
@ -236,17 +283,12 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
this object element,
|
||||
string eventName,
|
||||
RelayCommand<T> command,
|
||||
Binding commandParameterBinding = null)
|
||||
Binding commandParameterBinding)
|
||||
{
|
||||
var castedBinding = (Binding<T, T>)commandParameterBinding;
|
||||
|
||||
var t = element.GetType();
|
||||
var e = t.GetEvent(eventName);
|
||||
|
||||
if (e == null)
|
||||
{
|
||||
throw new ArgumentException("Event not found: " + eventName, "eventName");
|
||||
}
|
||||
var e = t.GetEventInfoForControl(eventName);
|
||||
|
||||
EventHandler<TEventArgs> handler = (s, args) =>
|
||||
{
|
||||
|
@ -283,68 +325,7 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuate the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding{T, T}">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
public static void SetCommand<T>(
|
||||
this object element,
|
||||
string eventName,
|
||||
RelayCommand<T> command,
|
||||
Binding commandParameterBinding = null)
|
||||
{
|
||||
var castedBinding = (Binding<T, T>)commandParameterBinding;
|
||||
|
||||
var t = element.GetType();
|
||||
var e = t.GetEvent(eventName);
|
||||
|
||||
if (e == null)
|
||||
{
|
||||
throw new ArgumentException("Event not found: " + eventName, "eventName");
|
||||
}
|
||||
|
||||
EventHandler handler = (s, args) =>
|
||||
{
|
||||
var param = castedBinding == null ? default(T) : castedBinding.Value;
|
||||
|
||||
if (command.CanExecute(param))
|
||||
{
|
||||
command.Execute(param);
|
||||
}
|
||||
};
|
||||
|
||||
e.AddEventHandler(
|
||||
element,
|
||||
handler);
|
||||
|
||||
if (commandParameterBinding == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var enabledProperty = t.GetProperty("Enabled");
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(castedBinding.Value));
|
||||
|
||||
commandParameterBinding.ValueChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(castedBinding.Value));
|
||||
|
||||
command.CanExecuteChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(castedBinding.Value));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a non-generic RelayCommand to an object and actuate the command when a specific event is raised. This method
|
||||
/// Sets a non-generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// </summary>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
|
@ -353,15 +334,10 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
public static void SetCommand(
|
||||
this object element,
|
||||
string eventName,
|
||||
RelayCommand command)
|
||||
ICommand command)
|
||||
{
|
||||
var t = element.GetType();
|
||||
var e = t.GetEvent(eventName);
|
||||
|
||||
if (e == null)
|
||||
{
|
||||
throw new ArgumentException("Event not found: " + eventName, "eventName");
|
||||
}
|
||||
var e = t.GetEventInfoForControl(eventName);
|
||||
|
||||
EventHandler handler = (s, args) =>
|
||||
{
|
||||
|
@ -379,117 +355,393 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(null));
|
||||
}
|
||||
|
||||
command.CanExecuteChanged += (s, args) =>
|
||||
command.CanExecuteChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(null));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a non-generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
public static void SetCommand<TEventArgs>(
|
||||
this object element,
|
||||
string eventName,
|
||||
ICommand command)
|
||||
{
|
||||
var t = element.GetType();
|
||||
var e = t.GetEventInfoForControl(eventName);
|
||||
|
||||
EventHandler<TEventArgs> handler = (s, args) =>
|
||||
{
|
||||
if (enabledProperty != null)
|
||||
if (command.CanExecute(null))
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(null));
|
||||
command.Execute(null);
|
||||
}
|
||||
};
|
||||
|
||||
e.AddEventHandler(
|
||||
element,
|
||||
handler);
|
||||
|
||||
var enabledProperty = t.GetProperty("Enabled");
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(null));
|
||||
|
||||
command.CanExecuteChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(null));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="commandParameter">The command parameter that will be passed to the RelayCommand when it
|
||||
/// is executed. This is a fixed value. To pass an observable value, use one of the SetCommand
|
||||
/// overloads that uses a Binding as CommandParameter.</param>
|
||||
public static void SetCommand<T>(
|
||||
this object element,
|
||||
string eventName,
|
||||
RelayCommand<T> command,
|
||||
T commandParameter)
|
||||
{
|
||||
var t = element.GetType();
|
||||
var e = t.GetEventInfoForControl(eventName);
|
||||
|
||||
EventHandler handler = (s, args) =>
|
||||
{
|
||||
if (command.CanExecute(commandParameter))
|
||||
{
|
||||
command.Execute(commandParameter);
|
||||
}
|
||||
};
|
||||
|
||||
e.AddEventHandler(
|
||||
element,
|
||||
handler);
|
||||
|
||||
var enabledProperty = t.GetProperty("Enabled");
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(commandParameter));
|
||||
|
||||
command.CanExecuteChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(commandParameter));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="eventName">The name of the event that will be subscribed to to actuate the command.</param>
|
||||
/// <param name="commandParameter">The command parameter that will be passed to the RelayCommand when it
|
||||
/// is executed. This is a fixed value. To pass an observable value, use one of the SetCommand
|
||||
/// overloads that uses a Binding as CommandParameter.</param>
|
||||
public static void SetCommand<T, TEventArgs>(
|
||||
this object element,
|
||||
string eventName,
|
||||
RelayCommand<T> command,
|
||||
T commandParameter)
|
||||
{
|
||||
var t = element.GetType();
|
||||
var e = t.GetEventInfoForControl(eventName);
|
||||
|
||||
EventHandler<TEventArgs> handler = (s, args) =>
|
||||
{
|
||||
if (command.CanExecute(commandParameter))
|
||||
{
|
||||
command.Execute(commandParameter);
|
||||
}
|
||||
};
|
||||
|
||||
e.AddEventHandler(
|
||||
element,
|
||||
handler);
|
||||
|
||||
var enabledProperty = t.GetProperty("Enabled");
|
||||
if (enabledProperty != null)
|
||||
{
|
||||
enabledProperty.SetValue(element, command.CanExecute(commandParameter));
|
||||
|
||||
command.CanExecuteChanged += (s, args) => enabledProperty.SetValue(
|
||||
element,
|
||||
command.CanExecute(commandParameter));
|
||||
}
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableAdapter{T}"/> for a given <see cref="ObservableCollection{T}"/>.
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For CheckBox: CheckedChange.
|
||||
/// - For Button: Click.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the <see cref="ObservableCollection{T}"/>.</typeparam>
|
||||
/// <param name="collection">The collection that the adapter will be created for.</param>
|
||||
/// <param name="getTemplateDelegate">A method taking an item's position in the list, the item itself,
|
||||
/// and a recycled Android View, and returning an adapted View for this item. Note that the recycled
|
||||
/// view might be null, in which case a new View must be inflated by this method.</param>
|
||||
/// <returns>A View adapted for the item passed as parameter.</returns>
|
||||
public static ObservableAdapter<T> GetAdapter<T>(
|
||||
this ObservableCollection<T> collection,
|
||||
Func<int, T, View, View> getTemplateDelegate)
|
||||
{
|
||||
return new ObservableAdapter<T>
|
||||
{
|
||||
DataSource = collection,
|
||||
GetTemplateDelegate = getTemplateDelegate
|
||||
};
|
||||
}
|
||||
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding<TSource, TTarget>">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
#elif __IOS__
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableAdapter{T}"/> for a given <see cref="IList{T}"/>.
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For UIBarButtonItem: Clicked.
|
||||
/// - For UIButton: TouchUpInside.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the <see cref="IList{T}"/>.</typeparam>
|
||||
/// <param name="list">The list that the adapter will be created for.</param>
|
||||
/// <param name="getTemplateDelegate">A method taking an item's position in the list, the item itself,
|
||||
/// and a recycled Android <see cref="View"/>, and returning an adapted View for this item. Note that the recycled
|
||||
/// View might be null, in which case a new View must be inflated by this method.</param>
|
||||
/// <returns>An adapter adapted to the collection passed in parameter..</returns>
|
||||
public static ObservableAdapter<T> GetAdapter<T>(
|
||||
this IList<T> list,
|
||||
Func<int, T, View, View> getTemplateDelegate)
|
||||
{
|
||||
return new ObservableAdapter<T>
|
||||
{
|
||||
DataSource = list,
|
||||
GetTemplateDelegate = getTemplateDelegate
|
||||
};
|
||||
}
|
||||
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding<TSource, TTarget>">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
#endif
|
||||
|
||||
#if IOS
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableTableViewController{T}"/> for a given <see cref="ObservableCollection{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the collection.</typeparam>
|
||||
/// <param name="collection">The collection that the adapter will be created for.</param>
|
||||
/// <param name="createCellDelegate">A delegate to a method creating or reusing a <see cref="UITableViewCell"/>.
|
||||
/// The cell will then be passed to the bindCellDelegate
|
||||
/// delegate to set the elements' properties.</param>
|
||||
/// <param name="bindCellDelegate">A delegate to a method taking a <see cref="UITableViewCell"/>
|
||||
/// and setting its elements' properties according to the item
|
||||
/// passed as second parameter.
|
||||
/// The cell must be created first in the createCellDelegate
|
||||
/// delegate.</param>
|
||||
/// <returns>A controller adapted to the collection passed in parameter.</returns>
|
||||
public static ObservableTableViewController<T> GetController<T>(
|
||||
this ObservableCollection<T> collection,
|
||||
Func<NSString, UITableViewCell> createCellDelegate,
|
||||
Action<UITableViewCell, T, NSIndexPath> bindCellDelegate)
|
||||
public static void SetCommand<T>(
|
||||
this object element,
|
||||
RelayCommand<T> command,
|
||||
Binding commandParameterBinding)
|
||||
{
|
||||
return new ObservableTableViewController<T>
|
||||
{
|
||||
DataSource = collection,
|
||||
CreateCellDelegate = createCellDelegate,
|
||||
BindCellDelegate = bindCellDelegate
|
||||
};
|
||||
SetCommand(element, string.Empty, command, commandParameterBinding);
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableTableViewController{T}"/> for a given <see cref="IList{T}"/>.
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For CheckBox: CheckedChange.
|
||||
/// - For Button: Click.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the list.</typeparam>
|
||||
/// <param name="list">The list that the adapter will be created for.</param>
|
||||
/// <param name="createCellDelegate">A delegate to a method creating or reusing a <see cref="UITableViewCell"/>.
|
||||
/// The cell will then be passed to the bindCellDelegate
|
||||
/// delegate to set the elements' properties.</param>
|
||||
/// <param name="bindCellDelegate">A delegate to a method taking a <see cref="UITableViewCell"/>
|
||||
/// and setting its elements' properties according to the item
|
||||
/// passed as second parameter.
|
||||
/// The cell must be created first in the createCellDelegate
|
||||
/// delegate.</param>
|
||||
/// <returns>A controller adapted to the collection passed in parameter.</returns>
|
||||
public static ObservableTableViewController<T> GetController<T>(
|
||||
this IList<T> list,
|
||||
Func<NSString, UITableViewCell> createCellDelegate,
|
||||
Action<UITableViewCell, T, NSIndexPath> bindCellDelegate)
|
||||
{
|
||||
return new ObservableTableViewController<T>
|
||||
{
|
||||
DataSource = list,
|
||||
CreateCellDelegate = createCellDelegate,
|
||||
BindCellDelegate = bindCellDelegate
|
||||
};
|
||||
}
|
||||
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding<TSource, TTarget>">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
#elif __IOS__
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For UIBarButtonItem: Clicked.
|
||||
/// - For UIButton: TouchUpInside.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameterBinding">A <see cref="Binding<TSource, TTarget>">Binding</see> instance subscribed to
|
||||
/// the CommandParameter that will passed to the RelayCommand. Depending on the Binding, the CommandParameter
|
||||
/// will be observed and changes will be passed to the command, for example to update the CanExecute.</param>
|
||||
#endif
|
||||
public static void SetCommand<T, TEventArgs>(
|
||||
this object element,
|
||||
RelayCommand<T> command,
|
||||
Binding commandParameterBinding)
|
||||
{
|
||||
SetCommand<T, TEventArgs>(element, string.Empty, command, commandParameterBinding);
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
/// <summary>
|
||||
/// Sets an ICommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For CheckBox: CheckedChange.
|
||||
/// - For Button: Click.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
#elif __IOS__
|
||||
/// <summary>
|
||||
/// Sets an ICommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For UIBarButtonItem: Clicked.
|
||||
/// - For UIButton: TouchUpInside.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
#endif
|
||||
public static void SetCommand(
|
||||
this object element,
|
||||
ICommand command)
|
||||
{
|
||||
SetCommand(element, string.Empty, command);
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
/// <summary>
|
||||
/// Sets an ICommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For CheckBox: CheckedChange.
|
||||
/// - For Button: Click.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
#elif __IOS__
|
||||
/// <summary>
|
||||
/// Sets an ICommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For UIBarButtonItem: Clicked.
|
||||
/// - For UIButton: TouchUpInside.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
#endif
|
||||
public static void SetCommand<TEventArgs>(
|
||||
this object element,
|
||||
ICommand command)
|
||||
{
|
||||
SetCommand<TEventArgs>(element, string.Empty, command);
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For CheckBox: CheckedChange.
|
||||
/// - For Button: Click.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameter">The command parameter that will be passed to the RelayCommand when it
|
||||
/// is executed. This is a fixed value. To pass an observable value, use one of the SetCommand
|
||||
/// overloads that uses a Binding as CommandParameter.</param>
|
||||
#elif __IOS__
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// can only be used when the event uses a standard EventHandler.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For UIBarButtonItem: Clicked.
|
||||
/// - For UIButton: TouchUpInside.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameter">The command parameter that will be passed to the RelayCommand when it
|
||||
/// is executed. This is a fixed value. To pass an observable value, use one of the SetCommand
|
||||
/// overloads that uses a Binding as CommandParameter.</param>
|
||||
#endif
|
||||
public static void SetCommand<T>(
|
||||
this object element,
|
||||
RelayCommand<T> command,
|
||||
T commandParameter)
|
||||
{
|
||||
SetCommand(element, string.Empty, command, commandParameter);
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For CheckBox: CheckedChange.
|
||||
/// - For Button: Click.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameter">The command parameter that will be passed to the RelayCommand when it
|
||||
/// is executed. This is a fixed value. To pass an observable value, use one of the SetCommand
|
||||
/// overloads that uses a Binding as CommandParameter.</param>
|
||||
#elif __IOS__
|
||||
/// <summary>
|
||||
/// Sets a generic RelayCommand to an object and actuates the command when a specific event is raised. This method
|
||||
/// should be used when the event uses an EventHandler<TEventArgs>.
|
||||
/// This method does not specify the observed event explicitly. The following events are used:
|
||||
/// - For UIBarButtonItem: Clicked.
|
||||
/// - For UIButton: TouchUpInside.
|
||||
/// - At the moment, no other controls are supported. For other controls, use another SetCommand overload
|
||||
/// and specify the eventName parameter explicitly.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the CommandParameter that will be passed to the RelayCommand.</typeparam>
|
||||
/// <typeparam name="TEventArgs">The type of the event's arguments.</typeparam>
|
||||
/// <param name="element">The element to which the command is added.</param>
|
||||
/// <param name="command">The command that must be added to the element.</param>
|
||||
/// <param name="commandParameter">The command parameter that will be passed to the RelayCommand when it
|
||||
/// is executed. This is a fixed value. To pass an observable value, use one of the SetCommand
|
||||
/// overloads that uses a Binding as CommandParameter.</param>
|
||||
#endif
|
||||
public static void SetCommand<T, TEventArgs>(
|
||||
this object element,
|
||||
RelayCommand<T> command,
|
||||
T commandParameter)
|
||||
{
|
||||
SetCommand<T, TEventArgs>(element, string.Empty, command, commandParameter);
|
||||
}
|
||||
|
||||
internal static EventInfo GetEventInfoForControl(this Type type, string eventName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
{
|
||||
eventName = type.GetDefaultEventNameForControl();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
{
|
||||
throw new ArgumentException("Event not found", "eventName");
|
||||
}
|
||||
|
||||
var info = type.GetEvent(eventName);
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
throw new ArgumentException("Event not found: " + eventName, "eventName");
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
// ****************************************************************************
|
||||
// <copyright file="ExtensionsAndroid.cs" company="GalaSoft Laurent Bugnion">
|
||||
// Copyright © GalaSoft Laurent Bugnion 2009-2016
|
||||
// </copyright>
|
||||
// ****************************************************************************
|
||||
// <author>Laurent Bugnion</author>
|
||||
// <email>laurent@galasoft.ch</email>
|
||||
// <date>19.01.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.ObjectModel;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines extension methods for Android only.
|
||||
/// </summary>
|
||||
////[ClassInfo(typeof(Binding))]
|
||||
public static class ExtensionsAndroid
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableAdapter{T}"/> for a given <see cref="ObservableCollection{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the <see cref="ObservableCollection{T}"/>.</typeparam>
|
||||
/// <param name="collection">The collection that the adapter will be created for.</param>
|
||||
/// <param name="getTemplateDelegate">A method taking an item's position in the list, the item itself,
|
||||
/// and a recycled Android View, and returning an adapted View for this item. Note that the recycled
|
||||
/// view might be null, in which case a new View must be inflated by this method.</param>
|
||||
/// <returns>A View adapted for the item passed as parameter.</returns>
|
||||
public static ObservableAdapter<T> GetAdapter<T>(
|
||||
this ObservableCollection<T> collection,
|
||||
Func<int, T, View, View> getTemplateDelegate)
|
||||
{
|
||||
return new ObservableAdapter<T>
|
||||
{
|
||||
DataSource = collection,
|
||||
GetTemplateDelegate = getTemplateDelegate
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableAdapter{T}"/> for a given <see cref="IList{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the <see cref="IList{T}"/>.</typeparam>
|
||||
/// <param name="list">The list that the adapter will be created for.</param>
|
||||
/// <param name="getTemplateDelegate">A method taking an item's position in the list, the item itself,
|
||||
/// and a recycled Android <see cref="View"/>, and returning an adapted View for this item. Note that the recycled
|
||||
/// View might be null, in which case a new View must be inflated by this method.</param>
|
||||
/// <returns>An adapter adapted to the collection passed in parameter..</returns>
|
||||
public static ObservableAdapter<T> GetAdapter<T>(
|
||||
this IList<T> list,
|
||||
Func<int, T, View, View> getTemplateDelegate)
|
||||
{
|
||||
return new ObservableAdapter<T>
|
||||
{
|
||||
DataSource = list,
|
||||
GetTemplateDelegate = getTemplateDelegate
|
||||
};
|
||||
}
|
||||
|
||||
internal static string GetDefaultEventNameForControl(this Type type)
|
||||
{
|
||||
string eventName = null;
|
||||
|
||||
if (type == typeof (CheckBox)
|
||||
|| typeof (CheckBox).IsAssignableFrom(type))
|
||||
{
|
||||
eventName = "CheckedChange";
|
||||
}
|
||||
else if (type == typeof (Button)
|
||||
|| typeof (Button).IsAssignableFrom(type))
|
||||
{
|
||||
eventName = "Click";
|
||||
}
|
||||
|
||||
return eventName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,4 +37,4 @@ namespace System.Windows
|
|||
/// </returns>
|
||||
bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,9 +13,9 @@
|
|||
// </license>
|
||||
// ****************************************************************************
|
||||
|
||||
using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
namespace System.Windows
|
||||
|
@ -29,31 +29,21 @@ namespace System.Windows
|
|||
////[ClassInfo(typeof(Binding))]
|
||||
public class PropertyChangedEventManager
|
||||
{
|
||||
private class ListenerInfo
|
||||
private static PropertyChangedEventManager _manager;
|
||||
private static readonly object SyncLock = new object();
|
||||
private Dictionary<string, List<ListenerInfo>> _list;
|
||||
|
||||
/// <summary>
|
||||
/// Get the current instance of <see cref="PropertyChangedEventManager"/>
|
||||
/// </summary>
|
||||
private static PropertyChangedEventManager Instance
|
||||
{
|
||||
public IWeakEventListener Listener
|
||||
get
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public WeakReference InstanceReference
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ListenerInfo(IWeakEventListener listener, INotifyPropertyChanged inpc)
|
||||
{
|
||||
Listener = listener;
|
||||
InstanceReference = new WeakReference(inpc);
|
||||
return _manager ?? (_manager = new PropertyChangedEventManager());
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, List<ListenerInfo>> _list;
|
||||
private static readonly object SyncLock = new object();
|
||||
private static PropertyChangedEventManager _manager;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified listener to the list of listeners on the specified source.
|
||||
/// </summary>
|
||||
|
@ -62,8 +52,8 @@ namespace System.Windows
|
|||
/// <param name="propertyName">The name of the property that exists on
|
||||
/// source upon which to listen for changes.</param>
|
||||
public static void AddListener(
|
||||
INotifyPropertyChanged source,
|
||||
IWeakEventListener listener,
|
||||
INotifyPropertyChanged source,
|
||||
IWeakEventListener listener,
|
||||
string propertyName)
|
||||
{
|
||||
Instance.PrivateAddListener(source, listener, propertyName);
|
||||
|
@ -79,77 +69,6 @@ namespace System.Windows
|
|||
Instance.PrivateRemoveListener(listener);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current instance of <see cref="PropertyChangedEventManager"/>
|
||||
/// </summary>
|
||||
private static PropertyChangedEventManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _manager ?? (_manager = new PropertyChangedEventManager());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begin listening for the <see cref="PropertyChanged"/> event on
|
||||
/// the provided source.
|
||||
/// </summary>
|
||||
/// <param name="source">The object on which to start listening
|
||||
/// for <see cref="PropertyChanged"/>.</param>
|
||||
private void StartListening(INotifyPropertyChanged source)
|
||||
{
|
||||
if (source != null)
|
||||
{
|
||||
source.PropertyChanged += PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop listening for the <see cref="PropertyChanged"/> event on the
|
||||
/// provided source.
|
||||
/// </summary>
|
||||
/// <param name="source">The object on which to start listening for
|
||||
/// <see cref="PropertyChanged"/>.</param>
|
||||
private void StopListening(INotifyPropertyChanged source)
|
||||
{
|
||||
if (source != null)
|
||||
{
|
||||
source.PropertyChanged -= PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that handles the <see cref="INotifyPropertyChanged.PropertyChanged"/> event.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="args">A <see cref="PropertyChangedEventArgs"/> that
|
||||
/// contains the event data.</param>
|
||||
private void PropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
if (!_list.ContainsKey(args.PropertyName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var list = _list[args.PropertyName];
|
||||
if (list != null)
|
||||
{
|
||||
var recipients =
|
||||
list.Where(
|
||||
i => i.InstanceReference != null
|
||||
&& i.InstanceReference.IsAlive
|
||||
&& i.InstanceReference.Target == sender
|
||||
&& i.Listener != null)
|
||||
.ToList();
|
||||
|
||||
// We have the listeners. Deal with them
|
||||
foreach (var item in recipients)
|
||||
{
|
||||
item.Listener.ReceiveWeakEvent(GetType(), sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Private method to add the specified listener to the list of listeners
|
||||
/// on the specified source.
|
||||
|
@ -159,8 +78,8 @@ namespace System.Windows
|
|||
/// <param name="propertyName">The name of the property that exists
|
||||
/// on source upon which to listen for changes.</param>
|
||||
private void PrivateAddListener(
|
||||
INotifyPropertyChanged source,
|
||||
IWeakEventListener listener,
|
||||
INotifyPropertyChanged source,
|
||||
IWeakEventListener listener,
|
||||
string propertyName)
|
||||
{
|
||||
if (source == null)
|
||||
|
@ -168,19 +87,19 @@ namespace System.Windows
|
|||
return;
|
||||
}
|
||||
|
||||
if (_list == null)
|
||||
{
|
||||
_list = new Dictionary<string, List<ListenerInfo>>();
|
||||
}
|
||||
|
||||
lock (SyncLock)
|
||||
{
|
||||
if (_list == null)
|
||||
{
|
||||
_list = new Dictionary<string, List<ListenerInfo>>();
|
||||
}
|
||||
|
||||
var sourceExists = _list.Any(
|
||||
list => list.Value.Any(
|
||||
entry => entry.InstanceReference != null
|
||||
&& entry.InstanceReference.IsAlive
|
||||
&& entry.InstanceReference.Target != null
|
||||
&& entry.InstanceReference.Target.Equals(source)));
|
||||
entry => entry.InstanceReference != null
|
||||
&& entry.InstanceReference.IsAlive
|
||||
&& entry.InstanceReference.Target != null
|
||||
&& entry.InstanceReference.Target.Equals(source)));
|
||||
|
||||
if (_list.ContainsKey(propertyName))
|
||||
{
|
||||
|
@ -254,5 +173,86 @@ namespace System.Windows
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that handles the <see cref="INotifyPropertyChanged.PropertyChanged"/> event.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="args">A <see cref="PropertyChangedEventArgs"/> that
|
||||
/// contains the event data.</param>
|
||||
private void PropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
if (!_list.ContainsKey(args.PropertyName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var list = _list[args.PropertyName];
|
||||
if (list != null)
|
||||
{
|
||||
var recipients =
|
||||
list.Where(
|
||||
i => i.InstanceReference != null
|
||||
&& i.InstanceReference.IsAlive
|
||||
&& i.InstanceReference.Target == sender
|
||||
&& i.Listener != null)
|
||||
.ToList();
|
||||
|
||||
// We have the listeners. Deal with them
|
||||
foreach (var item in recipients)
|
||||
{
|
||||
item.Listener.ReceiveWeakEvent(GetType(), sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begin listening for the <see cref="PropertyChanged"/> event on
|
||||
/// the provided source.
|
||||
/// </summary>
|
||||
/// <param name="source">The object on which to start listening
|
||||
/// for <see cref="PropertyChanged"/>.</param>
|
||||
private void StartListening(INotifyPropertyChanged source)
|
||||
{
|
||||
if (source != null)
|
||||
{
|
||||
source.PropertyChanged += PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop listening for the <see cref="PropertyChanged"/> event on the
|
||||
/// provided source.
|
||||
/// </summary>
|
||||
/// <param name="source">The object on which to start listening for
|
||||
/// <see cref="PropertyChanged"/>.</param>
|
||||
private void StopListening(INotifyPropertyChanged source)
|
||||
{
|
||||
if (source != null)
|
||||
{
|
||||
source.PropertyChanged -= PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private class ListenerInfo
|
||||
{
|
||||
public WeakReference InstanceReference
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public IWeakEventListener Listener
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ListenerInfo(IWeakEventListener listener, INotifyPropertyChanged inpc)
|
||||
{
|
||||
Listener = listener;
|
||||
InstanceReference = new WeakReference(inpc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,9 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGeneric.cs">
|
||||
<Link>Helpers\BindingGeneric.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGenericObsolete.cs">
|
||||
<Link>Helpers\BindingGenericObsolete.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingMode.cs">
|
||||
<Link>Helpers\BindingMode.cs</Link>
|
||||
</Compile>
|
||||
|
@ -61,6 +64,9 @@
|
|||
<Compile Include="..\GalaSoft.MvvmLight.Platform %28NET45%29\Properties\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Helpers\BindingGenericObsoleteApple.cs" />
|
||||
<Compile Include="Helpers\BindingGenericApple.cs" />
|
||||
<Compile Include="Helpers\ExtensionsApple.cs" />
|
||||
<Compile Include="Helpers\ObservableTableViewController.cs" />
|
||||
<Compile Include="Threading\DispatcherHelper.cs" />
|
||||
<Compile Include="Views\ControllerBase.cs" />
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
// ****************************************************************************
|
||||
// <copyright file="BindingGenericApple.cs" company="GalaSoft Laurent Bugnion">
|
||||
// Copyright © GalaSoft Laurent Bugnion 2009-2015
|
||||
// </copyright>
|
||||
// ****************************************************************************
|
||||
// <author>Laurent Bugnion</author>
|
||||
// <email>laurent@galasoft.ch</email>
|
||||
// <date>22.01.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 UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
// Partial class for Apple only.
|
||||
public partial class Binding<TSource, TTarget>
|
||||
{
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's source property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>At this point, this method is inactive on iOS. Use
|
||||
/// <see cref="ObserveSourceEvent(string)"/> instead.</remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveSourceEvent()
|
||||
{
|
||||
return ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound source object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// NOTE: At this time the PropertyChanged mode is inactive on iOS. Use
|
||||
/// <see cref="ObserveSourceEvent(string)"/> instead.
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveSourceEvent(UpdateTriggerMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case UpdateTriggerMode.LostFocus:
|
||||
throw new ArgumentException(
|
||||
"UpdateTriggerMode.LostFocus is only supported in Android at this time",
|
||||
"mode");
|
||||
|
||||
case UpdateTriggerMode.PropertyChanged:
|
||||
return CheckControlSource();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's target property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>At this point, this method is inactive on iOS. Use
|
||||
/// <see cref="ObserveTargetEvent(string)"/> instead.</remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the target object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveTargetEvent()
|
||||
{
|
||||
return ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound target object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// NOTE: At this time the PropertyChanged mode is inactive on iOS. Use
|
||||
/// <see cref="ObserveTargetEvent(string)"/> instead.
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> ObserveTargetEvent(UpdateTriggerMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case UpdateTriggerMode.LostFocus:
|
||||
throw new ArgumentException(
|
||||
"UpdateTriggerMode.LostFocus is only supported in Android at this time",
|
||||
"mode");
|
||||
|
||||
case UpdateTriggerMode.PropertyChanged:
|
||||
return CheckControlTarget();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private Binding<TSource, TTarget> CheckControlSource()
|
||||
{
|
||||
var textBox = _propertySource.Target as UITextView;
|
||||
if (textBox != null)
|
||||
{
|
||||
var binding = ObserveSourceEvent("Changed");
|
||||
binding._sourceHandlers["Changed"].IsDefault = true;
|
||||
return binding;
|
||||
}
|
||||
|
||||
var checkbox = _propertySource.Target as UISwitch;
|
||||
if (checkbox != null)
|
||||
{
|
||||
var binding = ObserveSourceEvent("ValueChanged");
|
||||
binding._sourceHandlers["ValueChanged"].IsDefault = true;
|
||||
return binding;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private Binding<TSource, TTarget> CheckControlTarget()
|
||||
{
|
||||
if (Mode != BindingMode.TwoWay)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
var textBox = _propertyTarget.Target as UITextView;
|
||||
if (textBox != null)
|
||||
{
|
||||
var binding = ObserveTargetEvent("Changed");
|
||||
binding._targetHandlers["Changed"].IsDefault = true;
|
||||
return binding;
|
||||
}
|
||||
|
||||
var checkbox = _propertyTarget.Target as UISwitch;
|
||||
if (checkbox != null)
|
||||
{
|
||||
var binding = ObserveTargetEvent("ValueChanged");
|
||||
binding._targetHandlers["ValueChanged"].IsDefault = true;
|
||||
return binding;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// These methods are obsoleted and will be removed in a future version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
public partial class Binding<TSource, TTarget>
|
||||
{
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's source property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>At this point, this method is inactive on iOS. Use
|
||||
/// <see cref="ObserveSourceEvent(string)"/> instead.</remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> UpdateSourceTrigger()
|
||||
{
|
||||
return ObserveSourceEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound source object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// NOTE: At this time the PropertyChanged mode is inactive on iOS. Use
|
||||
/// <see cref="ObserveSourceEvent(string)"/> instead.
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime binding. Such bindings cannot be updated. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> UpdateSourceTrigger(UpdateTriggerMode mode)
|
||||
{
|
||||
return ObserveSourceEvent(mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define that the binding should be evaluated when the bound control's target property changes.
|
||||
/// Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to specify that the binding must be updated when the property changes.
|
||||
/// </summary>
|
||||
/// <remarks>At this point, this method is inactive on iOS. Use
|
||||
/// <see cref="ObserveTargetEvent(string)"/> instead.</remarks>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the target object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> UpdateTargetTrigger()
|
||||
{
|
||||
return ObserveTargetEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define when the binding should be evaluated when the bound target object
|
||||
/// is a control. Because Xamarin controls are not DependencyObjects, the
|
||||
/// bound property will not automatically update the binding attached to it. Instead,
|
||||
/// use this method to define which of the control's events should be observed.
|
||||
/// </summary>
|
||||
/// <param name="mode">Defines the binding's update mode. Use
|
||||
/// <see cref="UpdateTriggerMode.LostFocus"/> to update the binding when
|
||||
/// the source control loses the focus. You can also use
|
||||
/// <see cref="UpdateTriggerMode.PropertyChanged"/> to update the binding
|
||||
/// when the source control's property changes.
|
||||
/// NOTE: At this time the PropertyChanged mode is inactive on iOS. Use
|
||||
/// <see cref="ObserveTargetEvent(string)"/> instead.
|
||||
/// </param>
|
||||
/// <returns>The Binding instance.</returns>
|
||||
/// <exception cref="InvalidOperationException">When this method is called
|
||||
/// on a OneTime or a OneWay binding. This exception can
|
||||
/// also be thrown when the source object is null or has already been
|
||||
/// garbage collected before this method is called.</exception>
|
||||
public Binding<TSource, TTarget> UpdateTargetTrigger(UpdateTriggerMode mode)
|
||||
{
|
||||
return ObserveTargetEvent(mode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
// ****************************************************************************
|
||||
// <copyright file="ExtensionsApple.cs" company="GalaSoft Laurent Bugnion">
|
||||
// Copyright © GalaSoft Laurent Bugnion 2009-2016
|
||||
// </copyright>
|
||||
// ****************************************************************************
|
||||
// <author>Laurent Bugnion</author>
|
||||
// <email>laurent@galasoft.ch</email>
|
||||
// <date>19.01.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.ObjectModel;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines extension methods for iOS only.
|
||||
/// </summary>
|
||||
////[ClassInfo(typeof(Binding))]
|
||||
public static class ExtensionsApple
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableTableViewController{T}"/> for a given <see cref="ObservableCollection{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the collection.</typeparam>
|
||||
/// <param name="collection">The collection that the adapter will be created for.</param>
|
||||
/// <param name="createCellDelegate">A delegate to a method creating or reusing a <see cref="UITableViewCell"/>.
|
||||
/// The cell will then be passed to the bindCellDelegate
|
||||
/// delegate to set the elements' properties.</param>
|
||||
/// <param name="bindCellDelegate">A delegate to a method taking a <see cref="UITableViewCell"/>
|
||||
/// and setting its elements' properties according to the item
|
||||
/// passed as second parameter.
|
||||
/// The cell must be created first in the createCellDelegate
|
||||
/// delegate.</param>
|
||||
/// <returns>A controller adapted to the collection passed in parameter.</returns>
|
||||
public static ObservableTableViewController<T> GetController<T>(
|
||||
this ObservableCollection<T> collection,
|
||||
Func<NSString, UITableViewCell> createCellDelegate,
|
||||
Action<UITableViewCell, T, NSIndexPath> bindCellDelegate)
|
||||
{
|
||||
return new ObservableTableViewController<T>
|
||||
{
|
||||
DataSource = collection,
|
||||
CreateCellDelegate = createCellDelegate,
|
||||
BindCellDelegate = bindCellDelegate
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObservableTableViewController{T}"/> for a given <see cref="IList{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items contained in the list.</typeparam>
|
||||
/// <param name="list">The list that the adapter will be created for.</param>
|
||||
/// <param name="createCellDelegate">A delegate to a method creating or reusing a <see cref="UITableViewCell"/>.
|
||||
/// The cell will then be passed to the bindCellDelegate
|
||||
/// delegate to set the elements' properties.</param>
|
||||
/// <param name="bindCellDelegate">A delegate to a method taking a <see cref="UITableViewCell"/>
|
||||
/// and setting its elements' properties according to the item
|
||||
/// passed as second parameter.
|
||||
/// The cell must be created first in the createCellDelegate
|
||||
/// delegate.</param>
|
||||
/// <returns>A controller adapted to the collection passed in parameter.</returns>
|
||||
public static ObservableTableViewController<T> GetController<T>(
|
||||
this IList<T> list,
|
||||
Func<NSString, UITableViewCell> createCellDelegate,
|
||||
Action<UITableViewCell, T, NSIndexPath> bindCellDelegate)
|
||||
{
|
||||
return new ObservableTableViewController<T>
|
||||
{
|
||||
DataSource = list,
|
||||
CreateCellDelegate = createCellDelegate,
|
||||
BindCellDelegate = bindCellDelegate
|
||||
};
|
||||
}
|
||||
|
||||
internal static string GetDefaultEventNameForControl(this Type type)
|
||||
{
|
||||
string eventName = null;
|
||||
|
||||
if (type == typeof (UIButton)
|
||||
|| typeof (UIButton).IsAssignableFrom(type))
|
||||
{
|
||||
eventName = "TouchUpInside";
|
||||
}
|
||||
else if (type == typeof (UIBarButtonItem)
|
||||
|| typeof (UIBarButtonItem).IsAssignableFrom(type))
|
||||
{
|
||||
eventName = "Clicked";
|
||||
}
|
||||
|
||||
return eventName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,14 +53,8 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
private bool _loadedView;
|
||||
private Thread _mainThread;
|
||||
private INotifyCollectionChanged _notifier;
|
||||
private T _selectedItem;
|
||||
private ObservableTableSource<T> _tableSource;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a new item gets selected in the list.
|
||||
/// </summary>
|
||||
public event EventHandler SelectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// When set, specifies which animation should be used when rows change.
|
||||
/// </summary>
|
||||
|
@ -186,10 +180,8 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
/// </summary>
|
||||
public T SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedItem;
|
||||
}
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -218,16 +210,7 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
set
|
||||
{
|
||||
base.TableView = value;
|
||||
|
||||
if (_tableSource == null)
|
||||
{
|
||||
base.TableView.Source = CreateSource();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.TableView.Source = _tableSource;
|
||||
}
|
||||
|
||||
base.TableView.Source = _tableSource ?? CreateSource();
|
||||
_loadedView = true;
|
||||
}
|
||||
}
|
||||
|
@ -251,11 +234,6 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a property of this instance changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the <see cref="UIViewController.ViewDidLoad"/> method.
|
||||
/// </summary>
|
||||
|
@ -320,7 +298,7 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
/// <param name="indexPath">The NSIndexPath for the selected row.</param>
|
||||
protected virtual void OnRowSelected(object item, NSIndexPath indexPath)
|
||||
{
|
||||
_selectedItem = (T)item;
|
||||
SelectedItem = (T)item;
|
||||
|
||||
// ReSharper disable ExplicitCallerInfoArgument
|
||||
RaisePropertyChanged(SelectedItemPropertyName);
|
||||
|
@ -403,6 +381,16 @@ namespace GalaSoft.MvvmLight.Helpers
|
|||
DeleteAnimation = UITableViewRowAnimation.Automatic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a property of this instance changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a new item gets selected in the list.
|
||||
/// </summary>
|
||||
public event EventHandler SelectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="UITableViewSource"/> that handles changes to the underlying
|
||||
/// data source if this data source is an <see cref="INotifyCollectionChanged"/>.
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
Any raw assets you want to be deployed with your application can be placed in
|
||||
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||
|
||||
These files will be deployed with you package and will be accessible using Android's
|
||||
AssetManager, like this:
|
||||
|
||||
public class ReadAsset : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
InputStream input = Assets.Open ("my_asset.txt");
|
||||
}
|
||||
}
|
||||
|
||||
Additionally, some Android functions will automatically load asset files:
|
||||
|
||||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
|
@ -0,0 +1,261 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class BindingTest
|
||||
{
|
||||
private Binding<string, string> _binding;
|
||||
|
||||
public TestViewModel VmSource
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public TestViewModel VmTarget
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_ConverterWithFallbackValue_ErrorInConverterShouldUseFallbackValue()
|
||||
{
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = "Initial value"
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
const string fallbackValue = "Fallback value";
|
||||
const string targetNullValue = "Target null value";
|
||||
|
||||
_binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty,
|
||||
vmTarget,
|
||||
() => vmTarget.TargetProperty,
|
||||
BindingMode.Default,
|
||||
fallbackValue,
|
||||
targetNullValue)
|
||||
.ConvertSourceToTarget(
|
||||
value =>
|
||||
{
|
||||
throw new InvalidCastException("Only for test");
|
||||
});
|
||||
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
|
||||
vmSource.Model.MyProperty = "New value";
|
||||
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_MultipleLevelsOfNull_ShouldUseFallbackValueThenTargetNullValue()
|
||||
{
|
||||
var vmSource = new TestViewModel();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
const string fallbackValue = "Fallback value";
|
||||
const string targetNullValue = "Target null value";
|
||||
|
||||
_binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Nested.Model.MyProperty,
|
||||
vmTarget,
|
||||
() => vmTarget.TargetProperty,
|
||||
BindingMode.Default,
|
||||
fallbackValue,
|
||||
targetNullValue);
|
||||
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
vmSource.Nested = new TestViewModel();
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
vmSource.Nested.Model = new TestModel();
|
||||
Assert.AreEqual(targetNullValue, vmTarget.TargetProperty);
|
||||
vmSource.Nested.Model.MyProperty = DateTime.Now.Ticks.ToString();
|
||||
Assert.AreEqual(vmSource.Nested.Model.MyProperty, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void
|
||||
Binding_MultipleLevelsOfNullWithConverter_ShouldCallConverterWithNullThenTargetNullValueButNotFallbackValue(
|
||||
|
||||
)
|
||||
{
|
||||
var vmSource = new TestViewModel();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
const string fallbackValue = "Fallback value";
|
||||
const string targetNullValue = "Target null value";
|
||||
const string suffix = "Suffix";
|
||||
var converterWasCalledWithNull = 0;
|
||||
var converterWasCalledWithTargetNullValue = 0;
|
||||
var converterWasCalledWithFallbackValue = 0;
|
||||
|
||||
_binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Nested.Model.MyProperty,
|
||||
vmTarget,
|
||||
() => vmTarget.TargetProperty,
|
||||
BindingMode.Default,
|
||||
fallbackValue,
|
||||
targetNullValue)
|
||||
.ConvertSourceToTarget(
|
||||
v =>
|
||||
{
|
||||
if (v == null)
|
||||
{
|
||||
converterWasCalledWithNull++;
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (v)
|
||||
{
|
||||
case fallbackValue:
|
||||
converterWasCalledWithFallbackValue++;
|
||||
break;
|
||||
|
||||
case targetNullValue:
|
||||
converterWasCalledWithTargetNullValue++;
|
||||
break;
|
||||
}
|
||||
|
||||
return v + suffix;
|
||||
});
|
||||
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
Assert.AreEqual(0, converterWasCalledWithNull);
|
||||
Assert.AreEqual(0, converterWasCalledWithFallbackValue);
|
||||
Assert.AreEqual(0, converterWasCalledWithTargetNullValue);
|
||||
|
||||
vmSource.Nested = new TestViewModel();
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
Assert.AreEqual(0, converterWasCalledWithNull);
|
||||
Assert.AreEqual(0, converterWasCalledWithFallbackValue);
|
||||
Assert.AreEqual(0, converterWasCalledWithTargetNullValue);
|
||||
|
||||
vmSource.Nested.Model = new TestModel();
|
||||
Assert.AreEqual(targetNullValue + suffix, vmTarget.TargetProperty);
|
||||
Assert.AreEqual(1, converterWasCalledWithNull);
|
||||
Assert.AreEqual(0, converterWasCalledWithFallbackValue);
|
||||
Assert.AreEqual(1, converterWasCalledWithTargetNullValue);
|
||||
|
||||
vmSource.Nested.Model.MyProperty = DateTime.Now.Ticks.ToString();
|
||||
Assert.AreEqual(vmSource.Nested.Model.MyProperty + suffix, vmTarget.TargetProperty);
|
||||
Assert.AreEqual(1, converterWasCalledWithNull);
|
||||
Assert.AreEqual(0, converterWasCalledWithFallbackValue);
|
||||
Assert.AreEqual(1, converterWasCalledWithTargetNullValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_NoErrors_ShouldUpdateTargetValue()
|
||||
{
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = "Hello world"
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
_binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty,
|
||||
vmTarget,
|
||||
() => vmTarget.TargetProperty);
|
||||
|
||||
Assert.AreEqual(vmSource.Model.MyProperty, vmTarget.TargetProperty);
|
||||
var newValue = DateTime.Now.Ticks.ToString();
|
||||
vmSource.Model.MyProperty = newValue;
|
||||
Assert.AreEqual(vmSource.Model.MyProperty, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_NullSourceProperty_ShouldUseTargetNullValue()
|
||||
{
|
||||
var vmSource = new TestViewModel()
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
const string fallbackValue = "Fallback value";
|
||||
const string targetNullValue = "Target null value";
|
||||
|
||||
_binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty,
|
||||
vmTarget,
|
||||
() => vmTarget.TargetProperty,
|
||||
BindingMode.Default,
|
||||
fallbackValue,
|
||||
targetNullValue);
|
||||
|
||||
Assert.AreEqual(targetNullValue, vmTarget.TargetProperty);
|
||||
vmSource.Model.MyProperty = DateTime.Now.Ticks.ToString();
|
||||
Assert.AreEqual(vmSource.Model.MyProperty, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_ObjectCreation_ShouldAttachOnDemand()
|
||||
{
|
||||
VmSource = new TestViewModel();
|
||||
VmTarget = new TestViewModel();
|
||||
|
||||
_binding = this.SetBinding(
|
||||
() => VmSource.Model.MyProperty,
|
||||
() => VmTarget.TargetProperty);
|
||||
|
||||
Assert.IsNull(VmTarget.TargetProperty);
|
||||
VmSource.Model = new TestModel();
|
||||
Assert.IsNull(VmTarget.TargetProperty);
|
||||
VmSource.Model.MyProperty = DateTime.Now.Ticks.ToString();
|
||||
Assert.AreEqual(VmSource.Model.MyProperty, VmTarget.TargetProperty);
|
||||
VmSource.Model.MyProperty = "Another value";
|
||||
Assert.AreEqual(VmSource.Model.MyProperty, VmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneLevelOfNull_ShouldUseFallbackValue()
|
||||
{
|
||||
var vmSource = new TestViewModel();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
const string fallbackValue = "Fallback value";
|
||||
const string targetNullValue = "Target null value";
|
||||
|
||||
_binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty,
|
||||
vmTarget,
|
||||
() => vmTarget.TargetProperty,
|
||||
BindingMode.Default,
|
||||
fallbackValue,
|
||||
targetNullValue);
|
||||
|
||||
Assert.AreEqual(fallbackValue, vmTarget.TargetProperty);
|
||||
|
||||
vmSource.Model = new TestModel
|
||||
{
|
||||
MyProperty = DateTime.Now.Ticks.ToString()
|
||||
};
|
||||
|
||||
Assert.AreEqual(vmSource.Model.MyProperty, vmTarget.TargetProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventImplicitTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventLostFocusTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.IsTrue(control2.Checked);
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.ClearFocus();
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent() // LostFocus doesn't work programatically with CheckBoxes
|
||||
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.RequestFocus();
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent() // LostFocus doesn't work programatically with CheckBoxes
|
||||
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.IsTrue(control2.Checked);
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
|
||||
var value = "False";
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
control1.ClearFocus();
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.LostFocus)
|
||||
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.ClearFocus();
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.LostFocus)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
var newValue = value + "Suffix";
|
||||
control2.RequestFocus();
|
||||
control2.Text = newValue;
|
||||
Assert.AreEqual(newValue, control2.Text);
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
control2.ClearFocus();
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.RequestFocus();
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
var newValue = value + "Suffix";
|
||||
control1.RequestFocus();
|
||||
control1.Text = newValue;
|
||||
Assert.AreEqual(newValue, control1.Text);
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(newValue, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventNoArgumentTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventNonDefaultEventTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent<View.LongClickEventArgs>("LongClick");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.PerformLongClick();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<View.LongClickEventArgs>("LongClick")
|
||||
.ObserveTargetEvent<View.LongClickEventArgs>("LongClick");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.PerformLongClick();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
var newValue = value + "Suffix";
|
||||
control2.Text = newValue;
|
||||
Assert.AreEqual(newValue, control2.Text);
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
control2.PerformLongClick();
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventPropertyChangedTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,423 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Text;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.ObserveSourceEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange")
|
||||
.ObserveTargetEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange")
|
||||
.ObserveTargetEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<TextChangedEventArgs>("TextChanged")
|
||||
.ObserveTargetEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<TextChangedEventArgs>("TextChanged")
|
||||
.ObserveTargetEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,389 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class SetCommandTest
|
||||
{
|
||||
[Test]
|
||||
public void SetCommand_OnButtonExWithSimpleValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var button = new ButtonEx(Application.Context);
|
||||
|
||||
button.SetCommand(
|
||||
"Click",
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonExWithSimpleValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var button = new ButtonEx(Application.Context);
|
||||
|
||||
button.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonNoValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
button.SetCommand("Click", vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
button.SetCommand(vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithBinding_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
button.SetCommand(
|
||||
"Click",
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithBindingNoEventName_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
button.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithSimpleValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
button.SetCommand(
|
||||
"Click",
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithSimpleValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
button.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnCheckBoxNoValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>(
|
||||
"CheckedChange",
|
||||
vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnCheckBoxNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>(vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnCheckBoxWithBinding_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
"CheckedChange",
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnCheckBoxWithBindingNoEventName_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnCheckBoxWithSimpleValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
"CheckedChange",
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnCheckBoxWithSimpleValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnButtonNoValue_NoError()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
button.SetCommand("Click", vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnButtonNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var button = new Button(Application.Context);
|
||||
|
||||
button.SetCommand(vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
button.PerformClick();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnCheckBoxNoValue_NoError()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>("CheckedChange", vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnCheckBoxNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>(vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
checkBox.PerformClick();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerImplicitTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerLostFocusTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.IsTrue(control2.Checked);
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.ClearFocus();
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger() // LostFocus doesn't work programatically with CheckBoxes
|
||||
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.RequestFocus();
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger() // LostFocus doesn't work programatically with CheckBoxes
|
||||
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.IsTrue(control2.Checked);
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
|
||||
var value = "False";
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
control1.ClearFocus();
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus)
|
||||
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.ClearFocus();
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
var newValue = value + "Suffix";
|
||||
control2.RequestFocus();
|
||||
control2.Text = newValue;
|
||||
Assert.AreEqual(newValue, control2.Text);
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
control2.ClearFocus();
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.RequestFocus();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.RequestFocus();
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
var newValue = value + "Suffix";
|
||||
control1.RequestFocus();
|
||||
control1.Text = newValue;
|
||||
Assert.AreEqual(newValue, control1.Text);
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
control1.ClearFocus();
|
||||
Assert.AreEqual(newValue, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerNoArgumentTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerNonDefaultEventTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger<View.LongClickEventArgs>("LongClick");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.PerformLongClick();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<View.LongClickEventArgs>("LongClick")
|
||||
.ObserveTargetEvent<View.LongClickEventArgs>("LongClick");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(string.Empty, control2.Text);
|
||||
control1.PerformLongClick();
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
var newValue = value + "Suffix";
|
||||
control2.Text = newValue;
|
||||
Assert.AreEqual(newValue, control2.Text);
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
control2.PerformLongClick();
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerPropertyChangedTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,423 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Android.App;
|
||||
using Android.Text;
|
||||
using Android.Widget;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked)
|
||||
.UpdateSourceTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange")
|
||||
.UpdateTargetTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.IsTrue(control1.Checked);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange")
|
||||
.UpdateTargetTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
control2.Checked = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
control1.Checked = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<TextChangedEventArgs>("TextChanged")
|
||||
.UpdateTargetTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.Checked);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.Checked);
|
||||
|
||||
control2.Checked = false;
|
||||
Assert.IsFalse(control2.Checked);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new EditText(Application.Context);
|
||||
var control2 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<TextChangedEventArgs>("TextChanged")
|
||||
.UpdateTargetTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new CheckBox(Application.Context);
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Checked,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.Checked);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.Checked);
|
||||
|
||||
control1.Checked = false;
|
||||
Assert.IsFalse(control1.Checked);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new EditText(Application.Context);
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger<TextChangedEventArgs>("TextChanged");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using Android.Content;
|
||||
using Android.Runtime;
|
||||
using Android.Util;
|
||||
using Android.Widget;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Controls
|
||||
{
|
||||
public class ButtonEx : Button
|
||||
{
|
||||
public ButtonEx(IntPtr javaReference, JniHandleOwnership transfer)
|
||||
: base(javaReference, transfer)
|
||||
{
|
||||
}
|
||||
|
||||
public ButtonEx(Context context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public ButtonEx(Context context, IAttributeSet attrs)
|
||||
: base(context, attrs)
|
||||
{
|
||||
}
|
||||
|
||||
public ButtonEx(Context context, IAttributeSet attrs, int defStyleAttr)
|
||||
: base(context, attrs, defStyleAttr)
|
||||
{
|
||||
}
|
||||
|
||||
public ButtonEx(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes)
|
||||
: base(context, attrs, defStyleAttr, defStyleRes)
|
||||
{
|
||||
}
|
||||
|
||||
public void TestClick()
|
||||
{
|
||||
PerformClick();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{7141046B-7E7F-4D20-9F84-D2A65A9FA2CA}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>GalaSoft.MvvmLight.Test</RootNamespace>
|
||||
<AssemblyName>UnitTestApp1</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidApplication>true</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;ANDROID</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Xamarin.Android.NUnitLite" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\Binding.cs">
|
||||
<Link>Helpers\Binding.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGeneric.cs">
|
||||
<Link>Helpers\BindingGeneric.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGenericAndroid.cs">
|
||||
<Link>Helpers\BindingGenericAndroid.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGenericObsolete.cs">
|
||||
<Link>Helpers\BindingGenericObsolete.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGenericObsoleteAndroid.cs">
|
||||
<Link>Helpers\BindingGenericObsoleteAndroid.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingMode.cs">
|
||||
<Link>Helpers\BindingMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\Extensions.cs">
|
||||
<Link>Helpers\Extensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\ExtensionsAndroid.cs">
|
||||
<Link>Helpers\ExtensionsAndroid.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\IWeakEventListener.cs">
|
||||
<Link>Helpers\IWeakEventListener.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\ObservableAdapter.cs">
|
||||
<Link>Helpers\ObservableAdapter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\PropertyChangedEventManager.cs">
|
||||
<Link>Helpers\PropertyChangedEventManager.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\UpdateSourceTriggerMode.cs">
|
||||
<Link>Helpers\UpdateSourceTriggerMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Binding\BindingTest.cs" />
|
||||
<Compile Include="Binding\SetCommandTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventImplicitTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventLostFocusTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerLostFocusTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventNoArgumentTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerNoArgumentTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventNonDefaultEventTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventPropertyChangedTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerPropertyChangedTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerImplicitTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerNonDefaultEventTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerTest.cs" />
|
||||
<Compile Include="Controls\ButtonEx.cs" />
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ViewModel\CommandImpl.cs" />
|
||||
<Compile Include="ViewModel\TestModel.cs" />
|
||||
<Compile Include="ViewModel\TestViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Assets\AboutAssets.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\Icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\values\Strings.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\GalaSoft.MvvmLight %28PCL%29\GalaSoft.MvvmLight %28PCL%29.csproj">
|
||||
<Project>{6a912701-3ba1-4975-adbf-160caf66b640}</Project>
|
||||
<Name>GalaSoft.MvvmLight %28PCL%29</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\GalaSoft.MvvmLight.Extras %28PCL%29\GalaSoft.MvvmLight.Extras %28PCL%29.csproj">
|
||||
<Project>{39c71a69-4ace-4b45-9a2c-c274fada78ef}</Project>
|
||||
<Name>GalaSoft.MvvmLight.Extras %28PCL%29</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,23 @@
|
|||
using System.Reflection;
|
||||
using Android.App;
|
||||
using Android.OS;
|
||||
using Xamarin.Android.NUnitLite;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test
|
||||
{
|
||||
[Activity(Label = "AndroidTestApp", MainLauncher = true, Icon = "@drawable/icon")]
|
||||
public class MainActivity : TestSuiteActivity
|
||||
{
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
// tests can be inside the main assembly
|
||||
AddTest(Assembly.GetExecutingAssembly());
|
||||
// or in any reference assemblies
|
||||
// AddTest (typeof (Your.Library.TestClass).Assembly);
|
||||
|
||||
// Once you called base.OnCreate(), you cannot add more assemblies.
|
||||
base.OnCreate(bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="UnitTestApp1.UnitTestApp1" android:versionCode="1" android:versionName="1.0">
|
||||
<uses-sdk />
|
||||
<application android:label="UnitTestApp1"></application>
|
||||
</manifest>
|
|
@ -0,0 +1,30 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UnitTestApp1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UnitTestApp1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,44 @@
|
|||
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||
in your application as resource files. Various Android APIs are designed to
|
||||
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||
directly.
|
||||
|
||||
For example, a sample Android app that contains a user interface layout (main.axml),
|
||||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||
would keep its resources in the "Resources" directory of the application:
|
||||
|
||||
Resources/
|
||||
drawable/
|
||||
icon.png
|
||||
|
||||
layout/
|
||||
main.axml
|
||||
|
||||
values/
|
||||
strings.xml
|
||||
|
||||
In order to get the build system to recognize Android resources, set the build action to
|
||||
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||
the build system will package the resources for distribution and generate a class called "R"
|
||||
(this is an Android convention) that contains the tokens for each one of the resources
|
||||
included. For example, for the above Resources layout, this is what the R class would expose:
|
||||
|
||||
public class R {
|
||||
public class drawable {
|
||||
public const int icon = 0x123;
|
||||
}
|
||||
|
||||
public class layout {
|
||||
public const int main = 0x456;
|
||||
}
|
||||
|
||||
public class strings {
|
||||
public const int first_string = 0xabc;
|
||||
public const int second_string = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
|
||||
to reference the layout/main.axml file, or R.strings.first_string to reference the first
|
||||
string in the dictionary file values/strings.xml.
|
194
GalaSoft.MvvmLight/Tests/AndroidTestApp/Resources/Resource.Designer.cs
сгенерированный
Normal file
194
GalaSoft.MvvmLight/Tests/AndroidTestApp/Resources/Resource.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,194 @@
|
|||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("GalaSoft.MvvmLight.Test.Resource", IsApplication=true)]
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test
|
||||
{
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
static Resource()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
public static void UpdateIdValues()
|
||||
{
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.OptionHostName = global::GalaSoft.MvvmLight.Test.Resource.Id.OptionHostName;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.OptionPort = global::GalaSoft.MvvmLight.Test.Resource.Id.OptionPort;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.OptionRemoteServer = global::GalaSoft.MvvmLight.Test.Resource.Id.OptionRemoteServer;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.OptionsButton = global::GalaSoft.MvvmLight.Test.Resource.Id.OptionsButton;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultFullName = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultFullName;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultMessage = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultMessage;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultResultState = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultResultState;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultRunSingleMethodTest = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultRunSingleMethodTest;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultStackTrace = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultStackTrace;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsFailed = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsFailed;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsId = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsId;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsIgnored = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsIgnored;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsInconclusive = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsInconclusive;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsMessage = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsMessage;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsPassed = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsPassed;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.ResultsResult = global::GalaSoft.MvvmLight.Test.Resource.Id.ResultsResult;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.RunTestsButton = global::GalaSoft.MvvmLight.Test.Resource.Id.RunTestsButton;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Id.TestSuiteListView = global::GalaSoft.MvvmLight.Test.Resource.Id.TestSuiteListView;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Layout.options = global::GalaSoft.MvvmLight.Test.Resource.Layout.options;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Layout.results = global::GalaSoft.MvvmLight.Test.Resource.Layout.results;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Layout.test_result = global::GalaSoft.MvvmLight.Test.Resource.Layout.test_result;
|
||||
global::Xamarin.Android.NUnitLite.Resource.Layout.test_suite = global::GalaSoft.MvvmLight.Test.Resource.Layout.test_suite;
|
||||
}
|
||||
|
||||
public partial class Attribute
|
||||
{
|
||||
|
||||
static Attribute()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Attribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Drawable
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f020000
|
||||
public const int Icon = 2130837504;
|
||||
|
||||
static Drawable()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Drawable()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Id
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f050001
|
||||
public const int OptionHostName = 2131034113;
|
||||
|
||||
// aapt resource value: 0x7f050002
|
||||
public const int OptionPort = 2131034114;
|
||||
|
||||
// aapt resource value: 0x7f050000
|
||||
public const int OptionRemoteServer = 2131034112;
|
||||
|
||||
// aapt resource value: 0x7f050010
|
||||
public const int OptionsButton = 2131034128;
|
||||
|
||||
// aapt resource value: 0x7f05000b
|
||||
public const int ResultFullName = 2131034123;
|
||||
|
||||
// aapt resource value: 0x7f05000d
|
||||
public const int ResultMessage = 2131034125;
|
||||
|
||||
// aapt resource value: 0x7f05000c
|
||||
public const int ResultResultState = 2131034124;
|
||||
|
||||
// aapt resource value: 0x7f05000a
|
||||
public const int ResultRunSingleMethodTest = 2131034122;
|
||||
|
||||
// aapt resource value: 0x7f05000e
|
||||
public const int ResultStackTrace = 2131034126;
|
||||
|
||||
// aapt resource value: 0x7f050006
|
||||
public const int ResultsFailed = 2131034118;
|
||||
|
||||
// aapt resource value: 0x7f050003
|
||||
public const int ResultsId = 2131034115;
|
||||
|
||||
// aapt resource value: 0x7f050007
|
||||
public const int ResultsIgnored = 2131034119;
|
||||
|
||||
// aapt resource value: 0x7f050008
|
||||
public const int ResultsInconclusive = 2131034120;
|
||||
|
||||
// aapt resource value: 0x7f050009
|
||||
public const int ResultsMessage = 2131034121;
|
||||
|
||||
// aapt resource value: 0x7f050005
|
||||
public const int ResultsPassed = 2131034117;
|
||||
|
||||
// aapt resource value: 0x7f050004
|
||||
public const int ResultsResult = 2131034116;
|
||||
|
||||
// aapt resource value: 0x7f05000f
|
||||
public const int RunTestsButton = 2131034127;
|
||||
|
||||
// aapt resource value: 0x7f050011
|
||||
public const int TestSuiteListView = 2131034129;
|
||||
|
||||
static Id()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Id()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Layout
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f030000
|
||||
public const int options = 2130903040;
|
||||
|
||||
// aapt resource value: 0x7f030001
|
||||
public const int results = 2130903041;
|
||||
|
||||
// aapt resource value: 0x7f030002
|
||||
public const int test_result = 2130903042;
|
||||
|
||||
// aapt resource value: 0x7f030003
|
||||
public const int test_suite = 2130903043;
|
||||
|
||||
static Layout()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Layout()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class String
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f040001
|
||||
public const int ApplicationName = 2130968577;
|
||||
|
||||
// aapt resource value: 0x7f040000
|
||||
public const int Hello = 2130968576;
|
||||
|
||||
static String()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private String()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 4.0 KiB |
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="Hello">Hello World, Click Me!</string>
|
||||
<string name="ApplicationName">UnitTestApp1</string>
|
||||
</resources>
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
public class CommandImpl : ICommand
|
||||
{
|
||||
private readonly string _initialValue;
|
||||
|
||||
public string Parameter
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public CommandImpl(string initialValue)
|
||||
{
|
||||
_initialValue = initialValue;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
Parameter = _initialValue;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
public class TestModel : ObservableObject
|
||||
{
|
||||
private string _myProperty;
|
||||
|
||||
public string MyProperty
|
||||
{
|
||||
get
|
||||
{
|
||||
return _myProperty;
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(ref _myProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
using System.Windows.Input;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.ViewModel
|
||||
{
|
||||
public class TestViewModel : ViewModelBase
|
||||
{
|
||||
public const string ValueForCommand = "Command value";
|
||||
private TestModel _model;
|
||||
private TestViewModel _nested;
|
||||
private string _propertyValue;
|
||||
private RelayCommand<string> _setPropertyCommand;
|
||||
private RelayCommand _setPropertyWithoutValueCommand;
|
||||
private ICommand _testCommandImpl;
|
||||
|
||||
public TestModel Model
|
||||
{
|
||||
get
|
||||
{
|
||||
return _model;
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(ref _model, value);
|
||||
}
|
||||
}
|
||||
|
||||
public TestViewModel Nested
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nested;
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(ref _nested, value);
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand<string> SetPropertyCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _setPropertyCommand
|
||||
?? (_setPropertyCommand = new RelayCommand<string>(
|
||||
p =>
|
||||
{
|
||||
TargetProperty = p;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand SetPropertyWithoutValueCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _setPropertyWithoutValueCommand
|
||||
?? (_setPropertyWithoutValueCommand = new RelayCommand(
|
||||
() =>
|
||||
{
|
||||
TargetProperty = _propertyValue;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public string TargetProperty
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ICommand TestCommandImpl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _testCommandImpl
|
||||
?? (_testCommandImpl = new CommandImpl(ValueForCommand));
|
||||
}
|
||||
}
|
||||
|
||||
public void Configure(string propertyValue)
|
||||
{
|
||||
_propertyValue = propertyValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using Foundation;
|
||||
using MonoTouch.NUnit.UI;
|
||||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test
|
||||
{
|
||||
[Register("AppDelegate")]
|
||||
public class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
private TouchRunner _runner;
|
||||
|
||||
public override UIWindow Window
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
|
||||
{
|
||||
Window = new UIWindow(UIScreen.MainScreen.Bounds);
|
||||
_runner = new TouchRunner(Window);
|
||||
|
||||
// register every tests included in the main application/assembly
|
||||
_runner.Add(Assembly.GetExecutingAssembly());
|
||||
|
||||
Window.RootViewController = new UINavigationController(_runner.GetViewController());
|
||||
|
||||
// make the window visible
|
||||
Window.MakeKeyAndVisible();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,403 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventImplicitTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventNoArgumentTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent()
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventPropertyChangedTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class ObserveEventTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.ObserveSourceEvent("ValueChanged");
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.ObserveSourceEvent("ValueChanged");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent("ValueChanged");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.ObserveSourceEvent("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.ObserveSourceEvent("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.ObserveSourceEvent("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent("ValueChanged")
|
||||
.ObserveTargetEvent("ValueChanged");
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent("ValueChanged")
|
||||
.ObserveTargetEvent("Changed");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent("ValueChanged");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent("Changed")
|
||||
.ObserveTargetEvent("ValueChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent("Changed")
|
||||
.ObserveTargetEvent("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveSourceEvent("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent("ValueChanged");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.ObserveTargetEvent("Changed");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,519 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class SetCommandTest
|
||||
{
|
||||
[Test]
|
||||
public void SetCommand_OnBarButtonNoValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
control.SetCommand("Clicked", vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnBarButtonNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
control.SetCommand(vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnBarButtonWithBinding_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
control.SetCommand(
|
||||
"Clicked",
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnBarButtonWithBindingNoEventName_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
control.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnBarButtonWithSimpleValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
control.SetCommand(
|
||||
"Clicked",
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnBarButtonWithSimpleValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
control.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonNoValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var control = new UIButtonEx();
|
||||
|
||||
control.SetCommand("TouchUpInside", vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
vmTarget.Configure(value);
|
||||
|
||||
var control = new UIButtonEx();
|
||||
|
||||
control.SetCommand(vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithBinding_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIButtonEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
control.SetCommand(
|
||||
"TouchUpInside",
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithBindingNoEventName_ParameterShouldUpdate()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
var vmSource = new TestViewModel
|
||||
{
|
||||
Model = new TestModel
|
||||
{
|
||||
MyProperty = value
|
||||
}
|
||||
};
|
||||
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIButtonEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vmSource,
|
||||
() => vmSource.Model.MyProperty);
|
||||
|
||||
control.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
binding);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
value += "Test";
|
||||
vmSource.Model.MyProperty = value;
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithSimpleValue_NoError()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIButtonEx();
|
||||
|
||||
control.SetCommand(
|
||||
"TouchUpInside",
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_OnButtonWithSimpleValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
var vmTarget = new TestViewModel();
|
||||
|
||||
var control = new UIButtonEx();
|
||||
|
||||
control.SetCommand(
|
||||
vmTarget.SetPropertyCommand,
|
||||
value);
|
||||
|
||||
Assert.IsNull(vmTarget.TargetProperty);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnBarButtonNoValue_NoError()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
control.SetCommand("Clicked", vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnBarButtonNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var control = new UIBarButtonItemEx();
|
||||
|
||||
control.SetCommand(vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnButtonNoValue_NoError()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var control = new UIButtonEx();
|
||||
|
||||
control.SetCommand("TouchUpInside", vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetCommand_WithICommandOnButtonNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
{
|
||||
var vmTarget = new TestViewModel();
|
||||
var control = new UIButtonEx();
|
||||
|
||||
control.SetCommand(vmTarget.TestCommandImpl);
|
||||
|
||||
var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
Assert.IsNull(castedCommand.Parameter);
|
||||
control.PerformEvent();
|
||||
Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
}
|
||||
|
||||
// () => vmSource.Model.MyProperty);
|
||||
// vmSource,
|
||||
|
||||
// var binding = new Binding<string, string>(
|
||||
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// var vmTarget = new TestViewModel();
|
||||
// };
|
||||
// }
|
||||
// MyProperty = value
|
||||
// {
|
||||
// Model = new TestModel
|
||||
// {
|
||||
|
||||
// var vmSource = new TestViewModel
|
||||
// var value = DateTime.Now.Ticks.ToString();
|
||||
// {
|
||||
// public void SetCommand_OnCheckBoxWithBinding_ParameterShouldUpdate()
|
||||
|
||||
// [Test]
|
||||
|
||||
// checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
// "CheckedChange",
|
||||
// vmTarget.SetPropertyCommand,
|
||||
// binding);
|
||||
|
||||
// Assert.IsNull(vmTarget.TargetProperty);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
// value += "Test";
|
||||
// vmSource.Model.MyProperty = value;
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_OnCheckBoxWithBindingNoEventName_ParameterShouldUpdate()
|
||||
// {
|
||||
// var value = DateTime.Now.Ticks.ToString();
|
||||
|
||||
// var vmSource = new TestViewModel
|
||||
// {
|
||||
// Model = new TestModel
|
||||
// {
|
||||
// MyProperty = value
|
||||
// }
|
||||
// };
|
||||
|
||||
// var vmTarget = new TestViewModel();
|
||||
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// var binding = new Binding<string, string>(
|
||||
// vmSource,
|
||||
// () => vmSource.Model.MyProperty);
|
||||
|
||||
// checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
// vmTarget.SetPropertyCommand,
|
||||
// binding);
|
||||
|
||||
// Assert.IsNull(vmTarget.TargetProperty);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
|
||||
// value += "Test";
|
||||
// vmSource.Model.MyProperty = value;
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_OnCheckBoxWithSimpleValue_NoError()
|
||||
// {
|
||||
// var value = DateTime.Now.Ticks.ToString();
|
||||
// var vmTarget = new TestViewModel();
|
||||
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
// "CheckedChange",
|
||||
// vmTarget.SetPropertyCommand,
|
||||
// value);
|
||||
|
||||
// Assert.IsNull(vmTarget.TargetProperty);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_OnCheckBoxWithSimpleValueNoEventName_ClickEventShouldBeUsed()
|
||||
// {
|
||||
// var value = DateTime.Now.Ticks.ToString();
|
||||
// var vmTarget = new TestViewModel();
|
||||
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// checkBox.SetCommand<string, CompoundButton.CheckedChangeEventArgs>(
|
||||
// vmTarget.SetPropertyCommand,
|
||||
// value);
|
||||
|
||||
// Assert.IsNull(vmTarget.TargetProperty);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_OnCheckBoxNoValue_NoError()
|
||||
// {
|
||||
// var value = DateTime.Now.Ticks.ToString();
|
||||
// var vmTarget = new TestViewModel();
|
||||
// vmTarget.Configure(value);
|
||||
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>("CheckedChange", vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
// Assert.IsNull(vmTarget.TargetProperty);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_OnCheckBoxNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
// {
|
||||
// var value = DateTime.Now.Ticks.ToString();
|
||||
// var vmTarget = new TestViewModel();
|
||||
// vmTarget.Configure(value);
|
||||
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>(vmTarget.SetPropertyWithoutValueCommand);
|
||||
|
||||
// Assert.IsNull(vmTarget.TargetProperty);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(value, vmTarget.TargetProperty);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_WithICommandOnCheckBoxNoValue_NoError()
|
||||
// {
|
||||
// var vmTarget = new TestViewModel();
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>("CheckedChange", vmTarget.TestCommandImpl);
|
||||
|
||||
// var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
// Assert.IsNull(castedCommand.Parameter);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void SetCommand_WithICommandOnCheckBoxNoValueNoEventName_ClickEventShouldBeUsed()
|
||||
// {
|
||||
// var vmTarget = new TestViewModel();
|
||||
// var checkBox = new CheckBox(Application.Context);
|
||||
|
||||
// checkBox.SetCommand<CompoundButton.CheckedChangeEventArgs>(vmTarget.TestCommandImpl);
|
||||
|
||||
// var castedCommand = (CommandImpl)vmTarget.TestCommandImpl;
|
||||
|
||||
// Assert.IsNull(castedCommand.Parameter);
|
||||
// checkBox.PerformClick();
|
||||
// Assert.AreEqual(TestViewModel.ValueForCommand, castedCommand.Parameter);
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,403 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerImplicitTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerNoArgumentTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.UpdateTargetTrigger();
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.UpdateTargetTrigger();
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.UpdateTargetTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger()
|
||||
.UpdateTargetTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger();
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger();
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerPropertyChangedTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger(UpdateTriggerMode.PropertyChanged);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GalaSoft.MvvmLight.Helpers;
|
||||
using GalaSoft.MvvmLight.Test.Controls;
|
||||
using GalaSoft.MvvmLight.Test.ViewModel;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Binding
|
||||
{
|
||||
[TestFixture]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class UpdateTriggerTest
|
||||
{
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.UpdateSourceTrigger("ValueChanged");
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text)
|
||||
.UpdateSourceTrigger("ValueChanged");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger("ValueChanged");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On)
|
||||
.UpdateSourceTrigger("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text)
|
||||
.UpdateSourceTrigger("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty)
|
||||
.UpdateSourceTrigger("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToCheckBox_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_OneWayFromViewModelToEditText_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text);
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UISwitchEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, bool>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger("ValueChanged")
|
||||
.UpdateTargetTrigger("ValueChanged");
|
||||
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.IsFalse(control2.On);
|
||||
control1.On = true;
|
||||
Assert.IsTrue(control1.On);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control2,
|
||||
() => control2.On,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger("ValueChanged")
|
||||
.UpdateTargetTrigger("Changed");
|
||||
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
control2.On = true;
|
||||
Assert.AreEqual("True", control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
var value = "False";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<bool, string>(
|
||||
control1,
|
||||
() => control1.On,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger("ValueChanged");
|
||||
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
control1.On = true;
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
var value = "False";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger("Changed")
|
||||
.UpdateTargetTrigger("ValueChanged");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.IsFalse(control2.On);
|
||||
var value = "True";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.IsTrue(control2.On);
|
||||
|
||||
control2.On = false;
|
||||
Assert.IsFalse(control2.On);
|
||||
Assert.AreEqual("False", control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var control1 = new UITextViewEx();
|
||||
var control2 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
control2,
|
||||
() => control2.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger("Changed")
|
||||
.UpdateTargetTrigger("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, control2.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control2.Text = value;
|
||||
Assert.AreEqual(value, control2.Text);
|
||||
Assert.AreEqual(control2.Text, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromEditTextToViewModelWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
control1,
|
||||
() => control1.Text,
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateSourceTrigger("Changed");
|
||||
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
|
||||
value += "Suffix";
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UISwitchEx();
|
||||
|
||||
var binding = new Binding<string, bool>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.On,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger("ValueChanged");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.IsFalse(control1.On);
|
||||
vm.Model.MyProperty = "True";
|
||||
Assert.AreEqual("True", vm.Model.MyProperty);
|
||||
Assert.IsTrue(control1.On);
|
||||
|
||||
control1.On = false;
|
||||
Assert.IsFalse(control1.On);
|
||||
Assert.AreEqual("False", vm.Model.MyProperty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Binding_TwoWayFromViewModelToEditTextWithUpdateTrigger_BindingGetsUpdated()
|
||||
{
|
||||
var vm = new TestViewModel
|
||||
{
|
||||
Model = new TestModel()
|
||||
};
|
||||
|
||||
var control1 = new UITextViewEx();
|
||||
|
||||
var binding = new Binding<string, string>(
|
||||
vm,
|
||||
() => vm.Model.MyProperty,
|
||||
control1,
|
||||
() => control1.Text,
|
||||
BindingMode.TwoWay)
|
||||
.UpdateTargetTrigger("Changed");
|
||||
|
||||
Assert.AreEqual(null, vm.Model.MyProperty);
|
||||
Assert.AreEqual(string.Empty, control1.Text);
|
||||
var value = DateTime.Now.Ticks.ToString();
|
||||
vm.Model.MyProperty = value;
|
||||
Assert.AreEqual(value, vm.Model.MyProperty);
|
||||
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
|
||||
|
||||
value += "Suffix";
|
||||
control1.Text = value;
|
||||
Assert.AreEqual(value, control1.Text);
|
||||
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Controls
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class UIBarButtonItemEx : UIBarButtonItem
|
||||
{
|
||||
public UIBarButtonItemEx()
|
||||
{
|
||||
base.Clicked += BaseClicked;
|
||||
}
|
||||
|
||||
public void PerformEvent()
|
||||
{
|
||||
var handler = Clicked;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void BaseClicked(object sender, EventArgs e)
|
||||
{
|
||||
PerformEvent();
|
||||
}
|
||||
|
||||
public new event EventHandler Clicked;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Controls
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class UIButtonEx : UIButton
|
||||
{
|
||||
public UIButtonEx()
|
||||
{
|
||||
base.TouchUpInside += BaseTouchUpInside;
|
||||
}
|
||||
|
||||
public void PerformEvent()
|
||||
{
|
||||
var handler = TouchUpInside;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void BaseTouchUpInside(object sender, EventArgs e)
|
||||
{
|
||||
PerformEvent();
|
||||
}
|
||||
|
||||
public new event EventHandler TouchUpInside;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Controls
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class UISwitchEx : UISwitch
|
||||
{
|
||||
public new bool On
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.On;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (base.On != value)
|
||||
{
|
||||
base.On = value;
|
||||
PerformEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UISwitchEx()
|
||||
{
|
||||
base.ValueChanged += BaseValueChanged;
|
||||
}
|
||||
|
||||
public void PerformEvent()
|
||||
{
|
||||
var handler = ValueChanged;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void BaseValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
PerformEvent();
|
||||
}
|
||||
|
||||
public new event EventHandler ValueChanged;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test.Controls
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class UITextViewEx : UITextView
|
||||
{
|
||||
public new string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Text != value)
|
||||
{
|
||||
base.Text = value;
|
||||
PerformEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UITextViewEx()
|
||||
{
|
||||
base.Changed += BaseChanged;
|
||||
}
|
||||
|
||||
public void PerformEvent()
|
||||
{
|
||||
var handler = Changed;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void BaseChanged(object sender, EventArgs e)
|
||||
{
|
||||
PerformEvent();
|
||||
}
|
||||
|
||||
public new event EventHandler Changed;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
|
@ -0,0 +1,176 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProjectGuid>{D688119A-4FA8-4764-BE47-90724571B80C}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>GalaSoft.MvvmLight.Test</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>AppleTestApp</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>i386</MtouchArch>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>i386</MtouchArch>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<BuildIpa>True</BuildIpa>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\Binding.cs">
|
||||
<Link>Helpers\Binding.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGeneric.cs">
|
||||
<Link>Helpers\BindingGeneric.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingGenericObsolete.cs">
|
||||
<Link>Helpers\BindingGenericObsolete.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\BindingMode.cs">
|
||||
<Link>Helpers\BindingMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\Extensions.cs">
|
||||
<Link>Helpers\Extensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\IWeakEventListener.cs">
|
||||
<Link>Helpers\IWeakEventListener.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\PropertyChangedEventManager.cs">
|
||||
<Link>Helpers\PropertyChangedEventManager.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28Android%29\Helpers\UpdateSourceTriggerMode.cs">
|
||||
<Link>Helpers\UpdateSourceTriggerMode.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28iOS%29\Helpers\BindingGenericApple.cs">
|
||||
<Link>Helpers\BindingGenericApple.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28iOS%29\Helpers\BindingGenericObsoleteApple.cs">
|
||||
<Link>Helpers\BindingGenericObsoleteApple.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28iOS%29\Helpers\ExtensionsApple.cs">
|
||||
<Link>Helpers\ExtensionsApple.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GalaSoft.MvvmLight.Platform %28iOS%29\Helpers\ObservableTableViewController.cs">
|
||||
<Link>Helpers\ObservableTableViewController.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\AndroidTestApp\Binding\BindingTest.cs">
|
||||
<Link>Binding\BindingTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\AndroidTestApp\ViewModel\CommandImpl.cs">
|
||||
<Link>ViewModel\CommandImpl.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\AndroidTestApp\ViewModel\TestModel.cs">
|
||||
<Link>ViewModel\TestModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\AndroidTestApp\ViewModel\TestViewModel.cs">
|
||||
<Link>ViewModel\TestViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Binding\SetCommandTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventImplicitTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerImplicitTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventNoArgumentTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventPropertyChangedTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerPropertyChangedTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerNoArgumentTest.cs" />
|
||||
<Compile Include="Binding\ObserveEventTest.cs" />
|
||||
<Compile Include="Binding\UpdateTriggerTest.cs" />
|
||||
<Compile Include="Controls\UIBarButtonItemEx.cs" />
|
||||
<Compile Include="Controls\UIButtonEx.cs" />
|
||||
<Compile Include="Controls\UISwitchEx.cs" />
|
||||
<Compile Include="Controls\UITextViewEx.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<None Include="GettingStarted.Xamarin" />
|
||||
<None Include="Info.plist" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<InterfaceDefinition Include="Resources\LaunchScreen.xib" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoTouch.NUnitLite" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Entitlements.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\GalaSoft.MvvmLight %28PCL%29\GalaSoft.MvvmLight %28PCL%29.csproj">
|
||||
<Project>{6a912701-3ba1-4975-adbf-160caf66b640}</Project>
|
||||
<Name>GalaSoft.MvvmLight %28PCL%29</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\GalaSoft.MvvmLight.Extras %28PCL%29\GalaSoft.MvvmLight.Extras %28PCL%29.csproj">
|
||||
<Project>{39c71a69-4ace-4b45-9a2c-c274fada78ef}</Project>
|
||||
<Name>GalaSoft.MvvmLight.Extras %28PCL%29</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
<GettingStarted>
|
||||
<LocalContent>GS\iOS\CS\iOSApp\GettingStarted.html</LocalContent>
|
||||
<EmbeddedNavigation>false</EmbeddedNavigation>
|
||||
</GettingStarted>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>AppleTestApp</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.companyname.AppleTestApp</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.3</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,15 @@
|
|||
using UIKit;
|
||||
|
||||
namespace GalaSoft.MvvmLight.Test
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AppleTestApp")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AppleTestApp")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d688119a-4fa8-4764-be47-90724571b80c")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207" />
|
||||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1" />
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" />
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder" />
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="480" />
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2016 " textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines"
|
||||
minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
|
||||
<rect key="frame" x="20" y="439" width="441" height="21" />
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17" />
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
|
||||
<nil key="highlightedColor" />
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AppleTestApp" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
|
||||
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
|
||||
<rect key="frame" x="20" y="140" width="441" height="43" />
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
|
||||
<nil key="highlightedColor" />
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
|
||||
<constraints>
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC" />
|
||||
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk" />
|
||||
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l" />
|
||||
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0" />
|
||||
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9" />
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g" />
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics" />
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics" />
|
||||
<point key="canvasLocation" x="548" y="455" />
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
Загрузка…
Ссылка в новой задаче