Exemplo n.º 1
0
		public static Value Evaluate(INode code, Process context)
		{
			if (context.SelectedStackFrame == null && context.SelectedThread.MostRecentStackFrame == null)
				// This can happen when needed 'dll' is missing.  This causes an exception dialog to be shown even before the applicaiton starts
				throw new GetValueException("Can not evaluate because the process has no managed stack frames");
			
			return Evaluate(code, context.GetCurrentExecutingFrame());
		}
        /// <summary>
        /// Gets variable of given name.
        /// Returns null if unsuccessful. Can throw GetValueException.
        /// <exception cref="GetValueException">Thrown when evaluation fails. Exception message explains reason.</exception>
        /// </summary>
        public Value GetValueFromName(string variableName)
        {
            if (!CanEvaluate)
            {
                return(null);
            }

            var frame = debuggedProcess.GetCurrentExecutingFrame();

            if (frame == null)
            {
                return(null);
            }
            object data = debuggerDecompilerService.GetLocalVariableIndex(frame.MethodInfo.DeclaringType.MetadataToken,
                                                                          frame.MethodInfo.MetadataToken,
                                                                          variableName);

            // evaluate expression
            return(ExpressionEvaluator.Evaluate(variableName, SupportedLanguage.CSharp, frame, data));
        }