Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
XeroXP committed Jul 13, 2022
0 parents commit e4b48f7
Show file tree
Hide file tree
Showing 18 changed files with 2,001 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/obj
**/bin
.vs/
packages/
40 changes: 40 additions & 0 deletions BigSharp.ToFormat/BigSharp.ToFormat.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.0.0</Version>
<Authors>XeroXP</Authors>
<Description>Adds a ToFormat instance method to Big.</Description>
<Copyright>Copyright (c) $(Authors) 2022</Copyright>
<PackageProjectUrl>https://github.com/XeroXP/ToFormatSharp</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/XeroXP/ToFormatSharp.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>format, formatting</PackageTags>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="BigSharp" Version="2.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ToFormatSharp.Core\ToFormatSharp.Core.csproj" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions BigSharp.ToFormat/ToFormatExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using ToFormatSharp.Core;
using ToFormatSharp.Core.Extensions;

namespace BigSharp.ToFormat
{
public static class ToFormatExtension
{
public static string ToFormat(this Big big, FormatOptions? fmt = null) => ToFormat(big, null, null, fmt);
public static string ToFormat(this Big big, long? dp, FormatOptions? fmt = null) => ToFormat(big, dp, null, fmt);
public static string ToFormat(this Big big, long? dp, RoundingMode? rm, FormatOptions? fmt = null)
{
if (!big.e.IsTrue() && big.e != 0) return big.ToString();

var arr = big.ToFixed(dp, rm).Split('.');
return ToFormatSharp.Core.ToFormatExtension.ToFormat(() => big.ToString(), arr, big.e, big.s, fmt);
}
}
}
40 changes: 40 additions & 0 deletions DecimalSharp.Light.ToFormat/DecimalSharp.Light.ToFormat.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.0.0</Version>
<Authors>XeroXP</Authors>
<Description>Adds a ToFormat instance method to BigDecimalLight.</Description>
<Copyright>Copyright (c) $(Authors) 2022</Copyright>
<PackageProjectUrl>https://github.com/XeroXP/ToFormatSharp</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/XeroXP/ToFormatSharp.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>format, formatting</PackageTags>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="DecimalSharp.Light" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ToFormatSharp.Core\ToFormatSharp.Core.csproj" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions DecimalSharp.Light.ToFormat/ToFormatExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using DecimalSharp.Core;
using ToFormatSharp.Core;
using ToFormatSharp.Core.Extensions;

namespace DecimalSharp.Light.ToFormat
{
public static class ToFormatExtension
{
public static string ToFormat(this BigDecimalLight bigDecimal, FormatOptions? fmt = null) => ToFormat(bigDecimal, null, null, fmt);
public static string ToFormat(this BigDecimalLight bigDecimal, long? dp, FormatOptions? fmt = null) => ToFormat(bigDecimal, dp, null, fmt);
public static string ToFormat(this BigDecimalLight bigDecimal, long? dp, RoundingMode? rm, FormatOptions? fmt = null)
{
if (!bigDecimal.e.IsTrue() && bigDecimal.e != 0) return bigDecimal.ToString();

var arr = bigDecimal.ToFixed(dp, rm).Split('.');
return ToFormatSharp.Core.ToFormatExtension.ToFormat(() => bigDecimal.ToString(), arr, bigDecimal.e, bigDecimal.s, fmt);
}
}
}
40 changes: 40 additions & 0 deletions DecimalSharp.ToFormat/DecimalSharp.ToFormat.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.0.0</Version>
<Authors>XeroXP</Authors>
<Description>Adds a ToFormat instance method to BigDecimal.</Description>
<Copyright>Copyright (c) $(Authors) 2022</Copyright>
<PackageProjectUrl>https://github.com/XeroXP/ToFormatSharp</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/XeroXP/ToFormatSharp.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>format, formatting</PackageTags>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="DecimalSharp" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ToFormatSharp.Core\ToFormatSharp.Core.csproj" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions DecimalSharp.ToFormat/ToFormatExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using DecimalSharp.Core;
using ToFormatSharp.Core;
using ToFormatSharp.Core.Extensions;

namespace DecimalSharp.ToFormat
{
public static class ToFormatExtension
{
public static string ToFormat(this BigDecimal bigDecimal, FormatOptions? fmt = null) => ToFormat(bigDecimal, null, null, fmt);
public static string ToFormat(this BigDecimal bigDecimal, long? dp, FormatOptions? fmt = null) => ToFormat(bigDecimal, dp, null, fmt);
public static string ToFormat(this BigDecimal bigDecimal, long? dp, RoundingMode? rm, FormatOptions? fmt = null)
{
if (!bigDecimal.e.IsTrue() && bigDecimal.e != 0) return bigDecimal.ToString();

var arr = bigDecimal.ToFixed(dp, rm).Split('.');
return ToFormatSharp.Core.ToFormatExtension.ToFormat(() => bigDecimal.ToString(), arr, bigDecimal.e, bigDecimal.s, fmt);
}
}
}
Loading

0 comments on commit e4b48f7

Please sign in to comment.