Skip to content

Commit

Permalink
Add missing mutable ctors + optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mikernet committed Mar 8, 2024
1 parent dc05c49 commit e918686
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
22 changes: 14 additions & 8 deletions Source/Singulink.Globalization.Currency/MoneySet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,34 @@ public MoneySet(CurrencyRegistry registry)
_registry = registry;
}

/// <inheritdoc cref="MoneySet(ReadOnlySpan{Money})"/>
public MoneySet(IEnumerable<Money> values) : this(CurrencyRegistry.Default, values) { }

/// <inheritdoc cref="MoneySet(CurrencyRegistry, ReadOnlySpan{Money})"/>
public MoneySet(CurrencyRegistry registry, IEnumerable<Money> values)
: this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { }

/// <inheritdoc cref="MoneySet(ReadOnlySpan{Money})"/>
public MoneySet(params Money[] values) : this(CurrencyRegistry.Default, values) { }

/// <inheritdoc cref="MoneySet(CurrencyRegistry, ReadOnlySpan{Money})"/>
public MoneySet(CurrencyRegistry registry, params Money[] values) : this(registry, values.AsSpan()) { }

/// <summary>
/// Initializes a new instance of the <see cref="MoneySet"/> class with the <see cref="CurrencyRegistry.Default"/> currency registry and adds all
/// the specified values.
/// </summary>
/// <exception cref="ArgumentException">
/// Attempted to add a value with a currency that is not available in the currency registry.
/// </exception>
public MoneySet(IEnumerable<Money> values) : this(CurrencyRegistry.Default, values) { }
public MoneySet(ReadOnlySpan<Money> values) : this(CurrencyRegistry.Default, values) { }

/// <summary>
/// Initializes a new instance of the <see cref="MoneySet"/> class with the specified currency registry and adds all the specified values.
/// </summary>
/// <exception cref="ArgumentException">
/// Attempted to add a value with a currency that is not available in the currency registry.
/// </exception>
public MoneySet(CurrencyRegistry registry, IEnumerable<Money> values)
: this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { }

/// <inheritdoc cref="MoneySet(IEnumerable{Money})"/>
public MoneySet(ReadOnlySpan<Money> values) : this(CurrencyRegistry.Default, values) { }

/// <inheritdoc cref="MoneySet(CurrencyRegistry, IEnumerable{Money})"/>
public MoneySet(CurrencyRegistry registry, ReadOnlySpan<Money> values)
{
_registry = registry;
Expand Down
28 changes: 15 additions & 13 deletions Source/Singulink.Globalization.Currency/SortedMoneySet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public sealed partial class SortedMoneySet : IMoneySet
/// <summary>
/// Initializes a new instance of the <see cref="SortedMoneySet"/> class with the <see cref="CurrencyRegistry.Default"/> currency registry.
/// </summary>
public SortedMoneySet() : this(CurrencyRegistry.Default)
{
}
public SortedMoneySet() : this(CurrencyRegistry.Default) { }

/// <summary>
/// Initializes a new instance of the <see cref="SortedMoneySet"/> class with the specified currency registry.
Expand All @@ -38,30 +36,34 @@ public SortedMoneySet(CurrencyRegistry registry)
_registry = registry;
}

/// <inheritdoc cref="MoneySet(ReadOnlySpan{Money})"/>
public SortedMoneySet(IEnumerable<Money> values) : this(CurrencyRegistry.Default, values) { }

/// <inheritdoc cref="MoneySet(CurrencyRegistry, ReadOnlySpan{Money})"/>
public SortedMoneySet(CurrencyRegistry registry, IEnumerable<Money> values)
: this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { }

/// <inheritdoc cref="MoneySet(ReadOnlySpan{Money})"/>
public SortedMoneySet(params Money[] values) : this(CurrencyRegistry.Default, values) { }

/// <inheritdoc cref="MoneySet(CurrencyRegistry, ReadOnlySpan{Money})"/>
public SortedMoneySet(CurrencyRegistry registry, params Money[] values) : this(registry, values.AsSpan()) { }

/// <summary>
/// Initializes a new instance of the <see cref="SortedMoneySet"/> class with the <see cref="CurrencyRegistry.Default"/> currency registry and adds all
/// the specified values.
/// </summary>
/// <exception cref="ArgumentException">
/// Attempted to add a value with a currency that is not available in the currency registry.
/// </exception>
public SortedMoneySet(IEnumerable<Money> values) : this(CurrencyRegistry.Default, values)
{
}
public SortedMoneySet(ReadOnlySpan<Money> values) : this(CurrencyRegistry.Default, values) { }

/// <summary>
/// Initializes a new instance of the <see cref="SortedMoneySet"/> class with the specified currency registry and adds all the specified values.
/// </summary>
/// <exception cref="ArgumentException">
/// Attempted to add a value with a currency that is not available in the currency registry.
/// </exception>
public SortedMoneySet(CurrencyRegistry registry, IEnumerable<Money> values)
: this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { }

/// <inheritdoc cref="SortedMoneySet(IEnumerable{Money})"/>
public SortedMoneySet(ReadOnlySpan<Money> values) : this(CurrencyRegistry.Default, values) { }

/// <inheritdoc cref="SortedMoneySet(CurrencyRegistry, IEnumerable{Money})"/>
public SortedMoneySet(CurrencyRegistry registry, ReadOnlySpan<Money> values)
{
_registry = registry;
Expand Down

0 comments on commit e918686

Please sign in to comment.