The Persistence service in CAB

Seems nobody is writing down simple examples of how to use the CAB mechanisms, so here is a snippet that might be useful to somebody one day…
[csharp]
public IStatePersistenceService PersistenceService
{
get
{
return Services.Get();
}
}

if (PersistenceService.Contains(“SomeKey”))
Console.WriteLine(PersistenceService.Load(“SomeKey”)["a"].ToString());
else
{
State s = new State(“ab”);
s["a"] = ” Some string you want to persist, e.g. a favorite item.”;
s["b"] = new SomeObjectYouNeedToSave();

PersistenceService.Save(s);
}
[/csharp]

Related Posts

G2's interface hierarchy

Some (self-indulgent) overview of G2's interface hierarchy is available.

Read more

The bare bones of Unity interceptions

The Enterprise Library 4.1 was released together with Unity 1.2 in which a whole interception mechanism was added as part of the aspect-oriented approach to coding and a merge of the policy injection ideas. This little note is just a stepping stone if you wish to play with the new interception namespace.

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

top