StorageManager.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using OpenSim.Framework;
  5. using OpenSim.Framework.Communications;
  6. using OpenSim.Framework.Servers;
  7. using OpenSim.Region.Capabilities;
  8. using OpenSim.Region.Environment.Scenes;
  9. using OpenSim.Region.Interfaces;
  10. using System.Reflection;
  11. namespace OpenSim.Region.Environment
  12. {
  13. public class StorageManager
  14. {
  15. private IRegionDataStore m_dataStore;
  16. public IRegionDataStore DataStore
  17. {
  18. get
  19. {
  20. return m_dataStore;
  21. }
  22. }
  23. public StorageManager(IRegionDataStore storage)
  24. {
  25. m_dataStore = storage;
  26. }
  27. public StorageManager(string dllName, string dataStoreFile, string dataStoreDB)
  28. {
  29. Assembly pluginAssembly = Assembly.LoadFrom(dllName);
  30. foreach (Type pluginType in pluginAssembly.GetTypes())
  31. {
  32. if (pluginType.IsPublic)
  33. {
  34. Type typeInterface = pluginType.GetInterface("IRegionDataStore", true);
  35. if (typeInterface != null)
  36. {
  37. IRegionDataStore plug = (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
  38. plug.Initialise(dataStoreFile, dataStoreDB);
  39. m_dataStore = plug;
  40. }
  41. typeInterface = null;
  42. }
  43. }
  44. pluginAssembly = null;
  45. //TODO: Add checking and warning to make sure it initialised.
  46. }
  47. }
  48. }