コード例 #1
0
        public static unsafe void Initialize()
        {
            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);
                }
            }

#if DEBUG
            DebugLoggerCallback logger = DebugLogger;
            GCHandle.Alloc(logger);
            set_debug_logger(logger);
#endif
        }
コード例 #2
0
        internal static unsafe void Initialize()
        {
            if (Interlocked.CompareExchange(ref _isInitialized, 1, 0) == 0)
            {
                var platform = Environment.OSVersion.Platform;

                if (platform == PlatformID.Win32NT)
                {
                    // This is the path for regular windows apps using NuGet.
                    AddWindowsWrappersToPath("lib\\win32");

                    // This is the path for Unity apps built as standalone.
                    AddWindowsWrappersToPath("..\\Plugins", isUnityTarget: true);

                    // This is the path in the Unity package - it is what the Editor uses.
                    AddWindowsWrappersToPath("Windows", isUnityTarget: true);
                }

#if DEBUG
                DebugLoggerCallback logger = DebugLogger;
                GCHandle.Alloc(logger);
                set_debug_logger(logger);
#endif

                SynchronizationContextScheduler.Install();
            }
        }
コード例 #3
0
        public static unsafe void Initialize()
        {
            try
            {
                if (RuntimeInformation.FrameworkDescription.Contains(".NET Framework") &&
                    RuntimeInformation.OSDescription.Contains("Windows"))
                {
                    var assemblyLocationPI = typeof(Assembly).GetProperty("Location", BindingFlags.Public | BindingFlags.Instance);
                    if (assemblyLocationPI != null)
                    {
                        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
            {
                // HACK
                // RuntimeInformation seems to throw on Android. As we're only interested in windows, swallow the exception.
            }

#if DEBUG
            DebugLoggerCallback logger = DebugLogger;
            GCHandle.Alloc(logger);
            set_debug_logger(logger);
#endif

            FreeGCHandleCallback gchandleDeleter = FreeGCHandle;
            GCHandle.Alloc(gchandleDeleter);
            install_gchandle_deleter(gchandleDeleter);
        }
コード例 #4
0
        public static void Initialize()
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                var assemblyLocation = Path.GetDirectoryName(typeof(NativeCommon).Assembly.Location);
                var architecture     = Environment.Is64BitProcess ? "x64" : "x86";
                var path             = Path.Combine(assemblyLocation, "lib", "win32", architecture) + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH");
                Environment.SetEnvironmentVariable("PATH", path);
            }

#if DEBUG
            DebugLoggerCallback logger = DebugLogger;
            GCHandle.Alloc(logger);
            set_debug_logger(logger);
#endif

            FreeGCHandleCallback gchandleDeleter = FreeGCHandle;
            GCHandle.Alloc(gchandleDeleter);
            install_gchandle_deleter(gchandleDeleter);
        }
コード例 #5
0
ファイル: NativeCommon.cs プロジェクト: ruo2012/realm-dotnet
        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();
            }
        }
コード例 #6
0
 public static extern void set_debug_logger(DebugLoggerCallback callback);
コード例 #7
0
ファイル: NativeCommon.cs プロジェクト: realm/realm-dotnet
 public static extern void set_debug_logger(DebugLoggerCallback callback);