From: Jean-Philippe Bruyère Date: Fri, 12 Feb 2021 08:52:02 +0000 (+0100) Subject: handle enums in Configuration, use Task to run command.Execute X-Git-Tag: v0.9.5-beta~72 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=43c175adeca183de03bba9d1a23811f18bb3918e;p=jp%2Fcrow.git handle enums in Configuration, use Task to run command.Execute --- 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, IValueChange @@ -123,8 +124,10 @@ namespace Crow { /// trigger the execution of the command /// 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); diff --git a/LICENSE.md b/LICENSE.md index 2c2a0a13..e25d3a94 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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