xartigas pushed a commit to branch master. http://git.enlightenment.org/tools/examples.git/commit/?id=e06157c1f625adc2fe7c1df79a0148308bf67e57
commit e06157c1f625adc2fe7c1df79a0148308bf67e57 Author: Xavi Artigas <[email protected]> Date: Mon Dec 31 17:36:21 2018 +0100 efl-mono: Use new Eina.Value implicit conversions --- reference/csharp/eina/src/eina_value.cs | 37 ++++++++------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/reference/csharp/eina/src/eina_value.cs b/reference/csharp/eina/src/eina_value.cs index c4765e4a..d718b6b5 100644 --- a/reference/csharp/eina/src/eina_value.cs +++ b/reference/csharp/eina/src/eina_value.cs @@ -13,13 +13,9 @@ public class Example { static void ValueInt() { - int i; - // Setting up an integer value type - var int_val = new Eina.Value(Eina.ValueType.Int32); - int_val.Set(123); - int_val.Get(out i); - Console.WriteLine("int_val value is {0}", i); + Eina.Value int_val = 123; + Console.WriteLine("int_val value is {0}", int_val); // It can easily be converted to a string string str = int_val.ToString(); @@ -28,13 +24,9 @@ public class Example static void ValueString() { - string str; - // Setting up an string value type - var str_val = new Eina.Value(Eina.ValueType.String); - str_val.Set("My string"); - str_val.Get(out str); - Console.WriteLine("str_val value is \"{0}\"", str); + Eina.Value str_val = "My string"; + Console.WriteLine("str_val value is \"{0}\"", str_val); // To string should have the same content string newstr = str_val.ToString(); @@ -43,27 +35,16 @@ public class Example static void ValueConvert() { - // Set up string and int types to convert between - var str_val = new Eina.Value(Eina.ValueType.String); - var int_val = new Eina.Value(Eina.ValueType.Int32); - // Convert from int to string: - int i1; - string str1; - int_val.Set(123); - int_val.Get(out i1); + Eina.Value int_val = 123; + Eina.Value str_val = new Eina.Value(Eina.ValueType.String); int_val.ConvertTo(str_val); - str_val.Get(out str1); - Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", i1, str1); + Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", int_val, str_val); // And the other way around! - int i2; - string str2; - str_val.Set("33"); - str_val.Get(out str2); + str_val = "33.000"; str_val.ConvertTo(int_val); - int_val.Get(out i2); - Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str2, i2); + Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str_val, int_val); } public static void Main() --
