public static ITargetMethodInfo OverloadResolve(EvaluationContext context, ILanguage language, ITargetStructType stype, Expression[] types, ArrayList candidates) { // We do a very simple overload resolution here ITargetType[] argtypes = new ITargetType [types.Length]; for (int i = 0; i < types.Length; i++) argtypes [i] = types [i].EvaluateType (context); // Ok, no we need to find an exact match. ITargetMethodInfo match = null; foreach (ITargetMethodInfo method in candidates) { bool ok = true; for (int i = 0; i < types.Length; i++) { if (method.Type.ParameterTypes [i].TypeHandle != argtypes [i].TypeHandle) { ok = false; break; } } if (!ok) continue; // We need to find exactly one match if (match != null) return null; match = method; } return match; }
// Creates the object of the specified class, and wraps a tree node // around it ObjectInfo CreateObjectInternal(IDragDropItem sourceNode, ObjectTreeNode targetNode) { _sourceNode = sourceNode; _targetNode = targetNode; Object obj = null; ConstructorInfo constructor = null; ConstructorInfo[] constructors = null; try { if (sourceNode is ITargetType && !((ITargetType)sourceNode).IsMember) { ITargetType targetTypeNode = (ITargetType)sourceNode; Type t = targetTypeNode.Type; if (!CheckCreateType(t, sourceNode, !THROW)) { return(null); } // String is a special case, we just do it with the // string parameter value if (t.Equals(typeof(String))) { ObjectBrowser.ParamPanel.GetParameterValues(!Constants.IGNORE_EXCEPTION, ParamPanel.SET_MEMBER, out obj); } else { constructors = t.GetConstructors(ReflectionHelper.ALL_BINDINGS); if (constructors.Length == 0) { obj = Activator.CreateInstance(t); } else { constructor = FindConstructor(constructors); if (constructor == null) { return(null); } } } } else if (sourceNode is MemberTreeNode) { constructor = (ConstructorInfo)((MemberTreeNode)sourceNode).Member; } else if (sourceNode is AssemblyTreeNode) { CreateFromEntry(((AssemblyTreeNode)sourceNode).Assembly); // This gets finished when the event processing // is finished and we go to idle return(null); } else { throw new Exception("Bug: invalid node being dragged: " + sourceNode.GetType()); } // Invoke the constructor with the parameters // defined in the param panel if (obj == null) { Object fieldPropValue; obj = constructor.Invoke(ObjectBrowser.ParamPanel.GetParameterValues(!Constants.IGNORE_EXCEPTION, ParamPanel.SET_MEMBER, out fieldPropValue)); } return(FinishObjectCreation(obj)); } catch (Exception ex) { Exception showException = ex; // Remove the useless wrapper exception if (showException is TargetInvocationException) { showException = ex.InnerException; } ErrorDialog.Show(showException, "Error creating object", MessageBoxIcon.Error); return(null); } }
public TypeExpression(ITargetType type) { this.type = type; resolved = true; }