Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for optional passing of mongo-bin location
- Loading branch information
Showing
8 changed files
with
84 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Mongo2Go.Helper | ||
{ | ||
public interface IMongoBinaryLocator | ||
{ | ||
string ResolveBinariesDirectory (); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
|
||
namespace Mongo2Go.Helper | ||
{ | ||
|
||
public class MongoBinaryLocator : IMongoBinaryLocator | ||
{ | ||
private string nugetPrefix = System.IO.Path.Combine ("packages", "Mongo2Go*"); | ||
private string searchPattern = ""; | ||
|
||
public MongoBinaryLocator (string binSearchPattern) | ||
{ | ||
if (string.IsNullOrEmpty (binSearchPattern)) { | ||
throw new ArgumentException ("Missing the search pattern for finding the mongoDb binaries.", "binSearchPattern"); | ||
} | ||
|
||
searchPattern = binSearchPattern; | ||
} | ||
|
||
public string ResolveBinariesDirectory () | ||
{ | ||
// 1st: path when installed via nuget | ||
// 2nd: path when started from solution | ||
string binariesFolder = FolderSearch.CurrentExecutingDirectory ().FindFolderUpwards (System.IO.Path.Combine (nugetPrefix, searchPattern)) ?? | ||
FolderSearch.CurrentExecutingDirectory ().FindFolderUpwards (searchPattern); | ||
|
||
if (binariesFolder == null) { | ||
throw new MonogDbBinariesNotFoundException (string.Format ( | ||
"Could not find Mongo binaries using {0}. We walk up the directories {1} levels from {2}", | ||
searchPattern, | ||
FolderSearch.MaxLevelOfRecursion, | ||
FolderSearch.CurrentExecutingDirectory ())); | ||
} | ||
return binariesFolder; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters