public static NameForType ( |
||
t | ||
Результат | string |
public Exception WrongArityException(int reqArity) { string name = Util.NameForType(GetType()); int suffix = name.LastIndexOf("__", StringComparison.Ordinal); // NOt sure if this is necessary return(new ArityException( reqArity, (suffix == -1 ? name : name.Substring(0, suffix)).Replace('_', '-'))); }
public static object InvokeConstructor(Type t, object[] args) { // TODO: Replace with GetContructors/GetMatchingMethodAux IEnumerable <ConstructorInfo> einfos = t.GetConstructors().Where(ci => ci.GetParameters().Length == args.Length); List <ConstructorInfo> infos = new List <ConstructorInfo>(einfos); if (infos.Count == 0) { throw new ArgumentException("NO matching constructor found for " + t.Name); } else if (infos.Count == 1) { ConstructorInfo info = infos[0]; return(info.Invoke(BoxArgs(info.GetParameters(), args))); } else { ConstructorInfo info = null; // More than one with correct arity. Find best match. ConstructorInfo found = null; foreach (ConstructorInfo ci in infos) { ParameterInfo[] pinfos = ci.GetParameters(); if (IsCongruent(pinfos, args)) { if (found == null || Subsumes(pinfos, found.GetParameters())) { found = ci; } } } info = found; if (info == null) { throw new InvalidOperationException(string.Format("Cannot find c-tor for type: {0} with the correct argument type", Util.NameForType(t))); } return(info.Invoke(BoxArgs(info.GetParameters(), args))); } }
public Type importClass(Type t) { string n = Util.NameForType(t); return(importClass(Symbol.intern(n), t)); }