aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs
diff options
context:
space:
mode:
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}