Fluxera.Utilities
9.2.0
Prefix Reserved
dotnet add package Fluxera.Utilities --version 9.2.0
NuGet\Install-Package Fluxera.Utilities -Version 9.2.0
<PackageReference Include="Fluxera.Utilities" Version="9.2.0" />
<PackageVersion Include="Fluxera.Utilities" Version="9.2.0" />
<PackageReference Include="Fluxera.Utilities" />
paket add Fluxera.Utilities --version 9.2.0
#r "nuget: Fluxera.Utilities, 9.2.0"
#:package Fluxera.Utilities@9.2.0
#addin nuget:?package=Fluxera.Utilities&version=9.2.0
#tool nuget:?package=Fluxera.Utilities&version=9.2.0
Fluxera.Utilities
A collection of common utilities and extension methods.
This is the place for all "common" helpers, extension methods and utilities. There is only one condition: The helpers may not require any third party packages.
Available Helpers
AsyncHelperRun async method in a synchonous context.RandomHelperUseful randomizing methods.TempPathHelperCreate temp files or folders safely.DisposableBase class that implementsIDisposablecorrectly.
Available Collections
SortedListIList<T>implementation that inserts the items sorted using binary search.
Available Extensions Methods
There are a lot of extensions methods available. here we sort them by the type they are implemented on.
Array
IsIndexWithinChecks if the given index is within the array.ToMemoryStreamCreates aMemoryStreamfrom a byte array.
Assembly
GetResourceAsStringAsyncGets the content of the given embedded resource location as string.
Character
RepeatRepeats the givencharthe specified number of times.
Collection
AddIfNotContainsAdds item(s) to collection if they are not already in the collection.IsNullOrEmptyChecks if the collection is null or empty.RemoveMatchingRemoves all items from the collection that match a given predicate.
String Conversions
The custom interfaces IConverter and ITryConverter provide a fluent interface for
converting strings to numeric, boolean and Guid values.
string value = "5";
int result = value.Convert().ToInt();
string value = "5";
bool success = value.TryConvert().ToInt(out int result);
char value = '5';
int result = value.Convert().ToInt();
char value = '5';
bool success = value.TryConvert().ToInt(out int result);
The Convert() extension methods also provide overloads to provide a custom IFormatProvider. The default format provider is CultureInfo.CurrentCulture.
DateTime
AddMonthsToEndOfMonthAdds the months to end of month.AddWeeksAdds an amount of weeks to a date value.CalculateAgeCalculates the age based on a passed reference date.GetDayCountOfYearGet the number of days within that date year.GetDaysGet the number of days between two dates.GetDaysOfMonthCountReturns the number of days in the month of a provided date.GetFirstDayOfMonthReturns the first day of the month of a provided date.GetFirstDayOfWeekGets the first day of the week using a specific culture.GetLastDayOfMonthReturns the last day of the month of a provided date.GetLastDayOfWeekGets the last day of the week using a specific culture.GetNextWeekdayGets the next occurrence of the specified weekday.GetPeriodOfDayReturns the period of the dayPeriodOfDay.Morning,PeriodOfDay.Afternoon,PeriodOfDay.Evening.GetPreviousWeekdayGets the previous occurrence of the specified weekday.GetWeekOfYearGets the week number for a date time value based on the current culture settings.GetWeeksWeekdayGets the next occurrence of a specified weekday within the current week using a specific culture.IsDateEqualDetermines if the date part of twoDateTimevalues are equal.IsLeapYearReturns if or not aDateTimeis during a leap year.IsTimeEqualDetermines if the time part of twoDateTimevalues are equal.IsTodayDetermines if a date isDateTime.Today.IsWeekdayDetermines if aDateTimeorDayOfWeekis a weekday.- **
IsWeekend**Determines if aDateTimeorDayOfWeekis a weekend. MidnightGets aDateTimerepresenting midnight on a specified date.NextMonthGets the next month.NoonGets aDateTimerepresenting noon on a specified date.OrdinalSuffixConverts the day of a date to an ordinal string, f.e. 3 to '3rd'.SetTimeSets the time of the aDateTimewith a specified precicion. All other parts are set to zero.ToUnixTimestampConverts aDateTimeto a UNIX timestamp (seconds since 01.01.1970).
Dictionary
ContainsValueReturnstrueif the value is contained in a dictionary.GetOrAddGets a value from a dictionary with given key. Returns a default value if the value cannot be found.GetOrDefaultGets a value from a dictionary. Returnsdefaultif the value cannot be found.TryGetValueTries to get a value from a dictionary.
Enum
All operations utilize a cache of the enums metadata that is built lazily when using the extensions methods.
EnumOptionsGets all options of an enum type.EnumValuesGets all values of an enum type.HasFlagA generic version ofEnum.HasFlag(enum)"IsEmptyGets a flag, indicating if the enum has no values.MaxValueGets the maximum value of the enum.MinValueGets the minimum value of the enum.
Enumerable
AsReadOnlyConverts an enumerable to a read-only collection.ForEachExecutes anActionfor every item in the enumerable.IsAnyChecks if a enumerable is not null or empty.IsNullOrEmptyChecks if the enumerable is null or empty.
Guid
IsEmptyChecks aGuidisGuid.Empty.
List
AddForAdds a value to a list if the value matches a predicate.AddRangeAdds values to a list (IList<T>).AddRangeForAdds values to a list if the value to add matches a predicate.AddRangeSortedAdds values into a list sorted.AddSortedAdds a value into a list sorted.
MemoryStream
ToContentStringConverts the content of the memory stream to a string.
Nullable
IsNullChecks if a nullable has no value.
Numeric
The numeric extensions methods are available for the following primitives: byte, short, int, long
IsBetweenDetermines if a value is between the specified values a and b (inclusive).IsEvenDetermines whether a value is even.IsOddDetermines whether a value is odd.OrdinalizeOrdinalize a number, f.e. 6 to '6th'.TimesPerforms a specified action n times based on the value.
Object
GetDefaultValueGets the type default value for a type. In case of reference types:nulland for values typesdefault(T).IsNullReturnstrue, if the specified target reference is equal to the null reference.LockingExecutes anActionby locking on a given object.
Principal
GetClaimValueGets the first value of the given claim type and returns its value.GetClaimValuesGets all values of the given claim type and returns their values.GetDisplayNameGets the display name from theClaimsIdentityor uses the subject.GetSubjectIdGets the subject identifier.IsAuthenticatedDetermines whether a principal is authenticated.
Reflection
DefinesAttributeReturnstrueif aMemberInfoinstance is marked with the specified attribute.GetMemberTypeGets the underlying type of aMemberInfoinstance.IsIndexerDetermines if aPropertyInfois an indexer.IsPropertyDetermines if aMethodInfois a property.IsPropertyGetterDetermines if aMethodInfois a property getter.IsPropertySetterDetermines if aMethodInfois a property setter.
Stream
CopyToCopies aStreaminto a another one.CopyToMemoryCopies aStreaminto a localMemoryStream.GetBytesGets all bytes of aStream.GetReaderOpens aStreamReaderfor aStream.GetWriterOpens aStreamWriterfor aStream.RewindRewinds (set the current position to 0) aStream.WriteWrites all bytes to the aStream.
String
ConcatWithConcatenates a string with additional strings and an optional delimiter character.EnsureEndsWithEnsures that a string ends with a given suffix.EnsureStartsWithEnsures that a string starts with a given prefix.FormatInvariantWithApplies formatting to a string using the invariant culture.FormatWithApplies formatting to a string using the current culture.FromBase64Decodes a string from base64 to its normal representation.GetBytesConverts a string to abyte[]using a specific encoding.IsNullOrEmptyDetermines if a string isnullorstring.Empty.- **
IsNullOrWhiteSpace**Determines if a string isnullorstring.Emptyor consists of whitespace-only characters. IsNumericChecks if the contents of a string is a numeric value.LeftGets a substring of a string from beginning of the string.RemovePostFixRemoves the first occurrence of postfixes from the end of a string.RemovePrefixRemoves the first occurrence of prefixes from the beginning of a string.RemoveSpacesRemoves all whitespace (not line endings, etc.) from a string.RemoveSpecialCharactersRemoves all special characters from a string.RepeatRepeats a string value as provided by the repeat count.ReplaceDiacriticsReplaces all diacritical marks with an ascii representation, fe. '�' to 'u'.ReplaceWithEmptyReplaces all occurrences of a string in an input string withstring.Empty.- **
Reverse**Reverses the a string. RightGets a substring of a string from end of the string.SplitUsesstring.Split(string[], StringSplitOptions)method to split a string by a separator.ToBase64Encodes string to base64.ToEnumConverts a string to a matching enum value of a given enum type.ToMemoryStreamConverts a string to aMemoryStream.TruncateTruncates a string to a specified length and optionally replaces the truncated part with '...' suffix.UrlSafeDecodeEncodes a string for safe usage in URLs, f.e. for password reset or email confirmation tokens.UrlSafeEncodeDecodes a given URL-safe string.
Inflection
PluralizeReturns the plural form of a word.SingularizeReturns the singular form of a word.TitleizeReturn a string in a form that can be used as title.HumanizeHumanizes a string.PascalizePascalizes a string.CamelizeCamelizes a string.UnderscoreReplaces all dashes with underscores.CapitalizeCapitalizes a string.UncapitalizeUncapitalizes a string.OrdinalizeOrdinalizes the given number that is given as string, f.e. '6' to '6th'.DasherizeConverts all underscores to dashes.
Type
CreateInstanceCreates an instance of a type.DefinesAttributeReturnstrueif the type is marked with a specified attribute.GetBaseClassesGets all base classes recursively for a type.ImplementsReturnstrueif type implements a specified interface.IsAssignableToChecks if a type is assignable to another type.IsCollectionDetermines if the a type is a collection.IsEnumerableDetermines if the a type is an enumerable.IsNullableDetermines if the a type is a nullable.IsNumericDetermines if the a type is numeric.IsPrimitiveDetermines whether a type is a primitive.UnwrapNullableTypeGets the type without nullable if the type is aNullable<T>.
Uri
GetSubDomainGets the sub-domain part from aUri.
ValueType
IsDefaultDetermines if a value is empty (default(T)).IsNullableDetermines if a type is a nullable.ToNullableonverts a value to a corresponding nullable type.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (8)
Showing the top 5 NuGet packages that depend on Fluxera.Utilities:
| Package | Downloads |
|---|---|
|
Fluxera.Repository.Abstractions
The abstractions for the generic repository implementation. |
|
|
Fluxera.Extensions.Hosting.Modules.AspNetCore
A module that enables ASP.NET Core. |
|
|
Fluxera.Extensions.Hosting.Modules.DataManagement
A module that enables data management. |
|
|
Fluxera.Extensions.Hosting.Modules.Domain.Shared
A module that enables the domain. |
|
|
Fluxera.Extensions.Hosting.Modules.AutoMapper
A module that enables object mapping using AutoMapper. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 9.2.0 | 355 | 7/28/2025 | |
| 9.0.1 | 1,479 | 2/5/2025 | |
| 9.0.0 | 1,300 | 11/14/2024 | |
| 8.2.3 | 1,403 | 11/1/2024 | |
| 8.2.2 | 8,723 | 7/9/2024 | |
| 8.2.1 | 3,888 | 6/15/2024 | |
| 8.2.0 | 721 | 6/8/2024 | |
| 8.1.0 | 2,990 | 5/26/2024 | |
| 8.0.5 | 899 | 5/24/2024 | |
| 8.0.4 | 18,858 | 4/18/2024 | |
| 8.0.3 | 3,297 | 4/13/2024 | |
| 8.0.2 | 10,179 | 2/22/2024 | |
| 8.0.1 | 16,743 | 11/23/2023 | |
| 8.0.0 | 3,765 | 11/15/2023 | |
| 7.1.1 | 14,318 | 7/20/2023 | |
| 7.1.0 | 26,742 | 1/18/2023 | |
| 7.0.4 | 19,018 | 11/15/2022 | |
| 7.0.3 | 6,472 | 11/12/2022 | |
| 7.0.1 | 454 | 11/12/2022 | |
| 7.0.0 | 5,980 | 11/9/2022 | |
| 6.1.1 | 129,193 | 6/7/2022 | |
| 6.1.0 | 3,719 | 6/7/2022 | |
| 6.0.17 | 565 | 6/6/2022 | |
| 6.0.16 | 101,717 | 5/5/2022 | |
| 6.0.14 | 18,738 | 4/20/2022 | |
| 6.0.13 | 2,489 | 4/14/2022 | |
| 6.0.12 | 28,985 | 3/24/2022 | |
| 6.0.10 | 5,486 | 2/17/2022 | |
| 6.0.9 | 1,123 | 12/22/2021 | |
| 6.0.8 | 2,367 | 12/17/2021 | |
| 6.0.4 | 6,982 | 12/11/2021 | |
| 6.0.2 | 483 | 12/8/2021 |