extract IsInteractive to separate method

This commit is contained in:
Krzysztof Wicher 2015-11-23 16:31:27 -08:00
parent e8b9a44489
commit db9f9dfa6e

View file

@ -20,38 +20,38 @@ namespace Microsoft.DotNet.Tools.Run
public string Project = null; public string Project = null;
public IReadOnlyList<string> Args = null; public IReadOnlyList<string> Args = null;
bool _isInteractive = false;
ProjectContext _context; ProjectContext _context;
List<string> _args; List<string> _args;
public int Start() public int Start()
{ {
CalculateDefaultsForNonAssigned(); if (IsInteractive())
if (_isInteractive)
{ {
return RunInteractive(Project); return RunInteractive(Project);
} }
else else
{ {
CalculateDefaultsForNonAssigned();
return RunExecutable(); return RunExecutable();
} }
} }
private void CalculateDefaultsForNonAssigned() private bool IsInteractive()
{ {
if (!string.IsNullOrEmpty(Project)) if (!string.IsNullOrEmpty(Project))
{ {
if (File.Exists(Project) && (Path.GetExtension(Project) == ".csx")) if (File.Exists(Project) && (Path.GetExtension(Project).ToLowerInvariant() == ".csx"))
{ {
_isInteractive = true; return true;
return;
} }
} }
else
{ return false;
Project = Directory.GetCurrentDirectory(); }
}
private void CalculateDefaultsForNonAssigned()
{
Project = Directory.GetCurrentDirectory();
if (string.IsNullOrWhiteSpace(Configuration)) if (string.IsNullOrWhiteSpace(Configuration))
{ {