示例#1
0
        PullResponse IWSEnumerationContract.Pull(PullRequest request)
        {
            ResourceUriHeader resourceUriHeader = OperationContextProxy.Current.FindHeader <ResourceUriHeader>();

            //TODO: Fault
            PullDelegate handler = _pullRoutingTable[resourceUriHeader.ResourceUri];

            return(handler(request));
        }
示例#2
0
        /// <summary>
        /// Pull all pending deltas asynchronously (or get a new snapshot if this database hasn't been loaded before) and apply them.
        /// Will throw a DatastoreException if this method is called when any local changes are pending
        /// </summary>
        public void PullAsync(PullDelegate success, Action <Exception> failure)
        {
            foreach (var table in _tables)
            {
                if (table.Value.HasPendingChanges)
                {
                    failure(new DatastoreException("Unable to pull in remote changes to Datastore with id " + Id + " as it has local changes pending"));
                    return;
                }
            }

            if (Rev == 0)
            {
                IApiRequest request = GetSnapshotRequest();
                request.GetResponseAsync(response =>
                {
                    try
                    {
                        GetSnapshotResponse(response);
                        success();
                    }
                    catch (Exception ex)
                    {
                        failure(ex);
                    }
                });
            }
            else
            {
                IApiRequest request = GetDeltasRequest();
                request.GetResponseAsync(response =>
                {
                    try
                    {
                        GetDeltasResponse(response);
                        success();
                    }
                    catch (Exception ex)
                    {
                        failure(ex);
                    }
                });
            }
        }