Permalink
Browse files

for loop removal.

  • Loading branch information...
1 parent 761e31e commit 92131e783f2fde56729825f878cd25ad4d470ee6 @drunkcod committed Feb 2, 2011
Showing with 7 additions and 12 deletions.
  1. +7 −12 ConeTestNamer.cs
View
@@ -1,6 +1,7 @@
using System.Text.RegularExpressions;
using System.Reflection;
using System.Linq;
+using System;
namespace Cone
{
@@ -12,9 +13,7 @@ public class ConeTestNamer
public string NameFor(MethodBase method) {
var baseName = GetNameOf(method);
var parameters = method.GetParameters();
- var displayParameters = new string[parameters.Length];
- for(int i = 0; i != parameters.Length; ++i)
- displayParameters[i] = parameters[i].Name;
+ var displayParameters = Array.ConvertAll(parameters, x => x.Name);
return string.Format(baseName, displayParameters);
}
@@ -29,22 +28,18 @@ public class ConeTestNamer
var baseName = GetNameOf(method);
if (arguments == null)
return baseName;
+ var displayArguments = DisplayArguments(arguments);
if(IsFormatString(baseName))
- return string.Format(baseName, DisplayArguments(arguments));
- return string.Format("{0}({1})", baseName, FormatArguments(arguments));
+ return string.Format(baseName, displayArguments);
+ return string.Format("{0}({1})", baseName, FormatArguments(displayArguments));
}
- object[] DisplayArguments(object[] arguments) {
- var displayArguments = new object[arguments.Length];
- for (int i = 0; i != arguments.Length; ++i)
- displayArguments[i] = Format(arguments[i]);
- return displayArguments;
- }
+ object[] DisplayArguments(object[] arguments) { return Array.ConvertAll(arguments, Format); }
object Format(object obj) { return formatter.AsWritable(obj); }
string FormatArguments(object[] arguments) {
- return string.Join(", ", DisplayArguments(arguments).Select(x => x.ToString()).ToArray());
+ return string.Join(", ", Array.ConvertAll(DisplayArguments(arguments), x => x.ToString()));
}
bool IsFormatString(string s) {

0 comments on commit 92131e7

Please sign in to comment.