本文整理汇总了C#中System.Reflection.ParameterInfo.IsReturnValue方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.IsReturnValue方法的具体用法?C# ParameterInfo.IsReturnValue怎么用?C# ParameterInfo.IsReturnValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.IsReturnValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendParameter
/// <summary>
/// Appends a parameter to the buffer.
/// </summary>
/// <param name="parameter">
/// Information about the parameter to append.
/// </param>
/// <param name="argument">
/// The argument that was passed to the parameter.
/// </param>
private void AppendParameter(ParameterInfo parameter, object argument)
{
bool sensitive = this.sensitiveMethod || parameter.IsDefined(typeof(SensitiveDataAttribute), false);
try
{
if (!parameter.IsReturnValue())
{
this.buffer.Append(parameter.Name);
}
this.buffer.Append('=');
if (argument == null)
{
this.buffer.Append("<null>");
return;
}
#if DEBUG
// in debug builds sensitive data may be traced with the appropriate switch; in release builds it may not
if (sensitive && !StyleCopTrace.Switch.TraceSensitiveData)
#else
if (sensitive)
#endif
{
this.buffer.Append("<obscured>");
return;
}
// if the argument is a string then print it with quotes
if (argument is string)
{
this.buffer.Append("\"" + argument + "\"");
return;
}
// if the argument is a type then print it as a typeof
if (argument is Type)
{
this.buffer.Append("typeof(" + ((Type)argument).Name + ")");
return;
}
// if the argument is a primitive (or pseudo-primitive) type then print it 'as is'
Type argumentType = argument.GetType();
if (argumentType.IsPrimitive || argumentType == typeof(decimal))
{
this.buffer.Append(argument);
return;
}
// if it has an overridden ToString method print it in curly brackets
MethodInfo stringMethod = argumentType.GetMethod("ToString", BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null);
if (stringMethod.GetBaseDefinition().DeclaringType != stringMethod.DeclaringType)
{
this.buffer.Append("{" + argument + "}");
return;
}
// if the argument type has a DebuggerDisplayAttribute then format and print in square brackets
DebuggerDisplayAttribute displayAttribute =
(DebuggerDisplayAttribute)argumentType.GetCustomAttributes(typeof(DebuggerDisplayAttribute), true).FirstOrDefault();
if (displayAttribute != null)
{
MatchEvaluator evaluator = match =>
{
string memberName = match.Value.Replace("{", null).Replace("}", null);
PropertyInfo propertyInfo = argumentType.GetProperty(
memberName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
if (propertyInfo != null)
{
return Convert.ToString(propertyInfo.GetValue(argument, null), CultureInfo.InvariantCulture);
}
FieldInfo fieldInfo;
Type typeToInspect = argumentType;
do
{
fieldInfo = typeToInspect.GetField(memberName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
typeToInspect = typeToInspect.BaseType;
}
while (fieldInfo == null && typeToInspect != typeof(object));
return fieldInfo != null ? Convert.ToString(fieldInfo.GetValue(argument), CultureInfo.InvariantCulture) : "?";
};
string displayString = DebuggerDisplayFormatRegex.Replace(displayAttribute.Value, evaluator);
this.buffer.Append('[');
this.AppendTypeName(argumentType);
this.buffer.Append(": ").Append(displayString).Append(']');
//.........这里部分代码省略.........