/// <summary> /// Executes the dot attached node and all afterdot nodes. /// </summary> /// <param name="nextNode">The next node.</param> /// <param name="onWhich">The on which.</param> /// <returns></returns> private object executeDotAttachedNode(ExecutionNode nextNode, object onWhich) { Type onWichType = onWhich.GetType(); printMessageToLogger("Start processing dotNode: " + nextNode.executionText, 1); var parameters = getParameterObjects(nextNode); //NameFilter var possibleMembers = getPossibleMembers(nextNode, onWichType.GetMembers(), parameters); if (possibleMembers.Count == 0) { printMessageToLogger("No possible members for: " + nextNode.executionText, 50); throw new DotItemNotFoundException(); } //overloadFilter possibleMembers = getPossibleMembersFilteringOverloadMethods(parameters, possibleMembers); if (!enableFirstTake && possibleMembers.Count > 1) { printMessageToLogger("To many possibilities found and firstTake not enabled: " + nextNode.executionText, 50); throw new ToManyDotItemsFoundException(); } var chosen = possibleMembers[0]; object result; switch (chosen.MemberType) { case MemberTypes.Property: result = onWichType.GetProperty(chosen.Name).GetValue(chosen, new object[0]); break; case MemberTypes.Field: result = onWichType.GetField(chosen.Name).GetValue(onWhich); break; case MemberTypes.Method: //VIA methodbase result = ((MethodBase)chosen).Invoke(onWhich, parameters.ToArray()); break; case MemberTypes.Constructor: case MemberTypes.NestedType: case MemberTypes.Event: default: throw new NotImplementedException(); break; } if (nextNode.hasPostDotNode()) { printMessageToLogger(nextNode.executionText + " finished & given through to: " + nextNode.getPostDotNode().executionText, 1); return executeDotAttachedNode(nextNode.getPostDotNode(), result); } printMessageToLogger(nextNode.executionText + " finished", 1); return result; }
/// <summary> /// Executes the base node and all afterdot nodes. Basenodes are no methods and have no parameters. /// </summary> /// <param name="firstNode">The first node.</param> /// <returns></returns> private object executeBaseNode(ExecutionNode firstNode) { var executionText = firstNode.executionText; printMessageToLogger("Start processing baseNode: " + firstNode.executionText, 1); List<Object> possibilities = theConsole.myAutoCompleter.getAllFirstBasesObjects(AutoCompleter.getFirstPartOfName((firstNode.executionText))); #region preInterpreterReplacement //DIRECT PREINTERPRETE REPLACEMENT if (myPreInterpreter.getReplacementStringDictionary().Keys.Count > 0 && myPreInterpreter.getReplacementStringDictionary().ContainsKey(firstNode.executionText)) { object preResult; myPreInterpreter.getReplacementStringDictionary().TryGetValue(firstNode.executionText, out preResult); possibilities = new List<object>(1) { preResult }; } #endregion //END DIRECT PREINTERPRETE REPLACEMENT if (possibilities.Count == 0) { printMessageToLogger("No possible base object for: " + executionText, 50); throw new BaseItemNotFoundException(); } if (!enableFirstTake && possibilities.Count > 1) { printMessageToLogger("To many possibilities found and firstTake not enabled: " + executionText, 50); throw new ToManyBaseFoundException(); } if (firstNode.hasPostDotNode()) { printMessageToLogger(executionText + " finished & given through to: " + firstNode.getPostDotNode().executionText, 1); return executeDotAttachedNode(firstNode.getPostDotNode(), possibilities[0]); } printMessageToLogger(executionText + " finished", 1); return possibilities[0]; }