Skip to content

Commit

Permalink
Cleaning up some unused code and adding ValueTuple support to make un…
Browse files Browse the repository at this point in the history
…it abbreviations a bit clearer
  • Loading branch information
tmilnthorp committed Oct 17, 2018
1 parent 876f31f commit a3d0435
Show file tree
Hide file tree
Showing 7 changed files with 999 additions and 1,124 deletions.
4 changes: 2 additions & 2 deletions UnitsNet/CustomCode/UnitAbbreviationsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ private void LoadGeneratedAbbreviations()
{
foreach(var localization in GeneratedLocalizations)
{
var culture = new CultureInfo(localization.Item1);
MapUnitToAbbreviation(localization.Item2, localization.Item3, culture, localization.Item4);
var culture = new CultureInfo(localization.CultureName);
MapUnitToAbbreviation(localization.UnitType, localization.UnitValue, culture, localization.UnitAbbreviations);
}
}

Expand Down
1,990 changes: 993 additions & 997 deletions UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions UnitsNet/I18n/AbbreviationsForCulture.cs

This file was deleted.

39 changes: 0 additions & 39 deletions UnitsNet/I18n/CulturesForEnumValue.cs

This file was deleted.

40 changes: 0 additions & 40 deletions UnitsNet/I18n/UnitLocalization.cs

This file was deleted.

10 changes: 3 additions & 7 deletions UnitsNet/Scripts/Include-GenerateUnitSystemDefaultSourceCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
// THE SOFTWARE.
using System;
using System.Globalization;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnitsNet.I18n;
using UnitsNet.Units;
// ReSharper disable RedundantCommaInArrayInitializer
Expand All @@ -52,8 +48,8 @@ namespace UnitsNet
{
public partial class UnitAbbreviationsCache
{
private static readonly Tuple<string, Type, int, string[]>[] GeneratedLocalizations
= new Tuple<string, Type, int, string[]>[]
private static readonly (string CultureName, Type UnitType, int UnitValue, string[] UnitAbbreviations)[] GeneratedLocalizations
= new []
{
"@;
foreach ($quantity in $quantities)
Expand All @@ -70,7 +66,7 @@ namespace UnitsNet
$cultureName = $localization.Culture;
$abbreviationParams = $localization.Abbreviations -join '", "'
@"
Tuple.Create(`"$cultureName`", typeof($unitEnumName), (int)$unitEnumName.$enumValue, new string[]{`"$abbreviationParams`"}),
(`"$cultureName`", typeof($unitEnumName), (int)$unitEnumName.$enumValue, new string[]{`"$abbreviationParams`"}),
"@;
}
}
Expand Down
1 change: 1 addition & 0 deletions UnitsNet/UnitsNet.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<!-- NuGet references that work for both signed and unsigned -->
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" PrivateAssets="All" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<!-- Exclude obj folder from default inclusion pattern -->
Expand Down

0 comments on commit a3d0435

Please sign in to comment.