aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-25 12:42:10 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-25 12:42:10 +0100
commite8abbc812544aee80bbefa30b89d2c9bcaae2805 (patch)
tree40fca51662e1b7f7afa752d63d26a61a42c7ab47
parent66e20999196abae2c301baa16cfedd45b9f9b58d (diff)
add a static Parse method in ObservableList<T>, use semicolumn as separator
-rw-r--r--Crow/src/IML/Node.cs24
-rw-r--r--Crow/src/ObservableList.cs18
2 files changed, 23 insertions, 19 deletions
diff --git a/Crow/src/IML/Node.cs b/Crow/src/IML/Node.cs
index d984c8a8..811cfd6d 100644
--- a/Crow/src/IML/Node.cs
+++ b/Crow/src/IML/Node.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -66,23 +66,11 @@ namespace Crow.IML
}
#endregion
- public bool HasTemplate {
- get { return typeof (TemplatedControl).IsAssignableFrom (CrowType);}
- }
- public bool IsTemplatedGroup {
- get { return typeof (TemplatedGroup).IsAssignableFrom (CrowType);}
- }
- public bool HasDataSourceType {
- get { return DataSourceType != null; }
- }
+ public bool HasTemplate => typeof (TemplatedControl).IsAssignableFrom (CrowType);
+ public bool IsTemplatedGroup => typeof (TemplatedGroup).IsAssignableFrom (CrowType);
+ public bool HasDataSourceType => DataSourceType != null;
- public static implicit operator string (Node sn)
- {
- return sn.ToString ();
- }
- public override string ToString ()
- {
- return string.Format ("{0}.{1}", CrowType.FullName, Index);
- }
+ public static implicit operator string (Node sn) => sn.ToString ();
+ public override string ToString () => string.Format ("{0}.{1}", CrowType.FullName, Index);
}
}
diff --git a/Crow/src/ObservableList.cs b/Crow/src/ObservableList.cs
index e87226cd..6d7b71c7 100644
--- a/Crow/src/ObservableList.cs
+++ b/Crow/src/ObservableList.cs
@@ -1,4 +1,5 @@
-// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+using System.Reflection;
+// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
@@ -95,6 +96,21 @@ namespace Crow
public void RaiseEditAt (int index) {
ListEdit.Raise (this, new ListChangedEventArg (index, this[index]));
}
+
+
+ public static ObservableList<T> Parse (string str) {
+ ObservableList<T> tmp = new ObservableList<T>();
+ Type t = typeof(T);
+ MethodInfo miParse = t.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public,
+ Type.DefaultBinder, new Type [] {typeof (string)}, null);
+ if (miParse == null)
+ throw new Exception ("no Parse method found for: " + t.FullName);
+ if (!string.IsNullOrEmpty (str)) {
+ foreach (string s in str.Split(';'))
+ tmp.Add((T)miParse.Invoke (null, new object[] {s}));
+ }
+ return tmp;
+ }
}
}