Added IRegistryCore and RegistryCore to OpenSim.Framework.

Added a ApplicationRegistry to OpenSimBase.
Changed LoadRegionsPlugin so it registers itself to that application registry.
Added a event to LoadRegionsPlugin, that is triggered when it creates a new scene ,although maybe this event should actually be in opensimBase incase other plugins are creating regions (like the RemoteAdminPlugin).
This commit is contained in:
MW
2009-02-26 20:01:20 +00:00
parent c0c1a31f61
commit 33e7c09b7b
8 changed files with 153 additions and 48 deletions

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public interface IRegistryCore
{
T Get<T>();
void RegisterInterface<T>(T iface);
bool TryGet<T>(out T iface);
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class RegistryCore
{
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
/// <summary>
/// Register an Module interface.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="iface"></param>
public void RegisterInterface<T>(T iface)
{
lock (m_moduleInterfaces)
{
if (!m_moduleInterfaces.ContainsKey(typeof(T)))
{
m_moduleInterfaces.Add(typeof(T), iface);
}
}
}
public bool TryGet<T>(out T iface)
{
if (m_moduleInterfaces.ContainsKey(typeof(T)))
{
iface = (T)m_moduleInterfaces[typeof(T)];
return true;
}
iface = default(T);
return false;
}
public T Get<T>()
{
return (T)m_moduleInterfaces[typeof(T)];
}
}
}