-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
575a4c4
commit 612d7eb
Showing
55 changed files
with
2,509 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,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" 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>{544AF6A9-5CD3-4F0A-8826-1A3C884EE288}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Data.Dump</RootNamespace> | ||
<AssemblyName>Data.Dump.Engine</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.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> | ||
<LangVersion>latest</LangVersion> | ||
</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> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath> | ||
</Reference> | ||
<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="Exceptions\InvalidTypeException.cs" /> | ||
<Compile Include="Extensions\Inflector.cs" /> | ||
<Compile Include="Extensions\StringExtensions.cs" /> | ||
<Compile Include="Extensions\TypeExtensions.cs" /> | ||
<Compile Include="Persistence\RepositoryBase.cs" /> | ||
<Compile Include="Persistence\IRepository.cs" /> | ||
<Compile Include="Persistence\IStore.cs" /> | ||
<Compile Include="Persistence\TablePair.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Schema\DataContainerFactoryBase.cs" /> | ||
<Compile Include="Schema\DataSetFactory.cs" /> | ||
<Compile Include="Schema\DataTableFactory.cs" /> | ||
<Compile Include="Schema\FieldSelector.cs" /> | ||
<Compile Include="Schema\IDataSetFactory.cs" /> | ||
<Compile Include="Schema\IDataTableFactory.cs" /> | ||
<Compile Include="Schema\IFieldSelector.cs" /> | ||
<Compile Include="Schema\ITableDefinitionGenerator.cs" /> | ||
<Compile Include="Schema\IValueConverter.cs" /> | ||
<Compile Include="Schema\TableDefinitionGenerator.cs" /> | ||
<Compile Include="Schema\Conversion\ValueConverter.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PostBuildEvent>REM cd $(ProjectDir) | ||
REM nuget pack -OutputDirectory "C:\Projects\nuget"</PostBuildEvent> | ||
</PropertyGroup> | ||
</Project> |
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,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp71</s:String></wpf:ResourceDictionary> |
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,18 @@ | ||
<?xml version="1.0"?> | ||
<package > | ||
<metadata> | ||
<id>$id$</id> | ||
<version>$version$</version> | ||
<title>$title$</title> | ||
<authors>$author$</authors> | ||
<owners>$author$</owners> | ||
<!-- <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl> | ||
<projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl> | ||
<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl> --> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>$description$</description> | ||
<releaseNotes>First release.</releaseNotes> | ||
<copyright>Copyright 2018</copyright> | ||
<tags>data dump bulk import export dataset datatable poco</tags> | ||
</metadata> | ||
</package> |
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,21 @@ | ||
using System; | ||
|
||
namespace Data.Dump.Exceptions | ||
{ | ||
public class InvalidTypeException : ArgumentException | ||
{ | ||
public override string ParamName { get; } | ||
public Type InvalidType { get; } | ||
public Type ExpectedType { get; } | ||
|
||
public override string Message | ||
=> $"{ParamName} of type {InvalidType} is not assignable to {ExpectedType}."; | ||
|
||
public InvalidTypeException(string paramName, Type invalidType, Type expectedType) | ||
{ | ||
ParamName = paramName; | ||
InvalidType = invalidType; | ||
ExpectedType = expectedType; | ||
} | ||
} | ||
} |
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,143 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Data.Dump.Extensions | ||
{ | ||
//from Raven.Client.Documents.Conventions | ||
internal class Inflector | ||
{ | ||
private static readonly List<Inflector.Rule> Plurals = new List<Inflector.Rule>(); | ||
private static readonly List<Inflector.Rule> Singulars = new List<Inflector.Rule>(); | ||
private static readonly List<string> Uncountables = new List<string>(); | ||
|
||
private Inflector() | ||
{ | ||
} | ||
|
||
static Inflector() | ||
{ | ||
Inflector.AddPlural("$", "s"); | ||
Inflector.AddPlural("s$", "s"); | ||
Inflector.AddPlural("(ax|test)is$", "$1es"); | ||
Inflector.AddPlural("(octop|vir)us$", "$1i"); | ||
Inflector.AddPlural("(alias|status)$", "$1es"); | ||
Inflector.AddPlural("(bu)s$", "$1ses"); | ||
Inflector.AddPlural("(buffal|tomat)o$", "$1oes"); | ||
Inflector.AddPlural("([ti])um$", "$1a"); | ||
Inflector.AddPlural("sis$", "ses"); | ||
Inflector.AddPlural("(?:([^f])fe|([lr])f)$", "$1$2ves"); | ||
Inflector.AddPlural("(hive)$", "$1s"); | ||
Inflector.AddPlural("([^aeiouy]|qu)y$", "$1ies"); | ||
Inflector.AddPlural("(x|ch|ss|sh)$", "$1es"); | ||
Inflector.AddPlural("(matr|vert|ind)ix|ex$", "$1ices"); | ||
Inflector.AddPlural("([m|l])ouse$", "$1ice"); | ||
Inflector.AddPlural("^(ox)$", "$1en"); | ||
Inflector.AddPlural("(quiz)$", "$1zes"); | ||
Inflector.AddSingular("s$", ""); | ||
Inflector.AddSingular("(n)ews$", "$1ews"); | ||
Inflector.AddSingular("([ti])a$", "$1um"); | ||
Inflector.AddSingular("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$", "$1$2sis"); | ||
Inflector.AddSingular("(^analy)ses$", "$1sis"); | ||
Inflector.AddSingular("([^f])ves$", "$1fe"); | ||
Inflector.AddSingular("(hive)s$", "$1"); | ||
Inflector.AddSingular("(tive)s$", "$1"); | ||
Inflector.AddSingular("([lr])ves$", "$1f"); | ||
Inflector.AddSingular("([^aeiouy]|qu)ies$", "$1y"); | ||
Inflector.AddSingular("(s)eries$", "$1eries"); | ||
Inflector.AddSingular("(m)ovies$", "$1ovie"); | ||
Inflector.AddSingular("(x|ch|ss|sh)es$", "$1"); | ||
Inflector.AddSingular("([m|l])ice$", "$1ouse"); | ||
Inflector.AddSingular("(bus)es$", "$1"); | ||
Inflector.AddSingular("(o)es$", "$1"); | ||
Inflector.AddSingular("(shoe)s$", "$1"); | ||
Inflector.AddSingular("(cris|ax|test)es$", "$1is"); | ||
Inflector.AddSingular("(octop|vir)i$", "$1us"); | ||
Inflector.AddSingular("(alias|status)es$", "$1"); | ||
Inflector.AddSingular("^(ox)en", "$1"); | ||
Inflector.AddSingular("(vert|ind)ices$", "$1ex"); | ||
Inflector.AddSingular("(matr)ices$", "$1ix"); | ||
Inflector.AddSingular("(quiz)zes$", "$1"); | ||
Inflector.AddIrregular("person", "people"); | ||
Inflector.AddIrregular("man", "men"); | ||
Inflector.AddIrregular("child", "children"); | ||
Inflector.AddIrregular("sex", "sexes"); | ||
Inflector.AddIrregular("move", "moves"); | ||
Inflector.AddUncountable("equipment"); | ||
Inflector.AddUncountable("information"); | ||
Inflector.AddUncountable("rice"); | ||
Inflector.AddUncountable("money"); | ||
Inflector.AddUncountable("species"); | ||
Inflector.AddUncountable("series"); | ||
Inflector.AddUncountable("fish"); | ||
Inflector.AddUncountable("sheep"); | ||
} | ||
|
||
public static string Pluralize(string word) | ||
{ | ||
return Inflector.ApplyRules((IList)Inflector.Plurals, word); | ||
} | ||
|
||
public static string Singularize(string word) | ||
{ | ||
return Inflector.ApplyRules((IList)Inflector.Singulars, word); | ||
} | ||
|
||
public static string Capitalize(string word) | ||
{ | ||
return word.Substring(0, 1).ToUpper() + word.Substring(1).ToLower(); | ||
} | ||
|
||
private static void AddIrregular(string singular, string plural) | ||
{ | ||
Inflector.AddPlural("(" + singular[0].ToString() + ")" + singular.Substring(1) + "$", "$1" + plural.Substring(1)); | ||
Inflector.AddSingular("(" + plural[0].ToString() + ")" + plural.Substring(1) + "$", "$1" + singular.Substring(1)); | ||
} | ||
|
||
private static void AddUncountable(string word) | ||
{ | ||
Inflector.Uncountables.Add(word.ToLower()); | ||
} | ||
|
||
private static void AddPlural(string rule, string replacement) | ||
{ | ||
Inflector.Plurals.Add(new Inflector.Rule(rule, replacement)); | ||
} | ||
|
||
private static void AddSingular(string rule, string replacement) | ||
{ | ||
Inflector.Singulars.Add(new Inflector.Rule(rule, replacement)); | ||
} | ||
|
||
private static string ApplyRules(IList rules, string word) | ||
{ | ||
string str = word; | ||
if (!Inflector.Uncountables.Contains(word.ToLower())) | ||
{ | ||
int index = rules.Count - 1; | ||
while (index >= 0 && (str = ((Inflector.Rule)rules[index]).Apply(word)) == null) | ||
--index; | ||
} | ||
return str; | ||
} | ||
|
||
private class Rule | ||
{ | ||
private readonly Regex regex; | ||
private readonly string replacement; | ||
|
||
public Rule(string pattern, string replacement) | ||
{ | ||
this.regex = new Regex(pattern, RegexOptions.IgnoreCase); | ||
this.replacement = replacement; | ||
} | ||
|
||
public string Apply(string word) | ||
{ | ||
if (!this.regex.IsMatch(word)) | ||
return (string)null; | ||
return this.regex.Replace(word, this.replacement); | ||
} | ||
} | ||
} | ||
} |
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,20 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Data.Dump.Extensions | ||
{ | ||
public static class StringExtensions | ||
{ | ||
private static readonly Regex Alpha = new Regex(@"[^a-z_]", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
private static readonly Regex AlphaNumeric = new Regex(@"[^a-z0-9_]", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
|
||
public static string Sanitize(this string me, bool keepNumeric = true) | ||
{ | ||
if (keepNumeric) | ||
{ | ||
return AlphaNumeric.Replace(me, string.Empty); | ||
} | ||
|
||
return Alpha.Replace(me, string.Empty); | ||
} | ||
} | ||
} |
Oops, something went wrong.