Skip to content

Commit c7a2b59

Browse files
committed
removing some commented out bits (as per Claud's suggestions)
1 parent 5e88d20 commit c7a2b59

File tree

4 files changed

+2
-130
lines changed

4 files changed

+2
-130
lines changed

CodeGen/Helpers/ExpressionEvaluationHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ public static string GetConversionExpressionFormat(this CompositeExpression expr
351351
return $"new ConversionExpression(coefficient: {coefficientTermFormat}, exponent: {exponentFormat})";
352352
}
353353

354-
// return $"new ConversionExpression({coefficientTermFormat})";
355-
return coefficientTermFormat; // using the implicit constructor from QuantityValue
354+
// using the implicit constructor from QuantityValue, which is equivalent to "new ConversionExpression({coefficientTermFormat})"
355+
return coefficientTermFormat;
356356
}
357357

358358
private static string GetConversionExpressionFormat(string expression, string csharpParameter = "value", string jsonParameter = "{x}")

UnitsNet/CustomCode/QuantityConverters/DynamicQuantityConverter.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Licensed under MIT No Attribution, see LICENSE file at the root.
22
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
33

4-
using System;
54
using System.Collections.Concurrent;
6-
using System.Collections.Generic;
7-
using System.Diagnostics.CodeAnalysis;
85

96
namespace UnitsNet;
107

@@ -55,7 +52,6 @@ private bool TryConvertValue(QuantityValue value, UnitConversionKey conversionKe
5552

5653
if (TryGetUnitInfo(conversionKey.FromUnitKey, out UnitInfo? fromUnitInfo) &&
5754
TryGetUnitInfo(new UnitKey(conversionKey.FromUnitKey.UnitEnumType, conversionKey.ToUnitValue), out UnitInfo? toUnitInfo))
58-
// TryGetUnitInfo(conversionKey.FromUnitKey with { UnitValue = conversionKey.ToUnitValue }, out UnitInfo? toUnitInfo))
5955
{
6056
cachedConversion = _unitConversions.GetOrAdd(conversionKey, fromUnitInfo.GetUnitConversionExpressionTo(toUnitInfo, _reduceConstants));
6157
convertedValue = cachedConversion(value);
@@ -344,7 +340,6 @@ public override TTargetQuantity ConvertTo<TSourceUnit, TTargetQuantity, TTargetU
344340
{
345341
var conversionKey = QuantityConversionKey.Create<TSourceUnit, TTargetUnit>(fromUnit);
346342
QuantityConversionFunction conversionFunction = GetOrAdd(conversionKey, targetQuantityInfo);
347-
// return targetQuantityInfo.Create(conversionFunction.Convert(value), conversionFunction.TargetUnit);
348343
return targetQuantityInfo.From(conversionFunction.Convert(value), conversionFunction.TargetUnit.ToUnit<TTargetUnit>());
349344
}
350345

@@ -359,7 +354,6 @@ private ConvertValueDelegate GetConversionExpression(UnitConversionKey conversio
359354
{
360355
UnitInfo fromUnitInfo = GetUnitInfo(conversionKey.FromUnitKey);
361356
UnitInfo toUnitInfo = GetUnitInfo(new UnitKey(conversionKey.FromUnitKey.UnitEnumType, conversionKey.ToUnitValue));
362-
// UnitInfo toUnitInfo = GetUnitInfo(conversionKey.FromUnitKey with { UnitValue = conversionKey.ToUnitValue });
363357
return fromUnitInfo.GetUnitConversionExpressionTo(toUnitInfo, _reduceConstants);
364358
}
365359

UnitsNet/CustomCode/QuantityConverters/FrozenQuantityConverter.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#else
77
using System.Linq;
88
#endif
9-
using System.Collections.Generic;
10-
using System.Diagnostics.CodeAnalysis;
119

1210
namespace UnitsNet;
1311

@@ -64,7 +62,6 @@ private bool TryConvertValue(QuantityValue value, UnitConversionKey conversionKe
6462

6563
if (TryGetUnitInfo(conversionKey.FromUnitKey, out UnitInfo? fromUnitInfo) &&
6664
TryGetUnitInfo(new UnitKey(conversionKey.FromUnitKey.UnitEnumType, conversionKey.ToUnitValue), out UnitInfo? toUnitInfo))
67-
// TryGetUnitInfo(conversionKey.FromUnitKey with { UnitValue = conversionKey.ToUnitValue }, out UnitInfo? toUnitInfo))
6865
{
6966
convertedValue = toUnitInfo.GetValueFrom(value, fromUnitInfo);
7067
return true;
@@ -156,7 +153,6 @@ private QuantityValue ConvertValue(QuantityValue value, UnitConversionKey conver
156153

157154
UnitInfo fromUnitInfo = GetUnitInfo(conversionKey.FromUnitKey);
158155
UnitInfo toUnitInfo = GetUnitInfo(new UnitKey(conversionKey.FromUnitKey.UnitEnumType, conversionKey.ToUnitValue));
159-
// UnitInfo toUnitInfo = GetUnitInfo(conversionKey.FromUnitKey with { UnitValue = conversionKey.ToUnitValue });
160156
return toUnitInfo.GetValueFrom(value, fromUnitInfo);
161157
}
162158

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed under MIT No Attribution, see LICENSE file at the root.
22
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
33

4-
using System;
5-
using System.Collections.Generic;
64
using System.Linq;
75

86
namespace UnitsNet;
@@ -27,8 +25,6 @@ internal QuantitiesSelector(Func<IEnumerable<QuantityInfo>> defaultQuantitiesSel
2725
_defaultQuantitiesSelection = defaultQuantitiesSelection;
2826
}
2927

30-
// internal Lazy<IEnumerable<QuantityInfo>> QuantitiesSelected { get; }
31-
3228
/// <summary>
3329
/// Adds additional quantities to the current selection.
3430
/// </summary>
@@ -95,7 +91,6 @@ internal IEnumerable<QuantityInfo> GetQuantityInfos()
9591
}
9692

9793
return enumeration;
98-
// return enumeration.ToList();
9994
}
10095

10196
/// <summary>
@@ -129,116 +124,3 @@ internal QuantityInfo<TQuantity, TUnit> CreateOrDefault<TQuantity, TUnit>(Func<Q
129124
return _quantitiesInfoBuilder is null ? defaultConfiguration() : _quantitiesInfoBuilder.CreateOrDefault(defaultConfiguration);
130125
}
131126
}
132-
133-
// /// <summary>
134-
// /// Provides functionality to select and configure quantities for use within the UnitsNet library.
135-
// /// </summary>
136-
// /// <remarks>
137-
// /// This class allows for the selection of default quantities, addition of custom quantities, and configuration of
138-
// /// specific quantities.
139-
// /// It supports lazy loading of quantities and can be used to build a collection of quantity information dynamically at
140-
// /// runtime.
141-
// /// </remarks>
142-
// public sealed class QuantitiesSelector
143-
// {
144-
// private readonly Func<IReadOnlyCollection<QuantityInfo>> _defaultQuantitiesSelection;
145-
// private IEnumerable<QuantityInfo>? _additionalQuantities;
146-
// private QuantitiesInfoBuilder? _quantitiesInfoBuilder;
147-
//
148-
// internal QuantitiesSelector(Func<IReadOnlyCollection<QuantityInfo>> defaultQuantitiesSelection)
149-
// {
150-
// _defaultQuantitiesSelection = defaultQuantitiesSelection;
151-
// QuantitiesSelected = new Lazy<IReadOnlyCollection<QuantityInfo>>(BuildSelection);
152-
// }
153-
//
154-
// internal Lazy<IReadOnlyCollection<QuantityInfo>> QuantitiesSelected { get; }
155-
//
156-
// /// <summary>
157-
// /// Adds additional quantities to the current selection.
158-
// /// </summary>
159-
// /// <param name="quantities">The quantities to be added.</param>
160-
// /// <returns>The current <see cref="QuantitiesSelector" /> instance with the additional quantities included.</returns>
161-
// /// <remarks>
162-
// /// This method allows for the dynamic addition of custom quantities to the existing selection of quantities.
163-
// /// </remarks>
164-
// public QuantitiesSelector WithAdditionalQuantities(IEnumerable<QuantityInfo> quantities)
165-
// {
166-
// _additionalQuantities = _additionalQuantities?.Concat(quantities) ?? quantities;
167-
// return this;
168-
// }
169-
//
170-
// /// <summary>
171-
// /// Configures a specific quantity with a custom configuration.
172-
// /// </summary>
173-
// /// <typeparam name="TQuantity">The type of the quantity to configure.</typeparam>
174-
// /// <typeparam name="TUnit">The type of the unit associated with the quantity.</typeparam>
175-
// /// <param name="createCustomConfigurationDelegate">
176-
// /// A delegate that creates a custom configuration for the specified quantity.
177-
// /// </param>
178-
// /// <returns>The current instance of <see cref="QuantitiesSelector" /> to allow for method chaining.</returns>
179-
// /// <remarks>
180-
// /// This method allows for the customization of a specific quantity by providing a delegate that creates
181-
// /// a custom configuration. It initializes the <see cref="QuantitiesInfoBuilder" /> if it is not already initialized
182-
// /// and uses it to configure the quantity.
183-
// /// </remarks>
184-
// public QuantitiesSelector Configure<TQuantity, TUnit>(Func<QuantityInfo<TQuantity, TUnit>> createCustomConfigurationDelegate)
185-
// where TQuantity : IQuantity<TQuantity, TUnit>
186-
// where TUnit : struct, Enum
187-
// {
188-
// _quantitiesInfoBuilder ??= new QuantitiesInfoBuilder();
189-
// _quantitiesInfoBuilder.ConfigureQuantity(createCustomConfigurationDelegate);
190-
// return this;
191-
// }
192-
//
193-
// private IReadOnlyCollection<QuantityInfo> BuildSelection()
194-
// {
195-
// if (_quantitiesInfoBuilder is null && _additionalQuantities is null)
196-
// {
197-
// return _defaultQuantitiesSelection();
198-
// }
199-
//
200-
// IEnumerable<QuantityInfo> enumeration = _defaultQuantitiesSelection();
201-
// if (_additionalQuantities is not null)
202-
// {
203-
// enumeration = enumeration.Concat(_additionalQuantities);
204-
// }
205-
//
206-
// if (_quantitiesInfoBuilder is not null)
207-
// {
208-
// enumeration = enumeration.Select(_quantitiesInfoBuilder.CreateOrDefault);
209-
// }
210-
//
211-
// return enumeration.ToList();
212-
// }
213-
//
214-
// /// <summary>
215-
// /// Creates a quantity information instance using the provided default configuration or a custom configuration
216-
// /// if available.
217-
// /// </summary>
218-
// /// <typeparam name="TQuantity">
219-
// /// The type of the quantity, which must implement <see cref="IQuantity{TSelf, TUnitType}" />.
220-
// /// </typeparam>
221-
// /// <typeparam name="TUnit">
222-
// /// The type of the unit, which must be a struct and an enumeration.
223-
// /// </typeparam>
224-
// /// <param name="defaultConfiguration">
225-
// /// A delegate that provides the default configuration for creating the <see cref="QuantityInfo{TQuantity, TUnit}" />.
226-
// /// </param>
227-
// /// <returns>
228-
// /// An instance of <see cref="QuantityInfo{TQuantity, TUnit}" /> created using either the default configuration
229-
// /// or a custom configuration if available.
230-
// /// </returns>
231-
// /// <remarks>
232-
// /// This method checks if a custom configuration is available through the <see cref="QuantitiesInfoBuilder" />.
233-
// /// If no custom configuration is available, it falls back to the provided default configuration.
234-
// /// </remarks>
235-
// /// <exception cref="ArgumentNullException">
236-
// /// Thrown if the <paramref name="defaultConfiguration" /> is <c>null</c>.
237-
// /// </exception>
238-
// internal QuantityInfo<TQuantity, TUnit> CreateOrDefault<TQuantity, TUnit>(Func<QuantityInfo<TQuantity, TUnit>> defaultConfiguration)
239-
// where TQuantity : IQuantity<TQuantity, TUnit>
240-
// where TUnit : struct, Enum
241-
// {
242-
// return _quantitiesInfoBuilder is null ? defaultConfiguration() : _quantitiesInfoBuilder.CreateOrDefault(defaultConfiguration);
243-
// }
244-
// }

0 commit comments

Comments
 (0)