Exemplo n.º 1
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);
                }

                SynchronizationContextScheduler.Install();
                SharedRealmHandle.Initialize();
                SessionHandle.InstallCallbacks();
                HttpClientTransport.Install();
                AppHandle.Initialize();
            }
        }
Exemplo n.º 2
0
        static unsafe AppHandle()
        {
            NativeCommon.Initialize();
            SessionHandle.InstallCallbacks();

            NativeMethods.LogMessageCallback logMessage   = HandleLogMessage;
            NativeMethods.UserCallback       userLogin    = HandleUserCallback;
            NativeMethods.VoidTaskCallback   taskCallback = HandleTaskCompletion;
            NativeMethods.BsonCallback       bsonCallback = HandleBsonCallback;

            GCHandle.Alloc(logMessage);
            GCHandle.Alloc(userLogin);
            GCHandle.Alloc(taskCallback);
            GCHandle.Alloc(bsonCallback);

            //// This is a hack due to a mixup of what OS uses as platform/SDK and what is displayed in the UI.
            //// The original code is below:
            ////
            //// string platform;
            //// string platformVersion;
            //// var platformRegex = new Regex("^(?<platform>[^0-9]*) (?<version>[^ ]*)", RegexOptions.Compiled);
            //// var osDescription = platformRegex.Match(RuntimeInformation.OSDescription);
            //// if (osDescription.Success)
            //// {
            ////     platform = osDescription.Groups["platform"].Value;
            ////     platformVersion = osDescription.Groups["version"].Value;
            //// }
            //// else
            //// {
            ////     platform = Environment.OSVersion.Platform.ToString();
            ////     platformVersion = Environment.OSVersion.VersionString;
            //// }

            var platform        = "Realm .NET";
            var platformVersion = RuntimeInformation.OSDescription;

            // var sdkVersion = typeof(AppHandle).GetTypeInfo().Assembly.GetName().Version.ToString(3);

            // TODO: temporarily add -beta.X suffix to the SDK
            var sdkVersion = "10.0.0-beta.6";

            NativeMethods.initialize(
                platform, (IntPtr)platform.Length,
                platformVersion, (IntPtr)platformVersion.Length,
                sdkVersion, (IntPtr)sdkVersion.Length,
                userLogin, taskCallback, bsonCallback, logMessage);

            HttpClientTransport.Install();
        }
Exemplo n.º 3
0
        static unsafe AppHandle()
        {
            NativeCommon.Initialize();
            SessionHandle.InstallCallbacks();

            NativeMethods.LogMessageCallback logMessage   = HandleLogMessage;
            NativeMethods.UserCallback       userLogin    = HandleUserCallback;
            NativeMethods.VoidTaskCallback   taskCallback = HandleTaskCompletion;
            NativeMethods.BsonCallback       bsonCallback = HandleBsonCallback;

            GCHandle.Alloc(logMessage);
            GCHandle.Alloc(userLogin);
            GCHandle.Alloc(taskCallback);
            GCHandle.Alloc(bsonCallback);

            //// This is a hack due to a mixup of what OS uses as platform/SDK and what is displayed in the UI.
            //// The original code is below:
            ////
            //// string platform;
            //// string platformVersion;
            //// var platformRegex = new Regex("^(?<platform>[^0-9]*) (?<version>[^ ]*)", RegexOptions.Compiled);
            //// var osDescription = platformRegex.Match(RuntimeInformation.OSDescription);
            //// if (osDescription.Success)
            //// {
            ////     platform = osDescription.Groups["platform"].Value;
            ////     platformVersion = osDescription.Groups["version"].Value;
            //// }
            //// else
            //// {
            ////     platform = Environment.OSVersion.Platform.ToString();
            ////     platformVersion = Environment.OSVersion.VersionString;
            //// }

            var platform        = InteropConfig.Platform;
            var platformVersion = RuntimeInformation.OSDescription;

            // TODO: temp - remove that once we're out of beta
            var sdkVersion = "10.2.0-beta.2"; // InteropConfig.SDKVersion.ToString(3);

            NativeMethods.initialize(
                platform, platform.IntPtrLength(),
                platformVersion, platformVersion.IntPtrLength(),
                sdkVersion, sdkVersion.IntPtrLength(),
                userLogin, taskCallback, bsonCallback, logMessage);

            HttpClientTransport.Install();
        }