-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSQLiteConnectionsStringHandler.cs
More file actions
41 lines (40 loc) · 1.3 KB
/
SQLiteConnectionsStringHandler.cs
File metadata and controls
41 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
namespace OpenTNF.Library
{
/// <summary>
/// This class contains help methods for SQLite connection strings
/// </summary>
public class SQLiteConnectionsStringHandler
{
/// <summary>
/// Method can be used to determine if a connection string describes a connection to a in memory SQLite db.
/// </summary>
/// <param name="fileNameOrUriString"></param>
/// <returns></returns>
public static bool IsMemoryDB(string fileNameOrUriString)
{
if (fileNameOrUriString.IndexOf(":memory:", StringComparison.InvariantCultureIgnoreCase) > -1)
{
return true;
}
return false;
}
/// <summary>
/// If the <paramref name="fileNameOrUriString"/> is of 'FullUri' type the returned connection string is unchanged.
/// If not the string is assumed to be a filename and a connection string created containing with 'Data source=filename'
/// </summary>
/// <param name="fileNameOrUriString"></param>
/// <returns>A SQLite connections string</returns>
public static string GetSQLiteConnectionString(string fileNameOrUriString)
{
if (fileNameOrUriString.IndexOf("FullUri", StringComparison.InvariantCultureIgnoreCase) > -1)
{
return fileNameOrUriString;
}
else
{
return $"Data Source={fileNameOrUriString};Version=3;New=True;Compress=True;";
}
}
}
}