/// <summary> /// List all dropbox datastores /// </summary> /// <param name="options">Whether to retrieve a locally cached version, or to recheck with dropbox</param> /// <returns>A list of all Dropbox datastores</returns> public IEnumerable <Datastore> List(DatastoreQueryOptions options = DatastoreQueryOptions.UseCached) { if (string.IsNullOrEmpty(_token) || options == DatastoreQueryOptions.ForceRefresh) { IApiRequest request = ListRequest(); var response = request.GetResponse(); ListResponse(response); } return(_datastores.Values); }
/// <summary> /// Gets a datastore if it already exists, otherwise it is created /// </summary> /// <param name="id">The Dropbox id of the datastore</param> /// <param name="options">Whether to retrieve a locally cached version, or to recheck with dropbox</param> /// <returns>The existing or newly created datastore</returns> public Datastore GetOrCreate(string id, DatastoreQueryOptions options = DatastoreQueryOptions.UseCached) { Datastore store; if (!_datastores.TryGetValue(id, out store) || options == DatastoreQueryOptions.ForceRefresh) { IApiRequest request = GetOrCreateRequest(id); ApiResponse response = request.GetResponse(); store = GetOrCreateResponse(id, store, response); } return(store); }
/// <summary> /// Retrieve a datastore object from dropbox asynchronously /// </summary> /// <param name="id">The id of the datastore</param> /// <param name="options">Whether to retrieve a locally cached version, or to recheck with dropbox</param> /// <returns></returns> public async Task <Datastore> GetAsync(string id, DatastoreQueryOptions options = DatastoreQueryOptions.UseCached) { Datastore store; if (!_datastores.TryGetValue(id, out store) || options == DatastoreQueryOptions.ForceRefresh) { IApiRequest request = GetRequest(id); var response = await request.GetResponseAsync(); store = GetResponse(id, store, response); } return(store); }
/// <summary> /// Retrieve a datastore object from dropbox asynchronously /// </summary> /// <param name="id">The id of the datastore</param> /// <param name="options">Whether to retrieve a locally cached version, or to recheck with dropbox</param> /// <param name="success">Callback if the method is successful</param> /// <param name="failure">Callback if the method fails</param> /// <returns></returns> public void GetAsync(string id, Action <Datastore> success, Action <Exception> failure, DatastoreQueryOptions options = DatastoreQueryOptions.UseCached) { Datastore store; if (!_datastores.TryGetValue(id, out store) || options == DatastoreQueryOptions.ForceRefresh) { IApiRequest request = GetRequest(id); request.GetResponseAsync(response => { try { store = GetResponse(id, store, response); success(store); } catch (Exception ex) { failure(ex); } }); } else { success(store); } }
/// <summary> /// List all dropbox datastores asynchronously /// </summary> /// <param name="options">Whether to retrieve a locally cached version, or to recheck with dropbox</param> /// <param name="success">Callback if the method is successful</param> /// <param name="failure">Callback if the method fails</param> /// <returns></returns> public void ListAsync(Action <IEnumerable <Datastore> > success, Action <Exception> failure, DatastoreQueryOptions options = DatastoreQueryOptions.UseCached) { if (string.IsNullOrEmpty(_token) || options == DatastoreQueryOptions.ForceRefresh) { IApiRequest request = ListRequest(); request.GetResponseAsync(response => { try { ListResponse(response); success(_datastores.Values); } catch (Exception ex) { failure(ex); } }); } else { success(_datastores.Values); } }