Table of Contents

AdjustmentScope Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
AdjustmentScope.cs

Constrains where a reusable adjustment policy may apply: by territory, calendar, category, notable-date concept, or specific rule.

public sealed class AdjustmentScope
Inheritance
AdjustmentScope
Inherited Members
Extension Methods

Remarks

Each dimension is independent. A dimension with no entries imposes no restriction; a dimension with entries requires the candidate value to be one of them. An empty scope therefore matches every rule, while a populated scope must satisfy every populated dimension.

Constructors

AdjustmentScope(IEnumerable<string>, IEnumerable<CalendarSystem>, IEnumerable<NotableDateCategory>, IEnumerable<string>, IEnumerable<string>, int?, int?, IEnumerable<int>?, IEnumerable<int>?)

Initializes a new instance of the AdjustmentScope class.

public AdjustmentScope(IEnumerable<string> territories, IEnumerable<CalendarSystem> calendars, IEnumerable<NotableDateCategory> categories, IEnumerable<string> notableDateRefs, IEnumerable<string> ruleRefs, int? fromYear = null, int? toYear = null, IEnumerable<int>? onlyYears = null, IEnumerable<int>? exceptYears = null)

Parameters

territories IEnumerable<string>

The territories the policy is limited to, if any.

calendars IEnumerable<CalendarSystem>

The calendar systems the policy is limited to, if any.

categories IEnumerable<NotableDateCategory>

The categories the policy is limited to, if any.

notableDateRefs IEnumerable<string>

The notable-date concepts the policy is limited to, if any.

ruleRefs IEnumerable<string>

The rules the policy is limited to, if any.

fromYear int?

The first year the policy applies, or null for no lower bound.

toYear int?

The last year the policy applies, or null for no upper bound.

onlyYears IEnumerable<int>

The explicit inclusion years, or null for no restriction.

exceptYears IEnumerable<int>

The explicit exclusion years, or null for no exclusions.

Exceptions

ArgumentNullException

territories, calendars, categories, notableDateRefs, or ruleRefs is null.

Properties

Calendars

Gets the calendar systems the policy is limited to.

public IReadOnlyList<CalendarSystem> Calendars { get; }

Property Value

IReadOnlyList<CalendarSystem>

The scoped calendar systems; empty when unrestricted.

Categories

Gets the categories the policy is limited to.

public IReadOnlyList<NotableDateCategory> Categories { get; }

Property Value

IReadOnlyList<NotableDateCategory>

The scoped categories; empty when unrestricted.

ExceptYears

Gets the explicit exclusion years.

public IReadOnlyList<int> ExceptYears { get; }

Property Value

IReadOnlyList<int>

The years the policy is suppressed for; empty when there are none.

FromYear

Gets the first year the policy applies.

public int? FromYear { get; }

Property Value

int?

The lower year bound, or null when unbounded.

Global

Gets a shared AdjustmentScope that imposes no restriction.

public static AdjustmentScope Global { get; }

Property Value

AdjustmentScope

An empty, global scope.

NotableDateRefs

Gets the notable-date concepts the policy is limited to.

public IReadOnlyList<string> NotableDateRefs { get; }

Property Value

IReadOnlyList<string>

The scoped notable-date identifiers; empty when unrestricted.

OnlyYears

Gets the explicit inclusion years.

public IReadOnlyList<int> OnlyYears { get; }

Property Value

IReadOnlyList<int>

The years the policy is restricted to; empty when unrestricted.

RuleRefs

Gets the rules the policy is limited to.

public IReadOnlyList<string> RuleRefs { get; }

Property Value

IReadOnlyList<string>

The scoped rule identifiers; empty when unrestricted.

Territories

Gets the territories the policy is limited to.

public IReadOnlyList<string> Territories { get; }

Property Value

IReadOnlyList<string>

The scoped territory codes; empty when unrestricted.

ToYear

Gets the last year the policy applies.

public int? ToYear { get; }

Property Value

int?

The upper year bound, or null when unbounded.

Methods

Matches(string, CalendarSystem, NotableDateCategory, string, string, int)

Determines whether the policy may apply to a rule with the supplied attributes in the supplied year.

public bool Matches(string territory, CalendarSystem calendar, NotableDateCategory category, string notableDateId, string ruleId, int year)

Parameters

territory string

The territory being resolved.

calendar CalendarSystem

The calendar system of the rule.

category NotableDateCategory

The effective category of the rule.

notableDateId string

The identifier of the rule's notable-date concept.

ruleId string

The identifier of the rule.

year int

The Gregorian year of the occurrence the policy would adjust.

Returns

bool

true if every populated dimension is satisfied; otherwise false.

Remarks

The year dimensions combine like a rule's applicability: FromYear and ToYear bound an inclusive range, OnlyYears further restricts to an explicit set when non-empty, and ExceptYears removes individual years.

Applies to

ProductVersions
.NET8, 10

See Also