Class Helper
- Namespace
- OpenSettings
- Assembly
- OpenSettings.dll
Provides utility methods for string manipulation and collection operations in OpenSettings.
public static class Helper
- Inheritance
-
Helper
- Inherited Members
Methods
DistinctBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>)
Returns distinct elements from a sequence based on a specified key selector.
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
Parameters
source
IEnumerable<TSource>The sequence to remove duplicates from.
keySelector
Func<TSource, TKey>A function that extracts the key for each element.
Returns
- IEnumerable<TSource>
An IEnumerable<T> containing distinct elements from the source sequence.
Type Parameters
TSource
The type of elements in the source sequence.
TKey
The type of the key used for distinct comparisons.
GetEnvironmentName()
Retrieves the current environment name from environment variables. It checks the following variables in order: ASPNETCORE_ENVIRONMENT, DOTNET_ENVIRONMENT, and ENVIRONMENT. If none are set, it defaults to "Production".
public static string GetEnvironmentName()
Returns
- string
The detected environment name or "Production" if none are found.
GetInitials(string)
Extracts and returns the initials from a given name.
public static string GetInitials(string name)
Parameters
name
stringThe full name from which to extract initials.
Returns
- string
A string containing the uppercase initials of the name. Returns an empty string if the input is empty.