47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace Sep.Git.Tfs.Core
|
|
{
|
|
public static class Ext
|
|
{
|
|
public static Action<T> And<T>(this Action<T> originalAction, params Action<T> [] additionalActions)
|
|
{
|
|
return x => {
|
|
originalAction(x);
|
|
foreach(var action in additionalActions)
|
|
{
|
|
action(x);
|
|
}
|
|
};
|
|
}
|
|
|
|
public static void SetArguments(this ProcessStartInfo startInfo, params string [] args)
|
|
{
|
|
startInfo.Arguments = String.Join(" ", args.Select(arg => QuoteProcessArgument(arg)).ToArray());
|
|
}
|
|
|
|
private static string QuoteProcessArgument(string arg)
|
|
{
|
|
return arg.Contains(" ") ? ("\"" + arg + "\"") : arg;
|
|
}
|
|
|
|
public static string CombinePaths(string basePath, params string [] pathParts)
|
|
{
|
|
foreach(var part in pathParts)
|
|
{
|
|
basePath = Path.Combine(basePath, part);
|
|
}
|
|
return basePath;
|
|
}
|
|
|
|
public static string FormatForGit(this DateTime date)
|
|
{
|
|
// TODO
|
|
return date.ToString();
|
|
}
|
|
}
|
|
}
|