public ScriptUserdata CreateUserdata(object obj) { Type type = obj as Type; if (type != null) { if (type.GetTypeInfo().IsEnum) { return(GetEnum(type)); } else if (Util.IsDelegateType(type)) { return(GetDelegate(type)); } else { return(new ScriptUserdataObjectType(this, type, GetScorpioType(type))); } } if (obj is Delegate) { return(new ScriptUserdataDelegate(this, (Delegate)obj)); } else if (obj is BridgeEventInfo) { return(new ScriptUserdataEventInfo(this, (BridgeEventInfo)obj)); } return(new ScriptUserdataObject(this, obj, GetScorpioType(obj.GetType()))); }
public static object ChangeType(Script script, ScriptObject par, Type type) { if (type == TYPE_OBJECT) { return(par.ObjectValue); } else { if (par is ScriptUserdata && Util.IsType(type)) { return(((ScriptUserdata)par).ValueType); } else if (par is ScriptNumber) { return(ChangeType_impl(par.ObjectValue, type)); } else if (Util.IsDelegateType(type)) { if (par is ScriptFunction) { return(script.GetUserdataFactory().GetDelegate(type).Call(new ScriptObject[] { par })); } else { return(par.ObjectValue); } } else { return(par.ObjectValue); } } }