-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathEnumerableExtensions.cs
More file actions
35 lines (34 loc) · 1.42 KB
/
Copy pathEnumerableExtensions.cs
File metadata and controls
35 lines (34 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.IO;
using System.Linq;
using JetBrains.Annotations;
// ReSharper disable once CheckNamespace
namespace System.Collections.Generic
{
internal static class EnumerableExtensions
{
internal static IEnumerator<string> GetArgumentsEnumerator([NotNull]this IEnumerable<string> arguments)
{
var enumerable = arguments as IList<string> ?? arguments.ToList();
var firstArgument = enumerable.FirstOrDefault();
if (string.IsNullOrEmpty(firstArgument))
{
return enumerable.GetEnumerator();
}
if (firstArgument.StartsWith("@", StringComparison.CurrentCulture))
{
if (!firstArgument.StartsWith("@@", StringComparison.CurrentCulture))
{
var responseFileName = firstArgument.Remove(0, 1);
if (Path.GetExtension(responseFileName) == ".rsp" && File.Exists(responseFileName))
{
var responseFileContent = File.ReadAllLines(responseFileName);
return responseFileContent.AsEnumerable().GetEnumerator();
}
}
var firstArgumentWithoutAt = firstArgument.Remove(0, 1);
return new[] { firstArgumentWithoutAt }.Concat(enumerable.Skip(1)).GetEnumerator();
}
return enumerable.GetEnumerator();
}
}
}