diff --git a/.nuget/Cuemon.Core/PackageReleaseNotes.txt b/.nuget/Cuemon.Core/PackageReleaseNotes.txt index 537da6ea0..9cf7a4f38 100644 --- a/.nuget/Cuemon.Core/PackageReleaseNotes.txt +++ b/.nuget/Cuemon.Core/PackageReleaseNotes.txt @@ -19,15 +19,41 @@ Availability: .NET 9, .NET 8 and .NET Standard 2.0 - REMOVED YamlConverterFactory class from the Cuemon.Text.Yaml namespace - REMOVED YamlNamingPolicy class from the Cuemon.Text.Yaml namespace - RENAMED ReservedKeywordException class in the Cuemon namespace to ArgumentReservedKeywordException +- REMOVED SafeInvokeAsync methods from the Patterns class in the Cuemon namespace (moved to AsyncPatterns class in the Cuemon.Threading assembly) +- RENAMED TaskActionFactory class in the Cuemon namespace to AsyncActionFactory in the Cuemon.Threading namespace +- RENAMED TaskFuncFactory class in the Cuemon namespace to AsyncFuncFactory in the Cuemon.Threading namespace +- RENAMED Template class in the Cuemon namespace to MutableTuple +- RENAMED TemplateFactory class in the Cuemon namespace to MutableTupleFactory +- REMOVED ActionFactory static class from the Cuemon namespace (moved to the Cuemon.Extensions namespace in the Cuemon.Extensions.Core assembly) +- REMOVED FuncFactory static class from the Cuemon namespace (moved to the Cuemon.Extensions namespace in the Cuemon.Extensions.Core assembly) +- REMOVED TesterFuncFactory static class from the Cuemon namespace (moved to the Cuemon.Extensions namespace in the Cuemon.Extensions.Core assembly) +- REMOVED BinaryPrefix class from the Cuemon namespace +- REMOVED BitStorageCapacity class from the Cuemon namespace +- REMOVED BitUnit class from the Cuemon namespace +- REMOVED ByteStorageCapacity class from the Cuemon namespace +- REMOVED ByteUnit class from the Cuemon namespace +- REMOVED DecimalPrefix class from the Cuemon namespace +- REMOVED IPrefixMultiple interface from the Cuemon namespace +- REMOVED IUnit interface from the Cuemon namespace +- REMOVED MultipleTable class from the Cuemon namespace +- REMOVED NamingStyle enum from the Cuemon namespace +- REMOVED PrefixMultiple class from the Cuemon namespace +- REMOVED PrefixUnit class from the Cuemon namespace +- REMOVED StorageCapacity class from the Cuemon namespace +- REMOVED StorageCapacityOptions class from the Cuemon namespace +- REMOVED UnitFormatOptions class from the Cuemon namespace +- REMOVED UnitPrefix enum from the Cuemon namespace +- REMOVED UnitPrefixFormatter class from the Cuemon namespace +- REMOVED ZeroPrefix class from the Cuemon namespace   # New Features - ADDED Failure record in the Cuemon.Diagnostics namespace that represents a failure model with detailed information about an exception -   # Improvements - EXTENDED Condition class in the Cuemon namespace with an additional method: HasDifference - EXTENDED Validator class in the Cuemon namespace with five new methods: ThrowIfContainsReservedKeyword, ThrowIfNotDifferent, ThrowIfDifferent, ThrowIfContainsAny and ThrowIfNotContainsAny - CHANGED Validator class in the Cuemon namespace to comply with RSPEC-3343 +- EXTENDED Decorator class in the Cuemon namespace with an additional method: RawEnclose   Version 8.3.2 Availability: .NET 8, .NET 6 and .NET Standard 2.0 diff --git a/.nuget/Cuemon.Extensions.Core/PackageReleaseNotes.txt b/.nuget/Cuemon.Extensions.Core/PackageReleaseNotes.txt index a701552c1..8d8f5a45b 100644 --- a/.nuget/Cuemon.Extensions.Core/PackageReleaseNotes.txt +++ b/.nuget/Cuemon.Extensions.Core/PackageReleaseNotes.txt @@ -10,6 +10,12 @@ Availability: .NET 9, .NET 8 and .NET Standard 2.0 - REMOVED ValidatorExtensions class from the Cuemon.Extensions namespace and moved members to Validator class in the Cuemon.Core assembly (Cuemon namespace) - REMOVED ReplaceLineEndings extension method from the StringExtensions class in the Cuemon.Extensions namespace   +# New Features +- ADDED ActionFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating ActionFactory{TTuple} objects that encapsulate a delegate with a variable amount of generic arguments +- ADDED FuncFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating FuncFactory{TTuple, TResult} objects that encapsulate a function delegate with a variable amount of generic arguments +- ADDED MutableTupleFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating MutableTuple objects +- ADDED TesterFuncFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating TesterFuncFactory{TTuple, TResult, TSuccess} objects that encapsulate a tester function delegate with a variable amount of generic arguments +  Version 8.3.2 Availability: .NET 8, .NET 6 and .NET Standard 2.0   diff --git a/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt b/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt index c506fbdf8..6999f71e3 100644 --- a/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt +++ b/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt @@ -15,6 +15,7 @@ Availability: .NET 9, .NET 8 and .NET Standard 2.0   # Bug Fixes - FIXED ExceptionConverter class in the Cuemon.Extensions.Text.Json.Converters namespace to use JsonSerializerOptions when converting JSON to Exception +- FIXED the JSON converter that converts a Failure to JSON so it uses the actual key-value from the Data property of an exception instead of always writing key   Version 8.3.2 Availability: .NET 8 and .NET 6 diff --git a/.nuget/Cuemon.Threading/PackageReleaseNotes.txt b/.nuget/Cuemon.Threading/PackageReleaseNotes.txt index 5d5f5e8c3..38b63ce87 100644 --- a/.nuget/Cuemon.Threading/PackageReleaseNotes.txt +++ b/.nuget/Cuemon.Threading/PackageReleaseNotes.txt @@ -5,6 +5,11 @@ Availability: .NET 9, .NET 8 and .NET Standard 2.0 - CHANGED Dependencies to latest and greatest with respect to TFMs - REMOVED Support for TFM .NET 6 (LTS)   +# New Features +- ADDED AsyncPatterns class in the Cuemon.Threading namespace that provides a generic way to support different types of design patterns and practices with small utility methods scoped to Task +- ADDED AsyncActionFactory class in the Cuemon.Threading namespace that provides access to factory methods for creating AsyncActionFactory{TTuple} instances that encapsulate a Task based action delegate with a variable amount of generic arguments +- ADDED AsyncFuncFactory class in the Cuemon.Threading namespace that provides access to factory methods for creating AsyncFuncFactory{TTuple,TResult} instances that encapsulate a Task{TResult} based function delegate with a variable amount of generic arguments +  Version 8.3.2 Availability: .NET 8, .NET 6 and .NET Standard 2.0   diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4eaab35..eb96bf472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ For more details, please refer to `PackageReleaseNotes.txt` on a per assembly ba > - Cuemon.Extensions.Newtonsoft.Json was removed from the solution and migrated to [Codebelt.Extensions.Newtonsoft.Json](https://github.com/codebeltnet/newtonsoft-json) > - Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4 was removed from the solution and migrated to [Codebelt.Extensions.AwsSignature4](https://github.com/codebeltnet/aws-signature-v4) +> [!NOTE] +> Types that are removed from this solution (but otherwise fits naturally together) will be migrated to smaller and more focused repositories in the [Codebelt](https://github.com/codebeltnet) organization, renamed to better reflect their purpose and published as standalone packages on NuGet. + This major release is first and foremost focused on ironing out any wrinkles that have been introduced with .NET 9 preview releases so the final release is production ready together with the official launch from Microsoft. Next focus point will be ensuring a consistent developer experience while ironing out some of the more stale legacy code in the project. @@ -28,6 +31,7 @@ Expect breaking changes with this major release. Highlighted features included in this release: - Support for both **FaultDetails** (HttpExceptionDescriptor) and **ProblemDetails** in the context of ASP.NET (both vanilla and MVC) +- Reduced footprint in the core assemblies by removing obsolete and redundant code ### Added @@ -41,6 +45,14 @@ Highlighted features included in this release: - XmlConverterExtensions class in the Cuemon.Extensions.Xml.Serialization.Converters namespace was extended to include one new extension method: AddFailureConverter - JsonConverterCollectionExtensions class in the Cuemon.Extensions.Text.Json.Converters namespace was extended to include three new extension methods: AddFailureConverter, RemoveAllOf and RemoveAllOf{T} - JsonSerializerOptionsExtensions class in the Cuemon.Extensions.Text.Json namespace was extended to include one new extension method: Clone +- AsyncPatterns class in the Cuemon.Threading namespace that provides a generic way to support different types of design patterns and practices with small utility methods scoped to Task +- AsyncActionFactory class in the Cuemon.Threading namespace that provides access to factory methods for creating AsyncActionFactory{TTuple} instances that encapsulate a Task based action delegate with a variable amount of generic arguments +- AsyncFuncFactory class in the Cuemon.Threading namespace that provides access to factory methods for creating AsyncFuncFactory{TTuple,TResult} instances that encapsulate a Task{TResult} based function delegate with a variable amount of generic arguments +- Decorator class in the Cuemon namespace was extended with an additional method: RawEnclose +- ActionFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating ActionFactory{TTuple} objects that encapsulate a delegate with a variable amount of generic arguments +- FuncFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating FuncFactory{TTuple, TResult} objects that encapsulate a function delegate with a variable amount of generic arguments +- MutableTupleFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating MutableTuple objects +- TesterFuncFactory class in the Cuemon.Extensions namespace that provides access to factory methods for creating TesterFuncFactory{TTuple, TResult, TSuccess} objects that encapsulate a tester function delegate with a variable amount of generic arguments ### Changed @@ -83,10 +95,15 @@ Highlighted features included in this release: - ApplicationBuilderExtensions class in the Cuemon.Extensions.AspNetCore.Diagnostics namespace to support preferred fault descriptor (e.g., FaultDetails or ProblemDetails) in the UseFaultDescriptorExceptionHandler extension method - XmlConverter{T} class in the Cuemon.Xml.Serialization.Converters namespace to use generic type T with two new abstract methods: WriteXml and ReadXml - CultureInfoExtensions class in the Cuemon.Extensions.Globalization namespace to use Codebelt.Extensions.YamlDotNet assembly instead of previously built-in YAML support from Codebelt.Extensions.YamlDotNet assembly +- TaskActionFactory class in the Cuemon namespace was renamed to AsyncActionFactory and moved to the Cuemon.Threading namespace (breaking change) +- TaskFuncFactory class in the Cuemon namespace was renamed to AsyncFuncFactory and moved to the Cuemon.Threading namespace (breaking change) +- Template class in the Cuemon namespace was renamed to MutableTuple (breaking change) +- TemplateFactory class in the Cuemon namespace was renamed to MutableTupleFactory (breaking change) ### Fixed - ExceptionConverter class in the Cuemon.Xml.Serialization.Converters namespace to use Environment.NewLine instead of Alphanumeric.NewLine (vital for non-Windows operating systems) +- The JSON converter in the Cuemon.Extensions.Text.Json.Converters namespace that converts a Failure to JSON so it uses the actual key-value from the Data property of an exception instead of always writing key ### Removed @@ -125,6 +142,28 @@ Highlighted features included in this release: - MvcCoreBuilderExtensions class from the Cuemon.Extensions.AspNetCore.Mvc.Filters namespace (breaking change) - ExceptionDescriptorExtensions class from the Cuemon.Extensions.Diagnostics namespace (breaking change) - ReplaceLineEndings extension method from the StringExtensions class in the Cuemon.Extensions namespace (breaking change) +- SafeInvokeAsync methods from the Patterns class in the Cuemon namespace (breaking change - moved to AsyncPatterns class in the Cuemon.Threading assembly) +- ActionFactory static class from the Cuemon namespace (moved to the Cuemon.Extensions namespace in the Cuemon.Extensions.Core assembly) +- FuncFactory static class from the Cuemon namespace (moved to the Cuemon.Extensions namespace in the Cuemon.Extensions.Core assembly) +- TesterFuncFactory static class from the Cuemon namespace (moved to the Cuemon.Extensions namespace in the Cuemon.Extensions.Core assembly) +- BinaryPrefix class from the Cuemon namespace (breaking change) +- BitStorageCapacity class from the Cuemon namespace (breaking change) +- BitUnit class from the Cuemon namespace (breaking change) +- ByteStorageCapacity class from the Cuemon namespace +- ByteUnit class from the Cuemon namespace (breaking change) +- DecimalPrefix class from the Cuemon namespace (breaking change) +- IPrefixMultiple interface from the Cuemon namespace (breaking change) +- IUnit interface from the Cuemon namespace (breaking change) +- MultipleTable class from the Cuemon namespace (breaking change) +- NamingStyle enum from the Cuemon namespace (breaking change) +- PrefixMultiple class from the Cuemon namespace (breaking change) +- PrefixUnit class from the Cuemon namespace (breaking change) +- StorageCapacity class from the Cuemon namespace (breaking change) +- StorageCapacityOptions class from the Cuemon namespace (breaking change) +- UnitFormatOptions class from the Cuemon namespace (breaking change) +- UnitPrefix enum from the Cuemon namespace (breaking change) +- UnitPrefixFormatter class from the Cuemon namespace (breaking change) +- ZeroPrefix class from the Cuemon namespace (breaking change) ## [8.3.2] - 2024-08-04 diff --git a/src/Cuemon.Core/BinaryPrefix.cs b/src/Cuemon.Core/BinaryPrefix.cs deleted file mode 100644 index 8874e0af6..000000000 --- a/src/Cuemon.Core/BinaryPrefix.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Cuemon -{ - /// - /// Defines a binary unit prefix for multiples of measurement for data that refers strictly to powers of 2. This class cannot be inherited. - /// - /// - public sealed class BinaryPrefix : PrefixMultiple - { - private static readonly Lazy> LazyPrefixes = new(() => - { - var list = new List() - { - Exbi, - Gibi, - Kibi, - Mebi, - Pebi, - Tebi, - Yobi, - Zebi - }; - return list; - }); - - /// - /// Gets the binary-multiple prefix kibi (symbol 'Ki'), 2^10 = 1024. - /// - /// The binary-multiple prefix kibi (symbol 'Ki'). - public static BinaryPrefix Kibi => new("kibi", "Ki", 10); - - /// - /// Gets the binary-multiple prefix mebi (symbol 'Mi'), 2^20 = 1048576. - /// - /// The binary-multiple prefix mebi (symbol 'Mi'). - public static BinaryPrefix Mebi => new("mebi", "Mi", 20); - - /// - /// Gets the binary-multiple prefix gibi (symbol 'Gi'), 2^30 = 1073741824. - /// - /// The binary-multiple prefix gibi (symbol 'Gi'). - public static BinaryPrefix Gibi => new("gibi", "Gi", 30); - - /// - /// Gets the binary-multiple prefix tebi (symbol 'Ti'), 2^40 = 1099511627776. - /// - /// The binary-multiple prefix tebi (symbol 'Ti'). - public static BinaryPrefix Tebi => new("tebi", "Ti", 40); - - /// - /// Gets the binary-multiple prefix pebi (symbol 'Pi'), 2^50 = 1125899906842624. - /// - /// The binary-multiple prefix pebi (symbol 'Pi'). - public static BinaryPrefix Pebi => new("pebi", "Pi", 50); - - /// - /// Gets the binary-multiple prefix exbi (symbol 'Ei'), 2^60 = 1152921504606846976. - /// - /// The binary-multiple prefix exbi (symbol 'Ei'). - public static BinaryPrefix Exbi => new("exbi", "Ei", 60); - - /// - /// Gets the binary-multiple prefix zebi (symbol 'Zi'), 2^70 = 1180591620717411303424. - /// - /// The binary-multiple prefix zebi (symbol 'Zi'). - public static BinaryPrefix Zebi => new("zebi", "Zi", 70); - - /// - /// Gets the binary-multiple prefix yobi (symbol 'Yi'), 2^80 = 1208925819614629174706176. - /// - /// The binary-multiple prefix yobi (symbol 'Yi'). - public static BinaryPrefix Yobi => new("yobi", "Yi", 80); - - /// - /// Gets the complete sequence of multiples and submultiples binary prefixes as specified by Institute of Electrical and Electronics Engineers (IEEE). - /// - /// The complete sequence of multiples and submultiples binary prefixes as specified by Institute of Electrical and Electronics Engineers (IEEE). - public static IEnumerable BinaryPrefixes => LazyPrefixes.Value; - - /// - /// Initializes a new instance of the struct. - /// - /// The name of the binary prefix. - /// The symbol of the binary prefix. - /// The number that specifies a power. - public BinaryPrefix(string name, string symbol, double exponent) : base(name, symbol, 2, exponent) - { - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/BitStorageCapacity.cs b/src/Cuemon.Core/BitStorageCapacity.cs deleted file mode 100644 index e82eb1475..000000000 --- a/src/Cuemon.Core/BitStorageCapacity.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Represent a table of both binary and metric prefixes for a . This class cannot be inherited from. - /// - /// - public sealed class BitStorageCapacity : StorageCapacity - { - /// - /// Creates a new instance of initialized with . - /// - /// The to convert. - /// The which may be configured. - /// A that is initialized with * (ceiling). - public static BitStorageCapacity FromBytes(double bytes, Action setup = null) - { - Validator.ThrowIfLowerThan(bytes, 0, nameof(bytes)); - return FromBits(Math.Ceiling(bytes * ByteUnit.BitsPerByte), setup); - } - - /// - /// Creates a new instance of initialized with . - /// - /// The to set the amount of bit for this table. - /// The which may be configured. - /// A that is equivalent to . - public static BitStorageCapacity FromBits(double bits, Action setup = null) - { - Validator.ThrowIfLowerThan(bits, 0, nameof(bits)); - return new BitStorageCapacity(new BitUnit(bits, PrefixMultiple.None, Patterns.ConfigureExchange(setup)), setup); - } - - /// - /// Initializes a new instance of the class. - /// - /// The to convert. - /// The which may be configured. - private BitStorageCapacity(BitUnit unit, Action setup = null) : base(unit, setup) - { - } - } -} diff --git a/src/Cuemon.Core/BitUnit.cs b/src/Cuemon.Core/BitUnit.cs deleted file mode 100644 index d059fb972..000000000 --- a/src/Cuemon.Core/BitUnit.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Represents a unit of measurement for bits and is used with measurement of data. - /// - /// - /// - /// - public sealed class BitUnit : PrefixUnit - { - /// - /// Defines the name of a bit unit. - /// - public const string Name = "bit"; - - /// - /// Defines the symbol of a bit unit. - /// - public const string Symbol = "b"; - - /// - /// Performs an implicit conversion from to . - /// - /// The to convert. - /// A that is equivalent to . - public static implicit operator double(BitUnit unit) - { - return unit.UnitValue; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The value of this unit expressed as bits. - /// The prefix to associate with this unit. - /// The which may be configured. - /// - /// is lower than 0 -or- - /// is less than a metric-multiple . - /// - public BitUnit(double value, IPrefixMultiple prefix, Action setup = null) : base(Name, Symbol, value, Validator.CheckParameter(prefix, () => - { - if (prefix != null && prefix != PrefixMultiple.None) { Validator.ThrowIfLowerThan(prefix.Multiplier, DecimalPrefix.Kilo.Multiplier, nameof(prefix.Multiplier), "Prefix multiplier must be greater or equal to 1000."); } - }), setup) - { - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/ByteStorageCapacity.cs b/src/Cuemon.Core/ByteStorageCapacity.cs deleted file mode 100644 index 98c558440..000000000 --- a/src/Cuemon.Core/ByteStorageCapacity.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Represent a table of both binary and metric prefixes for a . This class cannot be inherited from. - /// - /// - public sealed class ByteStorageCapacity : StorageCapacity - { - /// - /// Creates a new instance of initialized with . - /// - /// The to convert. - /// The which may be configured. - /// A that is initialized with / . - public static ByteStorageCapacity FromBits(double bits, Action setup = null) - { - if (bits < ByteUnit.BitsPerByte) { bits = ByteUnit.BitsPerByte; } - return FromBytes(bits / ByteUnit.BitsPerByte, setup); - } - - /// - /// Creates a new instance of initialized with . - /// - /// The to set the amount of byte for this table. - /// The which may be configured. - /// A that is equivalent to . - public static ByteStorageCapacity FromBytes(double bytes, Action setup = null) - { - Validator.ThrowIfLowerThan(bytes, 0, nameof(bytes)); - return new ByteStorageCapacity(new ByteUnit(bytes, PrefixMultiple.None, Patterns.ConfigureExchange(setup)), setup); - } - - /// - /// Initializes a new instance of the class. - /// - /// The to convert. - /// The which may be configured. - private ByteStorageCapacity(ByteUnit unit, Action setup = null) : base(unit, setup) - { - } - } -} diff --git a/src/Cuemon.Core/ByteUnit.cs b/src/Cuemon.Core/ByteUnit.cs deleted file mode 100644 index 4adc2594a..000000000 --- a/src/Cuemon.Core/ByteUnit.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Represents a unit of measurement for bytes and is used with measurement of data. - /// - /// - /// - /// - public sealed class ByteUnit : PrefixUnit - { - /// - /// Defines how many bits is needed for one byte. - /// - public const int BitsPerByte = 8; - - /// - /// Defines how many bits is needed for one nibble (one hexadecimal digit). - /// - public const int BitsPerNibble = BitsPerByte / 2; - - /// - /// Defines the name of a byte unit. - /// - public const string Name = "byte"; - - /// - /// Defines the symbol of a byte unit. - /// - public const string Symbol = "B"; - - /// - /// Performs an implicit conversion from to . - /// - /// The to convert. - /// A that is equivalent to . - public static implicit operator double(ByteUnit unit) - { - return unit.UnitValue; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The value of this unit expressed as bytes. - /// The prefix to associate with this unit. - /// The which may be configured. - /// - /// is lower than 0 -or- - /// is less than a metric-multiple . - /// - public ByteUnit(double value, IPrefixMultiple prefix, Action setup = null) : base(Name, Symbol, value, Validator.CheckParameter(prefix, () => - { - if (prefix != null && prefix != PrefixMultiple.None) { Validator.ThrowIfLowerThan(prefix.Multiplier, DecimalPrefix.Kilo.Multiplier, nameof(prefix.Multiplier), "Prefix multiplier must be greater or equal to 1000."); } - }), setup) - { - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/Convertible.cs b/src/Cuemon.Core/Convertible.cs index d28cc2d2e..a4bdb10cd 100644 --- a/src/Cuemon.Core/Convertible.cs +++ b/src/Cuemon.Core/Convertible.cs @@ -43,6 +43,16 @@ public static class Convertible /// public const int NullValue = 0; + /// + /// Defines how many bits is needed for one byte. + /// + public const int BitsPerByte = 8; + + /// + /// Defines how many bits is needed for one nibble (one hexadecimal digit). + /// + public const int BitsPerNibble = BitsPerByte / 2; + /// /// Registers the specified implementation of to make it globally known. /// @@ -99,7 +109,7 @@ public static ulong ReverseBits64(ulong input) private static ulong ReverseBits(ulong input, byte byteSize) { - var bitSize = byteSize * ByteUnit.BitsPerByte; + var bitSize = byteSize * BitsPerByte; ulong output = 0; for (var i = 0; i < bitSize; i++) { @@ -475,4 +485,4 @@ private static bool TryCast(IConvertible convertible, out T concrete) where T return false; } } -} \ No newline at end of file +} diff --git a/src/Cuemon.Core/DecimalPrefix.cs b/src/Cuemon.Core/DecimalPrefix.cs deleted file mode 100644 index 3c5e8720e..000000000 --- a/src/Cuemon.Core/DecimalPrefix.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Cuemon -{ - /// - /// Defines a decimal (metric) unit prefix for multiples and submultiples of measurement that refers strictly to powers of 10. This class cannot be inherited. - /// - /// - public sealed class DecimalPrefix : PrefixMultiple - { - private static readonly Lazy> LazyPrefixes = new(() => - { - var list = new List() - { - Atto, - Centi, - Deca, - Deci, - Exa, - Femto, - Giga, - Hecto, - Kilo, - Mega, - Micro, - Milli, - Nano, - Peta, - Pico, - Tera, - Yocto, - Yotta, - Zepto, - Zetta - }; - return list; - }); - - /// - /// Gets the decimal-submultiple prefix yocto (symbol 'y'), 10^-24 = 0.000000000000000000000001. - /// - /// The decimal-submultiple prefix yocto (symbol 'y'). - public static DecimalPrefix Yocto => new("yocto", "y", -24); - - /// - /// Gets the decimal-submultiple prefix zepto (symbol 'z'), 10^-21 = 0.000000000000000000001. - /// - /// The decimal-submultiple prefix zepto (symbol 'z'). - public static DecimalPrefix Zepto => new("zepto", "z", -21); - - /// - /// Gets the decimal-submultiple prefix atto (symbol 'a'), 10^-18 = 0.000000000000000001. - /// - /// The decimal-submultiple prefix atto (symbol 'a'). - public static DecimalPrefix Atto => new("atto", "a", -18); - - /// - /// Gets the decimal-submultiple prefix femto (symbol 'f'), 10^-15 = 0.000000000000001. - /// - /// The decimal-submultiple prefix femto (symbol 'f'). - public static DecimalPrefix Femto => new("femto", "f", -15); - - /// - /// Gets the decimal-submultiple prefix pico (symbol 'f'), 10^-12 = 0.000000000001. - /// - /// The decimal-submultiple prefix pico (symbol 'f'). - public static DecimalPrefix Pico => new("pico", "p", -12); - - /// - /// Gets the decimal-submultiple prefix nano (symbol 'n'), 10^-9 = 0.000000001. - /// - /// The decimal-submultiple prefix nano (symbol 'n'). - public static DecimalPrefix Nano => new("nano", "n", -9); - - /// - /// Gets the decimal-submultiple prefix micro (symbol 'μ'), 10^-6 = 0.000001. - /// - /// The decimal-submultiple prefix micro (symbol 'μ'). - public static DecimalPrefix Micro => new("micro", "μ", -6); - - /// - /// Gets the decimal-submultiple prefix milli (symbol 'μ'), 10^-3 = 0.001. - /// - /// The decimal-submultiple prefix milli (symbol 'μ'). - public static DecimalPrefix Milli => new("milli", "m", -3); - - /// - /// Gets the decimal-submultiple prefix centi (symbol 'c'), 10^-2 = 0.01. - /// - /// The decimal-submultiple prefix centi (symbol 'c'). - public static DecimalPrefix Centi => new("centi", "c", -2); - - /// - /// Gets the decimal-submultiple prefix deci (symbol 'd'), 10^-1 = 0.1. - /// - /// The decimal-submultiple prefix deci (symbol 'd'). - public static DecimalPrefix Deci => new("deci", "d", -1); - - /// - /// Gets the decimal-multiple prefix deca (symbol 'da'), 10^1 = 10. - /// - /// The decimal-multiple prefix deca (symbol 'da'). - public static DecimalPrefix Deca => new("deca", "da", 1); - - /// - /// Gets the decimal-multiple prefix hecto (symbol 'h'), 10^2 = 100. - /// - /// The decimal-multiple prefix hecto (symbol 'h'). - public static DecimalPrefix Hecto => new("hecto", "h", 2); - - /// - /// Gets the decimal-multiple prefix kilo (symbol 'k'), 10^3 = 1000. - /// - /// The decimal-multiple prefix kilo (symbol 'k'). - public static DecimalPrefix Kilo => new("kilo", "k", 3); - - /// - /// Gets the decimal-multiple prefix mega (symbol 'M'), 10^6 = 1000000. - /// - /// The decimal-multiple prefix mega (symbol 'M'). - public static DecimalPrefix Mega => new("mega", "M", 6); - - /// - /// Gets the decimal-multiple prefix giga (symbol 'G'), 10^9 = 1000000000. - /// - /// The decimal-multiple prefix giga (symbol 'G'). - public static DecimalPrefix Giga => new("giga", "G", 9); - - /// - /// Gets the decimal-multiple prefix tera (symbol 'T'), 10^12 = 1000000000000. - /// - /// The decimal-multiple prefix tera (symbol 'T'). - public static DecimalPrefix Tera => new("tera", "T", 12); - - /// - /// Gets the decimal-multiple prefix peta (symbol 'P'), 10^15 = 1000000000000000. - /// - /// The decimal-multiple prefix peta (symbol 'P'). - public static DecimalPrefix Peta => new("peta", "P", 15); - - /// - /// Gets the decimal-multiple prefix exa (symbol 'E'), 10^18 = 1000000000000000000. - /// - /// The decimal-multiple prefix exa (symbol 'E'). - public static DecimalPrefix Exa => new("exa", "E", 18); - - /// - /// Gets the decimal-multiple prefix zetta (symbol 'Z'), 10^21 = 1000000000000000000000. - /// - /// The decimal-multiple prefix zetta (symbol 'Z'). - public static DecimalPrefix Zetta => new("zetta", "Z", 21); - - /// - /// Gets the decimal-multiple prefix yotta (symbol 'Y'), 10^24 = 1000000000000000000000000. - /// - /// The decimal-multiple prefix yotta (symbol 'Y'). - public static DecimalPrefix Yotta => new("yotta", "Y", 24); - - /// - /// Gets the complete sequence of multiples and submultiples metric prefixes as specified by International System of Units (SI). - /// - /// The complete sequence of multiples and submultiples metric prefixes as specified by International System of Units (SI). - public static IEnumerable MetricPrefixes => LazyPrefixes.Value; - - /// - /// Initializes a new instance of the struct. - /// - /// The name of the decimal prefix. - /// The symbol of the decimal prefix. - /// The number that specifies a power. - public DecimalPrefix(string name, string symbol, double exponent) : base(name, symbol, 10, exponent) - { - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/Diagnostics/ProcessInfo.cs b/src/Cuemon.Core/Diagnostics/ProcessInfo.cs index 92f2e299d..36bb206cd 100644 --- a/src/Cuemon.Core/Diagnostics/ProcessInfo.cs +++ b/src/Cuemon.Core/Diagnostics/ProcessInfo.cs @@ -30,9 +30,9 @@ public override string ToString() builder.Append(Alphanumeric.CaretChar); builder.Append(FormattableString.Invariant($"ThreadCount: {Process.Threads.Count}")); builder.Append(Alphanumeric.CaretChar); - builder.Append(FormattableString.Invariant($"WorkingSet64: {ByteStorageCapacity.FromBytes(Process.WorkingSet64, o => o.Prefix = UnitPrefix.Decimal)}")); + builder.Append(FormattableString.Invariant($"WorkingSet64: {Process.WorkingSet64.ToString(CultureInfo.InvariantCulture)}")); builder.Append(Alphanumeric.CaretChar); - builder.Append(FormattableString.Invariant($"TotalWorkingSet64: {ByteStorageCapacity.FromBytes(Process.GetProcesses().Select(p => p.WorkingSet64).Sum(), o => o.Prefix = UnitPrefix.Decimal)}")); + builder.Append(FormattableString.Invariant($"TotalWorkingSet64: {Process.GetProcesses().Select(p => p.WorkingSet64).Sum().ToString(CultureInfo.InvariantCulture)}")); builder.Append(Alphanumeric.CaretChar); builder.Append(FormattableString.Invariant($"TotalProcessorTime: {Process.TotalProcessorTime.ToString("G", CultureInfo.InvariantCulture)}")); } diff --git a/src/Cuemon.Core/Extensions/PrefixMultipleDecoratorExtensions.cs b/src/Cuemon.Core/Extensions/PrefixMultipleDecoratorExtensions.cs deleted file mode 100644 index 681802bd4..000000000 --- a/src/Cuemon.Core/Extensions/PrefixMultipleDecoratorExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Reflection; - -namespace Cuemon -{ - /// - /// Extension methods for the class hidden behind the interface. - /// - /// - /// - public static class PrefixMultipleDecoratorExtensions - { - /// - /// Converts the enclosed of the to an implementation equivalent. - /// - /// The to extend. - /// The unit of measurement that is used as a standard for measurement of the same kind of quantity. - /// The which may be configured. - /// An implementation. - public static IPrefixUnit ApplyPrefix(this IDecorator decorator, IPrefixUnit unit, Action setup = null) - { - Validator.ThrowIfNull(unit); - try - { - return (IPrefixUnit)Activator.CreateInstance(unit.GetType(), unit.UnitValue, decorator.Inner, setup); - } - catch (TargetInvocationException e) - { - throw e.InnerException ?? e; - } - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/IPrefixMultiple.cs b/src/Cuemon.Core/IPrefixMultiple.cs deleted file mode 100644 index 2a80ac234..000000000 --- a/src/Cuemon.Core/IPrefixMultiple.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Cuemon -{ - /// - /// Defines a unit prefix that can can be expressed as a either a multiple or a submultiple of the unit of measurement. - /// - /// - /// - public interface IPrefixMultiple - { - /// - /// Gets the name of the unit prefix. - /// - /// The name of the unit prefix. - string Name { get; } - - /// - /// Gets the symbol of the unit prefix. - /// - /// The symbol of the unit prefix. - string Symbol { get; } - - /// - /// Gets the unit prefix multiplier. - /// - /// The unit prefix multiplier. - double Multiplier { get; } - - /// - /// Converts the unit base to a unit prefix value. - /// - /// The value of the base unit. - /// A that represents a unit prefix value. - double ToPrefixValue(double value); - - /// - /// Converts the back to a unit base value. - /// - /// The value of the unit prefix. - /// A that represents a unit base value. - double ToBaseValue(double prefixValue); - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/IUnit.cs b/src/Cuemon.Core/IUnit.cs deleted file mode 100644 index 0d6b90554..000000000 --- a/src/Cuemon.Core/IUnit.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Defines a unit of measurement that is used as a standard for measurement of the same kind of quantity. - /// Implements the - /// - /// - public interface IUnit : IEquatable - { - /// - /// Gets the name of the base unit. - /// - /// The name of the base unit. - string UnitName { get; } - - /// - /// Gets the symbol of the base unit. - /// - /// The symbol of the base unit. - string UnitSymbol { get; } - - /// - /// Gets the base value of the unit. - /// - /// The base value of the unit. - double UnitValue { get; } - - /// - /// Returns a that represents this instance. - /// - /// The which need to be configured. - /// A that represents this instance. - string ToString(Action setup); - } - - /// - /// Defines a unit of measurement that is used as a standard for measurement of the same kind of quantity. - /// Any other quantity of that kind can be expressed as a multiple or fraction of the unit of measurement. - /// Implements the - /// - /// - public interface IPrefixUnit : IUnit - { - /// - /// Gets the prefix that can be either a multiple or a submultiple to the base unit. - /// - /// The prefix that can be either a multiple or a submultiple to the base unit. - IPrefixMultiple Prefix { get; } - - /// - /// Gets the prefix value of the base unit. - /// - /// The prefix value of the base unit. - double PrefixValue { get; } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/MultipleTable.cs b/src/Cuemon.Core/MultipleTable.cs deleted file mode 100644 index d4ea5816a..000000000 --- a/src/Cuemon.Core/MultipleTable.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Provides a way to represent a table of prefixes that precedes a unit of measure to indicate a multiple of the unit. - /// Implements the - /// - /// - public abstract class MultipleTable : IEquatable - { - /// - /// Performs an implicit conversion from to . - /// - /// The to convert. - /// A that is equivalent to . - public static implicit operator double(MultipleTable mt) - { - return mt.Unit.UnitValue; - } - - /// - /// Initializes a new instance of the class. - /// - /// The instance of an object that implements the interface. - /// - /// cannot be null. - /// - protected MultipleTable(IPrefixUnit unit) - { - Validator.ThrowIfNull(unit); - Unit = unit; - } - - /// - /// Gets the base unit of this table. - /// - /// The base unit of this table. - public IPrefixUnit Unit { get; } - - /// - /// Returns a that represents largest metric-multiple prefix of this instance. - /// - /// A that represents largest metric-multiple prefix of this instance. - /// Evaluates the largest metric-multiple prefix that is greater or equal to 1 and returns that as either or formatted. - public override string ToString() - { - return Unit.ToString(); - } - - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// true if the current object is equal to the parameter; otherwise, false. - public virtual bool Equals(IUnit other) - { - if (other == null) { return false; } - return Unit.UnitValue.Equals(other.UnitValue); - } - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The object to compare with the current object. - /// true if the specified is equal to this instance; otherwise, false. - public override bool Equals(object obj) - { - if (obj is null) { return false; } - if (ReferenceEquals(this, obj)) { return true; } - if (obj.GetType() != GetType()) { return false; } - return Equals(((MultipleTable)obj).Unit); - } - - /// - /// Returns a hash code for this instance. - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - public override int GetHashCode() - { - return Generate.HashCode32(Unit.UnitValue); - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/NamingStyle.cs b/src/Cuemon.Core/NamingStyle.cs deleted file mode 100644 index db1758d69..000000000 --- a/src/Cuemon.Core/NamingStyle.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Cuemon -{ - /// - /// Specifies ways that a string must be represented in terms of naming style. - /// - public enum NamingStyle - { - /// - /// Indicates the compound naming style string representation (eg. 1 Gigabyte / 0.93 Gibibyte). - /// - Compound, - /// - /// Indicates the symbol naming style string representation (eg. 1 GB / 0.93 GiB). - /// - Symbol - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/PrefixMultiple.cs b/src/Cuemon.Core/PrefixMultiple.cs deleted file mode 100644 index b376ccbce..000000000 --- a/src/Cuemon.Core/PrefixMultiple.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Represents the base class from which all implementations of unit prefix that can can be expressed as a either a multiple or a submultiple of the unit of measurement should derive. - /// Implements the - /// - /// - public abstract class PrefixMultiple : IPrefixMultiple - { - /// - /// Defines a prefix multiple of none (0). - /// - public static readonly IPrefixMultiple None = new ZeroPrefix(); - - /// - /// Initializes a new instance of the struct. - /// - /// The name of the binary unit. - /// The symbol of the unit prefix. - /// The number to be raised to a power. - /// The number that specifies a power. - protected PrefixMultiple(string name, string symbol, double value, double exponent) - { - Name = name; - Symbol = symbol; - Value = value; - Multiplier = Math.Pow(value, exponent); - } - - private double Value { get; } - - /// - /// Gets the name of the unit prefix. - /// - /// The name of the unit prefix. - public string Name { get; } - - /// - /// Gets the symbol of the unit prefix. - /// - /// The symbol of the unit prefix. - public string Symbol { get; } - - /// - /// Gets the unit prefix multiplier. - /// - /// The unit prefix multiplier. - public double Multiplier { get; } - - /// - /// Converts the unit base to a unit prefix value. - /// - /// The value of the base unit. - /// A that represents a unit prefix value. - public double ToPrefixValue(double value) - { - return value / Multiplier; - } - - /// - /// Converts the unit back to a unit base value. - /// - /// The value of the unit prefix. - /// A that represents a unit base value. - public double ToBaseValue(double prefixValue) - { - return prefixValue * Multiplier; - } - - /// - /// Returns a that represents this instance. - /// - /// A that represents this instance. - public override string ToString() - { - return FormattableString.Invariant($"{Name} ({Symbol}) {Value}^{Math.Log(Multiplier, Value)}"); - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/PrefixUnit.cs b/src/Cuemon.Core/PrefixUnit.cs deleted file mode 100644 index 13b62edc4..000000000 --- a/src/Cuemon.Core/PrefixUnit.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; - -namespace Cuemon -{ - /// - /// Represents the base class from which all implementations of a unit of measurement should derive. - /// Implements the - /// - /// - public abstract class PrefixUnit : IPrefixUnit - { - private readonly Action _setup; - - /// - /// Initializes a new instance of the struct. - /// - /// The name of the unit. - /// The symbol of the unit. - /// The value of this unit expressed as bytes. - /// The prefix to associate with this unit. - /// The which may be configured. - /// - /// cannot be null -or- - /// cannot be null. - /// - /// - /// cannot be empty or consist only of white-space characters -or- - /// cannot be empty or consist only of white-space characters. - /// - /// - /// is lower than 0. - /// - protected PrefixUnit(string name, string symbol, double value, IPrefixMultiple prefix, Action setup = null) - { - Validator.ThrowIfNullOrWhitespace(name); - Validator.ThrowIfNullOrWhitespace(symbol); - Validator.ThrowIfLowerThan(value, 0, nameof(value)); - - UnitName = name; - UnitSymbol = symbol; - UnitValue = value; - Prefix = prefix ?? PrefixMultiple.None; - PrefixValue = Prefix.ToPrefixValue(value); - _setup = setup; - } - - /// - /// Gets the name of this unit. - /// - /// The name of this unit. - public string UnitName { get; } - - /// - /// Gets the symbol of this unit. - /// - /// The symbol of this unit. - public string UnitSymbol { get; } - - /// - /// Gets the value of this unit expressed as bytes. - /// - /// The value of this unit. - public double UnitValue { get; } - - /// - /// Gets the prefix multiple to this unit. - /// - /// The prefix multiple to this unit. - public IPrefixMultiple Prefix { get; } - - /// - /// Gets the prefix value of this unit. - /// - /// The prefix value of this unit. - public double PrefixValue { get; } - - /// - /// Indicates whether the current object is equal to another object of the same type. - /// - /// An object to compare with this object. - /// true if the current object is equal to the parameter; otherwise, false. - public virtual bool Equals(IUnit other) - { - if (other == null) { return false; } - return UnitValue.Equals(other.UnitValue); - } - - /// - /// Returns a that represents this instance. - /// - /// A that represents this instance. - public override string ToString() - { - return ToString(_setup); - } - - /// - /// Returns a that represents this instance. - /// - /// The which may be configured. - /// A that represents this instance. - public string ToString(Action setup) - { - var options = Patterns.Configure(setup); - var formatter = new UnitPrefixFormatter(); - var format = Prefix == PrefixMultiple.None ? $"{options.NumberFormat} {UnitSymbol}" : $"{options.NumberFormat} {Prefix.Symbol}{UnitSymbol}"; - return formatter.Format(options.Style == NamingStyle.Compound ? $"{format} X" : format, this, options.FormatProvider); - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/Security/FowlerNollVoHash.cs b/src/Cuemon.Core/Security/FowlerNollVoHash.cs index bb4a720bd..ab00a38cf 100644 --- a/src/Cuemon.Core/Security/FowlerNollVoHash.cs +++ b/src/Cuemon.Core/Security/FowlerNollVoHash.cs @@ -66,9 +66,9 @@ public override HashResult ComputeHash(byte[] input) break; } var result = hash.ToByteArray(); - Array.Resize(ref result, Bits / ByteUnit.BitsPerByte); + Array.Resize(ref result, Bits / Convertible.BitsPerByte); result = Convertible.ReverseEndianness(result, o => o.ByteOrder = Options.ByteOrder); return new HashResult(result); } } -} \ No newline at end of file +} diff --git a/src/Cuemon.Core/StorageCapacity.cs b/src/Cuemon.Core/StorageCapacity.cs deleted file mode 100644 index e88e506c1..000000000 --- a/src/Cuemon.Core/StorageCapacity.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Text; - -namespace Cuemon -{ - /// - /// Provides a way to represent a table of both binary and metric prefixes that precedes a unit of measure optimized for storage capacity measurement standards. - /// - /// - public abstract class StorageCapacity : MultipleTable - { - private readonly Action _setup; - private readonly Action _us; - - /// - /// Initializes a new instance of the class. - /// - /// The instance of an object that implements the interface. - /// The which may be configured. - /// - /// cannot be null. - /// - protected StorageCapacity(IPrefixUnit unit, Action setup = null) : base(unit) - { - _setup = setup; - _us = Patterns.ConfigureExchange(_setup); - } - - /// - /// Gets the binary-multiple prefix kibi (Ki). - /// - /// The binary-multiple prefix kibi (Ki). - public IPrefixUnit Kibi => Decorator.Enclose(BinaryPrefix.Kibi).ApplyPrefix(Unit, _us); - - /// - /// Gets the binary-multiple prefix mebi (Mi). - /// - /// The binary-multiple prefix mebi (Mi). - public IPrefixUnit Mebi => Decorator.Enclose(BinaryPrefix.Mebi).ApplyPrefix(Unit, _us); - - /// - /// Gets the binary-multiple prefix gibi (Gi). - /// - /// The binary-multiple prefix gibi (Gi). - public IPrefixUnit Gibi => Decorator.Enclose(BinaryPrefix.Gibi).ApplyPrefix(Unit, _us); - - /// - /// Gets the binary-multiple prefix tebi (Ti). - /// - /// The binary-multiple prefix tebi (Ti). - public IPrefixUnit Tebi => Decorator.Enclose(BinaryPrefix.Tebi).ApplyPrefix(Unit, _us); - - /// - /// Gets the binary-multiple prefix pebi (Pi). - /// - /// The binary-multiple prefix pebi (Pi). - public IPrefixUnit Pebi => Decorator.Enclose(BinaryPrefix.Pebi).ApplyPrefix(Unit, _us); - - /// - /// Gets the metric-multiple prefix kilo (k). - /// - /// The metric-multiple prefix kilo (k). - public IPrefixUnit Kilo => Decorator.Enclose(DecimalPrefix.Kilo).ApplyPrefix(Unit, _us); - - /// - /// Gets the metric-multiple prefix mega (M). - /// - /// The metric-multiple prefix mega (M). - public IPrefixUnit Mega => Decorator.Enclose(DecimalPrefix.Mega).ApplyPrefix(Unit, _us); - - /// - /// Gets the metric-multiple prefix giga (G). - /// - /// The metric-multiple prefix giga (G). - public IPrefixUnit Giga => Decorator.Enclose(DecimalPrefix.Giga).ApplyPrefix(Unit, _us); - - /// - /// Gets the metric-multiple prefix tera (T). - /// - /// The metric-multiple prefix tera (T). - public IPrefixUnit Tera => Decorator.Enclose(DecimalPrefix.Tera).ApplyPrefix(Unit, _us); - - /// - /// Gets the metric-multiple prefix peta (P). - /// - /// The metric-multiple prefix peta (P). - public IPrefixUnit Peta => Decorator.Enclose(DecimalPrefix.Peta).ApplyPrefix(Unit, _us); - - /// - /// Returns a that represents largest metric-multiple prefix of this instance. - /// - /// A that represents largest metric-multiple prefix of this instance. - /// Evaluates the largest metric-multiple prefix that is greater or equal to 1 and returns that as either or formatted. - public override string ToString() - { - var options = Patterns.Configure(_setup); - if (Peta.PrefixValue >= 1) { return options.Prefix == UnitPrefix.Binary ? Pebi.ToString() : Peta.ToString(); } - if (Tera.PrefixValue >= 1) { return options.Prefix == UnitPrefix.Binary ? Tebi.ToString() : Tera.ToString(); } - if (Giga.PrefixValue >= 1) { return options.Prefix == UnitPrefix.Binary ? Gibi.ToString() : Giga.ToString(); } - if (Mega.PrefixValue >= 1) { return options.Prefix == UnitPrefix.Binary ? Mebi.ToString() : Mega.ToString(); } - if (Kilo.PrefixValue >= 1) { return options.Prefix == UnitPrefix.Binary ? Kibi.ToString() : Kilo.ToString(); } - return Unit.ToString(); - } - - /// - /// Returns an aggregated of all multiple prefix of this instance. - /// - /// if set to true all binary-multiple prefix is included in the aggregate. - /// if set to true all metric-multiple prefix is included in the aggregate. - /// if set to true the base unit is included in the aggregate. - /// System.String. - public string ToAggregateString(bool includePowerOfTwoGroup = true, bool includePowerOfTenGroup = true, bool includeUnit = true) - { - var sb = new StringBuilder(); - if (includePowerOfTwoGroup) - { - sb.AppendLine(Pebi.ToString()); - sb.AppendLine(Tebi.ToString()); - sb.AppendLine(Gibi.ToString()); - sb.AppendLine(Mebi.ToString()); - sb.AppendLine(Kibi.ToString()); - } - if (includePowerOfTenGroup) - { - sb.AppendLine(Peta.ToString()); - sb.AppendLine(Tera.ToString()); - sb.AppendLine(Giga.ToString()); - sb.AppendLine(Mega.ToString()); - sb.AppendLine(Kilo.ToString()); - } - if (includeUnit) { sb.AppendLine(Unit.ToString()); } - return sb.ToString(); - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/StorageCapacityOptions.cs b/src/Cuemon.Core/StorageCapacityOptions.cs deleted file mode 100644 index b02ab4ab2..000000000 --- a/src/Cuemon.Core/StorageCapacityOptions.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Globalization; - -namespace Cuemon -{ - /// - /// Configuration options for . - /// - /// - /// - public sealed class StorageCapacityOptions : FormattingOptions - { - /// - /// Initializes a new instance of the class. - /// - /// - /// The following table shows the initial property values for an instance of . - /// - /// - /// Property - /// Initial Value - /// - /// - /// - /// - /// - /// - /// - /// #,##0.## - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public StorageCapacityOptions() - { - Style = NamingStyle.Symbol; - NumberFormat = "#,##0.##"; - Prefix = UnitPrefix.Binary; - } - - /// - /// Gets or sets the desired naming style. - /// - /// The desired naming style. - public NamingStyle Style { get; set; } - - /// - /// Gets or sets the desired number format when using ToString(). - /// - /// The desired number format when using ToString(). - public string NumberFormat { get; set; } - - /// - /// Gets or sets the proffered when calling ToString(). - /// - /// The proffered when calling ToString(). - public UnitPrefix Prefix { get; set; } - } -} diff --git a/src/Cuemon.Core/UnitFormatOptions.cs b/src/Cuemon.Core/UnitFormatOptions.cs deleted file mode 100644 index 86bddf8c4..000000000 --- a/src/Cuemon.Core/UnitFormatOptions.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Globalization; - -namespace Cuemon -{ - /// - /// Configuration options for and . - /// Implements the - /// - /// - /// - /// - /// - /// - public sealed class UnitFormatOptions : FormattingOptions - { - /// - /// Initializes a new instance of the class. - /// - /// - /// The following table shows the initial property values for an instance of . - /// - /// - /// Property - /// Initial Value - /// - /// - /// - /// - /// - /// - /// - /// #,##0.## - /// - /// - /// - /// - /// - /// - /// - public UnitFormatOptions() - { - Style = NamingStyle.Symbol; - NumberFormat = "#,##0.##"; - } - - /// - /// Gets or sets the desired naming style. - /// - /// The desired naming style. - public NamingStyle Style { get; set; } - - /// - /// Gets or sets the desired number format. - /// - /// The desired number format. - public string NumberFormat { get; set; } - } -} diff --git a/src/Cuemon.Core/UnitPrefix.cs b/src/Cuemon.Core/UnitPrefix.cs deleted file mode 100644 index a5ccf1fe3..000000000 --- a/src/Cuemon.Core/UnitPrefix.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Cuemon -{ - /// - /// Specifies the two standards for binary multiples and decimal multiples. - /// - public enum UnitPrefix - { - /// - /// Defines the IEEE 1541 standard for binary prefix that refers strictly to powers of 2 (eg. one kibibit represents 1024 bits and not 1000 bits). - /// - Binary, - /// - /// Defines the International System of Units (SI) standard for metric prefixes that refers strictly to powers of 10 (eg. one kilobit represents 1000 bits and not 1024 bits). - /// - Decimal - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/UnitPrefixFormatter.cs b/src/Cuemon.Core/UnitPrefixFormatter.cs deleted file mode 100644 index cb4332737..000000000 --- a/src/Cuemon.Core/UnitPrefixFormatter.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Cuemon -{ - /// - /// Defines the string formatting of objects having an implementation of either or . - /// Implements the - /// Implements the - /// - /// - /// - /// - /// - public class UnitPrefixFormatter : IFormatProvider, ICustomFormatter - { - private static readonly string[] BaseFormats = { BitUnit.Name, ByteUnit.Name, BitUnit.Symbol, ByteUnit.Symbol }; - private static readonly IEnumerable MultipleFormats = DecimalPrefix.MetricPrefixes.Where(dp => dp.Multiplier >= 1000).Select(dp => $"{dp.Symbol}{BitUnit.Symbol}") - .Concat(DecimalPrefix.MetricPrefixes.Where(dp => dp.Multiplier >= 1000).Select(dp => $"{dp.Symbol}{ByteUnit.Symbol}")) - .Concat(BinaryPrefix.BinaryPrefixes.Select(dp => $"{dp.Symbol}{BitUnit.Symbol}")) - .Concat(BinaryPrefix.BinaryPrefixes.Select(dp => $"{dp.Symbol}{BitUnit.Name}")) - .Concat(BinaryPrefix.BinaryPrefixes.Select(dp => $"{dp.Symbol}{ByteUnit.Symbol}")); - - /// - /// Returns an object that provides formatting services for the specified type. - /// - /// An object that specifies the type of format object to return. - /// An instance of the object specified by , if the implementation can supply that type of object; otherwise, null. - public object GetFormat(Type formatType) - { - if (formatType == typeof(ICustomFormatter)) { return this; } - return null; - } - - /// - /// Converts the value of a specified to an equivalent string representation using specified and culture-specific format . - /// - /// A format string containing formatting specifications. - /// An object that implements either interface , or both. - /// An object that supplies format information about . - /// The string representation of the value of , formatted as specified by and . - public string Format(string format, object arg, IFormatProvider formatProvider) - { - var formats = format.Split(' '); - if (arg is IPrefixUnit unit && formats.Intersect(MultipleFormats, StringComparer.Ordinal).Any()) { return FormatInterpreter(formats, unit, formatProvider); } - if (arg is IUnit baseUnit && formats.Intersect(BaseFormats, StringComparer.Ordinal).Any()) { return FormatInterpreter(formats, baseUnit, formatProvider); } - return null; - } - - private static string FormatInterpreter(string[] formats, IPrefixUnit unit, IFormatProvider provider) - { - var numberFormat = formats[0].Trim(); - var unitFormat = formats[1].Trim(); - var useCompoundFormat = formats.Last().Trim() == "X"; - return string.Format(provider, "{0} {1}", unit.PrefixValue.ToString(numberFormat, provider), useCompoundFormat ? $"{unit.Prefix.Name}{unit.UnitName}" : unitFormat); - } - - private static string FormatInterpreter(string[] formats, IUnit unit, IFormatProvider provider) - { - var numberFormat = formats[0].Trim(); - var unitFormat = formats[1].Trim(); - var useCompoundFormat = formats.Last().Trim() == "X"; - return string.Format(provider, "{0} {1}", unit.UnitValue.ToString(numberFormat, provider), useCompoundFormat ? $"{unit.UnitName}" : unitFormat); - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Core/ZeroPrefix.cs b/src/Cuemon.Core/ZeroPrefix.cs deleted file mode 100644 index aaa4706cd..000000000 --- a/src/Cuemon.Core/ZeroPrefix.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Cuemon -{ - internal sealed class ZeroPrefix : PrefixMultiple - { - internal ZeroPrefix() : base("", "", 0, 0) - { - } - } -} \ No newline at end of file diff --git a/src/Cuemon.Extensions.Core/DoubleExtensions.cs b/src/Cuemon.Extensions.Core/DoubleExtensions.cs index ccbb1e51d..7b93fd644 100644 --- a/src/Cuemon.Extensions.Core/DoubleExtensions.cs +++ b/src/Cuemon.Extensions.Core/DoubleExtensions.cs @@ -67,4 +67,4 @@ public static double RoundOff(this double value, RoundOffAccuracy accuracy) return Math.Round(value / (long)accuracy) * (long)accuracy; } } -} \ No newline at end of file +} diff --git a/src/Cuemon.Core/RoundOffAccuracy.cs b/src/Cuemon.Extensions.Core/RoundOffAccuracy.cs similarity index 97% rename from src/Cuemon.Core/RoundOffAccuracy.cs rename to src/Cuemon.Extensions.Core/RoundOffAccuracy.cs index 77f07cf77..b699fce68 100644 --- a/src/Cuemon.Core/RoundOffAccuracy.cs +++ b/src/Cuemon.Extensions.Core/RoundOffAccuracy.cs @@ -1,4 +1,4 @@ -namespace Cuemon +namespace Cuemon.Extensions { /// /// The accuracy of a rounding for a computed number. @@ -30,4 +30,4 @@ public enum RoundOffAccuracy /// NearestMillion = NearestTenth * NearestHundredThousandth } -} \ No newline at end of file +} diff --git a/src/Cuemon.Extensions.Net/Security/SignedUriOptions.cs b/src/Cuemon.Extensions.Net/Security/SignedUriOptions.cs index bf3172b39..5372f7fdd 100644 --- a/src/Cuemon.Extensions.Net/Security/SignedUriOptions.cs +++ b/src/Cuemon.Extensions.Net/Security/SignedUriOptions.cs @@ -176,8 +176,8 @@ public string ContentMd5Header set { Validator.ThrowIfNullOrWhitespace(value); - Validator.ThrowIfLowerThan(value.Length, MessageDigest5.BitSize / ByteUnit.BitsPerNibble, nameof(value), FormattableString.Invariant($"The length of the value is lower than 128-bit / 32 byte.")); - Validator.ThrowIfGreaterThan(value.Length, MessageDigest5.BitSize / ByteUnit.BitsPerNibble, nameof(value), FormattableString.Invariant($"The length of the value is greater than 128-bit / 32 byte.")); + Validator.ThrowIfLowerThan(value.Length, MessageDigest5.BitSize / Convertible.BitsPerNibble, nameof(value), FormattableString.Invariant($"The length of the value is lower than 128-bit / 32 byte.")); + Validator.ThrowIfGreaterThan(value.Length, MessageDigest5.BitSize / Convertible.BitsPerNibble, nameof(value), FormattableString.Invariant($"The length of the value is greater than 128-bit / 32 byte.")); Validator.ThrowIfNotBase64String(value); _contentMd5Header = value; } diff --git a/src/Cuemon.Security.Cryptography/AesCryptor.cs b/src/Cuemon.Security.Cryptography/AesCryptor.cs index e60ab45aa..b4b8ffd33 100644 --- a/src/Cuemon.Security.Cryptography/AesCryptor.cs +++ b/src/Cuemon.Security.Cryptography/AesCryptor.cs @@ -40,8 +40,8 @@ public AesCryptor(byte[] key, byte[] initializationVector) { Validator.ThrowIfNull(key); Validator.ThrowIfNull(initializationVector); - var keyBits = key.Length * ByteUnit.BitsPerByte; - var initializationVectorBits = initializationVector.Length * ByteUnit.BitsPerByte; + var keyBits = key.Length * Convertible.BitsPerByte; + var initializationVectorBits = initializationVector.Length * Convertible.BitsPerByte; if (!(keyBits == 128 || keyBits == 192 || keyBits == 256)) { throw new CryptographicException("The key does not meet the required fixed size of either 128 bits, 192 bits or 256 bits."); } if (initializationVectorBits != BlockSize) { throw new CryptographicException("The initialization vector does not meet the required fixed size of 128 bits."); } Key = key; @@ -124,7 +124,7 @@ private byte[] CryptoTransformCore(byte[] value, AesMode mode, ActionA random 128 bit generated initialization vector (IV). public static byte[] GenerateInitializationVector() { - return Convertible.GetBytes(Generate.RandomString(BlockSize / ByteUnit.BitsPerByte, Alphanumeric.LettersAndNumbers, Alphanumeric.PunctuationMarks), options => + return Convertible.GetBytes(Generate.RandomString(BlockSize / Convertible.BitsPerByte, Alphanumeric.LettersAndNumbers, Alphanumeric.PunctuationMarks), options => { options.Encoding = Encoding.UTF8; options.Preamble = PreambleSequence.Remove; diff --git a/src/Cuemon.Security.Cryptography/AesKeyOptions.cs b/src/Cuemon.Security.Cryptography/AesKeyOptions.cs index 6ad56c205..a09635932 100644 --- a/src/Cuemon.Security.Cryptography/AesKeyOptions.cs +++ b/src/Cuemon.Security.Cryptography/AesKeyOptions.cs @@ -59,11 +59,11 @@ public AesKeyOptions() switch (size) { case AesSize.Aes128: - return Generate.RandomString(128 / ByteUnit.BitsPerByte, characters); + return Generate.RandomString(128 / Convertible.BitsPerByte, characters); case AesSize.Aes192: - return Generate.RandomString(192 / ByteUnit.BitsPerByte, characters); + return Generate.RandomString(192 / Convertible.BitsPerByte, characters); default: - return Generate.RandomString(256 / ByteUnit.BitsPerByte, characters); + return Generate.RandomString(256 / Convertible.BitsPerByte, characters); } }; } diff --git a/src/Cuemon.Core/RelationalOperator.cs b/src/Cuemon.Threading/RelationalOperator.cs similarity index 97% rename from src/Cuemon.Core/RelationalOperator.cs rename to src/Cuemon.Threading/RelationalOperator.cs index 0e2de3f0c..569a0a941 100644 --- a/src/Cuemon.Core/RelationalOperator.cs +++ b/src/Cuemon.Threading/RelationalOperator.cs @@ -1,4 +1,4 @@ -namespace Cuemon +namespace Cuemon.Threading { /// /// Defines the most common numerical relational operators. @@ -33,4 +33,4 @@ public enum RelationalOperator /// LessThanOrEqual } -} \ No newline at end of file +} diff --git a/test/Cuemon.Core.Tests/BinaryPrefixTest.cs b/test/Cuemon.Core.Tests/BinaryPrefixTest.cs deleted file mode 100644 index 16ffa5a28..000000000 --- a/test/Cuemon.Core.Tests/BinaryPrefixTest.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Codebelt.Extensions.Xunit; -using Xunit; -using Xunit.Abstractions; - -namespace Cuemon -{ - public class BinaryPrefixTest : Test - { - public BinaryPrefixTest(ITestOutputHelper output) : base(output) - { - } - - [Fact] - public void BinaryPrefix_ShouldVerifyMultiplePrefixConstants() - { - Assert.Equal(BinaryPrefix.Kibi.Multiplier, 1024d); - Assert.Equal(BinaryPrefix.Mebi.Multiplier, 1048576d); - Assert.Equal(BinaryPrefix.Gibi.Multiplier, 1073741824d); - Assert.Equal(BinaryPrefix.Tebi.Multiplier, 1099511627776d); - Assert.Equal(BinaryPrefix.Pebi.Multiplier, 1125899906842624d); - Assert.Equal(BinaryPrefix.Exbi.Multiplier, 1152921504606846976d); - Assert.Equal(BinaryPrefix.Zebi.Multiplier, 1180591620717411303424d); - Assert.Equal(BinaryPrefix.Yobi.Multiplier, 1208925819614629174706176d); - } - } -} \ No newline at end of file diff --git a/test/Cuemon.Core.Tests/BitStorageCapacityTest.cs b/test/Cuemon.Core.Tests/BitStorageCapacityTest.cs deleted file mode 100644 index b941f76ba..000000000 --- a/test/Cuemon.Core.Tests/BitStorageCapacityTest.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Codebelt.Extensions.Xunit; -using Xunit; -using Xunit.Abstractions; - -namespace Cuemon -{ - public class BitStorageCapacityTest : Test - { - public BitStorageCapacityTest(ITestOutputHelper output) : base(output) - { - } - - [Fact] - public void BitStorageCapacity_ShouldBeEqualWithAFactorOfEight() - { - var x = BitStorageCapacity.FromBytes(1000000000); - var y = BitStorageCapacity.FromBits(8000000000); - Assert.Equal(x, y); - } - - [Fact] - public void BitStorageCapacity_UseSymbol_ShouldConvertOneBillionBitsToBinaryAndMetricPrefixToStringRepresentation() - { - var x = BitStorageCapacity.FromBits(1000000000); - - Assert.Equal("0 Pib", x.Pebi.ToString()); - Assert.Equal("0 Tib", x.Tebi.ToString()); - Assert.Equal("0.93 Gib", x.Gibi.ToString()); - Assert.Equal("953.67 Mib", x.Mebi.ToString()); - Assert.Equal("976,562.5 Kib", x.Kibi.ToString()); - - Assert.Equal("0 Pb", x.Peta.ToString()); - Assert.Equal("0 Tb", x.Tera.ToString()); - Assert.Equal("1 Gb", x.Giga.ToString()); - Assert.Equal("1,000 Mb", x.Mega.ToString()); - Assert.Equal("1,000,000 kb", x.Kilo.ToString()); - - Assert.Equal("1,000,000,000 b", x.Unit.ToString()); - - TestOutput.WriteLine(x.ToAggregateString()); - } - - [Fact] - public void BitStorageCapacity_UseCompound_ShouldConvertOneBillionBitsToBinaryAndMetricPrefixToStringRepresentation() - { - var x = BitStorageCapacity.FromBits(1000000000, o => o.Style = NamingStyle.Compound); - - Assert.Equal("0 pebibit", x.Pebi.ToString()); - Assert.Equal("0 tebibit", x.Tebi.ToString()); - Assert.Equal("0.93 gibibit", x.Gibi.ToString()); - Assert.Equal("953.67 mebibit", x.Mebi.ToString()); - Assert.Equal("976,562.5 kibibit", x.Kibi.ToString()); - - Assert.Equal("0 petabit", x.Peta.ToString()); - Assert.Equal("0 terabit", x.Tera.ToString()); - Assert.Equal("1 gigabit", x.Giga.ToString()); - Assert.Equal("1,000 megabit", x.Mega.ToString()); - Assert.Equal("1,000,000 kilobit", x.Kilo.ToString()); - - Assert.Equal("1,000,000,000 bit", x.Unit.ToString()); - - TestOutput.WriteLine(x.ToAggregateString()); - } - - public void BitStorageCapacity_UseCompound_ShouldConvertOneBillionBitsToBinaryAndMetricPrefixDoubleRepresentation() - { - var bs = BitStorageCapacity.FromBits(1000000000, o => - { - o.Style = NamingStyle.Compound; - o.Prefix = UnitPrefix.Decimal; - }); - - Assert.Equal(1000000000, (double)bs); - Assert.Equal(1000000, bs.Kilo.PrefixValue); - Assert.Equal(1000, bs.Mega.PrefixValue); - Assert.Equal(1, bs.Giga.PrefixValue); - Assert.Equal(0.001, bs.Tera.PrefixValue); - Assert.Equal(1E-06, bs.Peta.PrefixValue); - Assert.Equal(976562.5, bs.Kibi.PrefixValue); - Assert.Equal(953.67431640625, bs.Mebi.PrefixValue); - Assert.Equal(0.93132257461547852, bs.Gibi.PrefixValue); - Assert.Equal(0.00090949470177292824, bs.Tebi.PrefixValue); - Assert.Equal(8.8817841970012523E-07, bs.Pebi.PrefixValue); - Assert.Equal("1 gigabit", bs.ToString()); - - TestOutput.WriteLine(bs.ToString()); - } - } -} \ No newline at end of file diff --git a/test/Cuemon.Core.Tests/ByteStorageCapacityTest.cs b/test/Cuemon.Core.Tests/ByteStorageCapacityTest.cs deleted file mode 100644 index c91dc9a56..000000000 --- a/test/Cuemon.Core.Tests/ByteStorageCapacityTest.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Codebelt.Extensions.Xunit; -using Xunit; -using Xunit.Abstractions; - -namespace Cuemon -{ - public class ByteStorageCapacityTest : Test - { - public ByteStorageCapacityTest(ITestOutputHelper output) : base(output) - { - } - - [Fact] - public void ByteStorageCapacity_UseSymbol_ShouldConvertOneBillionBytesToBinaryAndMetricPrefixToStringRepresentation() - { - var x = ByteStorageCapacity.FromBytes(1000000000); - - Assert.Equal("0 PiB", x.Pebi.ToString()); - Assert.Equal("0 TiB", x.Tebi.ToString()); - Assert.Equal("0.93 GiB", x.Gibi.ToString()); - Assert.Equal("953.67 MiB", x.Mebi.ToString()); - Assert.Equal("976,562.5 KiB", x.Kibi.ToString()); - - Assert.Equal("0 PB", x.Peta.ToString()); - Assert.Equal("0 TB", x.Tera.ToString()); - Assert.Equal("1 GB", x.Giga.ToString()); - Assert.Equal("1,000 MB", x.Mega.ToString()); - Assert.Equal("1,000,000 kB", x.Kilo.ToString()); - - Assert.Equal("1,000,000,000 B", x.Unit.ToString()); - - TestOutput.WriteLine(x.ToAggregateString()); - } - - [Fact] - public void ByteStorageCapacity_UseCompound_ShouldConvertOneBillionBytesToBinaryAndMetricPrefixToStringRepresentation() - { - var x = ByteStorageCapacity.FromBytes(1000000000, o => o.Style = NamingStyle.Compound); - - Assert.Equal("0 pebibyte", x.Pebi.ToString()); - Assert.Equal("0 tebibyte", x.Tebi.ToString()); - Assert.Equal("0.93 gibibyte", x.Gibi.ToString()); - Assert.Equal("953.67 mebibyte", x.Mebi.ToString()); - Assert.Equal("976,562.5 kibibyte", x.Kibi.ToString()); - - Assert.Equal("0 petabyte", x.Peta.ToString()); - Assert.Equal("0 terabyte", x.Tera.ToString()); - Assert.Equal("1 gigabyte", x.Giga.ToString()); - Assert.Equal("1,000 megabyte", x.Mega.ToString()); - Assert.Equal("1,000,000 kilobyte", x.Kilo.ToString()); - - Assert.Equal("1,000,000,000 byte", x.Unit.ToString()); - - TestOutput.WriteLine(x.ToAggregateString()); - } - } -} \ No newline at end of file diff --git a/test/Cuemon.Core.Tests/DecimalPrefixTest.cs b/test/Cuemon.Core.Tests/DecimalPrefixTest.cs deleted file mode 100644 index 169f8e8ef..000000000 --- a/test/Cuemon.Core.Tests/DecimalPrefixTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Codebelt.Extensions.Xunit; -using Xunit; -using Xunit.Abstractions; - -namespace Cuemon -{ - public class DecimalPrefixTest : Test - { - public DecimalPrefixTest(ITestOutputHelper output) : base(output) - { - } - - [Fact] - public void DecimalPrefix_ShouldVerifyMultiplePrefixConstants() - { - Assert.Equal(DecimalPrefix.Deca.Multiplier, 10d); - Assert.Equal(DecimalPrefix.Hecto.Multiplier, 100d); - Assert.Equal(DecimalPrefix.Kilo.Multiplier, 1000d); - Assert.Equal(DecimalPrefix.Mega.Multiplier, 1000000d); - Assert.Equal(DecimalPrefix.Giga.Multiplier, 1000000000d); - Assert.Equal(DecimalPrefix.Tera.Multiplier, 1000000000000d); - Assert.Equal(DecimalPrefix.Peta.Multiplier, 1000000000000000d); - Assert.Equal(DecimalPrefix.Exa.Multiplier, 1000000000000000000d); - Assert.Equal(DecimalPrefix.Zetta.Multiplier, 1000000000000000000000d); - Assert.Equal(DecimalPrefix.Yotta.Multiplier, 1000000000000000000000000d); - } - } -} \ No newline at end of file diff --git a/test/Cuemon.Extensions.Core.Tests/DoubleExtensionsTest.cs b/test/Cuemon.Extensions.Core.Tests/DoubleExtensionsTest.cs index f4b9ba087..a62d96539 100644 --- a/test/Cuemon.Extensions.Core.Tests/DoubleExtensionsTest.cs +++ b/test/Cuemon.Extensions.Core.Tests/DoubleExtensionsTest.cs @@ -3,6 +3,7 @@ using Codebelt.Extensions.Xunit; using Xunit; using Xunit.Abstractions; +using Cuemon.Extensions; namespace Cuemon.Extensions { diff --git a/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs b/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs index e871b8066..e19684ebf 100644 --- a/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs +++ b/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs @@ -240,9 +240,9 @@ public void CompressBrotli_ShouldCompressAndDecompress() Assert.Equal(sut5, sut7); Assert.NotEqual(sut5, sut6); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(sut2.Length)}): {sut5.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(sut3.Length)}): {sut6.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(sut4.Length)}): {sut7.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({sut2.Length}): {sut5.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({sut3.Length}): {sut6.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({sut4.Length}): {sut7.Substring(0, 50)} ..."); } [Fact] @@ -264,9 +264,9 @@ public async Task CompressBrotliAsync_ShouldCompressAndDecompress() Assert.Equal(sut5, sut7); Assert.NotEqual(sut5, sut6); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(sut2.Length)}): {sut5.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(sut3.Length)}): {sut6.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(sut4.Length)}): {sut7.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({sut2.Length}): {sut5.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({sut3.Length}): {sut6.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({sut4.Length}): {sut7.Substring(0, 50)} ..."); } [Fact] @@ -304,9 +304,9 @@ public void CompressGZip_ShouldCompressAndDecompress() Assert.Equal(sut5, sut7); Assert.NotEqual(sut5, sut6); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(sut2.Length)}): {sut5.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(sut3.Length)}): {sut6.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(sut4.Length)}): {sut7.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({sut2.Length}): {sut5.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({sut3.Length}): {sut6.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({sut4.Length}): {sut7.Substring(0, 50)} ..."); } [Fact] @@ -328,9 +328,9 @@ public async Task CompressGZipAsync_ShouldCompressAndDecompress() Assert.Equal(sut5, sut7); Assert.NotEqual(sut5, sut6); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(sut2.Length)}): {sut5.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(sut3.Length)}): {sut6.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(sut4.Length)}): {sut7.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({sut2.Length}): {sut5.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({sut3.Length}): {sut6.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({sut4.Length}): {sut7.Substring(0, 50)} ..."); } [Fact] @@ -366,9 +366,9 @@ public void CompressDeflate_ShouldCompressAndDecompress() Assert.Equal(sut5, sut7); Assert.NotEqual(sut5, sut6); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(sut2.Length)}): {sut5.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(sut3.Length)}): {sut6.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(sut4.Length)}): {sut7.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({sut2.Length}): {sut5.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({sut3.Length}): {sut6.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({sut4.Length}): {sut7.Substring(0, 50)} ..."); } [Fact] @@ -390,9 +390,9 @@ public async Task CompressDeflateAsync_ShouldCompressAndDecompress() Assert.Equal(sut5, sut7); Assert.NotEqual(sut5, sut6); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(sut2.Length)}): {sut5.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(sut3.Length)}): {sut6.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(sut4.Length)}): {sut7.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({sut2.Length}): {sut5.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({sut3.Length}): {sut6.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({sut4.Length}): {sut7.Substring(0, 50)} ..."); } [Fact] diff --git a/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs b/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs index 89f63c981..9f345fa86 100644 --- a/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs +++ b/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs @@ -38,9 +38,9 @@ public void CompressBrotli_ShouldCompressAndDecompress() Assert.Equal(osResult, dosResult); Assert.NotEqual(osResult, cosResult); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(os.Length)}): {osResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(cos.Length)}): {cosResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(dos.Length)}): {dosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({os.Length}): {osResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({cos.Length}): {cosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({dos.Length}): {dosResult.Substring(0, 50)} ..."); } [Fact] @@ -62,9 +62,9 @@ public async Task CompressBrotliAsync_ShouldCompressAndDecompress() Assert.Equal(osResult, dosResult); Assert.NotEqual(osResult, cosResult); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(os.Length)}): {osResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(cos.Length)}): {cosResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(dos.Length)}): {dosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({os.Length}): {osResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({cos.Length}): {cosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({dos.Length}): {dosResult.Substring(0, 50)} ..."); } [Fact] @@ -102,9 +102,9 @@ public void CompressGZip_ShouldCompressAndDecompress() Assert.Equal(osResult, dosResult); Assert.NotEqual(osResult, cosResult); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(os.Length)}): {osResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(cos.Length)}): {cosResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(dos.Length)}): {dosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({os.Length}): {osResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({cos.Length}): {cosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({dos.Length}): {dosResult.Substring(0, 50)} ..."); } [Fact] @@ -126,9 +126,9 @@ public async Task CompressGZipAsync_ShouldCompressAndDecompress() Assert.Equal(osResult, dosResult); Assert.NotEqual(osResult, cosResult); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(os.Length)}): {osResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(cos.Length)}): {cosResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(dos.Length)}): {dosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({os.Length}): {osResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({cos.Length}): {cosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({dos.Length}): {dosResult.Substring(0, 50)} ..."); } [Fact] @@ -164,9 +164,9 @@ public void CompressDeflate_ShouldCompressAndDecompress() Assert.Equal(osResult, dosResult); Assert.NotEqual(osResult, cosResult); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(os.Length)}): {osResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(cos.Length)}): {cosResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(dos.Length)}): {dosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({os.Length}): {osResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({cos.Length}): {cosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({dos.Length}): {dosResult.Substring(0, 50)} ..."); } [Fact] @@ -188,9 +188,9 @@ public async Task CompressDeflateAsync_ShouldCompressAndDecompress() Assert.Equal(osResult, dosResult); Assert.NotEqual(osResult, cosResult); - TestOutput.WriteLine($"Original ({ByteStorageCapacity.FromBytes(os.Length)}): {osResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Compressed ({ByteStorageCapacity.FromBytes(cos.Length)}): {cosResult.Substring(0, 50)} ..."); - TestOutput.WriteLine($"Decompressed ({ByteStorageCapacity.FromBytes(dos.Length)}): {dosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Original ({os.Length}): {osResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Compressed ({cos.Length}): {cosResult.Substring(0, 50)} ..."); + TestOutput.WriteLine($"Decompressed ({dos.Length}): {dosResult.Substring(0, 50)} ..."); } [Fact]