Skip to content

Commit

Permalink
Merge pull request #7 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
Support for async command
  • Loading branch information
Ali-YousefiTelori authored Nov 17, 2023
2 parents 1bbc509 + 577c9d8 commit 76f95f8
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using EasyMicroservices.ServiceContracts;
using EasyMicroservices.UI.Core.Interfaces;
using EasyMicroservices.UI.Cores.Interfaces;
using System;
using System.ComponentModel;
using System.Threading.Tasks;

namespace EasyMicroservices.UI.Core;
namespace EasyMicroservices.UI.Cores;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using EasyMicroservices.ServiceContracts.Exceptions;
using EasyMicroservices.UI.Core.Interfaces;
using EasyMicroservices.UI.Cores.Interfaces;
using System;
using System.Windows.Input;

namespace EasyMicroservices.UI.Core.Commands;
namespace EasyMicroservices.UI.Cores.Commands;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace EasyMicroservices.UI.Core.Commands;
namespace EasyMicroservices.UI.Cores.Commands;

/// <summary>
///
Expand Down Expand Up @@ -51,7 +51,7 @@ public RelayCommand(Action<T> execute, Func<T, bool> canExecute)
/// </summary>
/// <param name="execute"></param>
public RelayCommand(Action<T> execute)
: this((x) => execute((T)x), (x) => true)
: this((x) => execute(x), (x) => true)
{

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using EasyMicroservices.ServiceContracts.Exceptions;
using EasyMicroservices.UI.Core.Interfaces;
using EasyMicroservices.UI.Cores.Interfaces;
using System;
using System.Threading.Tasks;
using System.Windows.Input;

namespace EasyMicroservices.UI.Core.Commands
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
@@ -1,8 +1,8 @@
using EasyMicroservices.UI.Core.Interfaces;
using EasyMicroservices.UI.Cores.Interfaces;
using System;
using System.Threading.Tasks;

namespace EasyMicroservices.UI.Core.Commands
namespace EasyMicroservices.UI.Cores.Commands
{
/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<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>
<PackageProjectUrl>https://github.com/EasyMicroservices/UICores</PackageProjectUrl>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>.\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.UI.Core.Mvvm.xml</DocumentationFile>
<RootNamespace>EasyMicroservices.UI.Core</RootNamespace>
<DocumentationFile>.\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.UI.Cores.Mvvm.xml</DocumentationFile>
<RootNamespace>EasyMicroservices.UI.Cores</RootNamespace>
</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
Expand Up @@ -3,7 +3,7 @@
using System.ComponentModel;
using System.Threading.Tasks;

namespace EasyMicroservices.UI.Core.Interfaces
namespace EasyMicroservices.UI.Cores.Interfaces
{
/// <summary>
///
Expand Down
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);
}
}
44 changes: 44 additions & 0 deletions src/CSharp/Cores/EasyMicroservices.UI.Cores.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
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}") = "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} = {0042F7CD-62D1-4CCE-9BCC-1C7793C844EC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {77EBEEBB-EB05-4329-BA01-C8E0B8EA5A08}
EndGlobalSection
EndGlobal
30 changes: 0 additions & 30 deletions src/CSharp/EasyMicroservices.UI.Core.sln

This file was deleted.

0 comments on commit 76f95f8

Please sign in to comment.