Skip to content

Commit

Permalink
Merge pull request #493 from irihitech/collection
Browse files Browse the repository at this point in the history
Revert collection expression.
  • Loading branch information
zdpcdt authored Nov 22, 2024
2 parents cd3d425 + 8df275c commit 5db7793
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/Ursa/Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Ursa.Common;

internal static class Constants
{
public static readonly char[] SpaceSeparator = [' '];
}
5 changes: 3 additions & 2 deletions src/Ursa/Controls/Dialog/Dialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Ursa.Common;

namespace Ursa.Controls;

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Ursa/Controls/Dialog/OverlayDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Layout;
using Ursa.Common;

namespace Ursa.Controls;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/Ursa/Controls/Drawer/Drawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Avalonia.Input;
using Ursa.Common;
using Ursa.Controls.Options;
// ReSharper disable RedundantExplicitArrayCreation

namespace Ursa.Controls;

Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Ursa/Controls/MessageBox/MessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input;
using Ursa.Common;

namespace Ursa.Controls;

Expand All @@ -22,7 +23,7 @@ public static async Task<MessageBoxResult> 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;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static async Task<MessageBoxResult> 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<MessageBoxResult>(owner);
Expand Down Expand Up @@ -82,7 +83,7 @@ public static async Task<MessageBoxResult> 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);
Expand Down

0 comments on commit 5db7793

Please sign in to comment.