internal T GetProperty <T> (string name) { object o = GetProperty(name); ScriptObjectHelper.TryChangeType(o, typeof(T), null, out o); return((T)o); }
internal bool ValidateArguments(MethodInfo mi, object[] args) { if (mi.GetParameters().Length != args.Length) { int required_paramcount = 0; bool optional_param = false; foreach (ParameterInfo p in mi.GetParameters()) { if (IsOptional(p)) { optional_param = true; break; } required_paramcount++; } // if we don't supply enough required arguments, we fail regardless of optional parameters. if (required_paramcount > args.Length) { return(false); } // if we don't have optional parameters, make sure we don't supply more than the required arguments. if (!optional_param && args.Length > required_paramcount) { return(false); } } // TODO: refactor this, the js binder is doing this work already ParameterInfo[] parms = mi.GetParameters(); for (int i = 0; i < parms.Length; i++) { if (IsOptional(parms[i])) { break; } if (args[i] == null) { continue; } Type cstype = parms[i].ParameterType; object ret; if (ScriptObjectHelper.TryChangeType(args[i], cstype, CultureInfo.CurrentUICulture, out ret)) { continue; } } return(true); }