diff --git a/csharp/Facebook.Yoga/YogaLogger.cs b/csharp/Facebook.Yoga/YogaLogger.cs index 52731af7..68d946e6 100644 --- a/csharp/Facebook.Yoga/YogaLogger.cs +++ b/csharp/Facebook.Yoga/YogaLogger.cs @@ -8,17 +8,14 @@ */ using System; -using System.Runtime.InteropServices; namespace Facebook.Yoga { internal static class YogaLogger { - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void Func(YogaLogLevel level, string message); private static bool _initialized; - private static Func _managedLogger = null; public static Func Logger = null; @@ -26,42 +23,27 @@ namespace Facebook.Yoga { if (!_initialized) { - _managedLogger = (level, message) => { - if (Logger != null) - { - Logger(level, message); - } - if (level == YogaLogLevel.Error) - { - throw new InvalidOperationException(message); - } - }; -#if __IOS__ - Native.YGInteropSetLogger(ManagedLogger); -#else - Native.YGInteropSetLogger(_managedLogger); -#endif + Native.YGInteropSetLogger(LoggerInternal); _initialized = true; } } #if __IOS__ - delegate void ManagedLoggerCallback(YogaLogLevel level, string message); - - [ObjCRuntime.MonoPInvokeCallback(typeof(ManagedLoggerCallback))] - public static void ManagedLogger(YogaLogLevel level, string message) - { - if (Logger != null) - { - Logger(level, message); - } - - if (level == YogaLogLevel.Error) - { - throw new InvalidOperationException(message); - } - } + [ObjCRuntime.MonoPInvokeCallback(typeof(Func))] #endif + public static void LoggerInternal(YogaLogLevel level, string message) + { + if (Logger != null) + { + Logger(level, message); + } + + if (level == YogaLogLevel.Error) + { + throw new InvalidOperationException(message); + } + } + } }