예제 #1
0
        public IntPtr ResolveReference(ThreadSafeReference reference)
        {
            if (reference.Handle.IsClosed)
            {
                throw new RealmException("Can only resolve a thread safe reference once.");
            }

            NativeException nativeException;
            IntPtr          result;

            switch (reference.ReferenceType)
            {
            case ThreadSafeReference.Type.Object:
                result = NativeMethods.resolve_object_reference(this, reference.Handle, out nativeException);
                break;

            case ThreadSafeReference.Type.List:
                result = NativeMethods.resolve_list_reference(this, reference.Handle, out nativeException);
                break;

            case ThreadSafeReference.Type.Query:
                result = NativeMethods.resolve_query_reference(this, reference.Handle, out nativeException);
                break;

            default:
                throw new NotSupportedException();
            }
            nativeException.ThrowIfNecessary();

            reference.Handle.Close();

            return(result);
        }
        public IntPtr ResolveReference(ThreadSafeReference reference)
        {
            if (reference.Handle.IsClosed)
            {
                throw new RealmException("Can only resolve a thread safe reference once.");
            }

            var result = NativeMethods.resolve_reference(this, reference.Handle, reference.ReferenceType, out var nativeException);

            nativeException.ThrowIfNecessary();

            reference.Handle.Close();

            return(result);
        }
예제 #3
0
        public IntPtr ResolveReference(ThreadSafeReference reference)
        {
            if (reference.Handle.IsClosed)
            {
                throw new RealmException("Can only resolve a thread safe reference once.");
            }

            NativeException nativeException;
            var             result = reference.ReferenceType switch
            {
                ThreadSafeReference.Type.Object => NativeMethods.resolve_object_reference(this, reference.Handle, out nativeException),
                ThreadSafeReference.Type.List => NativeMethods.resolve_list_reference(this, reference.Handle, out nativeException),
                ThreadSafeReference.Type.Query => NativeMethods.resolve_query_reference(this, reference.Handle, out nativeException),
                ThreadSafeReference.Type.Set => NativeMethods.resolve_set_reference(this, reference.Handle, out nativeException),
                _ => throw new NotSupportedException(),
            };

            nativeException.ThrowIfNecessary();

            reference.Handle.Close();

            return(result);
        }