This project has moved. For the latest updates, please go here.

DataManager

DataManager is the primary contract through which applications use the functionality of AgFx. As it's name implies, it manages the retrieval and availability of data within an application.

The primary usage of DataManager is always via its singleton Current property, and is as follows:

this.DataContext = DataManager.Current.Load<UserVm>(_userid); 

Alternatively , code can be notified of completion or error by supplying Action lambdas:

 

 this.DataContext = DataManager.Current.Load<SearchVm>(id,
                    (svm) =>
                    {
                        complete(svm);
                    },
                    (exception) =>
                    {
                        HandleError(exception);
                    }
                 );

 

In the bottom case, the instance passed into the completion lambda (svm in this case) will be the same as that returned from the Load call.

Clear<T> - Clears the specified item from memory and from the cache.

DeleteCache() - Deletes everything in the cache.

Invalidate<T>() - Sets the specified item to expired, such that the next load request will result in a fetch.

Load<T>() - Loads the specified item

LoadFromCache<T>() - Loads the specified item from the cache only and returns either that value or a default new instance of T.

Refresh<T>() - Refreshes the current item in the cache. This is the equivalent of calling Invalidate then Load.

RegisterProxy<T>() - Registers a proxy for the specified item. A proxy is an instance of T with the same LoadContext identity as an item already handled by AgFx, but the proxy item will also be updated whenever an update occurs to the main instance.

Save<T>() - Pushes a value into the cache and updates the current value.  The DataLoader for T must implement IDataOptimizer.

UnregisterProxy<T>() - Unregisters an instance as a proxy.

IsLoading - True when DataManager is performing a fetch operation for any object it is managing.  This property supports INotifyPropertyChanged, so it can be bound to.

UnhandledError - Event that fires when a fetch or deserialize event throws an exception that is not handled from the originating Load/Refresh call.

Last edited Mar 31, 2011 at 12:36 AM by shawnburke, version 4

Comments

No comments yet.