Ejemplo n.º 1
0
        private static void HandleSubscribeForObjectsCallback(IntPtr results, IntPtr taskCompletionSource, NativeException ex)
        {
            var handle = GCHandle.FromIntPtr(taskCompletionSource);
            var tcs    = (TaskCompletionSource <ResultsHandle>)handle.Target;

            try
            {
                if (ex.type == RealmExceptionCodes.NoError)
                {
                    var resultsHandle = new ResultsHandle(null, results);
                    tcs.TrySetResult(resultsHandle);
                }
                else
                {
                    tcs.TrySetException(ex.Convert());
                }
            }
            finally
            {
                handle.Free();
            }
        }
Ejemplo n.º 2
0
        public static SubscriptionHandle Create(ResultsHandle results, string name, long?timeToLive, bool update, string[] inclusions)
        {
            var nativeInclusions = Array.Empty <Native.StringValue>();

            if (inclusions != null)
            {
                nativeInclusions = inclusions.Select(i => new Native.StringValue {
                    Value = i
                }).ToArray();
            }

            // We use -1 to signal "no value"
            var handle = NativeMethods.subscribe(
                results,
                name, name?.Length ?? -1,
                timeToLive ?? -1,
                update,
                nativeInclusions, inclusions?.Length ?? -1,
                out var ex);

            ex.ThrowIfNecessary();

            return(new SubscriptionHandle(handle));
        }
Ejemplo n.º 3
0
 public static extern IntPtr subscribe(
     ResultsHandle results,
     [MarshalAs(UnmanagedType.LPWStr)] string name,
     IntPtr name_len,
     [MarshalAs(UnmanagedType.I1)] bool has_name,
     out NativeException ex);