Class Helper
- Namespace
- OpenSettings.Helpers
- Assembly
- OpenSettings.dll
Provides utility methods for string manipulation and collection operations in OpenSettings.
public static class Helper
- Inheritance
-
Helper
- Inherited Members
Methods
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.
GetExpiryTime(string)
Parses an HTTP-date formatted expiration string (RFC1123 format) into a UTC DateTime.
public static DateTime GetExpiryTime(string expires)
Parameters
expiresstringThe expiration time as a string in RFC1123 ("R") format.
Returns
Exceptions
GetExpiryTimeOffset(string)
Parses an HTTP-date formatted expiration string (RFC1123 format) into a UTC DateTimeOffset.
public static DateTimeOffset GetExpiryTimeOffset(string expires)
Parameters
expiresstringExpiry time in RFC1123 format e.g. "Thu, 26 Jun 2025 14:14:56 GMT".
Returns
- DateTimeOffset
A DateTimeOffset object representing the expiration time in UTC.
Exceptions
GetInitials(string)
Extracts and returns the initials from a given name.
public static string GetInitials(string name)
Parameters
namestringThe 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.
GetPublicCacheControlValue(double)
public static string GetPublicCacheControlValue(double expiresInSeconds)
Parameters
expiresInSecondsdouble
Returns
IsMigrationEnabled()
Indicates whether the application is running in "Migration" mode. Used to determine if Entity Framework Core migration should be generated.
public static bool IsMigrationEnabled()