Seeing everything that is persisted
(Created page with "There is something called a ChainedPersistenceHandlerBase that you can inherit from and intercept everything that goes to and from the database. You can use override as you s...")
 
No edit summary
Line 2: Line 2:


You can use override as you see fit:
You can use override as you see fit:
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4869107b-10cc-491f-ac1b-58d4e717a2b4" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li><span style="color:#0000ff">namespace</span> Eco.Persistence</li> <li style="background: #f3f3f3">{</li> <li>  <span style="color:#008000">// Summary:</span></li> <li style="background: #f3f3f3">  <span style="color:#008000">//     Base class for persistence handler.</span></li> <li>  <span style="color:#008000">//</span></li> <li style="background: #f3f3f3">  <span style="color:#008000">// Remarks:</span></li> <li>  <span style="color:#008000">//     Use this class to implement your own IPersistenceHandler override any of</span></li> <li style="background: #f3f3f3">  <span style="color:#008000">//     the virtual methods to inject your own behaviour and copy the Install-procedure</span></li> <li>  <span style="color:#008000">//     (from the source of this class) for a convenient way to install the new class</span></li> <li style="background: #f3f3f3">  <span style="color:#008000">//     in the EcoSpace.</span></li> <li>  <span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">ChainedPersistenceHandlerBase</span> : <span style="color:#2b91af">IPersistenceHandler</span></li> <li style="background: #f3f3f3">  {</li> <li>    <span style="color:#0000ff">public</span> ChainedPersistenceHandlerBase(<span style="color:#2b91af">IEcoTypeSystem</span> typeSystem);</li> <li style="background: #f3f3f3">&nbsp;</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> IsPersistent { <span style="color:#0000ff">get</span>; }</li> <li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">int</span> MaxSavedVersion { <span style="color:#0000ff">get</span>; }</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#2b91af">IPersistenceHandler</span> NextPersistenceHandler { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }</li> <li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> SupportsSync { <span style="color:#0000ff">get</span>; }</li> <li>    <span style="color:#0000ff">protected</span> <span style="color:#2b91af">IEcoTypeSystem</span> TypeSystem { <span style="color:#0000ff">get</span>; }</li> <li style="background: #f3f3f3">&nbsp;</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">LocatorArrayEventHandler</span> ObjectsUpdated;</li> <li style="background: #f3f3f3">&nbsp;</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> Fetch(<span style="color:#2b91af">ICollection</span>&lt;<span style="color:#2b91af">Locator</span>&gt; locators, <span style="color:#0000ff">int</span>[] members, <span style="color:#2b91af">FetchStrategy</span> FetchStrategy);</li> <li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#2b91af">ICollection</span>&lt;<span style="color:#2b91af">Locator</span>&gt; FetchLinksWithObjects(<span style="color:#2b91af">ICollection</span>&lt;<span style="color:#2b91af">Locator</span>&gt; objects, <span style="color:#2b91af">IAssociationEnd</span> assocEnd);</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#2b91af">ICollection</span>&lt;<span style="color:#2b91af">Locator</span>&gt; GetAllWithCondition(<span style="color:#2b91af">AbstractCondition</span> condition, <span style="color:#0000ff">int</span> maxAnswers, <span style="color:#0000ff">int</span> offset);</li> <li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#2b91af">Datablock</span> GetValueWithCondition(<span style="color:#2b91af">AbstractCondition</span> condition, <span style="color:#0000ff">int</span> maxAnswers, <span style="color:#0000ff">int</span> offset);</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> RetrieveChanges(<span style="color:#0000ff">out</span> <span style="color:#2b91af">DBChangeCollection</span> ignoredChanges);</li> <li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#2b91af">DateTime</span> TimeForVersion(<span style="color:#0000ff">int</span> version);</li> <li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> UpdateDatabaseWithList(<span style="color:#2b91af">ICollection</span>&lt;<span style="color:#2b91af">Locator</span>&gt; locators);</li> <li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">int</span> VersionAtTime(<span style="color:#2b91af">DateTime</span> time);</li> <li>  }</li> <li style="background: #f3f3f3">}</li> </ol> </div> </div> </div>


Maybe you have a common base class for all classes in your model, and maybe this class implements an Interface ITrackUpdate, then it would be a good thing to catch all updates and set the datetime…
Maybe you have a common base class for all classes in your model, and maybe this class implements an Interface ITrackUpdate, then it would be a good thing to catch all updates and set the datetime…


We need to install our ChainedPersistenceHandlerBase baseclass. We do this by mixing it in before the current persistencehandler , we do this in the ecospace – before we go active:
We need to install our ChainedPersistenceHandlerBase baseclass. We do this by mixing it in before the current persistencehandler , we do this in the ecospace – before we go active:

Revision as of 16:24, 28 November 2018

There is something called a ChainedPersistenceHandlerBase that you can inherit from and intercept everything that goes to and from the database.

You can use override as you see fit:

  1. namespace Eco.Persistence
  2. {
  3.   // Summary:
  4.   //     Base class for persistence handler.
  5.   //
  6.   // Remarks:
  7.   //     Use this class to implement your own IPersistenceHandler override any of
  8.   //     the virtual methods to inject your own behaviour and copy the Install-procedure
  9.   //     (from the source of this class) for a convenient way to install the new class
  10.   //     in the EcoSpace.
  11.   public class ChainedPersistenceHandlerBase : IPersistenceHandler
  12.   {
  13.     public ChainedPersistenceHandlerBase(IEcoTypeSystem typeSystem);
  14.  
  15.     public bool IsPersistent { get; }
  16.     public virtual int MaxSavedVersion { get; }
  17.     public IPersistenceHandler NextPersistenceHandler { get; set; }
  18.     public bool SupportsSync { get; }
  19.     protected IEcoTypeSystem TypeSystem { get; }
  20.  
  21.     public virtual event LocatorArrayEventHandler ObjectsUpdated;
  22.  
  23.     public virtual void Fetch(ICollection<Locator> locators, int[] members, FetchStrategy FetchStrategy);
  24.     public virtual ICollection<Locator> FetchLinksWithObjects(ICollection<Locator> objects, IAssociationEnd assocEnd);
  25.     public virtual ICollection<Locator> GetAllWithCondition(AbstractCondition condition, int maxAnswers, int offset);
  26.     public virtual Datablock GetValueWithCondition(AbstractCondition condition, int maxAnswers, int offset);
  27.     public virtual void RetrieveChanges(out DBChangeCollection ignoredChanges);
  28.     public virtual DateTime TimeForVersion(int version);
  29.     public virtual void UpdateDatabaseWithList(ICollection<Locator> locators);
  30.     public virtual int VersionAtTime(DateTime time);
  31.   }
  32. }


Maybe you have a common base class for all classes in your model, and maybe this class implements an Interface ITrackUpdate, then it would be a good thing to catch all updates and set the datetime…

We need to install our ChainedPersistenceHandlerBase baseclass. We do this by mixing it in before the current persistencehandler , we do this in the ecospace – before we go active:

This page was edited 78 days ago on 02/10/2024. What links here