]> O.S.I.I.S - jp/crow.git/commitdiff
handle enums in Configuration, use Task to run command.Execute
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 12 Feb 2021 08:52:02 +0000 (09:52 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 12 Feb 2021 08:52:02 +0000 (09:52 +0100)
Crow/src/Command.cs
Crow/src/Configuration.cs
LICENSE.md

index a068224ebafd0ccdeab0b5cdbafefcb0f1273420..6c225030c18ad2151ba23484930588100a961e9f 100644 (file)
@@ -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);
index e43916042c31bb5c722d15e1609b3acbedaedf7b..f6f4cee95174abbbb4b4c996be760bd502b203de 100644 (file)
@@ -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);
index 2c2a0a137d5e0b088a1946af92b7a242a20e1770..e25d3a94e8a24b532974c8c13f7f3859313a549f 100644 (file)
@@ -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