Table of Contents

Class ConsentInfoExtensions

Namespace
CMS.DataProtection
Assembly
CMS.DataProtection.dll

Extension methods for ConsentInfo.

public static class ConsentInfoExtensions
Inheritance
object
ConsentInfoExtensions

Methods

GetConsentLanguages(ConsentInfo)

Gets language names from the consents language variants.

public static IEnumerable<string> GetConsentLanguages(this ConsentInfo consent)

Parameters

consent ConsentInfo

Consent info.

Returns

IEnumerable<string>

GetConsentTextAsync(ConsentInfo, string)

Gets consent's text for specific languageName. The method follows the language fallback chain when retrieving consent text language variant.

public static Task<ConsentText> GetConsentTextAsync(this ConsentInfo consent, string languageName)

Parameters

consent ConsentInfo

Consent for which the text gets retrieved.

languageName string

Language of the consent text.

Returns

Task<ConsentText>

Language specific consent's text.

Exceptions

ArgumentNullException

Thrown when consent is null.

ArgumentException

Thrown when languageName is null, empty or does not correspond to an existing content language.

GetConsentTextWithoutFallback(ConsentInfo, string)

Gets consent's text for the exact languageName without following the language fallback chain.

public static ConsentText GetConsentTextWithoutFallback(this ConsentInfo consent, string languageName)

Parameters

consent ConsentInfo

Consent for which the text gets retrieved.

languageName string

Language of the consent text.

Returns

ConsentText

Language specific consent's text.

Exceptions

ArgumentNullException

Thrown when consent is null.

ArgumentException

Thrown when languageName is null or empty.

HasLanguageVariant(ConsentInfo, string)

Indicates whether a given consent's text has a language variant specified by languageName.

public static bool HasLanguageVariant(this ConsentInfo consent, string languageName)

Parameters

consent ConsentInfo

Consent.

languageName string

Language name.

Returns

bool

UpsertConsentText(ConsentInfo, string, string, string)

Adds new or updates existing consent language variant.

public static void UpsertConsentText(this ConsentInfo consent, string languageName, string shortText, string fullText)

Parameters

consent ConsentInfo

Consent info.

languageName string

Language of the consent text.

shortText string

Short text of consent.

fullText string

Full text of consent.

Exceptions

ArgumentNullException

Thrown when consent is null.

ArgumentException

Thrown when languageName is null or empty.

ArgumentNullException

Thrown when shortText is null.

ArgumentNullException

Thrown when fullText is null.