Table of Contents

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

Properties

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 { get; }

Property Value

bool

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

expires string

The expiration time as a string in RFC1123 ("R") format.

Returns

DateTime

A DateTime object representing the expiration time in UTC.

Exceptions

ArgumentException
ArgumentNullException
FormatException

GetExpiryTimeOffset(string)

Parses an HTTP-date formatted expiration string (RFC1123 format) into a UTC DateTimeOffset.

public static DateTimeOffset GetExpiryTimeOffset(string expires)

Parameters

expires string

Expiry 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

ArgumentException
ArgumentNullException
FormatException

GetInitials(string)

Extracts and returns the initials from a given name.

public static string GetInitials(string name)

Parameters

name string

The 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

expiresInSeconds double

Returns

string