Fluxera.Utilities
6.1.0
Prefix Reserved
See the version list below for details.
dotnet add package Fluxera.Utilities --version 6.1.0
NuGet\Install-Package Fluxera.Utilities -Version 6.1.0
<PackageReference Include="Fluxera.Utilities" Version="6.1.0" />
paket add Fluxera.Utilities --version 6.1.0
#r "nuget: Fluxera.Utilities, 6.1.0"
// Install Fluxera.Utilities as a Cake Addin #addin nuget:?package=Fluxera.Utilities&version=6.1.0 // Install Fluxera.Utilities as a Cake Tool #tool nuget:?package=Fluxera.Utilities&version=6.1.0
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
AsyncHelper
Run async method in a synchonous context.RandomHelper
Useful randomizing methods.TempPathHelper
Create temp files or folders safely.Disposable
Base class that implementsIDisposable
correctly.
Available Collections
SortedList
IList<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
IsIndexWithin
Checks if the given index is within the array.ToMemoryStream
Creates aMemoryStream
from a byte array.
Assembly
GetResourceAsStringAsync
Gets the content of the given embedded resource location as string.
Character
Repeat
Repeats the givenchar
the specified number of times.
Collection
AddIfNotContains
Adds item(s) to collection if they are not already in the collection.IsNullOrEmpty
Checks if the collection is null or empty.RemoveMatching
Removes 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
AddMonthsToEndOfMonth
Adds the months to end of month.AddWeeks
Adds an amount of weeks to a date value.CalculateAge
Calculates the age based on a passed reference date.GetDayCountOfYear
Get the number of days within that date year.GetDays
Get the number of days between two dates.GetDaysOfMonthCount
Returns the number of days in the month of a provided date.GetFirstDayOfMonth
Returns the first day of the month of a provided date.GetFirstDayOfWeek
Gets the first day of the week using a specific culture.GetLastDayOfMonth
Returns the last day of the month of a provided date.GetLastDayOfWeek
Gets the last day of the week using a specific culture.GetNextWeekday
Gets the next occurrence of the specified weekday.GetPeriodOfDay
Returns the period of the dayPeriodOfDay.Morning
,PeriodOfDay.Afternoon
,PeriodOfDay.Evening
.GetPreviousWeekday
Gets the previous occurrence of the specified weekday.GetWeekOfYear
Gets the week number for a date time value based on the current culture settings.GetWeeksWeekday
Gets the next occurrence of a specified weekday within the current week using a specific culture.IsDateEqual
Determines if the date part of twoDateTime
values are equal.IsLeapYear
Returns if or not aDateTime
is during a leap year.IsTimeEqual
Determines if the time part of twoDateTime
values are equal.IsToday
Determines if a date isDateTime.Today
.IsWeekday
Determines if aDateTime
orDayOfWeek
is a weekday.- **
IsWeekend
**Determines if aDateTime
orDayOfWeek
is a weekend. Midnight
Gets aDateTime
representing midnight on a specified date.NextMonth
Gets the next month.Noon
Gets aDateTime
representing noon on a specified date.OrdinalSuffix
Converts the day of a date to an ordinal string, f.e. 3 to '3rd'.SetTime
Sets the time of the aDateTime
with a specified precicion. All other parts are set to zero.ToUnixTimestamp
Converts aDateTime
to a UNIX timestamp (seconds since 01.01.1970).
Dictionary
ContainsValue
Returnstrue
if the value is contained in a dictionary.GetOrAdd
Gets a value from a dictionary with given key. Returns a default value if the value cannot be found.GetOrDefault
Gets a value from a dictionary. Returnsdefault
if the value cannot be found.TryGetValue
Tries 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.
EnumOptions
Gets all options of an enum type.EnumValues
Gets all values of an enum type.HasFlag
A generic version ofEnum.HasFlag(enum)"
IsEmpty
Gets a flag, indicating if the enum has no values.MaxValue
Gets the maximum value of the enum.MinValue
Gets the minimum value of the enum.
Enumerable
AsReadOnly
Converts an enumerable to a read-only collection.ForEach
Executes anAction
for every item in the enumerable.IsAny
Checks if a enumerable is not null or empty.IsNullOrEmpty
Checks if the enumerable is null or empty.
Guid
IsEmpty
Checks aGuid
isGuid.Empty
.
List
AddFor
Adds a value to a list if the value matches a predicate.AddRange
Adds values to a list (IList<T>
).AddRangeFor
Adds values to a list if the value to add matches a predicate.AddRangeSorted
Adds values into a list sorted.AddSorted
Adds a value into a list sorted.
MemoryStream
ToContentString
Converts the content of the memory stream to a string.
Nullable
IsNull
Checks if a nullable has no value.
Numeric
The numeric extensions methods are available for the following primitives: byte
, short
, int
, long
IsBetween
Determines if a value is between the specified values a and b (inclusive).IsEven
Determines whether a value is even.IsOdd
Determines whether a value is odd.Ordinalize
Ordinalize a number, f.e. 6 to '6th'.Times
Performs a specified action n times based on the value.
Object
GetDefaultValue
Gets the type default value for a type. In case of reference types:null
and for values typesdefault(T)
.IsNull
Returnstrue
, if the specified target reference is equal to the null reference.Locking
Executes anAction
by locking on a given object.
Principal
GetClaimValue
Gets the first value of the given claim type and returns its value.GetClaimValues
Gets all values of the given claim type and returns their values.GetDisplayName
Gets the display name from theClaimsIdentity
or uses the subject.GetSubjectId
Gets the subject identifier.IsAuthenticated
Determines whether a principal is authenticated.
Reflection
DefinesAttribute
Returnstrue
if aMemberInfo
instance is marked with the specified attribute.GetMemberType
Gets the underlying type of aMemberInfo
instance.IsIndexer
Determines if aPropertyInfo
is an indexer.IsProperty
Determines if aMethodInfo
is a property.IsPropertyGetter
Determines if aMethodInfo
is a property getter.IsPropertySetter
Determines if aMethodInfo
is a property setter.
Stream
CopyTo
Copies aStream
into a another one.CopyToMemory
Copies aStream
into a localMemoryStream
.GetBytes
Gets all bytes of aStream
.GetReader
Opens aStreamReader
for aStream
.GetWriter
Opens aStreamWriter
for aStream
.Rewind
Rewinds (set the current position to 0) aStream
.Write
Writes all bytes to the aStream
.
String
ConcatWith
Concatenates a string with additional strings and an optional delimiter character.EnsureEndsWith
Ensures that a string ends with a given suffix.EnsureStartsWith
Ensures that a string starts with a given prefix.FormatInvariantWith
Applies formatting to a string using the invariant culture.FormatWith
Applies formatting to a string using the current culture.FromBase64
Decodes a string from base64 to its normal representation.GetBytes
Converts a string to abyte[]
using a specific encoding.IsNullOrEmpty
Determines if a string isnull
orstring.Empty
.- **
IsNullOrWhiteSpace
**Determines if a string isnull
orstring.Empty
or consists of whitespace-only characters. IsNumeric
Checks if the contents of a string is a numeric value.Left
Gets a substring of a string from beginning of the string.RemovePostFix
Removes the first occurrence of postfixes from the end of a string.RemovePrefix
Removes the first occurrence of prefixes from the beginning of a string.RemoveSpaces
Removes all whitespace (not line endings, etc.) from a string.RemoveSpecialCharacters
Removes all special characters from a string.Repeat
Repeats a string value as provided by the repeat count.ReplaceDiacritics
Replaces all diacritical marks with an ascii representation, fe. '�' to 'u'.ReplaceWithEmpty
Replaces all occurrences of a string in an input string withstring.Empty
.- **
Reverse
**Reverses the a string. Right
Gets a substring of a string from end of the string.Split
Usesstring.Split(string[], StringSplitOptions)
method to split a string by a separator.ToBase64
Encodes string to base64.ToEnum
Converts a string to a matching enum value of a given enum type.ToMemoryStream
Converts a string to aMemoryStream
.Truncate
Truncates a string to a specified length and optionally replaces the truncated part with '...' suffix.UrlSafeDecode
Encodes a string for safe usage in URLs, f.e. for password reset or email confirmation tokens.UrlSafeEncode
Decodes a given URL-safe string.
Inflection
Pluralize
Returns the plural form of a word.Singularize
Returns the singular form of a word.Titleize
Return a string in a form that can be used as title.Humanize
Humanizes a string.Pascalize
Pascalizes a string.Camelize
Camelizes a string.Underscore
Replaces all dashes with underscores.Capitalize
Capitalizes a string.Uncapitalize
Uncapitalizes a string.Ordinalize
Ordinalizes the given number that is given as string, f.e. '6' to '6th'.Dasherize
Converts all underscores to dashes.
Type
CreateInstance
Creates an instance of a type.DefinesAttribute
Returnstrue
if the type is marked with a specified attribute.GetBaseClasses
Gets all base classes recursively for a type.Implements
Returnstrue
if type implements a specified interface.IsAssignableTo
Checks if a type is assignable to another type.IsCollection
Determines if the a type is a collection.IsEnumerable
Determines if the a type is an enumerable.IsNullable
Determines if the a type is a nullable.IsNumeric
Determines if the a type is numeric.IsPrimitive
Determines whether a type is a primitive.UnwrapNullableType
Gets the type without nullable if the type is aNullable<T>
.
Uri
GetSubDomain
Gets the sub-domain part from aUri
.
ValueType
IsDefault
Determines if a value is empty (default(T)
).IsNullable
Determines if a type is a nullable.ToNullable
onverts a value to a corresponding nullable type.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Fluxera.Guards (>= 6.1.0)
- JetBrains.Annotations (>= 2022.1.0)
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.0.0 | 479 | 11/14/2024 | |
8.2.3 | 714 | 11/1/2024 | |
8.2.2 | 604 | 7/9/2024 | |
8.2.1 | 1,746 | 6/15/2024 | |
8.2.0 | 412 | 6/8/2024 | |
8.1.0 | 1,795 | 5/26/2024 | |
8.0.5 | 518 | 5/24/2024 | |
8.0.4 | 12,062 | 4/18/2024 | |
8.0.3 | 1,999 | 4/13/2024 | |
8.0.2 | 6,333 | 2/22/2024 | |
8.0.1 | 10,862 | 11/23/2023 | |
8.0.0 | 1,933 | 11/15/2023 | |
7.1.1 | 12,567 | 7/20/2023 | |
7.1.0 | 19,316 | 1/18/2023 | |
7.0.4 | 14,650 | 11/15/2022 | |
7.0.3 | 5,670 | 11/12/2022 | |
7.0.1 | 344 | 11/12/2022 | |
7.0.0 | 5,305 | 11/9/2022 | |
6.1.1 | 118,660 | 6/7/2022 | |
6.1.0 | 3,409 | 6/7/2022 | |
6.0.17 | 432 | 6/6/2022 | |
6.0.16 | 94,671 | 5/5/2022 | |
6.0.14 | 17,575 | 4/20/2022 | |
6.0.13 | 2,217 | 4/14/2022 | |
6.0.12 | 27,193 | 3/24/2022 | |
6.0.10 | 5,061 | 2/17/2022 | |
6.0.9 | 883 | 12/22/2021 | |
6.0.8 | 2,051 | 12/17/2021 | |
6.0.4 | 6,078 | 12/11/2021 | |
6.0.2 | 297 | 12/8/2021 |