diff --git a/wrappers/csharp/wrapper_impl.mustache b/wrappers/csharp/wrapper_impl.mustache
index 924be6fda..d9488b22f 100644
--- a/wrappers/csharp/wrapper_impl.mustache
+++ b/wrappers/csharp/wrapper_impl.mustache
@@ -30,7 +30,7 @@ namespace Linphone
///
/// Only contains the LIB_NAME value that represents the library in which all DllImport are made
///
- public class LinphoneWrapper
+ public class LinphoneWrapper
{
#if __IOS__
public const string LIB_NAME = "linphone.framework/linphone";
@@ -86,7 +86,7 @@ namespace Linphone
protected LinphoneException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
#endif
-
+
[StructLayout(LayoutKind.Sequential)]
///
/// Parent class for a Linphone public objects
@@ -94,7 +94,7 @@ namespace Linphone
public class LinphoneObject
{
internal IntPtr nativePtr;
-
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void OnLinphoneObjectDataDestroyed(IntPtr data);
@@ -103,16 +103,16 @@ namespace Linphone
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME)]
static extern IntPtr belle_sip_object_data_get(IntPtr ptr, string name);
-
+
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME)]
static extern IntPtr belle_sip_object_ref(IntPtr ptr);
-
+
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME)]
static extern void belle_sip_object_unref(IntPtr ptr);
-
+
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME)]
static extern IntPtr bctbx_list_next(IntPtr ptr);
-
+
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME)]
static extern IntPtr bctbx_list_get_data(IntPtr ptr);
@@ -134,7 +134,7 @@ namespace Linphone
handle.Free();
}
}
-
+
~LinphoneObject()
{
//Console.WriteLine("Destroying " + this.ToString());
@@ -143,7 +143,7 @@ namespace Linphone
belle_sip_object_unref(nativePtr);
}
}
-
+
internal static T fromNativePtr(IntPtr ptr, bool takeRef=true) where T : LinphoneObject, new()
{
if (ptr == IntPtr.Zero) return null;
@@ -184,7 +184,7 @@ namespace Linphone
}
return null;
}
-
+
internal static IEnumerable MarshalStringArray(IntPtr arrayPtr)
{
if (arrayPtr != IntPtr.Zero)
@@ -199,7 +199,7 @@ namespace Linphone
}
}
}
-
+
internal static IEnumerable MarshalBctbxList(IntPtr listPtr) where T : LinphoneObject, new()
{
if (listPtr != IntPtr.Zero)
@@ -239,7 +239,7 @@ namespace Linphone
return bctbx_list;
}
}
-
+
#if ANDROID
///
/// Methods that are only found in Android version of Linphone libraries and related to JNI
@@ -251,7 +251,7 @@ namespace Linphone
[DllImport(LinphoneWrapper.LIB_NAME)]
static extern void setMediastreamerAndroidContext(IntPtr jnienv, IntPtr context);
-
+
///
/// Sets the JVM and JNI pointers in Linphone, required to be able to make JAVA upcalls.
/// Calling this method is mandatory and must be done as soon as possible !
@@ -264,7 +264,7 @@ namespace Linphone
}
#endif
#endregion
-
+
#region Enums
{{#enums}}
{{#enum}}
@@ -284,11 +284,11 @@ namespace Linphone
{{name}} = {{value}},
{{/values}}
}
-
+
{{/enum}}
{{/enums}}
#endregion
-
+
#region Listeners
{{#interfaces}}
{{#interface}}
@@ -298,14 +298,19 @@ namespace Linphone
{{#methods}}
[DllImport(LinphoneWrapper.LIB_NAME)]
{{#cb_setter}}
+#if WINDOWS_UWP
+ static extern void {{name}}(IntPtr thiz, IntPtr cb);
+#else
static extern void {{name}}(IntPtr thiz, {{name_private}} cb);
+#endif
{{/cb_setter}}
-
+
{{#delegate}}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void {{name_private}}({{params_private}});
-
+
public delegate void {{name_public}}({{params_public}});
+ private {{name_private}} {{var_private}};
private {{name_public}} {{var_public}};
#if __IOS__
@@ -328,17 +333,23 @@ namespace Linphone
set
{
{{var_public}} = value;
+#if WINDOWS_UWP
+ {{var_private}} = {{cb_name}};
+ IntPtr cb = Marshal.GetFunctionPointerForDelegate({{var_private}});
+ {{c_name_setter}}(nativePtr, cb);
+#else
{{c_name_setter}}(nativePtr, {{cb_name}});
+#endif
}
}
- {{/delegate}}
+ {{/delegate}}
{{/methods}}
}
-
+
{{/interface}}
{{/interfaces}}
#endregion
-
+
#region Classes
{{#classes}}
{{#_class}}
@@ -353,21 +364,21 @@ namespace Linphone
{{#isLinphoneFactory}}
[DllImport(LinphoneWrapper.LIB_NAME)]
static extern IntPtr linphone_factory_create_core_cbs(IntPtr factory);
-
+
public CoreListener CreateCoreListener()
{
IntPtr coreCbsPtr = linphone_factory_create_core_cbs(nativePtr);
return fromNativePtr(coreCbsPtr, false);
}
- {{/isLinphoneFactory}}
- {{#dllImports}}
+ {{/isLinphoneFactory}}
+ {{#dllImports}}
[DllImport(LinphoneWrapper.LIB_NAME)]
{{{prototype}}}
{{#has_second_prototype}}
[DllImport(LinphoneWrapper.LIB_NAME)]
{{second_prototype}}
{{/has_second_prototype}}
-
+
{{#has_property}}
{{#doc}}
{{#lines}}
@@ -478,7 +489,7 @@ namespace Linphone
{{/has_impl}}
{{/dllImports}}
}
- {{/_class}}
+ {{/_class}}
{{/classes}}
#endregion
-}
\ No newline at end of file
+}