static Realm() { NativeCommon.Initialize(); NativeCommon.NotifyRealmCallback notifyRealm = RealmState.NotifyRealmChanged; GCHandle.Alloc(notifyRealm); NativeCommon.register_notify_realm_changed(notifyRealm); SynchronizationContextEventLoopSignal.Install(); }
static Realm() { NativeCommon.Initialize(); NativeCommon.NotifyRealmCallback notifyRealm = RealmState.NotifyRealmChanged; GCHandle.Alloc(notifyRealm); NativeCommon.GetNativeSchemaCallback getNativeSchema = GetNativeSchema; GCHandle.Alloc(getNativeSchema); NativeCommon.register_callbacks(notifyRealm, getNativeSchema); SynchronizationContextEventLoopSignal.Install(); }
internal static unsafe void Initialize() { if (Interlocked.CompareExchange(ref _isInitialized, 1, 0) == 0) { try { var osVersionPI = typeof(Environment).GetProperty("OSVersion"); var platformPI = osVersionPI?.PropertyType.GetProperty("Platform"); var assemblyLocationPI = typeof(Assembly).GetProperty("Location", BindingFlags.Public | BindingFlags.Instance); if (osVersionPI != null && osVersionPI != null && assemblyLocationPI != null) { var osVersion = osVersionPI.GetValue(null); var platform = platformPI.GetValue(osVersion); if (platform.ToString() == "Win32NT") { var assemblyLocation = Path.GetDirectoryName((string)assemblyLocationPI.GetValue(typeof(NativeCommon).GetTypeInfo().Assembly)); var architecture = InteropConfig.Is64BitProcess ? "x64" : "x86"; var path = Path.Combine(assemblyLocation, "lib", "win32", architecture) + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH"); Environment.SetEnvironmentVariable("PATH", path); } } } catch { // Try to put wrappers in PATH on Windows Desktop, but be silent if anything fails. } #if DEBUG DebugLoggerCallback logger = DebugLogger; GCHandle.Alloc(logger); set_debug_logger(logger); #endif SynchronizationContextEventLoopSignal.Install(); } }