]> O.S.I.I.S - jp/crow.git/commitdiff
Typed static Parse instead of returning object
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 20 Jan 2021 19:56:20 +0000 (20:56 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 6 Feb 2021 19:28:02 +0000 (20:28 +0100)
Crow/src/Colors.cs
Crow/src/Fill/Fill.cs
Crow/src/Fill/Picture.cs
Crow/src/Font.cs

index eb62cb1406ffd7156ce4aabe72a0c32b2b07427b..5b4396f71f169947dec50534f139687ca6cc6f9e 100644 (file)
@@ -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) :
index 24c94dcad2e0c7f6cd890526f602a8ddced2c623..a11b666e60e4c336ef5db459711159be8867a087 100644 (file)
@@ -18,12 +18,12 @@ namespace Crow
                /// <param name="ctx">backend context</param>
                /// <param name="bounds">paint operation bounding box, unused for SolidColor</param>
                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<char> 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) ||
index fd86506a33b02d866674664037b240762c694a60..c9b234041d6c4092c18849d9d7f7ff3c2765d1b3 100644 (file)
@@ -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;
index c326b4eaccbe8107315693d0bc6fe17a48f9668e..f05c6fb1e08d7659e31c7039870916b2494393fe 100644 (file)
@@ -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<char> tmp = s.AsSpan ().Trim ();