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


C# Value.InvokeToString方法代码示例

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


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

示例1: CreatePropertyFromValue

		private static ObjectProperty CreatePropertyFromValue(string propertyName, Value value)
		{
			ObjectProperty property = new ObjectProperty();
			property.Name = propertyName;
			// property.Expression = ?.Age
			// - cannot use expression,
			// if the value is returned from an enumerator, it has no meaningful expression
			property.IsAtomic = value.Type.IsPrimitive;
			property.IsNull = value.IsNull;
			property.Value = value.IsNull ? "" : value.InvokeToString();
			return property;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:12,代码来源:ObjectValue.cs

示例2: FormatValue

		public static string FormatValue(Thread evalThread, Value val)
		{
			if (val.IsNull) {
				return "null";
			} else if (val.Type.Kind == TypeKind.Array) {
				StringBuilder sb = new StringBuilder();
				sb.Append(new CSharpAmbience().ConvertType(val.Type));
				sb.Append(" {");
				bool first = true;
				int size = val.ArrayLength;
				for (int i = 0; i < size; i++) {
					if (!first) sb.Append(", ");
					first = false;
					sb.Append(FormatValue(evalThread, val.GetElementAtPosition(i)));
				}
				sb.Append("}");
				return sb.ToString();
			} else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection))) {
				StringBuilder sb = new StringBuilder();
				sb.Append(new CSharpAmbience().ConvertType(val.Type));
				sb.Append(" {");
				val = val.GetPermanentReference(evalThread);
				var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).Single();
				int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue;
				for(int i = 0; i < count; i++) {
					if (i > 0) sb.Append(", ");
					var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).Single();
					Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i));
					sb.Append(FormatValue(evalThread, item));
				}
				sb.Append("}");
				return sb.ToString();
			} else if (val.Type.IsKnownType(KnownTypeCode.String) || val.Type.IsPrimitiveType()) {
				return TextWriterTokenWriter.PrintPrimitiveValue(val.PrimitiveValue);
			} else {
				return val.InvokeToString(evalThread);
			}
		}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:38,代码来源:ExpressionEvaluationVisitor.cs

示例3: ValueNode

		/// <summary>
		/// Constructor used by the factory method Create()
		/// </summary>
		/// <param name="val"></param>
		/// <exception cref="System.Management.Automation.GetValueException">
		/// Can be thrown by InvokeToString()
		/// </exception>
		public ValueNode(Value val)
		{
			this.expression = val.Expression;
			
			canSetText = false;
			if (val.Type.IsInteger) {
				canSetText =
					(val.Expression is LocalVariableIdentifierExpression) ||
					(val.Expression is ParameterIdentifierExpression) ||
					(val.Expression is ArrayIndexerExpression) ||
					(val.Expression is MemberReferenceExpression && ((MemberReferenceExpression)val.Expression).MemberInfo is FieldInfo);
			}
			
			this.Image = IconService.GetBitmap("Icons.16x16." + GetImageName(val));
			
			this.Name = val.Expression.CodeTail;
			
			if (DebuggingOptions.Instance.ShowValuesInHexadecimal && val.Type.IsInteger) {
				fullText = String.Format("0x{0:X}", val.PrimitiveValue);
			} else if (val.Type.IsPointer) {
				fullText = String.Format("0x{0:X}", val.PointerAddress);
			} else {
				fullText = val.AsString;
			}
			
			if (val.Type != null) {
				this.Type = val.Type.Name;
			} else {
				this.Type = String.Empty;
			}
			
			// Note that these return enumerators so they are lazy-evaluated
			this.ChildNodes = null;
			if (val.IsNull) {
			} else if (val.Type.IsClass || val.Type.IsValueType) {
				this.ChildNodes = Utils.GetChildNodesOfObject(this.Expression, val.Type);
			} else if (val.Type.IsArray) {
				this.ChildNodes = Utils.GetChildNodesOfArray(this.Expression, val.ArrayDimensions);
			} else if (val.Type.IsPointer) {
				Value deRef = val.Dereference();
				if (deRef != null) {
					this.ChildNodes = new AbstractNode [] { new ValueNode(deRef) };
				}
			}
			
			if (DebuggingOptions.Instance.ICorDebugVisualizerEnabled) {
				AbstractNode info = ICorDebug.GetDebugInfoRoot(val.Process, val.CorValue);
				this.ChildNodes = PrependNode(info, this.ChildNodes);
			}
			
			// Do last since it may expire the object
			if ((val.Type.IsClass || val.Type.IsValueType) && !val.IsNull) {
				fullText = val.InvokeToString();
			}
			
			this.Text = (fullText.Length > 256) ? fullText.Substring(0, 256) + "..." : fullText;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:64,代码来源:ValueNode.cs


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