From 4714088d9cbaba81451a899cd97390f133b6a3cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 20 Jan 2021 20:56:20 +0100 Subject: [PATCH] Typed static Parse instead of returning object --- Crow/src/Colors.cs | 2 +- Crow/src/Fill/Fill.cs | 4 ++-- Crow/src/Fill/Picture.cs | 2 +- Crow/src/Font.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Crow/src/Colors.cs b/Crow/src/Colors.cs index eb62cb14..5b4396f7 100644 --- a/Crow/src/Colors.cs +++ b/Crow/src/Colors.cs @@ -350,7 +350,7 @@ namespace Crow return new Color (components); } - public static object Parse(string s) + public static Color Parse(string s) => string.IsNullOrEmpty (s) ? new Color (Colors.White) : s[0] == '#' ? new Color (UInt32.Parse (s.AsSpan().Slice (1), System.Globalization.NumberStyles.HexNumber)) : char.IsDigit(s[0]) ? FromIml (s) : diff --git a/Crow/src/Fill/Fill.cs b/Crow/src/Fill/Fill.cs index 24c94dca..a11b666e 100644 --- a/Crow/src/Fill/Fill.cs +++ b/Crow/src/Fill/Fill.cs @@ -18,12 +18,12 @@ namespace Crow /// backend context /// paint operation bounding box, unused for SolidColor public abstract void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle)); - public static object Parse (string s){ + public static Fill Parse (string s){ ReadOnlySpan tmp = s.AsSpan (); if (tmp.Length == 0) return null; if (tmp.Length > 8 && tmp.Slice (1, 8).SequenceEqual ("gradient")) - return Gradient.Parse (s); + return (Fill)Gradient.Parse (s); if (tmp.EndsWith (".svg", StringComparison.OrdinalIgnoreCase) || tmp.EndsWith (".png", StringComparison.OrdinalIgnoreCase) || tmp.EndsWith (".jpg", StringComparison.OrdinalIgnoreCase) || diff --git a/Crow/src/Fill/Picture.cs b/Crow/src/Fill/Picture.cs index fd86506a..c9b23404 100644 --- a/Crow/src/Fill/Picture.cs +++ b/Crow/src/Fill/Picture.cs @@ -100,7 +100,7 @@ namespace Crow public static implicit operator string(Picture _pic) => _pic == null ? null : _pic.Path; #endregion - public static new object Parse(string path) + public static new Picture Parse(string path) { if (string.IsNullOrEmpty (path)) return null; diff --git a/Crow/src/Font.cs b/Crow/src/Font.cs index c326b4ea..f05c6fb1 100644 --- a/Crow/src/Font.cs +++ b/Crow/src/Font.cs @@ -70,7 +70,7 @@ namespace Crow public override string ToString () => _style == FontStyle.Normal ? $"{_name},{_size}" : $"{_name} {_style},{_size}"; - public static object Parse(string s) + public static Font Parse(string s) { Font f = new Font (); ReadOnlySpan tmp = s.AsSpan ().Trim (); -- 2.47.3