diff --git a/src/Ursa/Common/Constants.cs b/src/Ursa/Common/Constants.cs new file mode 100644 index 00000000..acaab23c --- /dev/null +++ b/src/Ursa/Common/Constants.cs @@ -0,0 +1,6 @@ +namespace Ursa.Common; + +internal static class Constants +{ + public static readonly char[] SpaceSeparator = [' ']; +} \ No newline at end of file diff --git a/src/Ursa/Controls/Dialog/Dialog.cs b/src/Ursa/Controls/Dialog/Dialog.cs index 9922f155..73ddc053 100644 --- a/src/Ursa/Controls/Dialog/Dialog.cs +++ b/src/Ursa/Controls/Dialog/Dialog.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; +using Ursa.Common; namespace Ursa.Controls; @@ -216,7 +217,7 @@ private static void ConfigureDialogWindow(DialogWindow window, DialogOptions? op } if (!string.IsNullOrWhiteSpace(options.StyleClass)) { - var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = options.StyleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); window.Classes.AddRange(styles); } } @@ -247,7 +248,7 @@ private static void ConfigureDefaultDialogWindow(DefaultDialogWindow window, Dia } if (!string.IsNullOrWhiteSpace(options.StyleClass)) { - var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = options.StyleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); window.Classes.AddRange(styles); } } diff --git a/src/Ursa/Controls/Dialog/OverlayDialog.cs b/src/Ursa/Controls/Dialog/OverlayDialog.cs index 6028f83f..bc6e01a5 100644 --- a/src/Ursa/Controls/Dialog/OverlayDialog.cs +++ b/src/Ursa/Controls/Dialog/OverlayDialog.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Input; using Avalonia.Layout; +using Ursa.Common; namespace Ursa.Controls; @@ -207,7 +208,7 @@ private static void ConfigureCustomDialogControl(CustomDialogControl control, Ov control.CanResize = options.CanResize; if (!string.IsNullOrWhiteSpace(options.StyleClass)) { - var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = options.StyleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); control.Classes.AddRange(styles); } DialogControlBase.SetCanDragMove(control, options.CanDragMove); @@ -238,7 +239,7 @@ private static void ConfigureDefaultDialogControl(DefaultDialogControl control, control.CanResize = options.CanResize; if (!string.IsNullOrWhiteSpace(options.StyleClass)) { - var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = options.StyleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); control.Classes.AddRange(styles); } DialogControlBase.SetCanDragMove(control, options.CanDragMove); diff --git a/src/Ursa/Controls/Drawer/Drawer.cs b/src/Ursa/Controls/Drawer/Drawer.cs index 2bc33408..f2e0b858 100644 --- a/src/Ursa/Controls/Drawer/Drawer.cs +++ b/src/Ursa/Controls/Drawer/Drawer.cs @@ -3,6 +3,7 @@ using Avalonia.Input; using Ursa.Common; using Ursa.Controls.Options; +// ReSharper disable RedundantExplicitArrayCreation namespace Ursa.Controls; @@ -220,7 +221,7 @@ private static void ConfigureCustomDrawer(CustomDrawerControl drawer, DrawerOpti if (!string.IsNullOrWhiteSpace(options.StyleClass)) { - var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = options.StyleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); drawer.Classes.AddRange(styles); } } @@ -247,7 +248,7 @@ private static void ConfigureDefaultDrawer(DefaultDrawerControl drawer, DrawerOp } if (!string.IsNullOrWhiteSpace(options.StyleClass)) { - var styles = options.StyleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = options.StyleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); drawer.Classes.AddRange(styles); } } diff --git a/src/Ursa/Controls/MessageBox/MessageBox.cs b/src/Ursa/Controls/MessageBox/MessageBox.cs index 14c6c8ad..e998bb46 100644 --- a/src/Ursa/Controls/MessageBox/MessageBox.cs +++ b/src/Ursa/Controls/MessageBox/MessageBox.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Input; +using Ursa.Common; namespace Ursa.Controls; @@ -22,7 +23,7 @@ public static async Task ShowAsync( }; if (!string.IsNullOrWhiteSpace(styleClass)) { - var styles = styleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = styleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); messageWindow.Classes.AddRange(styles); } var lifetime = Application.Current?.ApplicationLifetime; @@ -54,7 +55,7 @@ public static async Task ShowAsync( }; if (!string.IsNullOrWhiteSpace(styleClass)) { - var styles = styleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = styleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); messageWindow.Classes.AddRange(styles!); } var result = await messageWindow.ShowDialog(owner); @@ -82,7 +83,7 @@ public static async Task ShowOverlayAsync( }; if (!string.IsNullOrWhiteSpace(styleClass)) { - var styles = styleClass!.Split([' '], StringSplitOptions.RemoveEmptyEntries); + var styles = styleClass!.Split(Constants.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries); messageControl.Classes.AddRange(styles!); } host.AddModalDialog(messageControl);