public static object ChangeType(Script script, ScriptObject par, Type type) { if (type == TYPE_OBJECT) { return(par.ObjectValue); } else { if (par is ScriptUserdata && type == TYPE_TYPE) { return(((ScriptUserdata)par).ValueType); } else if (par is ScriptNumber) { return(ChangeType_impl(par.ObjectValue, type)); } else if (TYPE_DELEGATE.GetTypeInfo().IsAssignableFrom(type)) { if (par is ScriptFunction) { return(script.GetDelegate(type).Call(new ScriptObject[] { par })); } else { return(par.ObjectValue); } } else { return(par.ObjectValue); } } }
public static object ChangeType(Script script, ScriptObject par, Type type) { if (type == TYPE_OBJECT) { return par.ObjectValue; } else { if (par is ScriptUserdata && type == TYPE_TYPE) return ((ScriptUserdata)par).ValueType; else if (par is ScriptNumber) return ChangeType_impl(par.ObjectValue, type); else if (TYPE_DELEGATE.GetTypeInfo().IsAssignableFrom(type)) { if (par is ScriptFunction) return script.GetDelegate(type).Call(new ScriptObject[] { par }); else return par.ObjectValue; } else return par.ObjectValue; } }