mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 17:02:51 +08:00
parent
87bde3e5a2
commit
3cc19520b0
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Spectre.Console.Internal;
|
using Spectre.Console.Internal;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console
|
||||||
@ -47,16 +48,6 @@ namespace Spectre.Console
|
|||||||
Decoration = decoration ?? Decoration.None;
|
Decoration = decoration ?? Decoration.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts the string representation of a style to its <see cref="Style"/> equivalent.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">A string containing a style to parse.</param>
|
|
||||||
/// <returns>A <see cref="Style"/> equivalent of the text contained in <paramref name="text"/>.</returns>
|
|
||||||
public static Style Parse(string text)
|
|
||||||
{
|
|
||||||
return StyleParser.Parse(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a copy of the current <see cref="Style"/>.
|
/// Creates a copy of the current <see cref="Style"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,21 +57,6 @@ namespace Spectre.Console
|
|||||||
return new Style(Foreground, Background, Decoration);
|
return new Style(Foreground, Background, Decoration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts the string representation of a style to its <see cref="Style"/> equivalent.
|
|
||||||
/// A return value indicates whether the operation succeeded.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">A string containing a style to parse.</param>
|
|
||||||
/// <param name="result">
|
|
||||||
/// When this method returns, contains the <see cref="Style"/> equivalent of the text contained in <paramref name="text"/>,
|
|
||||||
/// if the conversion succeeded, or <c>null</c> if the conversion failed.
|
|
||||||
/// </param>
|
|
||||||
/// <returns><c>true</c> if s was converted successfully; otherwise, <c>false</c>.</returns>
|
|
||||||
public static bool TryParse(string text, out Style? result)
|
|
||||||
{
|
|
||||||
return StyleParser.TryParse(text, out result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Combines this style with another one.
|
/// Combines this style with another one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -108,6 +84,41 @@ namespace Spectre.Console
|
|||||||
return new Style(foreground, background, Decoration | other.Decoration);
|
return new Style(foreground, background, Decoration | other.Decoration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implicitly converts <see cref="string"/> into a <see cref="Style"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="style">The style string.</param>
|
||||||
|
[SuppressMessage("Usage", "CA2225:Operator overloads have named alternates")]
|
||||||
|
public static explicit operator Style(string style)
|
||||||
|
{
|
||||||
|
return Parse(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the string representation of a style to its <see cref="Style"/> equivalent.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">A string containing a style to parse.</param>
|
||||||
|
/// <returns>A <see cref="Style"/> equivalent of the text contained in <paramref name="text"/>.</returns>
|
||||||
|
public static Style Parse(string text)
|
||||||
|
{
|
||||||
|
return StyleParser.Parse(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the string representation of a style to its <see cref="Style"/> equivalent.
|
||||||
|
/// A return value indicates whether the operation succeeded.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">A string containing a style to parse.</param>
|
||||||
|
/// <param name="result">
|
||||||
|
/// When this method returns, contains the <see cref="Style"/> equivalent of the text contained in <paramref name="text"/>,
|
||||||
|
/// if the conversion succeeded, or <c>null</c> if the conversion failed.
|
||||||
|
/// </param>
|
||||||
|
/// <returns><c>true</c> if s was converted successfully; otherwise, <c>false</c>.</returns>
|
||||||
|
public static bool TryParse(string text, out Style? result)
|
||||||
|
{
|
||||||
|
return StyleParser.TryParse(text, out result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user