mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-20 13:48:16 +08:00
Use file scoped namespace declarations
This commit is contained in:

committed by
Phil Scott

parent
1dbaf50935
commit
ec1188b837
@ -1,59 +1,58 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Spectre.Console.Cli
|
||||
namespace Spectre.Console.Cli;
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of a flag with an optional value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The flag's element type.</typeparam>
|
||||
public sealed class FlagValue<T> : IFlagValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of a flag with an optional value.
|
||||
/// Gets or sets a value indicating whether or not the flag was set or not.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The flag's element type.</typeparam>
|
||||
public sealed class FlagValue<T> : IFlagValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not the flag was set or not.
|
||||
/// </summary>
|
||||
public bool IsSet { get; set; }
|
||||
public bool IsSet { get; set; }
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
|
||||
/// <summary>
|
||||
/// Gets or sets the flag's value.
|
||||
/// </summary>
|
||||
public T Value { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the flag's value.
|
||||
/// </summary>
|
||||
public T Value { get; set; }
|
||||
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
|
||||
|
||||
/// <inheritdoc/>
|
||||
Type IFlagValue.Type => typeof(T);
|
||||
/// <inheritdoc/>
|
||||
Type IFlagValue.Type => typeof(T);
|
||||
|
||||
/// <inheritdoc/>
|
||||
object? IFlagValue.Value
|
||||
/// <inheritdoc/>
|
||||
object? IFlagValue.Value
|
||||
{
|
||||
get => Value;
|
||||
set
|
||||
{
|
||||
get => Value;
|
||||
set
|
||||
{
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
Value = (T)value;
|
||||
Value = (T)value;
|
||||
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
#pragma warning restore CS8601 // Possible null reference assignment.
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
var flag = (IFlagValue)this;
|
||||
if (flag.Value != null)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Set={0}, Value={1}",
|
||||
IsSet,
|
||||
flag.Value.ToString());
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Set={0}", IsSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
var flag = (IFlagValue)this;
|
||||
if (flag.Value != null)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Set={0}, Value={1}",
|
||||
IsSet,
|
||||
flag.Value.ToString());
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Set={0}", IsSet);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user