Skip to content

Commit

Permalink
Display no files text when no files loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Ivon committed Mar 9, 2021
1 parent f48fa8f commit 7406646
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Deploy/buildlpx.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@set version=6.5.1
@set version=6.5.2
@set zip="%ProgramFiles%\7-Zip\7z.exe"
@set output="CsvLINQPadDriver.%version%.lpx6"

Expand Down
11 changes: 10 additions & 1 deletion Src/CsvLINQPadDriver/CsvDataContextDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ public override string GetConnectionDescription(IConnectionInfo cxInfo)
{
var parsedFiles = new CsvDataContextDriverProperties(cxInfo).ParsedFiles.ToImmutableList();
var parsedFilesCount = parsedFiles.Count;
return $"{FileUtils.GetLongestCommonPrefixPath(parsedFiles)}{(parsedFilesCount > 1 ? $" ({"file".ToQuantity(parsedFilesCount)})" : string.Empty)}";

return $"{FileUtils.GetLongestCommonPrefixPath(parsedFiles)}{GetFilesCountString()}";

string GetFilesCountString() =>
parsedFilesCount switch
{
0 => "(no files)",
1 => string.Empty,
_ => $" ({"file".ToQuantity(parsedFilesCount)})"
};
}

public override bool ShowConnectionDialog(IConnectionInfo cxInfo, ConnectionDialogOptions connectionDialogOptions)
Expand Down
1 change: 0 additions & 1 deletion Src/CsvLINQPadDriver/CsvDataContextDriverProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public string Files

public IEnumerable<string> ParsedFiles =>
Regex.Split(Files, @"[\r\n]+")
.Select(fileName => fileName.Trim())
.GetFilesOnly()
.Distinct(StringComparer.InvariantCultureIgnoreCase);

Expand Down
8 changes: 4 additions & 4 deletions Src/CsvLINQPadDriver/CsvLINQPadDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/i2van/CsvLINQPadDriver</RepositoryUrl>
<PackageIcon>NuGetIcon.png</PackageIcon>
<PackageReleaseNotes>Display number of files loaded.</PackageReleaseNotes>
<PackageReleaseNotes>Display no files text when no files loaded.</PackageReleaseNotes>
<Copyright>Copyright © Martin Dobroucký 2013-2014, Ivan Ivon 2021</Copyright>
<AssemblyVersion>6.5.1.0</AssemblyVersion>
<FileVersion>6.5.1.0</FileVersion>
<Version>6.5.1</Version>
<AssemblyVersion>6.5.2.0</AssemblyVersion>
<FileVersion>6.5.2.0</FileVersion>
<Version>6.5.2</Version>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<ApplicationIcon>Connection.ico</ApplicationIcon>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions Src/CsvLINQPadDriver/Helpers/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ private static CsvParser CreateCsvParser(string fileName, char csvSeparator)

public static IEnumerable<string> GetFilesOnly(this IEnumerable<string> paths) =>
paths
.Select(p => p.Trim())
.Where(p => !p.StartsWith("#"))
.Where(p => !string.IsNullOrWhiteSpace(p));
.Select(path => path.Trim())
.Where(path => !path.StartsWith("#"))
.Where(path => !string.IsNullOrWhiteSpace(path));

private static IEnumerable<string> EnumFiles(string path)
{
Expand Down

0 comments on commit 7406646

Please sign in to comment.