当前位置: 首页>>代码示例>>C#>>正文


C# Debugger.Value类代码示例

本文整理汇总了C#中Debugger.Value的典型用法代码示例。如果您正苦于以下问题:C# Value类的具体用法?C# Value怎么用?C# Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Value类属于Debugger命名空间,在下文中一共展示了Value类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNullBasedArray

 public static NamedValue GetNullBasedArray(Value val)
 {
     IList<FieldInfo> flds = val.Type.GetFields();
     if (flds.Count != 3) return null;
     foreach (FieldInfo fi in flds)
         if (fi.Name == "NullBasedArray") return fi.GetValue(val);
     return null;
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:8,代码来源:Utility.cs

示例2: CreateDebugListExpression

		// Object graph visualizer: collection support temp disabled (porting to new NRefactory).
		/*
		/// <summary>
		/// Creates an expression which, when evaluated, creates a List&lt;T&gt; in the debugee
		/// filled with contents of IEnumerable&lt;T&gt; from the debugee.
		/// </summary>
		/// <param name="iEnumerableVariable">Expression for IEnumerable variable in the debugee.</param>
		/// <param name="itemType">
		/// The generic argument of IEnumerable&lt;T&gt; that <paramref name="iEnumerableVariable"/> implements.</param>
		public static Expression CreateDebugListExpression(Expression iEnumerableVariable, DebugType itemType, out DebugType listType)
		{
			// is using itemType.AppDomain ok?
			listType = DebugType.CreateFromType(itemType.AppDomain, typeof(System.Collections.Generic.List<>), itemType);
			var iEnumerableType = DebugType.CreateFromType(itemType.AppDomain, typeof(IEnumerable<>), itemType);
			// explicitely cast the variable to IEnumerable<T>, where T is itemType
			Expression iEnumerableVariableExplicitCast = new CastExpression(iEnumerableType.GetTypeReference() , iEnumerableVariable, CastType.Cast);
			return new ObjectCreateExpression(listType.GetTypeReference(), iEnumerableVariableExplicitCast.SingleItemList());
		}*/
		
		/// <summary>
		/// Evaluates 'new List&lt;T&gt;(iEnumerableValue)' in the debuggee.
		/// </summary>
		public static Value CreateListFromIEnumerable(Value iEnumerableValue)
		{
			ParameterizedType iEnumerableType;
			IType itemType;
			if (!iEnumerableValue.Type.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
				throw new GetValueException("Value is not IEnumerable");
			return ValueNode.CreateListFromIEnumerable(iEnumerableType, iEnumerableValue).GetPermanentReferenceOfHeapValue();
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:30,代码来源:DebuggerHelpers.cs

示例3: GetMemberValue

		/// <summary> Get the value of given member. </summary>
		/// <param name="objectInstance">null if member is static</param>
		public static Value GetMemberValue(Value objectInstance, MemberInfo memberInfo, Value[] arguments)
		{
			arguments = arguments ?? new Value[0];
			if (memberInfo is FieldInfo) {
				if (arguments.Length > 0) throw new GetValueException("Arguments can not be used for a field");
				return GetFieldValue(objectInstance, (FieldInfo)memberInfo);
			} else if (memberInfo is PropertyInfo) {
				return GetPropertyValue(objectInstance, (PropertyInfo)memberInfo, arguments);
			} else if (memberInfo is MethodInfo) {
				return InvokeMethod(objectInstance, (MethodInfo)memberInfo, arguments);
			}
			throw new DebuggerException("Unknown member type: " + memberInfo.GetType());
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:Value.Object.cs

示例4: CheckObject

		static void CheckObject(Value objectInstance, MemberInfo memberInfo)
		{
			if (!memberInfo.IsStatic) {
				if (objectInstance == null) {
					throw new DebuggerException("No target object specified");
				}
				if (objectInstance.IsNull) {
					throw new GetValueException("Null reference");
				}
				//if (!objectInstance.IsObject) // eg Array.Length can be called
				if (!memberInfo.DeclaringType.IsInstanceOfType(objectInstance)) {
					throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName);
				}
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:Value.Object.cs

示例5: GetValue

		/// <summary>
		/// Given an object of correct type, get the value of this field
		/// </summary>
		public MemberValue GetValue(Value objectInstance) {
			if (objectInstance != null)
			return new MemberValue(
				this,
				this.Process,
				new IExpirable[] {objectInstance},
				new IMutable[] {objectInstance},
				delegate { return GetCorValue(objectInstance); }
			);
			else return
			new MemberValue(
				this,
				this.Process,
				new IExpirable[0],
				new IMutable[0] ,
				delegate { return GetCorValue(objectInstance); }
			);
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:21,代码来源:FieldInfo.cs

示例6: GetImageListIndex

 public static int GetImageListIndex(Value val)
 {
     try
     {
         if (val.IsObject)
         {
             return 0; // Class
         }
         else
         {
             return 1; // Field
         }
     }
     catch (System.Exception e)
     {
         return 1;
     }
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:18,代码来源:LocalVars.cs

示例7: Exception

		internal Exception(Thread thread)
		{
			creationTime = DateTime.Now;
			this.process = thread.Process;
			this.thread = thread;
			corValue = thread.CorThread.CurrentException;
			exceptionType = thread.CurrentExceptionType;
			Value runtimeValue = new Value(process,
			                               new IExpirable[] {process.PauseSession},
			                               new IMutable[] {},
			                               delegate { return corValue; } );
			NamedValue nv = runtimeValue.GetMember("_message");
			if (!nv.IsNull)
			message = nv.AsString;
			else message = runtimeValue.Type.FullName;
			if (thread.LastFunctionWithLoadedSymbols != null) {
				location = thread.LastFunctionWithLoadedSymbols.NextStatement;
			}
			
			callstack = "";
			int callstackItems = 0;
			if (!nv.IsNull)
			foreach(Function function in thread.Callstack) {
				if (callstackItems >= 100) {
					callstack += "...\n";
					break;
				}
				
				SourcecodeSegment loc = function.NextStatement;
				callstack += function.Name + "()";
				if (loc != null) {
					callstack += " - " + loc.SourceFullFilename + ":" + loc.StartLine + "," + loc.StartColumn;
				}
				callstack += "\n";
				callstackItems++;
			}
			
			type = runtimeValue.Type.FullName;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:39,代码来源:Exception.cs

示例8: InjectInterpreter

		bool InjectInterpreter()
		{
			if (!DebuggerService.IsDebuggerLoaded) {
				PrintLine(ResourceService.GetString("ICSharpCode.BooInterpreter.Debuggee.ErrorDebuggerNotLoaded"));
				return false;
			}
			WindowsDebugger winDebugger = DebuggerService.CurrentDebugger as WindowsDebugger;
			if (winDebugger == null) {
				PrintLine(ResourceService.GetString("ICSharpCode.BooInterpreter.Debuggee.ErrorIncompatibleDebugger"));
				return false;
			}
			if (winDebugger.DebuggedProcess == null) {
				PrintLine(ResourceService.GetString("ICSharpCode.BooInterpreter.Debuggee.ErrorNoProgramDebugged"));
				return false;
			}
			process = winDebugger.DebuggedProcess;
			process.Expired += delegate { interpreter = null; };
			process.LogMessage -= OnDebuggerLogMessage;
			process.LogMessage += OnDebuggerLogMessage;
			
			Value assembly;
			// Boo.Lang.Interpreter.dll
			string path = Path.Combine(Path.GetDirectoryName(typeof(InterpreterContext).Assembly.Location), "Boo.Lang.Interpreter.dll");
			assembly = LoadAssembly(path);
			// Debugger.BooInterpreter.dll
			assembly = LoadAssembly(typeof(DebugeeInteractiveInterpreter).Assembly.Location);
			Value interpreterType = Eval.NewString(process, typeof(DebugeeInteractiveInterpreter).FullName);
			interpreter = Eval.InvokeMethod(process, typeof(Assembly), "CreateInstance", assembly, new Value[] {interpreterType});
			interpreter_localVariable = interpreter.GetMember("localVariable");
			RunCommand(
				"import System\n" + 
				"import System.IO\n" +
				"import System.Text\n" +
				"interpreter.RememberLastValue = true\n" +
				"interpreter.Print = def(msg): System.Diagnostics.Debugger.Log(0xB00, \"DebugeeInterpreterContext.PrintLine\", msg)");
			
			return true;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:38,代码来源:DebugeeInterpreterContext.cs

示例9: ValuesAsCorDebug

		static ICorDebugValue[] ValuesAsCorDebug(Value[] values)
		{
			ICorDebugValue[] valuesAsCorDebug = new ICorDebugValue[values.Length];
			for(int i = 0; i < values.Length; i++) {
				valuesAsCorDebug[i] = values[i].CorValue;
			}
			return valuesAsCorDebug;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:8,代码来源:Eval.cs

示例10: NewObject

		public static Value NewObject(Thread evalThread, IMethod constructor, Value[] constructorArguments)
		{
			return AsyncNewObject(evalThread, constructor, constructorArguments).WaitForResult();
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:4,代码来源:Eval.cs

示例11: AsyncInvokeMethod

		public static Eval AsyncInvokeMethod(Thread evalThread, IMethod method, Value thisValue, Value[] args)
		{
			return new Eval(
				evalThread,
				"Function call: " + method.FullName,
				delegate(Eval eval) {
					MethodInvokeStarter(eval, method, thisValue, args);
				}
			);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:10,代码来源:Eval.cs

示例12: NotifyEvaluationComplete

		internal void NotifyEvaluationComplete(bool successful)
		{
			// Eval result should be ICorDebugHandleValue so it should survive Continue()
			if (state == EvalState.EvaluatedTimeOut) {
				return;
			}
			if (corEval.GetResult() == null) {
				state = EvalState.EvaluatedNoResult;
			} else {
				if (successful) {
					state = EvalState.EvaluatedSuccessfully;
				} else {
					state = EvalState.EvaluatedException;
				}
				result = new Value(AppDomain, corEval.GetResult());
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:17,代码来源:Eval.cs

示例13: FormatDebugValue

		/// <summary>
		/// Formats current Value according to the given format, specified by <see cref="System.Diagnostics.DebuggerDisplayAttribute"/>.
		/// </summary>
		/// <param name="debugFormat">Format to use</param>
		/// <returns>Formatted string.</returns>
		/// <remarks>
		/// Not all possible expressions are supported, but only a simple set.
		/// Otherwise we would have to support any C# expression.
		/// </remarks>
		static string FormatDebugValue(Thread evalThread, Value value, string debugFormat)
		{
			StringBuilder formattedOutput = new StringBuilder();
			StringBuilder currentFieldName = new StringBuilder();
			bool insideFieldName = false;
			bool ignoringRestOfExpression = false;
			bool insideMethodBrackets = false;
			bool isMethodName = false;
			bool escapeNextChar = false;
			for (int i = 0; i < debugFormat.Length; i++) {
				char thisChar = debugFormat[i];
				
				if (!escapeNextChar && (thisChar == '{')) {
					insideFieldName = true;
				} else if (!escapeNextChar && (thisChar == '}')) {
					// Insert contents of specified member, if we can find it, otherwise we display "?"
					string memberValueStr = "?";
					
					// Decide if we want a method or field/property
					Predicate<IUnresolvedMember> isNeededMember;
					if (isMethodName) {
						// We only support methods without parameters here!
						isNeededMember = m => (m.Name == currentFieldName.ToString())
							&& (m.SymbolKind == SymbolKind.Method)
							&& (((IUnresolvedMethod) m).Parameters.Count == 0);
					} else {
						isNeededMember = m => (m.Name == currentFieldName.ToString())
							&& ((m.SymbolKind == SymbolKind.Field) || (m.SymbolKind == SymbolKind.Property));
					}
					
					IMember member = value.type.GetMembers(isNeededMember).FirstOrDefault();
					if (member != null) {
						Value memberValue = value.GetMemberValue(evalThread, member);
						memberValueStr = memberValue.InvokeToString(evalThread);
					}
					
					formattedOutput.Append(memberValueStr);
					
					insideFieldName = false;
					ignoringRestOfExpression = false;
					insideMethodBrackets = false;
					isMethodName = false;
					currentFieldName.Clear();
				} else if (!escapeNextChar && (thisChar == '\\')) {
					// Next character will be escaped
					escapeNextChar = true;
				} else if (insideFieldName && (thisChar == '(')) {
					insideMethodBrackets = true;
				} else if ((thisChar == ')') && insideMethodBrackets) {
					insideMethodBrackets = false;
					isMethodName = true;
					
					// Everything following the brackets will be ignored
					ignoringRestOfExpression = true;
				} else if (insideFieldName && !Char.IsDigit(thisChar) && !Char.IsLetter(thisChar)) {
					// Char seems not to belong to a field name, ignore everything from now on
					ignoringRestOfExpression = true;
				} else {
					if (insideFieldName) {
						if (!ignoringRestOfExpression)
							currentFieldName.Append(thisChar);
					} else {
						formattedOutput.Append(thisChar);
					}
					escapeNextChar = false;
				}
			}
			
			return formattedOutput.ToString();
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:79,代码来源:Value.cs

示例14: SetPropertyValue

		/// <summary> Set the value of the property using the set accessor </summary>
		public Value SetPropertyValue(Thread evalThread, IProperty propertyInfo, Value[] arguments, Value newValue)
		{
			return SetPropertyValue(evalThread, this, propertyInfo, arguments, newValue);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:5,代码来源:Value.cs

示例15: IsInstanceOfType

		/// <summary> Determines whether the given object is instance of the
		/// current type or can be implicitly cast to it </summary>
		public bool IsInstanceOfType(Value objectInstance)
		{
			return objectInstance.Type.Equals(this) ||
			       objectInstance.Type.IsSubclassOf(this);
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:7,代码来源:DebugType.cs


注:本文中的Debugger.Value类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。