public override string ToString() { return(memberInfo.Name + " = " + typedArgument.ToString()); }
// // Computes the ToString() value for a CustomAttributeTypedArgument struct. // private static String ComputeTypedArgumentString(CustomAttributeTypedArgument cat, bool typed) { Type argumentType = cat.ArgumentType; if (argumentType == null) return cat.ToString(); FoundationTypes foundationTypes = ReflectionCoreExecution.ExecutionDomain.FoundationTypes; Object value = cat.Value; TypeInfo argumentTypeInfo = argumentType.GetTypeInfo(); if (argumentTypeInfo.IsEnum) return String.Format(typed ? "{0}" : "({1}){0}", value, argumentType.FullName); if (value == null) return String.Format(typed ? "null" : "({0})null", argumentType.Name); if (argumentType.Equals(foundationTypes.SystemString)) return String.Format("\"{0}\"", value); if (argumentType.Equals(foundationTypes.SystemChar)) return String.Format("'{0}'", value); if (argumentType.Equals(foundationTypes.SystemType)) return String.Format("typeof({0})", ((Type)value).FullName); else if (argumentType.IsArray) { String result = null; IList<CustomAttributeTypedArgument> array = value as IList<CustomAttributeTypedArgument>; Type elementType = argumentType.GetElementType(); result = String.Format(@"new {0}[{1}] {{ ", elementType.GetTypeInfo().IsEnum ? elementType.FullName : elementType.Name, array.Count); for (int i = 0; i < array.Count; i++) result += String.Format(i == 0 ? "{0}" : ", {0}", ComputeTypedArgumentString(array[i], elementType != foundationTypes.SystemObject)); return result += " }"; } return String.Format(typed ? "{0}" : "({1}){0}", value, argumentType.Name); }