-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
2,770 additions
and
0 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,9 @@ | ||
DynamicLinqPadPostgreSqlDriver/obj/ | ||
packages/ | ||
DynamicLinqPadPostgreSqlDriver/bin/ | ||
DynamicLinqPadPostgreSqlDriver.UI/obj/ | ||
DynamicLinqPadPostgreSqlDriver.UI/bin/ | ||
DynamicLinqPadPostgreSqlDriver.Shared/obj/ | ||
DynamicLinqPadPostgreSqlDriver.Shared/bin/ | ||
DynamicLinqPadPostgreSqlDriver.Tests/obj/ | ||
DynamicLinqPadPostgreSqlDriver.Tests/bin/ |
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,10 @@ | ||
namespace DynamicLinqPadPostgreSqlDriver.Shared | ||
{ | ||
public enum DriverOption | ||
{ | ||
PluralizeSetAndTableProperties, | ||
SingularizeEntityNames, | ||
CapitalizePropertiesTablesAndColumns, | ||
UseExperimentalTypes | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
DynamicLinqPadPostgreSqlDriver.Shared/DynamicLinqPadPostgreSqlDriver.Shared.csproj
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,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8D343A09-D0DF-4C9E-B8FD-BDEB70CF7097}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>DynamicLinqPadPostgreSqlDriver.Shared</RootNamespace> | ||
<AssemblyName>DynamicLinqPadPostgreSqlDriver.Shared</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SignAssembly>true</SignAssembly> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AssemblyOriginatorKeyFile>StrongName.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="linq2db, Version=1.0.7.3, Culture=neutral, PublicKeyToken=f19f8aed7feff67e, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\linq2db.1.0.7.3\lib\net45\linq2db.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="LINQPad"> | ||
<HintPath>..\..\..\Program Files (x86)\LINQPad5\LINQPad.exe</HintPath> | ||
</Reference> | ||
<Reference Include="Npgsql, Version=3.0.4.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Npgsql.3.0.4\lib\net45\Npgsql.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="DriverOption.cs" /> | ||
<Compile Include="Extensions\ConnectionInfoExtensions.cs" /> | ||
<Compile Include="Extensions\XElementExtensions.cs" /> | ||
<Compile Include="Helpers\ConnectionHelper.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<None Include="StrongName.snk" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
66 changes: 66 additions & 0 deletions
66
DynamicLinqPadPostgreSqlDriver.Shared/Extensions/ConnectionInfoExtensions.cs
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,66 @@ | ||
using LINQPad.Extensibility.DataContext; | ||
using System; | ||
using System.Text; | ||
|
||
namespace DynamicLinqPadPostgreSqlDriver.Shared.Extensions | ||
{ | ||
public static class ConnectionInfoExtensions | ||
{ | ||
public static string GetPostgreSqlConnectionString(this IConnectionInfo cxInfo) | ||
{ | ||
if (cxInfo == null) | ||
throw new ArgumentNullException(nameof(cxInfo)); | ||
|
||
if (!string.IsNullOrWhiteSpace(cxInfo.DatabaseInfo.CustomCxString)) | ||
return cxInfo.DatabaseInfo.CustomCxString; | ||
|
||
return BuildConnectionString(cxInfo.DatabaseInfo.Server, cxInfo.DatabaseInfo.Database, cxInfo.DatabaseInfo.UserName, cxInfo.DatabaseInfo.Password); | ||
} | ||
|
||
internal static string BuildConnectionString(string serverWithPort, string database, string userName, string password) | ||
{ | ||
if (string.IsNullOrWhiteSpace(serverWithPort)) | ||
throw new ArgumentException("The argument may not be null or empty.", nameof(serverWithPort)); | ||
|
||
if (string.IsNullOrWhiteSpace(database)) | ||
throw new ArgumentException("The argument may not be null or empty.", nameof(database)); | ||
|
||
var server = ""; | ||
var port = ""; | ||
|
||
if (serverWithPort.Contains(":")) | ||
{ | ||
var parts = serverWithPort.Split(':'); | ||
server = parts[0]; | ||
port = parts[1]; | ||
} | ||
else | ||
{ | ||
server = serverWithPort; | ||
} | ||
|
||
var sb = new StringBuilder(); | ||
|
||
sb.AppendFormat("Server={0};", server); | ||
|
||
if (!string.IsNullOrWhiteSpace(port)) | ||
{ | ||
sb.AppendFormat("Port={0};", port); | ||
} | ||
|
||
sb.AppendFormat("Database={0};", database); | ||
|
||
if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password)) | ||
{ | ||
sb.AppendFormat("User Id={0};", userName); | ||
sb.AppendFormat("Password={0};", password); | ||
} | ||
else | ||
{ | ||
sb.Append("Integrated Security=true;"); | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
DynamicLinqPadPostgreSqlDriver.Shared/Extensions/XElementExtensions.cs
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,48 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
|
||
namespace DynamicLinqPadPostgreSqlDriver.Shared.Extensions | ||
{ | ||
public static class XElementExtensions | ||
{ | ||
public static T GetDescendantValue<T>(this XElement parent, DriverOption driverOption, Func<string, T> converter) | ||
{ | ||
return parent.GetDescendantValue(driverOption.ToString(), converter, default(T)); | ||
} | ||
|
||
public static T GetDescendantValue<T>(this XElement parent, string name, Func<string, T> converter) | ||
{ | ||
return parent.GetDescendantValue(name, converter, default(T)); | ||
} | ||
|
||
public static T GetDescendantValue<T>(this XElement parent, DriverOption driverOption, Func<string, T> converter, T defaultValue) | ||
{ | ||
return parent.GetDescendantValue(driverOption.ToString(), converter, defaultValue); | ||
} | ||
|
||
public static T GetDescendantValue<T>(this XElement parent, string name, Func<string, T> converter, T defaultValue) | ||
{ | ||
if (name == null) | ||
throw new ArgumentNullException(nameof(name)); | ||
|
||
if (converter == null) | ||
throw new ArgumentNullException(nameof(converter)); | ||
|
||
if (parent == null) | ||
return defaultValue; | ||
|
||
var element = parent.Descendants(name).FirstOrDefault(); | ||
if (element == null) | ||
return defaultValue; | ||
|
||
try | ||
{ | ||
return converter(element.Value); | ||
} | ||
catch { } | ||
|
||
return defaultValue; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
DynamicLinqPadPostgreSqlDriver.Shared/Helpers/ConnectionHelper.cs
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,28 @@ | ||
using DynamicLinqPadPostgreSqlDriver.Shared.Extensions; | ||
using Npgsql; | ||
using System; | ||
using System.Data; | ||
using System.Threading.Tasks; | ||
|
||
namespace DynamicLinqPadPostgreSqlDriver.Shared.Helpers | ||
{ | ||
public class ConnectionHelper | ||
{ | ||
public static async Task<bool> CheckConnection(string connectionString) | ||
{ | ||
if (string.IsNullOrWhiteSpace(connectionString)) | ||
throw new ArgumentException("The argument may not be null or empty", nameof(connectionString)); | ||
|
||
using (var connection = new NpgsqlConnection(connectionString)) | ||
{ | ||
await connection.OpenAsync(); | ||
return connection.State == ConnectionState.Open; | ||
} | ||
} | ||
|
||
public static async Task<bool> CheckConnection(string server, string database, string userName, string password) | ||
{ | ||
return await CheckConnection(ConnectionInfoExtensions.BuildConnectionString(server, database, userName, password)); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
DynamicLinqPadPostgreSqlDriver.Shared/Properties/AssemblyInfo.cs
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,14 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("DynamicLinqPadPostgreSqlDriver.Shared")] | ||
[assembly: AssemblyDescription("Shared part of the LINQPad PostgreSQL Driver")] | ||
[assembly: AssemblyProduct("DynamicLinqPadPostgreSqlDriver.Shared")] | ||
[assembly: AssemblyCopyright("Copyright © 2015 Frederik Knust")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
[assembly: ComVisible(false)] | ||
[assembly: Guid("8d343a09-d0df-4c9e-b8fd-bdeb70cf7097")] | ||
|
||
[assembly: AssemblyVersion("0.1.0.0")] | ||
[assembly: AssemblyFileVersion("0.1.0.0")] |
Binary file not shown.
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="linq2db" version="1.0.7.3" targetFramework="net452" /> | ||
<package id="linq2db.PostgreSQL" version="1.0.7.3" targetFramework="net452" /> | ||
<package id="linq2db.t4models" version="1.0.7.3" targetFramework="net452" /> | ||
<package id="Npgsql" version="3.0.4" targetFramework="net452" /> | ||
</packages> |
109 changes: 109 additions & 0 deletions
109
DynamicLinqPadPostgreSqlDriver.Tests/DynamicLinqPadPostgreSqlDriver.Tests.csproj
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,109 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{E04B12BF-0D89-40DB-8A9C-B5FA095A3F39}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>DynamicLinqPadPostgreSqlDriver.Tests</RootNamespace> | ||
<AssemblyName>DynamicLinqPadPostgreSqlDriver.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, PublicKeyToken=e3e8412083d25dd3, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Dapper.StrongName.1.40\lib\net45\Dapper.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="linq2db, Version=1.0.7.3, Culture=neutral, PublicKeyToken=f19f8aed7feff67e, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\linq2db.1.0.7.3\lib\net45\linq2db.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Npgsql, Version=3.0.4.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Npgsql.3.0.4\lib\net45\Npgsql.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="TestAdvancedTypeMappings.cs" /> | ||
<Compile Include="TestBase.cs" /> | ||
<Compile Include="TestBasicTypeMappings.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\DynamicLinqPadPostgreSqlDriver.Shared\DynamicLinqPadPostgreSqlDriver.Shared.csproj"> | ||
<Project>{8d343a09-d0df-4c9e-b8fd-bdeb70cf7097}</Project> | ||
<Name>DynamicLinqPadPostgreSqlDriver.Shared</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\DynamicLinqPadPostgreSqlDriver\DynamicLinqPadPostgreSqlDriver.csproj"> | ||
<Project>{824f300b-f0f9-4994-9097-b1b2270be12f}</Project> | ||
<Name>DynamicLinqPadPostgreSqlDriver</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" /> | ||
</Target> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Oops, something went wrong.