diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs index e0e2f5f76d..d1f3423abf 100644 --- a/src/bindings/mono/eina_mono/eina_value.cs +++ b/src/bindings/mono/eina_mono/eina_value.cs @@ -766,6 +766,18 @@ public class Value : IDisposable, IComparable, IEquatable Setup(containerType, subtype, step); } + /// Deep copies the given eina Value + public Value(Value v) + { + Handle = Alloc(); + if (!eina_value_copy(v.Handle, this.Handle)) + throw new System.InvalidOperationException("Failed to copy value to managed memory."); + + Disposed = false; + Flushed = false; + Ownership = Ownership.Managed; + } + /// Constructor to build value from Values_Natives passed by value from C. public Value(Value_Native value) { diff --git a/src/tests/efl_mono/Value.cs b/src/tests/efl_mono/Value.cs index 78bf0b4b50..31326f949c 100644 --- a/src/tests/efl_mono/Value.cs +++ b/src/tests/efl_mono/Value.cs @@ -836,6 +836,21 @@ public static class TestEinaValue { } } + public static void TestValueCopy() { + eina.Value v2 = null; + int raw_val = 42; + + using (eina.Value v = new eina.Value(eina.ValueType.Int32)) { + Test.Assert(v.Set(raw_val)); + + v2 = new eina.Value(v); + } + + int rec_val; + Test.Assert(v2.Get(out rec_val)); + Test.AssertEquals(raw_val, rec_val); + } + // FIXME Add remaining list tests /* public static void TestValueHash() { */