예제 #1
0
 public RemoteDatabaseChanges(
     string url,
     string apiKey,
     ICredentials credentials,
     HttpJsonRequestFactory jsonRequestFactory,
     DocumentConvention conventions,
     ReplicationInformer replicationInformer,
     Action onDispose,
     Func <string, Etag, string[], OperationMetadata, Task <bool> > tryResolveConflictByUsingRegisteredConflictListenersAsync)
 {
     ConnectionStatusChanged = LogOnConnectionStatusChanged;
     id = Interlocked.Increment(ref connectionCounter) + "/" +
          Base62Util.Base62Random();
     this.url                 = url;
     this.credentials         = new OperationCredentials(apiKey, credentials);
     this.jsonRequestFactory  = jsonRequestFactory;
     this.conventions         = conventions;
     this.replicationInformer = replicationInformer;
     this.onDispose           = onDispose;
     this.tryResolveConflictByUsingRegisteredConflictListenersAsync = tryResolveConflictByUsingRegisteredConflictListenersAsync;
     Task = EstablishConnection()
            .ObserveException()
            .ContinueWith(task =>
     {
         task.AssertNotFailed();
         return((IDatabaseChanges)this);
     });
 }
예제 #2
0
        protected RemoteChangesClientBase(
            string url,
            string apiKey,
            ICredentials credentials,
            HttpJsonRequestFactory jsonRequestFactory,
            TConventions conventions,
            Action onDispose)
        {
            // Precondition
            var api = this as TChangesApi;

            if (api == null)
            {
                throw new InvalidCastException(string.Format("The derived class does not implements {0}. Make sure the {0} interface is implemented by this class.", typeof(TChangesApi).Name));
            }

            ConnectionStatusChanged = LogOnConnectionStatusChanged;

            id = Interlocked.Increment(ref connectionCounter) + "/" + Base62Util.Base62Random();

            this.url                = url;
            this.credentials        = new OperationCredentials(apiKey, credentials);
            this.jsonRequestFactory = jsonRequestFactory;
            this.onDispose          = onDispose;
            Conventions             = conventions;
            Task = EstablishConnection()
                   .ObserveException()
                   .ContinueWith(task =>
            {
                task.AssertNotFailed();
                return(this as TChangesApi);
            });
        }
예제 #3
0
 public RemoteDatabaseChanges(string url, ICredentials credentials, HttpJsonRequestFactory jsonRequestFactory, DocumentConvention conventions, Action onDispose)
 {
     id = Interlocked.Increment(ref connectionCounter) + "/" +
          Base62Util.Base62Random();
     this.url                = url;
     this.credentials        = credentials;
     this.jsonRequestFactory = jsonRequestFactory;
     this.conventions        = conventions;
     this.onDispose          = onDispose;
     Task = EstablishConnection()
            .ObserveException();
 }
예제 #4
0
 public RemoteDatabaseChanges(string url, ICredentials credentials, HttpJsonRequestFactory jsonRequestFactory, DocumentConvention conventions, ReplicationInformer replicationInformer, Action onDispose)
 {
     id = Interlocked.Increment(ref connectionCounter) + "/" +
          Base62Util.Base62Random();
     this.url                 = url;
     this.credentials         = credentials;
     this.jsonRequestFactory  = jsonRequestFactory;
     this.conventions         = conventions;
     this.replicationInformer = replicationInformer;
     this.onDispose           = onDispose;
     Task = EstablishConnection()
            .ObserveException()
            .ContinueWith(task =>
     {
         task.AssertNotFailed();
         return((IDatabaseChanges)this);
     });
 }