Files
opensim/OpenSim/Region/Environment/StorageManager.cs
lbsa71 8f0b03597b * Modernized ScriptManager to new interface-based module calls.
* 'remove redundant this qualifier' ftw
2007-09-19 00:30:55 +00:00

53 lines
1.6 KiB
C#

using System;
using System.Reflection;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment
{
public class StorageManager
{
private IRegionDataStore m_dataStore;
public IRegionDataStore DataStore
{
get { return m_dataStore; }
}
public StorageManager(IRegionDataStore storage)
{
m_dataStore = storage;
}
public StorageManager(string dllName, string dataStoreFile, string dataStoreDB)
{
MainLog.Instance.Verbose("DATASTORE", "Attempting to load " + dllName);
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
Type typeInterface = pluginType.GetInterface("IRegionDataStore", true);
if (typeInterface != null)
{
IRegionDataStore plug =
(IRegionDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise(dataStoreFile, dataStoreDB);
m_dataStore = plug;
MainLog.Instance.Verbose("DATASTORE", "Added IRegionDataStore Interface");
}
typeInterface = null;
}
}
pluginAssembly = null;
//TODO: Add checking and warning to make sure it initialised.
}
}
}