diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-02-12 09:52:02 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-02-12 09:52:02 +0100 |
| commit | 43c175adeca183de03bba9d1a23811f18bb3918e (patch) | |
| tree | 84f72e9347ec19e3d78dedb46372d22ecb3a10df | |
| parent | da4753f74a1962c91e6c1aa77129a1ba63fbe873 (diff) | |
handle enums in Configuration, use Task to run command.Execute
| -rw-r--r-- | Crow/src/Command.cs | 7 | ||||
| -rw-r--r-- | Crow/src/Configuration.cs | 10 | ||||
| -rw-r--r-- | LICENSE.md | 2 |
3 files changed, 13 insertions, 6 deletions
diff --git a/Crow/src/Command.cs b/Crow/src/Command.cs index a068224e..6c225030 100644 --- a/Crow/src/Command.cs +++ b/Crow/src/Command.cs @@ -4,6 +4,7 @@ using System; using System.ComponentModel; +using System.Threading.Tasks; namespace Crow { public class CommandGroup : ObservableList<Command>, IValueChange @@ -123,8 +124,10 @@ namespace Crow { /// trigger the execution of the command /// </summary> public void Execute(){ - if (execute != null && CanExecute) - execute (); + if (execute != null && CanExecute){ + Task task = new Task(execute); + task.Start(); + } } internal void raiseAllValuesChanged(){ NotifyValueChanged ("CanExecute", CanExecute); diff --git a/Crow/src/Configuration.cs b/Crow/src/Configuration.cs index e4391604..f6f4cee9 100644 --- a/Crow/src/Configuration.cs +++ b/Crow/src/Configuration.cs @@ -29,9 +29,13 @@ namespace Crow if (type == null) type = typeof(T); if (parsingNeeded) { - MethodInfo miParse = type.GetMethod ("Parse", new Type[] {typeof(string)}); - if (miParse != null) - curVal = miParse.Invoke (null, new object[]{ curVal }); + if (type.IsEnum) { + curVal = Enum.Parse (typeof(T), (string)curVal); + }else{ + MethodInfo miParse = type.GetMethod ("Parse", new Type[] {typeof(string)}); + if (miParse != null) + curVal = miParse.Invoke (null, new object[]{ curVal }); + } parsingNeeded = false; } return (T)Convert.ChangeType (curVal, type); @@ -1,6 +1,6 @@ MIT License -Copyright (c) [2016] [Jean-Philippe Bruyère] +Copyright (c) [2016-2021] [Jean-Philippe Bruyère] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal |