private ConstructorInfo ComputeCtor() { int numArgs = _args.count(); List <ConstructorInfo> cinfos = new List <ConstructorInfo>(_type.GetConstructors() .Where(x => x.GetParameters().Length == numArgs && x.IsPublic)); if (cinfos.Count == 0) { throw new InvalidOperationException(string.Format("No constructor in type: {0} with {1} arguments", _type.Name, numArgs)); } int index = 0; if (cinfos.Count > 1) { List <ParameterInfo[]> parms = new List <ParameterInfo[]>(cinfos.Count); List <Type> rets = new List <Type>(cinfos.Count); foreach (ConstructorInfo cinfo in cinfos) { parms.Add(cinfo.GetParameters()); rets.Add(_type); } index = HostExpr.GetMatchingParams(".ctor", parms, _args, rets); } ConstructorInfo ctor = index >= 0 ? cinfos[index] : null; if (ctor == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { ((TextWriter)RT.ERR.deref()).WriteLine("Reflection warning, line: {0} - call to {1} ctor can't be resolved.", /* line */ 0, _type.FullName); } return(ctor); }