Table of Contents

Class TlumachValidationDefaults

Namespace
Tlumach.DataAnnotations
Assembly
Tlumach.DataAnnotations.dll

Process-wide settings shared by the localized validation attributes of Tlumach.

public static class TlumachValidationDefaults
Inheritance
TlumachValidationDefaults
Inherited Members

Properties

CultureSource

Gets or sets the culture source used by the attributes that leave CultureSource at Default.

The default value is TranslationManager. Set this property once during the startup of the application. A web application that localizes requests sets it to Ambient so that validation messages follow the culture of the request.

public static TranslationCultureSource CultureSource { get; set; }

Property Value

TranslationCultureSource

Exceptions

ArgumentOutOfRangeException

Thrown when the value is Default, which would be circular, or is not a defined value.

Methods

IsResolutionCached(Type, string)

Tells whether a binding for the given localization class and key is present in the cache. Intended for tests that verify that repeated validation does not resolve the annotation again.

public static bool IsResolutionCached(Type translationClass, string translationKey)

Parameters

translationClass Type

The class as it appears in the annotation.

translationKey string

The key as it appears in the annotation.

Returns

bool

true when the annotation has already been resolved.

Exceptions

ArgumentNullException

Thrown when either argument is null.

RegisterTranslationManager(Type, TranslationManager)

Registers the translation manager to use for the given localization class, so that the resolver does not have to look the manager up through reflection.

Call this method for a trimmed or NativeAOT application that refers to a translation key rather than to a translation unit member, and for a nested group class. Registrations are consulted before any reflection takes place.

public static void RegisterTranslationManager(Type translationClass, TranslationManager manager)

Parameters

translationClass Type

The class created by Tlumach Generator, or a nested group class inside one, as it appears in the annotation.

manager TranslationManager

The translation manager that provides the messages of that class.

Exceptions

ArgumentNullException

Thrown when either argument is null.

ResetResolutionCache()

Drops every cached message binding.

An application does not need to call this method: a binding refers to a translation unit or to a translation manager and never holds text, so a change of the culture or a reload of a translation is picked up without it. It exists for tests and for hosts that unload assemblies with localization classes.

public static void ResetResolutionCache()

UnregisterTranslationManager(Type)

Removes the registration made by RegisterTranslationManager(Type, TranslationManager).

public static bool UnregisterTranslationManager(Type translationClass)

Parameters

translationClass Type

The class, whose registration is to be removed.

Returns

bool

true when a registration was removed; false when there was none.

Exceptions

ArgumentNullException

Thrown when translationClass is null.