Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use some auto properties #1330

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 11 additions & 60 deletions src/Humanizer/Configuration/Configurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,41 @@ namespace Humanizer.Configuration
/// </summary>
public static class Configurator
{
private static readonly LocaliserRegistry<ICollectionFormatter> _collectionFormatters = new CollectionFormatterRegistry();

/// <summary>
/// A registry of formatters used to format collections based on the current locale
/// </summary>
public static LocaliserRegistry<ICollectionFormatter> CollectionFormatters
{
get { return _collectionFormatters; }
}
public static LocaliserRegistry<ICollectionFormatter> CollectionFormatters { get; } = new CollectionFormatterRegistry();

private static readonly LocaliserRegistry<IFormatter> _formatters = new FormatterRegistry();
/// <summary>
/// A registry of formatters used to format strings based on the current locale
/// </summary>
public static LocaliserRegistry<IFormatter> Formatters
{
get { return _formatters; }
}
public static LocaliserRegistry<IFormatter> Formatters { get; } = new FormatterRegistry();

private static readonly LocaliserRegistry<INumberToWordsConverter> _numberToWordsConverters = new NumberToWordsConverterRegistry();
/// <summary>
/// A registry of number to words converters used to localise ToWords and ToOrdinalWords methods
/// </summary>
public static LocaliserRegistry<INumberToWordsConverter> NumberToWordsConverters
{
get { return _numberToWordsConverters; }
}
public static LocaliserRegistry<INumberToWordsConverter> NumberToWordsConverters { get; } = new NumberToWordsConverterRegistry();

private static readonly LocaliserRegistry<IOrdinalizer> _ordinalizers = new OrdinalizerRegistry();
/// <summary>
/// A registry of ordinalizers used to localise Ordinalize method
/// </summary>
public static LocaliserRegistry<IOrdinalizer> Ordinalizers
{
get { return _ordinalizers; }
}
public static LocaliserRegistry<IOrdinalizer> Ordinalizers { get; } = new OrdinalizerRegistry();

private static readonly LocaliserRegistry<IDateToOrdinalWordConverter> _dateToOrdinalWordConverters = new DateToOrdinalWordsConverterRegistry();
/// <summary>
/// A registry of ordinalizers used to localise Ordinalize method
/// </summary>
public static LocaliserRegistry<IDateToOrdinalWordConverter> DateToOrdinalWordsConverters
{
get { return _dateToOrdinalWordConverters; }
}
public static LocaliserRegistry<IDateToOrdinalWordConverter> DateToOrdinalWordsConverters { get; } = new DateToOrdinalWordsConverterRegistry();

#if NET6_0_OR_GREATER
private static readonly LocaliserRegistry<IDateOnlyToOrdinalWordConverter> _dateOnlyToOrdinalWordConverters = new DateOnlyToOrdinalWordsConverterRegistry();
/// <summary>
/// A registry of ordinalizers used to localise Ordinalize method
/// </summary>
public static LocaliserRegistry<IDateOnlyToOrdinalWordConverter> DateOnlyToOrdinalWordsConverters
{
get { return _dateOnlyToOrdinalWordConverters; }
}
public static LocaliserRegistry<IDateOnlyToOrdinalWordConverter> DateOnlyToOrdinalWordsConverters { get; } = new DateOnlyToOrdinalWordsConverterRegistry();

private static readonly LocaliserRegistry<ITimeOnlyToClockNotationConverter> _timeOnlyToClockNotationConverters = new TimeOnlyToClockNotationConvertersRegistry();
/// <summary>
/// A registry of time to clock notation converters used to localise ToClockNotation methods
/// </summary>
public static LocaliserRegistry<ITimeOnlyToClockNotationConverter> TimeOnlyToClockNotationConverters
{
get { return _timeOnlyToClockNotationConverters; }
}
public static LocaliserRegistry<ITimeOnlyToClockNotationConverter> TimeOnlyToClockNotationConverters { get; } = new TimeOnlyToClockNotationConvertersRegistry();
#endif

internal static ICollectionFormatter CollectionFormatter
Expand Down Expand Up @@ -153,46 +124,26 @@ internal static ITimeOnlyToClockNotationConverter TimeOnlyToClockNotationConvert
}
#endif

private static IDateTimeHumanizeStrategy _dateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy();
/// <summary>
/// The strategy to be used for DateTime.Humanize
/// </summary>
public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy
{
get { return _dateTimeHumanizeStrategy; }
set { _dateTimeHumanizeStrategy = value; }
}
public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } = new DefaultDateTimeHumanizeStrategy();

private static IDateTimeOffsetHumanizeStrategy _dateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy();
/// <summary>
/// The strategy to be used for DateTimeOffset.Humanize
/// </summary>
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();
/// <summary>
/// The strategy to be used for DateOnly.Humanize
/// </summary>
public static IDateOnlyHumanizeStrategy DateOnlyHumanizeStrategy
{
get { return _dateOnlyHumanizeStrategy; }
set { _dateOnlyHumanizeStrategy = value; }
}
public static IDateOnlyHumanizeStrategy DateOnlyHumanizeStrategy { get; set; } = new DefaultDateOnlyHumanizeStrategy();

private static ITimeOnlyHumanizeStrategy _timeOnlyHumanizeStrategy = new DefaultTimeOnlyHumanizeStrategy();
/// <summary>
/// The strategy to be used for TimeOnly.Humanize
/// </summary>
public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy
{
get { return _timeOnlyHumanizeStrategy; }
set { _timeOnlyHumanizeStrategy = value; }
}
public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy { get; set; } = new DefaultTimeOnlyHumanizeStrategy();
#endif

private static readonly Func<PropertyInfo, bool> DefaultEnumDescriptionPropertyLocator = p => p.Name == "Description";
Expand Down