• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Debugger.Value类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetFieldCorValue

		static ICorDebugValue GetFieldCorValue(Thread contextThread, Value objectInstance, IField fieldInfo)
		{
			// Current frame is used to resolve context specific static values (eg. ThreadStatic)
			ICorDebugFrame curFrame = null;
			if (contextThread != null && contextThread.MostRecentStackFrame != null && contextThread.MostRecentStackFrame.CorILFrame != null) {
				curFrame = contextThread.MostRecentStackFrame.CorILFrame;
			}
			
			try {
				if (fieldInfo.IsStatic) {
					return (fieldInfo.DeclaringType).ToCorDebug().GetStaticFieldValue(fieldInfo.GetMetadataToken(), curFrame);
				} else {
					return objectInstance.CorObjectValue.GetFieldValue((fieldInfo.DeclaringType).ToCorDebug().GetClass(), fieldInfo.GetMetadataToken());
				}
			} catch (COMException e) {
				// System.Runtime.InteropServices.COMException (0x80131303): A class is not loaded. (Exception from HRESULT: 0x80131303)
				if ((uint)e.ErrorCode == 0x80131303)
					throw new GetValueException("Class " + fieldInfo.DeclaringType.FullName + " is not loaded");
				throw new GetValueException("Can not get value of field", e);
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:21,代码来源:Value.cs


示例17: GetPropertyValue

		/// <summary> Get the value of the property using the get accessor </summary>
		public static Value GetPropertyValue(Thread evalThread, Value objectInstance, IProperty propertyInfo, params Value[] arguments)
		{
			CheckObject(objectInstance, propertyInfo);
			
			if (!propertyInfo.CanGet) throw new GetValueException("Property does not have a get method");
			
			return Value.InvokeMethod(evalThread, objectInstance, propertyInfo.Getter, arguments);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:9,代码来源:Value.cs


示例18: Box

		// Box value type
		public Value Box(Thread evalThread)
		{
			byte[] rawValue = this.CorGenericValue.GetRawValue();
			// The type must not be a primive type (always true in current design)
			ICorDebugReferenceValue corRefValue = Eval.NewObjectNoConstructor(evalThread, this.Type).CorReferenceValue;
			// Make the reference to box permanent
			corRefValue = ((ICorDebugHeapValue2)corRefValue.Dereference()).CreateHandle(CorDebugHandleType.HANDLE_STRONG);
			// Create new value
			Value newValue = new Value(appDomain, corRefValue);
			// Copy the data inside the box
			newValue.CorGenericValue.SetRawValue(rawValue);
			return newValue;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:14,代码来源:Value.cs


示例19: SetValue

		/// <summary> Copy the acutal value from some other Value object </summary>
		public void SetValue(Thread evalThread, Value newValue)
		{
			ICorDebugValue newCorValue = newValue.CorValue;
			
			if (this.CorValue is ICorDebugReferenceValue) {
				if (!(newCorValue is ICorDebugReferenceValue))
					newCorValue = newValue.Box(evalThread).CorValue;
				((ICorDebugReferenceValue)this.CorValue).SetValue(((ICorDebugReferenceValue)newCorValue).GetValue());
			} else {
				this.CorGenericValue.SetRawValue(newValue.CorGenericValue.GetRawValue());
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:13,代码来源:Value.cs


示例20: AsyncInvokeMethod

		/// <summary> Asynchronously invoke the method </summary>
		public static Eval AsyncInvokeMethod(Thread evalThread, Value objectInstance, IMethod methodInfo, params Value[] arguments)
		{
			CheckObject(objectInstance, methodInfo);
			
			return Eval.AsyncInvokeMethod(
				evalThread,
				(IMethod)methodInfo,
				methodInfo.IsStatic ? null : objectInstance,
				arguments ?? new Value[0]
			);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:12,代码来源:Value.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Datatypes.Rectangle类代码示例发布时间:2022-05-24
下一篇:
C# Debugger.Process类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap