-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable VPAX extraction on non-Windows platforms (#126)
* Remove `windows` platform target * Use DbConnectionStringBuilder instead of OleDb * Remove `System.Data.OleDb` package reference * Fix build error
- Loading branch information
1 parent
7a1209b
commit c01b9d9
Showing
11 changed files
with
76 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Data.Common; | ||
using System.Globalization; | ||
|
||
namespace Dax.Model.Extractor.Data | ||
{ | ||
public static class ConnectionStringUtils | ||
{ | ||
public static string GetDataSource(string connectionString) => GetValue(connectionString, ConnectionStringKeywords.DataSource); | ||
|
||
public static string GetInitialCatalog(string connectionString) => GetValue(connectionString, ConnectionStringKeywords.InitialCatalog); | ||
|
||
public static string GetConnectionString(string serverNameOrConnectionString, string databaseName) | ||
{ | ||
var builder = new DbConnectionStringBuilder(useOdbcRules: false); | ||
try { | ||
builder.ConnectionString = serverNameOrConnectionString; | ||
} | ||
catch { | ||
// Assume servername | ||
builder[ConnectionStringKeywords.Provider] = "MSOLAP"; | ||
builder[ConnectionStringKeywords.DataSource] = serverNameOrConnectionString; | ||
} | ||
builder[ConnectionStringKeywords.InitialCatalog] = databaseName; | ||
return builder.ConnectionString; | ||
} | ||
|
||
private static string GetValue(string connectionString, string keyword) | ||
{ | ||
var builder = new DbConnectionStringBuilder(useOdbcRules: false); | ||
builder.ConnectionString = connectionString; | ||
|
||
if (builder.TryGetValue(keyword, out object value)) | ||
return ((IConvertible)value).ToString(CultureInfo.InvariantCulture); | ||
|
||
return string.Empty; // default to empty string to keep the result consistent with the OleDbConnectionStringBuilder | ||
} | ||
} | ||
|
||
internal static class ConnectionStringKeywords | ||
{ | ||
public const string Provider = "Provider"; | ||
public const string DataSource = "Data Source"; | ||
public const string InitialCatalog = "Initial Catalog"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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