Dynamix.Storage provides static methods for creating, editing and storing Dynamix objects.
Editing objects
// Get an editable copy of an object
public static T Edit<T>( T o ) where T : Object
// Get an editable copy of an object and perform an editing action on it
public static T Edit<T>( T o, Action<T> edit ) where T : Object
// Get an editable copy of an object, perform an editing action on it
// and store it in the database
public static T EditAndSave<T>( T o, Action<T> edit ) where T : Object
Storing objects in the database
public static T Save<T>( T o ) where T : Object
Creating new objects
The following methods are used to create new objects, optionally editing and saving them.
// Create a new editable object, equivalent to "new T()"
public static T Create<T>() where T : Object, new()
// Create a new editable object and perform an editing action on it
public static T Create<T>( Action<T> edit ) where T : Object, new()
// Create a new editable object, perform an editing action on it
// and store it in the database
public static T CreateAndSave<T>( Action<T> edit ) where T : Object, new()
Cloning existing objects
The following methods are used to create copies of existing objects, optionally editing and saving them.
// Copy an object into a new editable object
public static T Clone<T>( T source ) where T : Object
// Copy an object into a new editable object
// and perform an editing action on the new object
public static T Clone<T>( T source, Action<T> edit ) where T : Object
// Copy an object into a new editable object,
// perform an editing action on the new object
// and store it in the database
public static T CloneAndSave<T>( T source, Action<T> edit ) where T : Object, new()
Deleting objects
Deletes one or more objects from the database, along with all objects that are owned by them.
public static void Delete( Object o )
public static void Delete( IEnumerable<Object> objects )
Get single instance object
These methods get or create a single instance object of the supplied type.
If no object exists a single instance is created in the database.
If multiple objects exists, an exception is thrown.
public static Object GetInstance( Type type )
public static T GetInstance<T>() where T : Object, ISingleton
GetStoredVersion
Get the database version of the object, usually used for comparing with an in-memory object copy
public static T GetStoredVersion<T>( T o ) where T : Object