Figaro - The XML Database for the .NET Framework

You create an XmlManager object by calling its constructor. You destroy a XmlManager object by calling its destructor, either by using the delete operator or by allowing the object to go out of scope (if it was created on the stack). Note that XmlManager is closed and all of its resources released when the last open handle to the object is destroyed.

To construct an XmlManager object, you may or may not provide the destructor with an open FigaroEnv object. If you do instantiate XmlManager with an opened environment handle, then XmlManager will close and destroy that FigaroEnv object for you if you specify AdoptFigaroEnv for the XmlManager constructor.

If you provide a FigaroEnv object to the constructor, then you can use that object to use whatever subsystems that you application may require (see Environment Open Flags for some common subsystems).

If you do not provide an environment object, then XmlManager will implicitly create an environment for you. In this case, the environment will not be configured to use any subsystems and it is only capable of being shared by multiple threads from within the same process. Also, in this case you must identify the on-disk location where you want your containers to reside using one of the following mechanisms:

  • Specify the path to the on-disk location in the container's name.
  • Specify the environment's data location using the DB_HOME environment variable.
In either case, you can pass the XmlManager constructor a ManagerInitOptions argument that controls that object's behavior with regard to the underlying containers (the flag is NOT passed directly to the underlying environment or databases). Valid values are:

For example, to instantiate XmlManager with a default environment:

CopyC#
using (var mgr = new XmlManager())
{
    //do something here
}
And to instantiate an XmlManager using an explicit environment object:
CopyC#
public void ManagerWithEnv()
{
    const EnvOpenOptions flags = EnvOpenOptions.Create |
                            EnvOpenOptions.InitLock |
                            EnvOpenOptions.InitLog |
                            EnvOpenOptions.InitMemoryBufferPool |
                            EnvOpenOptions.InitTransaction |
                            EnvOpenOptions.Recover;
    var env = new FigaroEnv();

    env.Open(root, flags);
    const ManagerInitOptions mgrFlags = ManagerInitOptions.AdoptFigaroEnv |
                                   ManagerInitOptions.AllowAutoOpen |
                                   ManagerInitOptions.AllowExternalAccess;
    var mgr = new XmlManager(env, mgrFlags);
    //let FigaroEnv go by letting XmlManager kill it
    mgr.Dispose();
}

See Also