No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
Includes support for a EcoSpace cache provider and a mechanism that stores the EcoSpace on TempData during redirect. | Includes support for a EcoSpace cache provider and a mechanism that stores the EcoSpace on TempData during redirect. | ||
Without additions it creates an EcoSpace with the type | Without additions it creates an EcoSpace with the type given when subclassing using a type specifier (EcoController<your ecospace type>). When the controller goes out of scope (i.e. the web page is returned to the client) the EcoSpace is disposed. | ||
===== TempData used for "shelving" ===== | ===== TempData used for "shelving" ===== | ||
Line 10: | Line 10: | ||
The controller instantiated as a result of the redirect then uses UnshelveEcoSpace(), or even simpler, EnsureEcoSpace() on controller creation with the shelfkey passed as route values to the new controller. | The controller instantiated as a result of the redirect then uses UnshelveEcoSpace(), or even simpler, EnsureEcoSpace() on controller creation with the shelfkey passed as route values to the new controller. | ||
On a broken redirect, | On a broken redirect, i.e. the web browser don't complete the redirect to the new view, items will be left "shelved". EcoSpaces placed on the shelf will be disposed or returned to the cache provider if they aren't unshelved within 1 minute. This is done by any subsequent controller using the same session. If the whole session is removed and a garbage collection occurs, shelved EcoSpaces will be disposed or returned to the cache provider. | ||
===== VMClass ===== | ===== VMClass ===== | ||
The EcoController also supports subclasses of VMClass to be used as the controller "model". If you use this for your views, you get | The EcoController also supports subclasses of VMClass to be used as the controller "model". If you use this for your views, you get built in support for validation updating the ModelState of your view. | ||
Note that the redirect functions support passing your VMClass | Note that the redirect functions support passing your VMClass object to the new controller saving rendering time. | ||
===== | ===== EcoSpace cache provider ===== | ||
* Implement the interface IEcoSpaceCacheProvider on the class you use for the cache mechanism. | * Implement the interface IEcoSpaceCacheProvider on the class you use for the cache mechanism. | ||
* The IEcoSpaceCacheProvider should work with objects of a class implementing IEcoSpaceCacheWrapper. You add information in your wrapper to provide the best cached EcoSpace. | * The IEcoSpaceCacheProvider should work with objects of a class implementing IEcoSpaceCacheWrapper. You add information in your wrapper to provide the best cached EcoSpace to controllers. | ||
* Subclass the class EcoSpaceRequestInfo, add attributes that you need for your cache provider. Your cache provider will serve requests using the information in EcoSpaceRequestInfo objects. | * Subclass the class EcoSpaceRequestInfo, add attributes that you need for your cache provider. Your cache provider will serve requests using the information in EcoSpaceRequestInfo objects. | ||
* Subclass EcoController and set EcoSpaceProvider , like this; | * Subclass EcoController and set EcoSpaceProvider , like this; | ||
public TurnkeyController_Base() : base() | public TurnkeyController_Base() : base() | ||
{ | { | ||
EcoSpaceProvider = | EcoSpaceProvider = <your ecospace provider>; // Install the cache/EcoSpace -provider (one for the entire application) | ||
} | } | ||
* Also override GetEcoSpaceRequestInfo() in EcoController and provide the EcoSpaceRequestInfo when called. | * Also override GetEcoSpaceRequestInfo() in EcoController and provide the EcoSpaceRequestInfo when called. | ||
protected override EcoSpaceRequestInfo GetEcoSpaceRequestInfo() | protected override EcoSpaceRequestInfo GetEcoSpaceRequestInfo() | ||
{ | { | ||
return | return <object with information to the cache provider> | ||
} | } |
Revision as of 22:26, 7 July 2017
Implements support for a MVC Controller that uses an EcoSpace for persistence. The EcoController is the base class for all other MDriven controllers.
Includes support for a EcoSpace cache provider and a mechanism that stores the EcoSpace on TempData during redirect.
Without additions it creates an EcoSpace with the type given when subclassing using a type specifier (EcoController<your ecospace type>). When the controller goes out of scope (i.e. the web page is returned to the client) the EcoSpace is disposed.
TempData used for "shelving"
When your controller redirects to a new page, use the function ShelveEcoSpace() to temporarily place the active EcoSpace on TempData. The "shelfkey" is usually the pagename and id combined.
The controller instantiated as a result of the redirect then uses UnshelveEcoSpace(), or even simpler, EnsureEcoSpace() on controller creation with the shelfkey passed as route values to the new controller.
On a broken redirect, i.e. the web browser don't complete the redirect to the new view, items will be left "shelved". EcoSpaces placed on the shelf will be disposed or returned to the cache provider if they aren't unshelved within 1 minute. This is done by any subsequent controller using the same session. If the whole session is removed and a garbage collection occurs, shelved EcoSpaces will be disposed or returned to the cache provider.
VMClass
The EcoController also supports subclasses of VMClass to be used as the controller "model". If you use this for your views, you get built in support for validation updating the ModelState of your view.
Note that the redirect functions support passing your VMClass object to the new controller saving rendering time.
EcoSpace cache provider
- Implement the interface IEcoSpaceCacheProvider on the class you use for the cache mechanism.
- The IEcoSpaceCacheProvider should work with objects of a class implementing IEcoSpaceCacheWrapper. You add information in your wrapper to provide the best cached EcoSpace to controllers.
- Subclass the class EcoSpaceRequestInfo, add attributes that you need for your cache provider. Your cache provider will serve requests using the information in EcoSpaceRequestInfo objects.
- Subclass EcoController and set EcoSpaceProvider , like this;
public TurnkeyController_Base() : base() { EcoSpaceProvider = <your ecospace provider>; // Install the cache/EcoSpace -provider (one for the entire application) }
- Also override GetEcoSpaceRequestInfo() in EcoController and provide the EcoSpaceRequestInfo when called.
protected override EcoSpaceRequestInfo GetEcoSpaceRequestInfo() { return <object with information to the cache provider> }