private unsafe C4Slice Execute(C4TryLogicDelegate4 block, int attemptCount) { if (attemptCount > _maxAttempts) { ThrowOrHandle(); } var err = default(C4Error); var retVal = block(&err); if (retVal.buf != null || err.Code == 0) { Exception = null; return(retVal); } Exception = new LiteCoreException(err); if (err.Domain == C4ErrorDomain.ForestDB && err.Code == (int)ForestDBStatus.HandleBusy) { Task.Delay(RetryTime).Wait(); return(Execute(block, attemptCount + 1)); } ThrowOrHandle(); return(retVal); }
private unsafe int Execute(C4TryLogicDelegate3 block, int attemptCount) { if (attemptCount > _maxAttempts) { ThrowOrHandle(); } var err = default(C4Error); var retVal = block(&err); if (retVal >= 0 || err.code == 0) { Exception = null; return(retVal); } Exception = new LiteCoreException(err); if (IsBusy(err)) { Task.Delay(RetryTime).Wait(); return(Execute(block, attemptCount + 1)); } ThrowOrHandle(); return(retVal); }
private unsafe bool Execute(C4TryLogicDelegate1 block, int attemptCount) { if (attemptCount > _maxAttempts) { ThrowOrHandle(); } var err = default(C4Error); if (block(&err) || err.Code == 0) { Exception = null; return(true); } Exception = new LiteCoreException(err); if (err.Domain == C4ErrorDomain.LiteCore && err.Code == (int)LiteCoreError.Busy) { Task.Delay(RetryTime).Wait(); return(Execute(block, attemptCount + 1)); } ThrowOrHandle(); return(false); }
public void TestCreateWithEmptyDBNames() { LiteCoreException e = null;; try { OpenDB(""); } catch (LiteCoreException ex) { e = ex; ex.Error.code.Should().Be((int)C4ErrorCode.WrongFormat, "because the database cannot have an empty name"); ex.Error.domain.Should().Be(C4ErrorDomain.LiteCoreDomain, "because this is a LiteCore error"); } e.Should().NotBeNull("because an exception is expected"); }
public unsafe bool Execute(C4TryLogicDelegate1 block) { var err = default(C4Error); if (block(&err) || err.code == 0) { Exception = null; return(true); } Exception = new LiteCoreException(err); ThrowOrHandle(); return(false); }
public unsafe C4Slice Execute(C4TryLogicDelegate4 block) { var err = default(C4Error); var retVal = block(&err); if (retVal.buf != null || err.code == 0) { Exception = null; return(retVal); } Exception = new LiteCoreException(err); ThrowOrHandle(); return(retVal); }
private void UpdateStateProperties(C4ReplicatorStatus state) { Exception error = null; if (state.error.code > 0) { error = new LiteCoreException(state.error); } _rawStatus = state; var level = (ReplicatorActivityLevel)state.level; var progress = new ReplicatorProgress(state.progress.unitsCompleted, state.progress.unitsTotal); Status = new ReplicatorStatus(level, progress, error); Log.To.Sync.I(Tag, $"{this} is {state.level}, progress {state.progress.unitsCompleted}/{state.progress.unitsTotal}"); }
public void TestDeleteOpeningDBByStaticMethod() { var dir = Directory; var options = new DatabaseConfiguration { Directory = dir }; using (var db = new Database("db", options)) { LiteCoreException e = null; try { Database.Delete("db", dir); } catch (LiteCoreException ex) { e = ex; ex.Error.code.Should().Be((int)C4ErrorCode.Busy, "because an in-use database cannot be deleted"); ex.Error.domain.Should().Be(C4ErrorDomain.LiteCoreDomain, "because this is a LiteCore error"); } e.Should().NotBeNull("because an exception is expected"); } }