From 33e7c09b7b894551b35fb8ab29133c96a5d7b037 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 26 Feb 2009 20:01:20 +0000 Subject: 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). --- OpenSim/Framework/RegistryCore.cs | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 OpenSim/Framework/RegistryCore.cs (limited to 'OpenSim/Framework/RegistryCore.cs') diff --git a/OpenSim/Framework/RegistryCore.cs b/OpenSim/Framework/RegistryCore.cs new file mode 100644 index 0000000..06732f5 --- /dev/null +++ b/OpenSim/Framework/RegistryCore.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework +{ + public class RegistryCore + { + protected Dictionary m_moduleInterfaces = new Dictionary(); + + /// + /// Register an Module interface. + /// + /// + /// + public void RegisterInterface(T iface) + { + lock (m_moduleInterfaces) + { + if (!m_moduleInterfaces.ContainsKey(typeof(T))) + { + m_moduleInterfaces.Add(typeof(T), iface); + } + } + } + + public bool TryGet(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() + { + return (T)m_moduleInterfaces[typeof(T)]; + } + + } +} -- cgit v1.1