override public object GetCSLEObjectParmasByType(IType _type, params object[] _parmas) { if (_type == null) { throw new NullReferenceException("LS GetCSLEObjectParmasByType _type = null"); } ILType ilType = _type as ILType; if (ilType != null) { bool hasConstructor = _parmas != null && _parmas.Length != 0; ILTypeInstance res = ilType.Instantiate(!hasConstructor); if (hasConstructor) { IMethod ilm = ilType.GetConstructor(_parmas.Length); mApp.Invoke(ilm, res, _parmas); } return(res); } return(null); }
/// <summary> /// Create a instance of the specified type /// </summary> /// <param name="type">Full Name of the type</param> /// <param name="args">Arguments for the constructor</param> /// <returns></returns> public ILTypeInstance Instantiate(string type, object[] args = null) { IType t; if (mapType.TryGetValue(type, out t)) { ILType ilType = t as ILType; if (ilType != null) { bool hasConstructor = args != null && args.Length != 0; var res = ilType.Instantiate(!hasConstructor); if (hasConstructor) { var ilm = ilType.GetConstructor(args.Length); Invoke(ilm, res, args); } return(res); } } return(null); }
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { List <IType> param = new List <IType>(); for (int i = 0; i < types.Length; i++) { if (types[i] is ILRuntimeType) { param.Add(((ILRuntimeType)types[i]).type); } else { var t = appdomain.GetType(types[i]); if (t == null) { t = appdomain.GetType(types[i].AssemblyQualifiedName); } if (t == null) { throw new TypeLoadException(); } param.Add(t); } } var res = type.GetConstructor(param); if (res != null) { return(((ILMethod)res).ReflectionConstructorInfo); } else { return(null); } }