<< Click to Display Table of Contents >> NShape Concepts
|
While many sophisticated applications will require their own specific repository implementations, many others might served well with the repository implementation delivered with NShape. As the name already tells, this repository caches all diagramming objects and performs an updated against the data source only in the SaveChanges method. The actual loading and saving of objects is encapsulated in separate store classes. Two of them are also part of the framework and allow the application to store diagramming projects in XML file or relational database systems. These are the classes XmlStore and AdoNetStore. The latter has its name because it uses the ADO.NET 2.0 interfaces to communicate with the database server.
The CachedRepository class in fact only implements the caching part. All diagramming objects are stored together with their state (original, updated, deleted) in dictionaries using their id as the key. Newly created objects are stored in separate dictionaries. The whole idea partially resembles the .NET DataSet class. A CachedRepository object can be need not have a store attached to it. When there is no store, all diagramming work is only performed in memory. If the project is to be persisted somewhere, the appropriate store must be connected to the repository cache. The store knows the data source location - a directory for XML and database connection string for ADO.NET - and is capable of serializing the diagramming objects from and to this data source via specialized RepositoryReader and RepositoryWriter classes. The cache implements the IStoreCache interface explicitly for the stores to read and write diagramming objects. This interface is not intended for use by the application.
Due to the fact that the CachedRepository is used as in-memory repository and is therefore store independent, it needs a store for persisting its contents.