29 using System.Runtime.Remoting;
30 using System.Runtime.Remoting.Lifetime;
31 using System.Security.Permissions;
32 using System.Threading;
33 using System.Reflection;
34 using System.Collections;
35 using System.Collections.Generic;
36 using System.Diagnostics;
37 using OpenSim.Region.ScriptEngine.Interfaces;
38 using OpenSim.Region.ScriptEngine.Shared;
39 using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
41 namespace OpenSim.
Region.ScriptEngine.Shared.ScriptBase
43 public partial class ScriptBaseClass : MarshalByRefObject, IScript
45 private Dictionary<string, MethodInfo> inits =
new Dictionary<string, MethodInfo>();
50 ILease lease = (ILease)base.InitializeLifetimeService();
51 if (lease.CurrentState == LeaseState.Initial)
54 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
62 public static bool GCDummy =
false;
73 MethodInfo[] myArrayMethodInfo = GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance);
75 foreach (MethodInfo mi
in myArrayMethodInfo)
77 if (mi.Name.Length > 7 && mi.Name.Substring(0, 7) ==
"ApiType")
79 string type = mi.Name.Substring(7);
91 return (
int)m_Executor.GetStateEventFlags(state);
95 public void ExecuteEvent(
string state,
string FunctionName,
object[] args)
97 m_Executor.ExecuteEvent(state, FunctionName, args);
102 string[] apis =
new string[inits.Count];
103 inits.Keys.CopyTo(apis, 0);
107 private Dictionary<string, object> m_InitialValues =
108 new Dictionary<string, object>();
109 private Dictionary<string, FieldInfo> m_Fields =
110 new Dictionary<string, FieldInfo>();
114 if (!inits.ContainsKey(api))
121 MethodInfo mi = inits[api];
123 Object[] args =
new Object[1];
126 mi.Invoke(
this, args);
128 m_InitialValues = GetVars();
142 Dictionary<string, object> vars =
new Dictionary<string, object>();
144 if (m_Fields == null)
151 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
152 BindingFlags.Public |
153 BindingFlags.Instance |
154 BindingFlags.DeclaredOnly);
156 foreach (FieldInfo field
in fields)
158 m_Fields[field.Name] = field;
160 if (field.FieldType == typeof(
LSL_Types.list))
163 Object[] data =
new Object[v.Data.Length];
164 Array.Copy(v.Data, 0, data, 0, v.Data.Length);
167 vars[field.Name] = c;
169 else if (field.FieldType == typeof(
LSL_Types.LSLInteger) ||
170 field.FieldType == typeof(
LSL_Types.LSLString) ||
171 field.FieldType == typeof(
LSL_Types.LSLFloat) ||
172 field.FieldType == typeof(Int32) ||
173 field.FieldType == typeof(Double) ||
174 field.FieldType == typeof(Single) ||
175 field.FieldType == typeof(String) ||
176 field.FieldType == typeof(Byte) ||
177 field.FieldType == typeof(
short) ||
178 field.FieldType == typeof(
LSL_Types.Vector3) ||
179 field.FieldType == typeof(
LSL_Types.Quaternion))
181 vars[field.Name] = field.GetValue(
this);
188 public void SetVars(Dictionary<string, object> vars)
190 foreach (KeyValuePair<string, object> var
in vars)
192 if (m_Fields.ContainsKey(var.Key))
194 if (m_Fields[var.Key].FieldType == typeof(
LSL_Types.list))
198 v.Data =
new Object[data.Length];
199 Array.Copy(data, 0, v.Data, 0, data.Length);
200 m_Fields[var.Key].SetValue(
this, v);
202 else if (m_Fields[var.Key].FieldType == typeof(
LSL_Types.LSLInteger) ||
203 m_Fields[var.Key].FieldType == typeof(
LSL_Types.LSLString) ||
204 m_Fields[var.Key].FieldType == typeof(
LSL_Types.LSLFloat) ||
205 m_Fields[var.Key].FieldType == typeof(Int32) ||
206 m_Fields[var.Key].FieldType == typeof(Double) ||
207 m_Fields[var.Key].FieldType == typeof(Single) ||
208 m_Fields[var.Key].FieldType == typeof(String) ||
209 m_Fields[var.Key].FieldType == typeof(Byte) ||
210 m_Fields[var.Key].FieldType == typeof(
short) ||
211 m_Fields[var.Key].FieldType == typeof(
LSL_Types.Vector3) ||
212 m_Fields[var.Key].FieldType == typeof(
LSL_Types.Quaternion)
215 m_Fields[var.Key].SetValue(
this, var.Value);
223 SetVars(m_InitialValues);
void SetVars(Dictionary< string, object > vars)
virtual void StateChange(string newState)
int GetStateEventFlags(string state)
Dictionary< string, object > GetVars()
void ExecuteEvent(string state, string FunctionName, object[] args)
void InitApi(string api, IScriptApi data)
override Object InitializeLifetimeService()