diff --git a/LiteDB.Shell/Commands/Collections/Bulk.cs b/LiteDB.Shell/Commands/Collections/Bulk.cs index 66283928b..b2b9ceac0 100644 --- a/LiteDB.Shell/Commands/Collections/Bulk.cs +++ b/LiteDB.Shell/Commands/Collections/Bulk.cs @@ -18,7 +18,7 @@ public void Execute(LiteEngine engine, StringScanner s, Display display, InputCo var col = this.ReadCollection(engine, s); var filename = s.Scan(@".*"); - using (var sr = new StreamReader(filename, Encoding.UTF8)) + using (var sr = new StreamReader(new FileStream(filename, System.IO.FileMode.Open))) { var docs = JsonSerializer.DeserializeArray(sr); diff --git a/LiteDB.Shell/Commands/Console/ShowCollections.cs b/LiteDB.Shell/Commands/Console/ShowCollections.cs index 97d3705ad..b5315a906 100644 --- a/LiteDB.Shell/Commands/Console/ShowCollections.cs +++ b/LiteDB.Shell/Commands/Console/ShowCollections.cs @@ -14,6 +14,12 @@ public bool IsCommand(StringScanner s) public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env) { + if(engine == null) + { + display.WriteError("No database file currently open."); + return; + } + var cols = engine.GetCollectionNames().OrderBy(x => x).ToArray(); if (cols.Length > 0) diff --git a/LiteDB.Shell/Shell/Env.cs b/LiteDB.Shell/Shell/Env.cs index 82daaa931..23a3d8091 100644 --- a/LiteDB.Shell/Shell/Env.cs +++ b/LiteDB.Shell/Shell/Env.cs @@ -28,7 +28,11 @@ public LiteEngine CreateEngine(DataAccess access) var disk = new FileDiskService(this.Filename, new FileOptions { - FileMode = FileMode.Shared, + #if NET35 + FileMode = FileMode.Shared, + #else + FileMode = FileMode.Exclusive, + #endif Journal = this.Journal }); diff --git a/LiteDB.Shell/Shell/ShellProgram.cs b/LiteDB.Shell/Shell/ShellProgram.cs index 3dcaa3613..30b364b31 100644 --- a/LiteDB.Shell/Shell/ShellProgram.cs +++ b/LiteDB.Shell/Shell/ShellProgram.cs @@ -66,9 +66,9 @@ public static void Start(InputCommand input, Display display) public static void RegisterCommands(List commands) { var type = typeof(ICommand); - var types = Assembly.GetExecutingAssembly() + var types = typeof(ShellProgram).GetTypeInfo().Assembly .GetTypes() - .Where(p => type.IsAssignableFrom(p) && p.IsClass); + .Where(p => type.IsAssignableFrom(p) && p.GetTypeInfo().IsClass); foreach(var cmd in types) { diff --git a/LiteDB.Shell/project.json b/LiteDB.Shell/project.json new file mode 100644 index 000000000..b6ac14e85 --- /dev/null +++ b/LiteDB.Shell/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": { + "LiteDB": "3.0.0" + }, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" + } + } +}