aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
diff options
context:
space:
mode:
authorAdam Frisby2009-04-21 04:55:53 +0000
committerAdam Frisby2009-04-21 04:55:53 +0000
commit594c7c3eb13695304c755ec1bc65c5f239754222 (patch)
tree5de4d356929e3afa7efd0045167a92e44f710c21 /OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
parentChange a bad use of a type name as a variable. Thanks, Fly-Man (diff)
downloadopensim-SC_OLD-594c7c3eb13695304c755ec1bc65c5f239754222.zip
opensim-SC_OLD-594c7c3eb13695304c755ec1bc65c5f239754222.tar.gz
opensim-SC_OLD-594c7c3eb13695304c755ec1bc65c5f239754222.tar.bz2
opensim-SC_OLD-594c7c3eb13695304c755ec1bc65c5f239754222.tar.xz
* Implements Extensions to MRM. This allows Region Modules to insert new classes into OpenSim MRM's.
* Example in region module: Scene.GetModuleInterface<IMRMModule>.RegisterExtension<IMyInterface>(this); * In the MRM: //@DEPENDS:MyExtensionModule.dll ... Host.Extensions<IMyInterface>.DoStuff();
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
new file mode 100644
index 0000000..bc159eb
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
@@ -0,0 +1,39 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
5
6namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
7{
8 class ExtensionHandler : IExtension
9 {
10 private readonly Dictionary<Type, object> m_instances;
11
12 public ExtensionHandler(Dictionary<Type, object> instances)
13 {
14 m_instances = instances;
15 }
16
17 public T Get<T>()
18 {
19 return (T) m_instances[typeof (T)];
20 }
21
22 public bool TryGet<T>(out T extension)
23 {
24 if (!m_instances.ContainsKey(typeof(T)))
25 {
26 extension = default(T);
27 return false;
28 }
29
30 extension = Get<T>();
31 return true;
32 }
33
34 public bool Has<T>()
35 {
36 return m_instances.ContainsKey(typeof (T));
37 }
38 }
39}