Use file scoped namespace declarations

This commit is contained in:
Patrik Svensson
2021-12-21 11:06:46 +01:00
committed by Phil Scott
parent 1dbaf50935
commit ec1188b837
607 changed files with 28739 additions and 29245 deletions

View File

@ -1,66 +1,65 @@
using System;
using System.Globalization;
namespace Spectre.Console
namespace Spectre.Console;
/// <summary>
/// Contains extension methods for <see cref="IHasCulture"/>.
/// </summary>
public static class HasCultureExtensions
{
/// <summary>
/// Contains extension methods for <see cref="IHasCulture"/>.
/// Sets the culture.
/// </summary>
public static class HasCultureExtensions
/// <typeparam name="T">An object type with a culture.</typeparam>
/// <param name="obj">The object to set the culture for.</param>
/// <param name="culture">The culture to set.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Culture<T>(this T obj, CultureInfo culture)
where T : class, IHasCulture
{
/// <summary>
/// Sets the culture.
/// </summary>
/// <typeparam name="T">An object type with a culture.</typeparam>
/// <param name="obj">The object to set the culture for.</param>
/// <param name="culture">The culture to set.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Culture<T>(this T obj, CultureInfo culture)
where T : class, IHasCulture
if (obj is null)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
if (culture is null)
{
throw new ArgumentNullException(nameof(culture));
}
obj.Culture = culture;
return obj;
throw new ArgumentNullException(nameof(obj));
}
/// <summary>
/// Sets the culture.
/// </summary>
/// <typeparam name="T">An object type with a culture.</typeparam>
/// <param name="obj">The object to set the culture for.</param>
/// <param name="name">The culture to set.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Culture<T>(this T obj, string name)
where T : class, IHasCulture
if (culture is null)
{
if (name is null)
{
throw new ArgumentNullException(nameof(name));
}
return Culture(obj, CultureInfo.GetCultureInfo(name));
throw new ArgumentNullException(nameof(culture));
}
/// <summary>
/// Sets the culture.
/// </summary>
/// <typeparam name="T">An object type with a culture.</typeparam>
/// <param name="obj">The object to set the culture for.</param>
/// <param name="culture">The culture to set.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Culture<T>(this T obj, int culture)
where T : class, IHasCulture
{
return Culture(obj, CultureInfo.GetCultureInfo(culture));
}
obj.Culture = culture;
return obj;
}
}
/// <summary>
/// Sets the culture.
/// </summary>
/// <typeparam name="T">An object type with a culture.</typeparam>
/// <param name="obj">The object to set the culture for.</param>
/// <param name="name">The culture to set.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Culture<T>(this T obj, string name)
where T : class, IHasCulture
{
if (name is null)
{
throw new ArgumentNullException(nameof(name));
}
return Culture(obj, CultureInfo.GetCultureInfo(name));
}
/// <summary>
/// Sets the culture.
/// </summary>
/// <typeparam name="T">An object type with a culture.</typeparam>
/// <param name="obj">The object to set the culture for.</param>
/// <param name="culture">The culture to set.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Culture<T>(this T obj, int culture)
where T : class, IHasCulture
{
return Culture(obj, CultureInfo.GetCultureInfo(culture));
}
}