Skip to content

Commit

Permalink
Support for async command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Nov 17, 2023
1 parent a90e6df commit 577c9d8
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
using EasyMicroservices.UI.Cores.Interfaces;
using System;
using System.Threading.Tasks;
using System.Windows.Input;

namespace EasyMicroservices.UI.Cores.Commands
{
/// <summary>
///
/// </summary>
public class TaskBaseCommand : ICommand
public class TaskBaseCommand : ICommandAsync
{
/// <summary>
///
Expand Down Expand Up @@ -76,11 +75,7 @@ public virtual bool CanExecute(object parameter = null)
/// <param name="parameter"></param>
public virtual void Execute(object parameter)
{
if (_busyViewModel != null)
{
_busyViewModel.Busy();
CanExecuteChanged?.Invoke(this, new EventArgs());
}
InternalExecuteInit();
_ = InternalExecute(parameter);
}

Expand All @@ -107,5 +102,25 @@ async Task InternalExecute(object parameter)
}
}
}

void InternalExecuteInit()
{
if (_busyViewModel != null)
{
_busyViewModel.Busy();
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}

/// <summary>
///
/// </summary>
/// <param name="parameter"></param>
/// <returns></returns>
public async Task ExecuteAsync(object parameter)
{
InternalExecuteInit();
await InternalExecute(parameter);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.6</Version>
<Version>0.0.0.7</Version>
<Description>Model View View Model</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>mvvm,mvpvm,modelview,modelviewviewmodel</PackageTags>
Expand All @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EasyMicroservices.ServiceContracts" Version="0.0.0.18" />
<PackageReference Include="EasyMicroservices.ServiceContracts" Version="0.0.0.19" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Threading.Tasks;
using System.Windows.Input;

namespace EasyMicroservices.UI.Cores.Interfaces
{
/// <summary>
///
/// </summary>
public interface ICommandAsync : ICommand
{
/// <summary>
///
/// </summary>
/// <param name="parameter"></param>
/// <returns></returns>
Task ExecuteAsync(object parameter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,38 @@ VisualStudioVersion = 17.7.34018.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.UI.Cores.Mvvm", "EasyMicroservices.UI.Cores.Mvvm\EasyMicroservices.UI.Cores.Mvvm.csproj", "{301DB27A-4A96-4891-89BA-15FF9D6091B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "App", "App", "{0B34338E-D1A6-44EC-94AE-3D7A305E77E7}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BusinessLogic-Layer", "BusinessLogic-Layer", "{0042F7CD-62D1-4CCE-9BCC-1C7793C844EC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UserInterface-Layer", "UserInterface-Layer", "{27B243BB-7AEF-43B1-8C5D-55698CFEBC3A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Debug|x64.ActiveCfg = Debug|x64
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Debug|x64.Build.0 = Debug|x64
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Debug|x86.ActiveCfg = Debug|x86
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Debug|x86.Build.0 = Debug|x86
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Release|Any CPU.Build.0 = Release|Any CPU
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Release|x64.ActiveCfg = Release|x64
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Release|x64.Build.0 = Release|x64
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Release|x86.ActiveCfg = Release|x86
{301DB27A-4A96-4891-89BA-15FF9D6091B5}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{301DB27A-4A96-4891-89BA-15FF9D6091B5} = {0B34338E-D1A6-44EC-94AE-3D7A305E77E7}
{301DB27A-4A96-4891-89BA-15FF9D6091B5} = {0042F7CD-62D1-4CCE-9BCC-1C7793C844EC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {77EBEEBB-EB05-4329-BA01-C8E0B8EA5A08}
Expand Down

0 comments on commit 577c9d8

Please sign in to comment.