by

SimplePersist v1.0 – A Simple Object Persistance Library

Often times when writing apps, I hate writing framework code to support persisting objects and structures to disk. So, I wrote a quick and dirty little library that allows you to persist and restore any object from disk. It’s made available in open-source form under the zlib license written in C#. There are three commands, Put, Get and Delete. Put takes an arbitrary object and saves it, Get retrieves all objects of the type given to it and Delete deletes and instance of an object.

// create a persistance manager
PersistManager mgr = new
PersistManager();

// create a few classes I want to save
ExampleClass example1 = new
ExampleClass();
ExampleClass example2 =
new
ExampleClass();
example2.Firstname = “Otherfname”;
example2.Lastname = “otherlastname”;

// save them down
mgr.Put(example1);
mgr.Put(example2);

// get them back
object[] saved = mgr.Get(typeof
(ExampleClass));
foreach(ExampleClass o in
saved)
{
Console.WriteLine(o.Firstname);
}

Download SimplePersist v1.0.