Example #1
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();
        }
Example #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        = 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();
        }
Example #3
0
        public static void Initialize()
        {
            NativeMethods.LogMessageCallback logMessage      = HandleLogMessage;
            NativeMethods.UserCallback       userLogin       = HandleUserCallback;
            NativeMethods.VoidTaskCallback   taskCallback    = HandleTaskCompletion;
            NativeMethods.BsonCallback       bsonCallback    = HandleBsonCallback;
            NativeMethods.ApiKeysCallback    apiKeysCallback = HandleApiKeysCallback;

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

            //// 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: https://github.com/realm/realm-dotnet/issues/2218 remove that once we're out of beta or fix the issue.
            var sdkVersion = "10.2.0-beta.3"; // InteropConfig.SDKVersion.ToString(3);

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