From ef3c04c130470bc68bc6e363a60092ab49feb47e Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 12 Feb 2024 21:24:28 +1100 Subject: [PATCH] use some auto properties --- src/Humanizer/Configuration/Configurator.cs | 71 ++++----------------- 1 file changed, 11 insertions(+), 60 deletions(-) diff --git a/src/Humanizer/Configuration/Configurator.cs b/src/Humanizer/Configuration/Configurator.cs index 157d76865..fec82a8c6 100644 --- a/src/Humanizer/Configuration/Configurator.cs +++ b/src/Humanizer/Configuration/Configurator.cs @@ -18,70 +18,41 @@ namespace Humanizer.Configuration /// public static class Configurator { - private static readonly LocaliserRegistry _collectionFormatters = new CollectionFormatterRegistry(); - /// /// A registry of formatters used to format collections based on the current locale /// - public static LocaliserRegistry CollectionFormatters - { - get { return _collectionFormatters; } - } + public static LocaliserRegistry CollectionFormatters { get; } = new CollectionFormatterRegistry(); - private static readonly LocaliserRegistry _formatters = new FormatterRegistry(); /// /// A registry of formatters used to format strings based on the current locale /// - public static LocaliserRegistry Formatters - { - get { return _formatters; } - } + public static LocaliserRegistry Formatters { get; } = new FormatterRegistry(); - private static readonly LocaliserRegistry _numberToWordsConverters = new NumberToWordsConverterRegistry(); /// /// A registry of number to words converters used to localise ToWords and ToOrdinalWords methods /// - public static LocaliserRegistry NumberToWordsConverters - { - get { return _numberToWordsConverters; } - } + public static LocaliserRegistry NumberToWordsConverters { get; } = new NumberToWordsConverterRegistry(); - private static readonly LocaliserRegistry _ordinalizers = new OrdinalizerRegistry(); /// /// A registry of ordinalizers used to localise Ordinalize method /// - public static LocaliserRegistry Ordinalizers - { - get { return _ordinalizers; } - } + public static LocaliserRegistry Ordinalizers { get; } = new OrdinalizerRegistry(); - private static readonly LocaliserRegistry _dateToOrdinalWordConverters = new DateToOrdinalWordsConverterRegistry(); /// /// A registry of ordinalizers used to localise Ordinalize method /// - public static LocaliserRegistry DateToOrdinalWordsConverters - { - get { return _dateToOrdinalWordConverters; } - } + public static LocaliserRegistry DateToOrdinalWordsConverters { get; } = new DateToOrdinalWordsConverterRegistry(); #if NET6_0_OR_GREATER - private static readonly LocaliserRegistry _dateOnlyToOrdinalWordConverters = new DateOnlyToOrdinalWordsConverterRegistry(); /// /// A registry of ordinalizers used to localise Ordinalize method /// - public static LocaliserRegistry DateOnlyToOrdinalWordsConverters - { - get { return _dateOnlyToOrdinalWordConverters; } - } + public static LocaliserRegistry DateOnlyToOrdinalWordsConverters { get; } = new DateOnlyToOrdinalWordsConverterRegistry(); - private static readonly LocaliserRegistry _timeOnlyToClockNotationConverters = new TimeOnlyToClockNotationConvertersRegistry(); /// /// A registry of time to clock notation converters used to localise ToClockNotation methods /// - public static LocaliserRegistry TimeOnlyToClockNotationConverters - { - get { return _timeOnlyToClockNotationConverters; } - } + public static LocaliserRegistry TimeOnlyToClockNotationConverters { get; } = new TimeOnlyToClockNotationConvertersRegistry(); #endif internal static ICollectionFormatter CollectionFormatter @@ -153,46 +124,26 @@ internal static ITimeOnlyToClockNotationConverter TimeOnlyToClockNotationConvert } #endif - private static IDateTimeHumanizeStrategy _dateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy(); /// /// The strategy to be used for DateTime.Humanize /// - public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy - { - get { return _dateTimeHumanizeStrategy; } - set { _dateTimeHumanizeStrategy = value; } - } + public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } = new DefaultDateTimeHumanizeStrategy(); - private static IDateTimeOffsetHumanizeStrategy _dateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy(); /// /// The strategy to be used for DateTimeOffset.Humanize /// - public static IDateTimeOffsetHumanizeStrategy DateTimeOffsetHumanizeStrategy - { - get { return _dateTimeOffsetHumanizeStrategy; } - set { _dateTimeOffsetHumanizeStrategy = value; } - } + public static IDateTimeOffsetHumanizeStrategy DateTimeOffsetHumanizeStrategy { get; set; } = new DefaultDateTimeOffsetHumanizeStrategy(); #if NET6_0_OR_GREATER - private static IDateOnlyHumanizeStrategy _dateOnlyHumanizeStrategy = new DefaultDateOnlyHumanizeStrategy(); /// /// The strategy to be used for DateOnly.Humanize /// - public static IDateOnlyHumanizeStrategy DateOnlyHumanizeStrategy - { - get { return _dateOnlyHumanizeStrategy; } - set { _dateOnlyHumanizeStrategy = value; } - } + public static IDateOnlyHumanizeStrategy DateOnlyHumanizeStrategy { get; set; } = new DefaultDateOnlyHumanizeStrategy(); - private static ITimeOnlyHumanizeStrategy _timeOnlyHumanizeStrategy = new DefaultTimeOnlyHumanizeStrategy(); /// /// The strategy to be used for TimeOnly.Humanize /// - public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy - { - get { return _timeOnlyHumanizeStrategy; } - set { _timeOnlyHumanizeStrategy = value; } - } + public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy { get; set; } = new DefaultTimeOnlyHumanizeStrategy(); #endif private static readonly Func DefaultEnumDescriptionPropertyLocator = p => p.Name == "Description";