Skip to content

Split WRC #463

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

Merged
merged 3 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
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
235 changes: 0 additions & 235 deletions Common/GeneratedCode/Quantities/Acceleration.Common.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -671,59 +671,6 @@ public static Acceleration Parse(string str)
return Parse(str, null);
}

/// <summary>
/// Parse a string with one or two quantities of the format "&lt;quantity&gt; &lt;unit&gt;".
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
#if WINDOWS_UWP
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="UnitSystem" />'s default culture.</param>
#else
/// <param name="provider">Format to use when parsing number and unit. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
#endif
/// <example>
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
/// </example>
/// <exception cref="ArgumentNullException">The value of 'str' cannot be null. </exception>
/// <exception cref="ArgumentException">
/// Expected string to have one or two pairs of quantity and unit in the format
/// "&lt;quantity&gt; &lt;unit&gt;". Eg. "5.5 m" or "1ft 2in"
/// </exception>
/// <exception cref="AmbiguousUnitParseException">
/// More than one unit is represented by the specified unit abbreviation.
/// Example: Volume.Parse("1 cup") will throw, because it can refer to any of
/// <see cref="VolumeUnit.MetricCup" />, <see cref="VolumeUnit.UsLegalCup" /> and <see cref="VolumeUnit.UsCustomaryCup" />.
/// </exception>
/// <exception cref="UnitsNetException">
/// If anything else goes wrong, typically due to a bug or unhandled case.
/// We wrap exceptions in <see cref="UnitsNetException" /> to allow you to distinguish
/// Units.NET exceptions from other exceptions.
/// </exception>
public static Acceleration Parse(
string str,
#if WINDOWS_UWP
[CanBeNull] string cultureName)
#else
[CanBeNull] IFormatProvider provider)
#endif
{
if (str == null) throw new ArgumentNullException(nameof(str));

#if WINDOWS_UWP
// Windows Runtime Component does not support CultureInfo and IFormatProvider types, so we use culture name for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx
IFormatProvider provider = cultureName == null ? UnitSystem.DefaultCulture : new CultureInfo(cultureName);
#else
provider = provider ?? UnitSystem.DefaultCulture;
#endif

return QuantityParser.Parse<Acceleration, AccelerationUnit>(str, provider,
delegate(string value, string unit, IFormatProvider formatProvider2)
{
double parsedValue = double.Parse(value, formatProvider2);
AccelerationUnit parsedUnit = ParseUnit(unit, formatProvider2);
return From(parsedValue, parsedUnit);
}, (x, y) => FromMetersPerSecondSquared(x.MetersPerSecondSquared + y.MetersPerSecondSquared));
}

/// <summary>
/// Try to parse a string with one or two quantities of the format "&lt;quantity&gt; &lt;unit&gt;".
/// </summary>
Expand All @@ -737,54 +684,6 @@ public static bool TryParse([CanBeNull] string str, out Acceleration result)
return TryParse(str, null, out result);
}

/// <summary>
/// Try to parse a string with one or two quantities of the format "&lt;quantity&gt; &lt;unit&gt;".
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
#if WINDOWS_UWP
/// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="UnitSystem" />'s default culture.</param>
#else
/// <param name="provider">Format to use when parsing number and unit. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
#endif
/// <param name="result">Resulting unit quantity if successful.</param>
/// <example>
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
/// </example>
public static bool TryParse(
[CanBeNull] string str,
#if WINDOWS_UWP
[CanBeNull] string cultureName,
#else
[CanBeNull] IFormatProvider provider,
#endif
out Acceleration result)
{
#if WINDOWS_UWP
// Windows Runtime Component does not support CultureInfo and IFormatProvider types, so we use culture name for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx
IFormatProvider provider = cultureName == null ? UnitSystem.DefaultCulture : new CultureInfo(cultureName);
#else
provider = provider ?? UnitSystem.DefaultCulture;
#endif
try
{

result = Parse(
str,
#if WINDOWS_UWP
cultureName);
#else
provider);
#endif

return true;
}
catch
{
result = default(Acceleration);
return false;
}
}

/// <summary>
/// Parse a unit string.
/// </summary>
Expand Down Expand Up @@ -815,41 +714,6 @@ public static AccelerationUnit ParseUnit(string str, [CanBeNull] string cultureN
return ParseUnit(str, cultureName == null ? null : new CultureInfo(cultureName));
}

/// <summary>
/// Parse a unit string.
/// </summary>
/// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
/// <param name="provider">Format to use when parsing number and unit. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
/// <example>
/// Length.ParseUnit("m", new CultureInfo("en-US"));
/// </example>
/// <exception cref="ArgumentNullException">The value of 'str' cannot be null. </exception>
/// <exception cref="UnitsNetException">Error parsing string.</exception>

// Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
#if WINDOWS_UWP
internal
#else
public
#endif
static AccelerationUnit ParseUnit(string str, IFormatProvider provider = null)
{
if (str == null) throw new ArgumentNullException(nameof(str));

var unitSystem = UnitSystem.GetCached(provider);
var unit = unitSystem.Parse<AccelerationUnit>(str.Trim());

if (unit == AccelerationUnit.Undefined)
{
var newEx = new UnitsNetException("Error parsing string. The unit is not a recognized AccelerationUnit.");
newEx.Data["input"] = str;
newEx.Data["provider"] = provider?.ToString() ?? "(null)";
throw newEx;
}

return unit;
}

#endregion

[Obsolete("This is no longer used since we will instead use the quantity's Unit value as default.")]
Expand Down Expand Up @@ -877,105 +741,6 @@ public string ToString(AccelerationUnit unit)
return ToString(unit, null, 2);
}

/// <summary>
/// Get string representation of value and unit. Using two significant digits after radix.
/// </summary>
/// <param name="unit">Unit representation to use.</param>
#if WINDOWS_UWP
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="UnitSystem" />'s default culture.</param>
#else
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
#endif
/// <returns>String representation.</returns>
public string ToString(
AccelerationUnit unit,
#if WINDOWS_UWP
[CanBeNull] string cultureName)
#else
[CanBeNull] IFormatProvider provider)
#endif
{
return ToString(
unit,
#if WINDOWS_UWP
cultureName,
#else
provider,
#endif
2);
}

/// <summary>
/// Get string representation of value and unit.
/// </summary>
/// <param name="unit">Unit representation to use.</param>
#if WINDOWS_UWP
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="UnitSystem" />'s default culture.</param>
#else
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
#endif
/// <param name="significantDigitsAfterRadix">The number of significant digits after the radix point.</param>
/// <returns>String representation.</returns>
[UsedImplicitly]
public string ToString(
AccelerationUnit unit,
#if WINDOWS_UWP
[CanBeNull] string cultureName,
#else
[CanBeNull] IFormatProvider provider,
#endif
int significantDigitsAfterRadix)
{
double value = As(unit);
string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
return ToString(
unit,
#if WINDOWS_UWP
cultureName,
#else
provider,
#endif
format);
}

/// <summary>
/// Get string representation of value and unit.
/// </summary>
#if WINDOWS_UWP
/// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="UnitSystem" />'s default culture.</param>
#else
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
#endif
/// <param name="unit">Unit representation to use.</param>
/// <param name="format">String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively."</param>
/// <param name="args">Arguments for string format. Value and unit are implictly included as arguments 0 and 1.</param>
/// <returns>String representation.</returns>
[UsedImplicitly]
public string ToString(
AccelerationUnit unit,
#if WINDOWS_UWP
[CanBeNull] string cultureName,
#else
[CanBeNull] IFormatProvider provider,
#endif
[NotNull] string format,
[NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));

#if WINDOWS_UWP
// Windows Runtime Component does not support CultureInfo and IFormatProvider types, so we use culture name for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx
IFormatProvider provider = cultureName == null ? UnitSystem.DefaultCulture : new CultureInfo(cultureName);
#else
provider = provider ?? UnitSystem.DefaultCulture;
#endif

double value = As(unit);
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, provider, args);
return string.Format(provider, format, formatArgs);
}

/// <summary>
/// Represents the largest possible value of Acceleration
/// </summary>
Expand Down
Loading