OpenSimMirror/OpenSim/Framework/RegistryCore.cs

55 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class RegistryCore : IRegistryCore
{
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)];
}
public void StackModuleInterface<M>(M mod)
{
}
public T[] RequestModuleInterfaces<T>()
{
return new T[] { default(T) };
}
}
}