add IEnum<T>.JoinWith, use it to clean up a bunch of things
This commit is contained in:
@@ -171,5 +171,10 @@ namespace OpenRA
|
||||
++v;
|
||||
return v;
|
||||
}
|
||||
|
||||
public static string JoinWith<T>(this IEnumerable<T> ts, string j)
|
||||
{
|
||||
return string.Join(j, ts.Select(t => t.ToString()).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace OpenRA.FileFormats
|
||||
if (f.FieldType.IsArray)
|
||||
{
|
||||
var elems = ((Array)v).OfType<object>();
|
||||
return string.Join(",", elems.Select(a => a.ToString()).ToArray());
|
||||
return elems.JoinWith(",");
|
||||
}
|
||||
|
||||
return v.ToString();
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace OpenRA.FileFormats
|
||||
if (throwErrors)
|
||||
if (noInherit.ContainsValue(false))
|
||||
throw new YamlException("Bogus yaml removals: {0}".F(
|
||||
string.Join(", ", noInherit.Where(x => !x.Value).Select(x => x.Key).ToArray())));
|
||||
noInherit.Where(x => !x.Value).JoinWith(", ")));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public static string WriteToString(this MiniYamlNodes y)
|
||||
{
|
||||
return string.Join("\n", y.ToLines(true).Select(x => x.TrimEnd()).ToArray());
|
||||
return y.ToLines(true).Select(x => x.TrimEnd()).JoinWith("\n");
|
||||
}
|
||||
|
||||
public static IEnumerable<string> ToLines(this MiniYamlNodes y, bool lowest)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", BitAllocator<T>.GetStrings(Value).ToArray());
|
||||
return BitAllocator<T>.GetStrings(Value).JoinWith(",");
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return Value.GetHashCode(); }
|
||||
|
||||
Reference in New Issue
Block a user