Files
BeWoPlaner/BeWo/Core/Commands/CommandFactory.cs
2025-06-11 12:51:32 +02:00

41 lines
1.1 KiB
C#

using BS.Shared;
using DevExpress.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static DevExpress.Mvvm.Native.Either;
namespace BeWo.Core.Commands
{
public static class CommandFactory
{
public static DelegateCommand GetAiViewCommand(Action openView, UserRightType userRightType, Func<bool> additionalCheckup = null)
{
bool canExecute() =>
BeWoApp.AppSettings.ModuleAiEnabled &&
BeWoApp.HasLoggedOnUserRight(userRightType) &&
(additionalCheckup is null || additionalCheckup());
return GetTestClientCommand(openView, canExecute, false);
}
public static DelegateCommand GetTestClientCommand(Action action, Func<bool> canExecute = null, bool? useCommandManager = null)
{
bool canExecute2() =>
CheckupTestVersion() &&
(canExecute is null || canExecute());
return new DelegateCommand(action, canExecute2, useCommandManager);
}
private static bool CheckupTestVersion()
{
var version = BeWoApp.Version.Split(' ');
var test_string = version[version.Length - 1].ToLower();
return test_string == "test";
}
}
}