示例#1
0
        private static void DocObserverCallback(C4DocumentObserver *observer, C4Slice docID, ulong sequence, void *context)
        {
            var idHolder = GCHandle.FromIntPtr((IntPtr)context);
            var id       = (Guid)idHolder.Target;
            var obj      = _ObserverMap[id];

            obj._callback?.Invoke(observer, docID.CreateString(), sequence, obj._context);
        }
 private static void SocketRequestClose(C4Socket *socket, int status, C4Slice message)
 {
     try {
         _externalRequestClose?.Invoke(socket, status, message.CreateString());
     } catch (Exception e) {
         _error?.Invoke(socket, new Exception("Error requesting socket close", e));
     }
 }
 private static void SocketOpened(C4Socket *socket, C4Address *address, C4Slice options)
 {
     try {
         _externalOpen?.Invoke(socket, address, options);
     } catch (Exception e) {
         _error?.Invoke(socket, new Exception("Error opening to socket", e));
         Native.c4socket_closed(socket, new C4Error(C4ErrorCode.UnexpectedError));
     }
 }
        public static C4Key *c4key_withBytes(byte[] bytes)
        {
            fixed(void *b = bytes)
            {
                var c4 = new C4Slice(b, (ulong)bytes.Length);

                return(NativeRaw.c4key_withBytes(c4));
            }
        }
示例#5
0
        public static bool c4blob_create(C4BlobStore *store, byte[] content, C4BlobKey *outKey, C4Error *outError)
        {
            fixed(byte *p = content)
            {
                var c4Slice = new C4Slice(p, (ulong)content.Length);

                return(NativeRaw.c4blob_create(store, c4Slice, outKey, outError));
            }
        }
示例#6
0
 public C4ReplicatorParameters(C4ReplicatorMode push, C4ReplicatorMode pull, C4Slice optionsFleece, void *context)
 {
     this.push         = push;
     this.pull         = pull;
     optionsDictFleece = optionsFleece;
     validationFunc    = Marshal.GetFunctionPointerForDelegate(ReplicatorParameters.NativeValidateFunction);
     onStatusChanged   = Marshal.GetFunctionPointerForDelegate(ReplicatorParameters.NativeChangedCallback);
     onDocumentError   = Marshal.GetFunctionPointerForDelegate(ReplicatorParameters.NativeErrorCallback);
     callbackContext   = context;
 }
示例#7
0
 private static void OnError(C4Replicator *replicator, bool pushing, C4Slice docID, C4Error error,
                             bool transient, void *context)
 {
     // Don't throw exceptions here, it will bubble up to native code
     try {
         var id  = (long)context;
         var obj = _StaticMap[id];
         obj._errorCallback?.Invoke(pushing, docID.CreateString(), error, transient, obj._context);
     } catch (Exception) { }
 }
示例#8
0
 private static bool PerformValidate(C4Slice docID, FLDict *body, void *context)
 {
     // Don't throw exceptions here, it will bubble up to native code
     try {
         var id     = (long)context;
         var obj    = _StaticMap[id];
         var result = obj._validateFunction?.Invoke(docID.CreateString(), (IntPtr)body, obj._context);
         return(result.HasValue && result.Value);
     } catch (Exception) {
         return(false);
     }
 }
示例#9
0
 public static extern C4QueryEnumerator *c4query_run(C4Query *query,
                                                     C4QueryOptions *options,
                                                     C4Slice encodedParams,
                                                     C4Error *outError);
示例#10
0
 public static extern C4Document *c4doc_update(C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error);
示例#11
0
 public static extern ulong c4doc_getExpiration(C4Database *db, C4Slice docId);
示例#12
0
 public static extern bool c4db_purgeDoc(C4Database *database, C4Slice docID, C4Error *outError);
示例#13
0
 public static extern int c4doc_purgeRevision(C4Document *doc, C4Slice revID, C4Error *outError);
示例#14
0
 public static extern uint c4db_getRemoteDBID(C4Database *db, C4Slice remoteAddress, [MarshalAs(UnmanagedType.U1)] bool canCreate, C4Error *outError);
示例#15
0
 public static extern C4RawDocument *c4raw_get(C4Database *database, C4Slice storeName, C4Slice docID, C4Error *outError);
示例#16
0
 public static extern bool c4doc_selectNextPossibleAncestorOf(C4Document *doc, C4Slice revID);
示例#17
0
 public static extern bool c4doc_selectCommonAncestorRevision(C4Document *doc, C4Slice rev1ID, C4Slice rev2ID);
示例#18
0
 public static extern bool c4raw_put(C4Database *database, C4Slice storeName, C4Slice key, C4Slice meta, C4Slice body, C4Error *outError);
示例#19
0
 public static extern uint c4rev_getGeneration(C4Slice revID);
 public static extern bool c4blob_keyFromString(C4Slice str, C4BlobKey *x);
示例#21
0
 public static extern bool c4doc_resolveConflict(C4Document *doc, C4Slice winningRevID, C4Slice losingRevID, C4Slice mergedBody, C4RevisionFlags mergedFlags, C4Error *error);
 public static extern C4BlobStore *c4blob_openStore(C4Slice dirPath, C4DatabaseFlags flags, C4EncryptionKey *encryptionKey, C4Error *outError);
示例#23
0
 public static extern bool c4doc_setExpiration(C4Database *db, C4Slice docId, ulong timestamp, C4Error *outError);
 public static extern C4BlobKey c4blob_computeKey(C4Slice contents);
示例#25
0
 public static extern C4Document *c4doc_create(C4Database *db, C4Slice docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error);
 public static extern bool c4blob_create(C4BlobStore *store, C4Slice contents, C4BlobKey *expectedKey, C4BlobKey *outKey, C4Error *error);
示例#27
0
 public static extern C4Query *c4query_new(C4Database *db, C4Slice queryExpression, C4Slice sortExpression, C4Error *outError);
示例#28
0
 public static extern C4Document *c4doc_get(C4Database *database, C4Slice docID, [MarshalAs(UnmanagedType.U1)] bool mustExist, C4Error *outError);
示例#29
0
 public static extern bool c4db_deleteIndex(C4Database *db, C4Slice expression, C4Error *outError);
示例#30
0
 public static extern bool c4doc_selectRevision(C4Document *doc, C4Slice revID, [MarshalAs(UnmanagedType.U1)] bool withBody, C4Error *outError);