From ab21ac0a06afe0e37df549be999a396b4618f52a Mon Sep 17 00:00:00 2001 From: David Moreira Date: Sat, 25 Nov 2023 19:38:56 +0000 Subject: [PATCH 1/3] Docs : DataGrid Virtualize Example | Set a fixed row height (#5151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Docs : DataGrid Virtualize Example | Set a fixed row height * Update Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridVirtualizeExample.razor * Update Documentation/Blazorise.Docs/Models/Snippets.generated.cs --------- Co-authored-by: Mladen Macanović --- Documentation/Blazorise.Docs/Models/Snippets.generated.cs | 1 + .../Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html | 1 + .../Extensions/DataGrid/Examples/DataGridVirtualizeExample.razor | 1 + 3 files changed, 3 insertions(+) diff --git a/Documentation/Blazorise.Docs/Models/Snippets.generated.cs b/Documentation/Blazorise.Docs/Models/Snippets.generated.cs index 0362728b21..d8670f64ca 100644 --- a/Documentation/Blazorise.Docs/Models/Snippets.generated.cs +++ b/Documentation/Blazorise.Docs/Models/Snippets.generated.cs @@ -7803,6 +7803,7 @@ public void CheckName( ValidatorEventArgs validationArgs ) Data=""@employeeList"" @bind-SelectedRow=""@selectedEmployee"" Responsive + RowStyling='(x,y ) => y.Style = ""height: 70px;""' Virtualize VirtualizeOptions=""@(new() { DataGridHeight = ""250px""})""> diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html index b8a7197afe..a509ddf481 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html +++ b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html @@ -4,6 +4,7 @@ Data="@employeeList" @bind-SelectedRow="@selectedEmployee" Responsive + RowStyling='(x,y ) => y.Style = "height: 70px;"' Virtualize VirtualizeOptions="@(new() { DataGridHeight = "250px"})"> <DataGridCommandColumn /> diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridVirtualizeExample.razor b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridVirtualizeExample.razor index 97a839b311..b787e30aa7 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridVirtualizeExample.razor +++ b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridVirtualizeExample.razor @@ -4,6 +4,7 @@ Data="@employeeList" @bind-SelectedRow="@selectedEmployee" Responsive + RowStyling='(x,y ) => y.Style = "height: 70px;"' Virtualize VirtualizeOptions="@(new() { DataGridHeight = "250px"})"> From 3b3ca0ebc601077e30a66af0203dc38c7f7b713f Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Tue, 28 Nov 2023 09:18:30 +0100 Subject: [PATCH 2/3] Readonly members on NumericEdit --- Source/Blazorise/Components/NumericEdit/NumericEdit.razor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Blazorise/Components/NumericEdit/NumericEdit.razor.cs b/Source/Blazorise/Components/NumericEdit/NumericEdit.razor.cs index 413f0768a0..b5e51a5b7d 100644 --- a/Source/Blazorise/Components/NumericEdit/NumericEdit.razor.cs +++ b/Source/Blazorise/Components/NumericEdit/NumericEdit.razor.cs @@ -22,12 +22,12 @@ public partial class NumericEdit : BaseTextInput, IAsyncDisposab /// /// True if the TValue is an integer type. /// - private bool isIntegerType; + private readonly bool isIntegerType; /// /// Contains the correct inputmode for the input element, based in the TValue. /// - private string inputMode; + private readonly string inputMode; /// /// Indicates if parameter is defined. From 7846675357ff7e3880ae363b23fe59fbea62b578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Macanovi=C4=87?= Date: Tue, 28 Nov 2023 10:01:10 +0100 Subject: [PATCH 3/3] Code cleanup for null checks (#5165) * Null check with is null * Not-Null check with is not null * is null check --- .../Code/DataGridVirtualizeExampleCode.html | 2 +- Source/Blazorise/Base/BaseColumnComponent.cs | 2 +- Source/Blazorise/Base/BaseComponent.cs | 30 +++++------ .../Base/BaseFocusableContainerComponent.cs | 10 ++-- .../Base/BaseInputComponent.razor.cs | 16 +++--- Source/Blazorise/Base/BaseLinkComponent.cs | 8 +-- Source/Blazorise/Base/BaseTextInput.razor.cs | 2 +- Source/Blazorise/Base/BaseValidationResult.cs | 2 +- Source/Blazorise/ComponentActivator.cs | 2 +- .../Components/Addon/Addons.razor.cs | 10 ++-- Source/Blazorise/Components/Badge/Badge.razor | 2 +- .../Blazorise/Components/Bar/BarBrand.razor | 2 +- .../Components/Bar/BarDropdown.razor.cs | 14 ++--- .../Components/Bar/BarDropdownToggle.razor.cs | 6 +-- .../Blazorise/Components/Bar/BarItem.razor.cs | 2 +- .../Components/Bar/BarToggler.razor.cs | 8 +-- .../Breadcrumb/BreadcrumbItem.razor.cs | 2 +- Source/Blazorise/Components/Button/Button.cs | 18 +++---- .../Components/Button/CloseButton.razor.cs | 4 +- .../Blazorise/Components/Card/Card.razor.cs | 2 +- .../Components/Card/CardSubtitle.razor.cs | 2 +- .../Blazorise/Components/Card/CardTitle.razor | 2 +- .../Components/Card/CardTitle.razor.cs | 2 +- .../Components/Carousel/Carousel.razor.cs | 12 ++--- .../Carousel/CarouselSlide.razor.cs | 2 +- .../Blazorise/Components/Check/Check.razor.cs | 2 +- .../Components/Collapse/Collapse.razor.cs | 2 +- .../Collapse/CollapseHeader.razor.cs | 2 +- .../Components/ColorEdit/ColorEdit.razor.cs | 2 +- .../ColorPicker/ColorPicker.razor.cs | 4 +- .../Components/DateEdit/DateEdit.razor.cs | 2 +- .../Components/DatePicker/DatePicker.razor.cs | 10 ++-- .../Components/Divider/Divider.razor.cs | 4 +- .../Components/Dropdown/Dropdown.razor.cs | 22 ++++---- .../Components/Dropdown/DropdownMenu.razor.cs | 4 +- .../Dropdown/DropdownToggle.razor.cs | 8 +-- .../Droppable/DraggableTransaction.cs | 4 +- .../Droppable/DropContainer.razor.cs | 6 +-- .../Components/Droppable/DropZone.razor | 2 +- .../Components/Droppable/DropZone.razor.cs | 22 ++++---- .../Components/Droppable/_Draggable.razor.cs | 4 +- .../Blazorise/Components/Field/Field.razor.cs | 6 +-- .../Components/Field/FieldHelp.razor.cs | 2 +- .../Blazorise/Components/Field/Fields.razor | 4 +- .../Components/Field/Fields.razor.cs | 2 +- .../Components/FileEdit/FileEdit.razor.cs | 8 +-- Source/Blazorise/Components/Icon/Icon.razor | 2 +- .../Components/InputMask/InputMask.razor.cs | 2 +- .../Blazorise/Components/Layout/Layout.razor | 2 +- .../Components/Layout/Layout.razor.cs | 2 +- .../ListGroup/ListGroupItem.razor.cs | 2 +- .../Components/MemoEdit/MemoEdit.razor.cs | 2 +- .../MessageAlert/MessageAlert.razor | 6 +-- .../MessageAlert/MessageAlert.razor.cs | 6 +-- .../MessageAlert/MessageProvider.razor | 6 +-- .../Blazorise/Components/Modal/Modal.razor.cs | 4 +- .../Components/Modal/ModalBody.razor.cs | 2 +- .../Components/Modal/ModalContent.razor.cs | 4 +- .../NumericEdit/NumericEdit.razor.cs | 4 +- .../NumericPicker/NumericPicker.razor.cs | 4 +- .../Components/Offcanvas/Offcanvas.razor.cs | 4 +- .../Components/Pagination/Pagination.razor.cs | 4 +- .../Components/Progress/PageProgress.razor.cs | 4 +- .../Progress/PageProgressAlert.razor.cs | 4 +- .../Components/Progress/Progress.razor.cs | 6 +-- .../Components/Progress/ProgressBar.razor | 2 +- .../Components/Progress/ProgressBar.razor.cs | 2 +- .../Blazorise/Components/Radio/Radio.razor.cs | 10 ++-- .../Components/Radio/RadioGroup.razor.cs | 2 +- .../Blazorise/Components/Repeater/Repeater.cs | 6 +-- Source/Blazorise/Components/Row/Row.razor.cs | 2 +- .../Components/Select/Select.razor.cs | 20 +++---- .../Components/Slider/Slider.razor.cs | 2 +- Source/Blazorise/Components/Steps/Step.razor | 6 +-- .../Blazorise/Components/Steps/Step.razor.cs | 2 +- Source/Blazorise/Components/Steps/Steps.razor | 2 +- .../Components/Switch/Switch.razor.cs | 2 +- Source/Blazorise/Components/Tabs/Tab.razor.cs | 2 +- Source/Blazorise/Components/Tabs/Tabs.razor | 16 +++--- .../Blazorise/Components/Tabs/Tabs.razor.cs | 2 +- .../Components/TextEdit/TextEdit.razor.cs | 2 +- .../ThemeProvider/ThemeProvider.razor.cs | 6 +-- .../Components/TimeEdit/TimeEdit.razor.cs | 2 +- .../Components/TimePicker/TimePicker.razor.cs | 2 +- .../DescriptionListDefinition.razor.cs | 2 +- .../Typography/DescriptionListTerm.razor.cs | 2 +- .../Validation/EditContextValidator.cs | 8 +-- .../Handlers/ValidatorValidationHandler.cs | 2 +- .../Components/Validation/Validation.razor.cs | 6 +-- .../Validation/ValidationError.razor | 2 +- .../Validation/ValidationHandlerFactory.cs | 2 +- .../Validation/ValidationNone.razor | 2 +- .../Components/Validation/ValidationRule.cs | 10 ++-- .../Validation/ValidationSuccess.razor | 2 +- .../Validation/ValidationSummary.razor.cs | 2 +- .../Validation/Validations.razor.cs | 8 +-- Source/Blazorise/Enums/Enumeration.cs | 4 +- Source/Blazorise/Extensions/EnumExtensions.cs | 2 +- .../Blazorise/Extensions/ObjectExtensions.cs | 4 +- Source/Blazorise/Fluent/FluentBorder.cs | 2 +- Source/Blazorise/Fluent/FluentColumn.cs | 2 +- Source/Blazorise/Fluent/FluentFlex.cs | 6 +-- Source/Blazorise/Fluent/FluentGap.cs | 2 +- Source/Blazorise/Fluent/FluentSizing.cs | 2 +- Source/Blazorise/Fluent/FluentSpacing.cs | 2 +- .../Blazorise/Localization/TextLocalizer.cs | 10 ++-- Source/Blazorise/Modules/BaseJSModule.cs | 4 +- .../Blazorise/Providers/BaseIconProvider.cs | 2 +- .../Themes/Options/ThemeInputOptions.cs | 2 +- Source/Blazorise/Themes/ThemeGenerator.cs | 54 +++++++++---------- Source/Blazorise/Utilities/AsyncDisposable.cs | 2 +- Source/Blazorise/Utilities/ClassBuilder.cs | 4 +- .../Utilities/CompositeDisposable.cs | 4 +- Source/Blazorise/Utilities/Converters.cs | 22 ++++---- Source/Blazorise/Utilities/CountdownTimer.cs | 2 +- .../Utilities/DateTimeFormatConverter.cs | 4 +- Source/Blazorise/Utilities/EventArgsMapper.cs | 2 +- .../Utilities/ExpressionConverter.cs | 4 +- .../Utilities/ValidationAttributeHelper.cs | 4 +- ...lidationMessageLocalizerAttributeFinder.cs | 2 +- Source/Blazorise/Utilities/ValueDebouncer.cs | 2 +- 121 files changed, 322 insertions(+), 322 deletions(-) diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html index a509ddf481..6083161a0a 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html +++ b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Code/DataGridVirtualizeExampleCode.html @@ -4,7 +4,7 @@ Data="@employeeList" @bind-SelectedRow="@selectedEmployee" Responsive - RowStyling='(x,y ) => y.Style = "height: 70px;"' + RowStyling='(x,y ) => y.Style = "height: 70px;"' Virtualize VirtualizeOptions="@(new() { DataGridHeight = "250px"})"> <DataGridCommandColumn /> diff --git a/Source/Blazorise/Base/BaseColumnComponent.cs b/Source/Blazorise/Base/BaseColumnComponent.cs index 1f6e2b175a..b1f25a87c5 100644 --- a/Source/Blazorise/Base/BaseColumnComponent.cs +++ b/Source/Blazorise/Base/BaseColumnComponent.cs @@ -22,7 +22,7 @@ public abstract class BaseColumnComponent : BaseComponent, IColumnComponent /// protected override void BuildClasses( ClassBuilder builder ) { - if ( ColumnSize != null && !PreventColumnSize ) + if ( ColumnSize is not null && !PreventColumnSize ) builder.Append( ColumnSize.Class( InsideGrid, ClassProvider ) ); base.BuildClasses( builder ); diff --git a/Source/Blazorise/Base/BaseComponent.cs b/Source/Blazorise/Base/BaseComponent.cs index d839aeb72a..43096c1c82 100644 --- a/Source/Blazorise/Base/BaseComponent.cs +++ b/Source/Blazorise/Base/BaseComponent.cs @@ -103,12 +103,12 @@ public override Task SetParametersAsync( ParameterView parameters ) Attributes ??= new(); - if ( widthAttribute != null && parametersDictionary.Remove( "width" ) ) + if ( widthAttribute is not null && parametersDictionary.Remove( "width" ) ) { Attributes.Add( "width", widthAttribute ); } - if ( heightAttribute != null && parametersDictionary.Remove( "height" ) ) + if ( heightAttribute is not null && parametersDictionary.Remove( "height" ) ) { Attributes.Add( "height", heightAttribute ); } @@ -122,7 +122,7 @@ public override Task SetParametersAsync( ParameterView parameters ) /// protected override void OnInitialized() { - if ( ShouldAutoGenerateId && ElementId == null ) + if ( ShouldAutoGenerateId && ElementId is null ) { ElementId = IdGenerator.Generate; } @@ -174,31 +174,31 @@ protected override ValueTask DisposeAsync( bool disposing ) /// Class builder used to append the classnames. protected virtual void BuildClasses( ClassBuilder builder ) { - if ( Class != null ) + if ( Class is not null ) builder.Append( Class ); - if ( Margin != null ) + if ( Margin is not null ) builder.Append( Margin.Class( ClassProvider ) ); - if ( Padding != null ) + if ( Padding is not null ) builder.Append( Padding.Class( ClassProvider ) ); - if ( Gap != null ) + if ( Gap is not null ) builder.Append( Gap.Class( ClassProvider ) ); - if ( Display != null ) + if ( Display is not null ) builder.Append( Display.Class( ClassProvider ) ); - if ( Border != null ) + if ( Border is not null ) builder.Append( Border.Class( ClassProvider ) ); - if ( Flex != null ) + if ( Flex is not null ) builder.Append( Flex.Class( ClassProvider ) ); - if ( Position != null ) + if ( Position is not null ) builder.Append( Position.Class( ClassProvider ) ); - if ( Overflow != null ) + if ( Overflow is not null ) builder.Append( Overflow.Class( ClassProvider ) ); if ( Float != Float.Default ) @@ -213,10 +213,10 @@ protected virtual void BuildClasses( ClassBuilder builder ) if ( VerticalAlignment != VerticalAlignment.Default ) builder.Append( ClassProvider.VerticalAlignment( VerticalAlignment ) ); - if ( Width != null ) + if ( Width is not null ) builder.Append( Width.Class( ClassProvider ) ); - if ( Height != null ) + if ( Height is not null ) builder.Append( Height.Class( ClassProvider ) ); if ( Casing != CharacterCasing.Normal ) @@ -254,7 +254,7 @@ protected virtual void BuildClasses( ClassBuilder builder ) /// Style builder used to append the styles. protected virtual void BuildStyles( StyleBuilder builder ) { - if ( Style != null ) + if ( Style is not null ) builder.Append( Style ); } diff --git a/Source/Blazorise/Base/BaseFocusableContainerComponent.cs b/Source/Blazorise/Base/BaseFocusableContainerComponent.cs index 788ba13885..ef95ffa16a 100644 --- a/Source/Blazorise/Base/BaseFocusableContainerComponent.cs +++ b/Source/Blazorise/Base/BaseFocusableContainerComponent.cs @@ -35,7 +35,7 @@ protected override async ValueTask DisposeAsync( bool disposing ) { if ( disposing && Rendered ) { - if ( focusableComponents != null ) + if ( focusableComponents is not null ) { focusableComponents.Clear(); focusableComponents = null; @@ -57,10 +57,10 @@ protected Task HandleFocusableComponent() var firstFocusableComponent = FocusableComponents.FirstOrDefault( x => x.Autofocus ); // take first component if Autofocus is unspecified - if ( firstFocusableComponent == null ) + if ( firstFocusableComponent is null ) firstFocusableComponent = FocusableComponents.FirstOrDefault(); - if ( firstFocusableComponent != null ) + if ( firstFocusableComponent is not null ) { return firstFocusableComponent.Focus(); } @@ -72,7 +72,7 @@ protected Task HandleFocusableComponent() /// public void NotifyFocusableComponentInitialized( IFocusableComponent focusableComponent ) { - if ( focusableComponent == null ) + if ( focusableComponent is null ) return; if ( !FocusableComponents.Contains( focusableComponent ) ) @@ -84,7 +84,7 @@ public void NotifyFocusableComponentInitialized( IFocusableComponent focusableCo /// public void NotifyFocusableComponentRemoved( IFocusableComponent focusableComponent ) { - if ( focusableComponent == null ) + if ( focusableComponent is null ) return; if ( FocusableComponents.Contains( focusableComponent ) ) diff --git a/Source/Blazorise/Base/BaseInputComponent.razor.cs b/Source/Blazorise/Base/BaseInputComponent.razor.cs index 2cdc84230e..86d653f08c 100644 --- a/Source/Blazorise/Base/BaseInputComponent.razor.cs +++ b/Source/Blazorise/Base/BaseInputComponent.razor.cs @@ -57,7 +57,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) if ( autofocus ) { - if ( ParentFocusableContainer != null ) + if ( ParentFocusableContainer is not null ) { ParentFocusableContainer.NotifyFocusableComponentInitialized( this ); } @@ -76,7 +76,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) /// protected override void OnInitialized() { - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed += OnThemeChanged; } @@ -111,7 +111,7 @@ protected override ValueTask DisposeAsync( bool disposing ) /// protected virtual void ReleaseResources() { - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { // To avoid leaking memory, it's important to detach any event handlers in Dispose() ParentValidation.ValidationStatusChanged -= OnValidationStatusChanged; @@ -119,7 +119,7 @@ protected virtual void ReleaseResources() ParentFocusableContainer?.NotifyFocusableComponentRemoved( this ); - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed -= OnThemeChanged; } @@ -166,7 +166,7 @@ protected async Task CurrentValueHandler( string value ) } } // send the value to the validation for processing - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { await ParentValidation.NotifyInputChanged( default ); } @@ -294,7 +294,7 @@ protected virtual Task OnFocusOutHandler( FocusEventArgs eventArgs ) /// public Task Revalidate() { - if ( ParentValidation != null ) + if ( ParentValidation is not null ) return ParentValidation.NotifyInputChanged( default ); return Task.CompletedTask; @@ -334,14 +334,14 @@ private void OnThemeChanged( object sender, EventArgs eventArgs ) protected override bool ShouldAutoGenerateId => true; /// - public virtual object ValidationValue => CustomValidationValue != null + public virtual object ValidationValue => CustomValidationValue is not null ? CustomValidationValue.Invoke() : InternalValue; /// /// Returns true if input belong to a . /// - protected bool ParentIsFieldBody => ParentFieldBody != null; + protected bool ParentIsFieldBody => ParentFieldBody is not null; /// /// Returns the default value for the type. diff --git a/Source/Blazorise/Base/BaseLinkComponent.cs b/Source/Blazorise/Base/BaseLinkComponent.cs index 626dd57f7d..d32ace927e 100644 --- a/Source/Blazorise/Base/BaseLinkComponent.cs +++ b/Source/Blazorise/Base/BaseLinkComponent.cs @@ -45,10 +45,10 @@ protected override void OnParametersSet() PreventDefault = false; // in case the user has specified href instead of To we need to use that instead - if ( Attributes != null && Attributes.TryGetValue( "href", out var href ) ) + if ( Attributes is not null && Attributes.TryGetValue( "href", out var href ) ) To = $"{href}"; - if ( To != null && To.StartsWith( "#" ) ) + if ( To is not null && To.StartsWith( "#" ) ) { // If the href contains an anchor link we don't want the default click action to occur, but // rather take care of the click in our own method. @@ -76,7 +76,7 @@ protected override void Dispose( bool disposing ) if ( disposing ) { // To avoid leaking memory, it's important to detach any event handlers in Dispose() - if ( NavigationManager != null ) + if ( NavigationManager is not null ) { NavigationManager.LocationChanged -= OnLocationChanged; } @@ -146,7 +146,7 @@ private string GetAbsoluteUri( string relativeUri ) { try { - if ( relativeUri == null ) + if ( relativeUri is null ) return string.Empty; if ( relativeUri.StartsWith( "mailto:", StringComparison.OrdinalIgnoreCase ) ) diff --git a/Source/Blazorise/Base/BaseTextInput.razor.cs b/Source/Blazorise/Base/BaseTextInput.razor.cs index a7ce14ef1d..36f2296b81 100644 --- a/Source/Blazorise/Base/BaseTextInput.razor.cs +++ b/Source/Blazorise/Base/BaseTextInput.razor.cs @@ -63,7 +63,7 @@ protected override ValueTask DisposeAsync( bool disposing ) /// protected override void ReleaseResources() { - if ( inputValueDebouncer != null ) + if ( inputValueDebouncer is not null ) { inputValueDebouncer.Debounce -= OnInputValueDebounce; inputValueDebouncer = null; diff --git a/Source/Blazorise/Base/BaseValidationResult.cs b/Source/Blazorise/Base/BaseValidationResult.cs index 05e6460a9a..4f8fd42e67 100644 --- a/Source/Blazorise/Base/BaseValidationResult.cs +++ b/Source/Blazorise/Base/BaseValidationResult.cs @@ -59,7 +59,7 @@ protected override void OnParametersSet() private void DetachValidationStatusChangedListener() { - if ( previousParentValidation != null ) + if ( previousParentValidation is not null ) { previousParentValidation.ValidationStatusChanged -= OnValidationStatusChanged; } diff --git a/Source/Blazorise/ComponentActivator.cs b/Source/Blazorise/ComponentActivator.cs index bac8ee7cf8..b3703a5fdc 100644 --- a/Source/Blazorise/ComponentActivator.cs +++ b/Source/Blazorise/ComponentActivator.cs @@ -35,7 +35,7 @@ public IComponent CreateInstance( Type componentType ) { var instance = ServiceProvider.GetService( componentType ); - if ( instance == null ) + if ( instance is null ) { instance = Activator.CreateInstance( componentType ); } diff --git a/Source/Blazorise/Components/Addon/Addons.razor.cs b/Source/Blazorise/Components/Addon/Addons.razor.cs index 14867a78c8..cae1493c1d 100644 --- a/Source/Blazorise/Components/Addon/Addons.razor.cs +++ b/Source/Blazorise/Components/Addon/Addons.razor.cs @@ -28,7 +28,7 @@ protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed += OnThemeChanged; } @@ -52,7 +52,7 @@ protected override void Dispose( bool disposing ) { if ( disposing ) { - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed -= OnThemeChanged; } @@ -77,7 +77,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// A button reference that is placed inside of the addons. internal void NotifyButtonInitialized( Button button ) { - if ( button == null ) + if ( button is null ) return; registeredButtons ??= new(); @@ -94,10 +94,10 @@ internal void NotifyButtonInitialized( Button button ) /// A button reference that is placed inside of the addons. internal void NotifyButtonRemoved( Button button ) { - if ( button == null ) + if ( button is null ) return; - if ( registeredButtons != null && registeredButtons.Contains( button ) ) + if ( registeredButtons is not null && registeredButtons.Contains( button ) ) { registeredButtons.Remove( button ); } diff --git a/Source/Blazorise/Components/Badge/Badge.razor b/Source/Blazorise/Components/Badge/Badge.razor index 07ba265581..836ccbde84 100644 --- a/Source/Blazorise/Components/Badge/Badge.razor +++ b/Source/Blazorise/Components/Badge/Badge.razor @@ -1,6 +1,6 @@ @namespace Blazorise @inherits BaseComponent -@if ( Link != null ) +@if ( Link is not null ) { @ChildContent diff --git a/Source/Blazorise/Components/Bar/BarBrand.razor b/Source/Blazorise/Components/Bar/BarBrand.razor index fd37ebc46f..7abf111e8a 100644 --- a/Source/Blazorise/Components/Bar/BarBrand.razor +++ b/Source/Blazorise/Components/Bar/BarBrand.razor @@ -2,7 +2,7 @@ @inherits BaseComponent
@ChildContent - @if ( ParentBarState != null && ParentBarState.Mode != BarMode.Horizontal ) + @if ( ParentBarState is not null && ParentBarState.Mode != BarMode.Horizontal ) { Reference to the that is placed inside of this . internal void NotifyChildDropdownInitialized( BarDropdown barDropdown ) { - if ( childBarDropdown == null ) + if ( childBarDropdown is null ) childBarDropdown = barDropdown; } @@ -199,7 +199,7 @@ protected override void Dispose( bool disposing ) { if ( disposing ) { - if ( ParentBarDropdown != null ) + if ( ParentBarDropdown is not null ) { ParentBarDropdown.NotifyChildDropdownRemoved( this ); } @@ -233,12 +233,12 @@ protected override void Dispose( bool disposing ) /// /// Returns true if the BarDropdown is placed inside of another BarDropdown. /// - protected internal bool IsBarDropdownSubmenu => ParentBarDropdown != null; + protected internal bool IsBarDropdownSubmenu => ParentBarDropdown is not null; /// /// Returns true if this BarDropdown contains any child BarDropdown. /// - protected internal bool HasSubmenu => childBarDropdown != null; + protected internal bool HasSubmenu => childBarDropdown is not null; /// /// Gets the flag represented as a string. diff --git a/Source/Blazorise/Components/Bar/BarDropdownToggle.razor.cs b/Source/Blazorise/Components/Bar/BarDropdownToggle.razor.cs index f688bc37ff..df9805dc2f 100644 --- a/Source/Blazorise/Components/Bar/BarDropdownToggle.razor.cs +++ b/Source/Blazorise/Components/Bar/BarDropdownToggle.razor.cs @@ -99,7 +99,7 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) if ( IsDisabled ) return; - if ( ParentBarDropdown != null ) + if ( ParentBarDropdown is not null ) await ParentBarDropdown.Toggle( ElementId ); await Clicked.InvokeAsync( eventArgs ); @@ -115,7 +115,7 @@ protected Task KeyDownHandler( KeyboardEventArgs eventArgs ) if ( IsDisabled ) return Task.CompletedTask; - if ( ParentBarDropdown != null && eventArgs.Key == "Enter" ) + if ( ParentBarDropdown is not null && eventArgs.Key == "Enter" ) return ParentBarDropdown.Toggle( ElementId ); return Task.CompletedTask; @@ -130,7 +130,7 @@ public Task IsSafeToClose( string elementId, CloseReason closeReason, bool /// public Task Close( CloseReason closeReason ) { - if ( ParentBarDropdown != null ) + if ( ParentBarDropdown is not null ) return ParentBarDropdown.Hide(); return Task.CompletedTask; diff --git a/Source/Blazorise/Components/Bar/BarItem.razor.cs b/Source/Blazorise/Components/Bar/BarItem.razor.cs index ed9a6ea978..61971d4398 100644 --- a/Source/Blazorise/Components/Bar/BarItem.razor.cs +++ b/Source/Blazorise/Components/Bar/BarItem.razor.cs @@ -84,7 +84,7 @@ internal void NotifyBarDropdownInitialized( BarDropdown barDropdown ) /// /// True if component is placed inside of this . /// - protected bool HasDropdown => barDropdown != null; + protected bool HasDropdown => barDropdown is not null; /// /// Gets or sets the flag to indicate if is active, or focused. diff --git a/Source/Blazorise/Components/Bar/BarToggler.razor.cs b/Source/Blazorise/Components/Bar/BarToggler.razor.cs index 3efdd100b6..07ce4852c2 100644 --- a/Source/Blazorise/Components/Bar/BarToggler.razor.cs +++ b/Source/Blazorise/Components/Bar/BarToggler.razor.cs @@ -42,7 +42,7 @@ protected override Task OnInitializedAsync() protected override void BuildClasses( ClassBuilder builder ) { builder.Append( ClassProvider.BarToggler( ParentBarState?.Mode ?? BarMode.Horizontal, Mode ) ); - builder.Append( ClassProvider.BarTogglerCollapsed( ParentBarState?.Mode ?? BarMode.Horizontal, Mode, Bar != null ? Bar.Visible : ParentBarState.Visible ) ); + builder.Append( ClassProvider.BarTogglerCollapsed( ParentBarState?.Mode ?? BarMode.Horizontal, Mode, Bar is not null ? Bar.Visible : ParentBarState.Visible ) ); base.BuildClasses( builder ); } @@ -50,7 +50,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// protected override void BuildStyles( StyleBuilder builder ) { - if ( Bar != null ) + if ( Bar is not null ) { builder.Append( "display: inline-flex" ); } @@ -70,13 +70,13 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) await Clicked.InvokeAsync( eventArgs ); } - if ( Bar != null ) + if ( Bar is not null ) { await Bar.Toggle(); DirtyClasses(); } - else if ( ParentBar != null ) + else if ( ParentBar is not null ) { await ParentBar.Toggle(); } diff --git a/Source/Blazorise/Components/Breadcrumb/BreadcrumbItem.razor.cs b/Source/Blazorise/Components/Breadcrumb/BreadcrumbItem.razor.cs index 31a6690f97..ed2ec42737 100644 --- a/Source/Blazorise/Components/Breadcrumb/BreadcrumbItem.razor.cs +++ b/Source/Blazorise/Components/Breadcrumb/BreadcrumbItem.razor.cs @@ -89,7 +89,7 @@ protected virtual void OnLocationChanged( object sender, LocationChangedEventArg internal void NotifyRelativeUriChanged( string relativeUri ) { // uri will always be applied, no matter the BreadcrumbActivation state. - absoluteUri = relativeUri == null ? string.Empty : NavigationManager.ToAbsoluteUri( relativeUri ).AbsoluteUri; + absoluteUri = relativeUri is null ? string.Empty : NavigationManager.ToAbsoluteUri( relativeUri ).AbsoluteUri; } #endregion diff --git a/Source/Blazorise/Components/Button/Button.cs b/Source/Blazorise/Components/Button/Button.cs index 4b8b391ad8..d0744478c6 100644 --- a/Source/Blazorise/Components/Button/Button.cs +++ b/Source/Blazorise/Components/Button/Button.cs @@ -55,7 +55,7 @@ protected override void BuildClasses( ClassBuilder builder ) builder.Append( ClassProvider.ButtonBlock( Outline ), Block ); builder.Append( ClassProvider.ButtonActive( Outline ), Active ); builder.Append( ClassProvider.ButtonDisabled( Outline ), Disabled ); - builder.Append( ClassProvider.ButtonLoading( Outline ), Loading && LoadingTemplate == null ); + builder.Append( ClassProvider.ButtonLoading( Outline ), Loading && LoadingTemplate is null ); base.BuildClasses( builder ); } @@ -79,7 +79,7 @@ protected override void OnInitialized() LoadingTemplate ??= ProvideDefaultLoadingTemplate(); - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed += OnThemeChanged; } @@ -107,12 +107,12 @@ protected override async ValueTask DisposeAsync( bool disposing ) await JSModule.SafeDestroy( ElementRef, ElementId ); } - if ( command != null ) + if ( command is not null ) { command.CanExecuteChanged -= OnCanExecuteChanged; } - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed -= OnThemeChanged; } @@ -176,12 +176,12 @@ protected override void BuildRenderTree( RenderTreeBuilder builder ) } builder.OnClick( this, EventCallback.Factory.Create( this, ClickHandler ) ); - builder.OnClickPreventDefault( Type == ButtonType.Link && To != null && To.StartsWith( "#" ) ); + builder.OnClickPreventDefault( Type == ButtonType.Link && To is not null && To.StartsWith( "#" ) ); builder.Attributes( Attributes ); builder.ElementReferenceCapture( capturedRef => ElementRef = capturedRef ); - if ( Loading && LoadingTemplate != null ) + if ( Loading && LoadingTemplate is not null ) { builder.Content( LoadingTemplate ); } @@ -197,14 +197,14 @@ protected override void BuildRenderTree( RenderTreeBuilder builder ) private void BindCommand( ICommand value ) { - if ( command != null ) + if ( command is not null ) { command.CanExecuteChanged -= OnCanExecuteChanged; } command = value; - if ( command != null ) + if ( command is not null ) { command.CanExecuteChanged += OnCanExecuteChanged; } @@ -269,7 +269,7 @@ private void OnThemeChanged( object sender, EventArgs eventArgs ) /// /// True if button is placed inside of a . /// - protected bool ParentIsField => ParentField != null; + protected bool ParentIsField => ParentField is not null; /// /// Gets the size based on the theme settings. diff --git a/Source/Blazorise/Components/Button/CloseButton.razor.cs b/Source/Blazorise/Components/Button/CloseButton.razor.cs index def1af9c91..59ed23f348 100644 --- a/Source/Blazorise/Components/Button/CloseButton.razor.cs +++ b/Source/Blazorise/Components/Button/CloseButton.razor.cs @@ -38,11 +38,11 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) // And we don't want to close both Alert and Modal in that case. if ( IsAutoClose ) { - if ( ParentAlert != null ) + if ( ParentAlert is not null ) { await ParentAlert.Hide(); } - else if ( ParentModal != null ) + else if ( ParentModal is not null ) { await ParentModal.Hide(); } diff --git a/Source/Blazorise/Components/Card/Card.razor.cs b/Source/Blazorise/Components/Card/Card.razor.cs index 1f965b3206..eddb03ed11 100644 --- a/Source/Blazorise/Components/Card/Card.razor.cs +++ b/Source/Blazorise/Components/Card/Card.razor.cs @@ -35,7 +35,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// /// True if card is placed inside of a deck. /// - protected bool InsideDeck => ParentCardDeck != null; + protected bool InsideDeck => ParentCardDeck is not null; /// /// Sets the white text when using the darker background. diff --git a/Source/Blazorise/Components/Card/CardSubtitle.razor.cs b/Source/Blazorise/Components/Card/CardSubtitle.razor.cs index 7d272dbeeb..3f0a4c46de 100644 --- a/Source/Blazorise/Components/Card/CardSubtitle.razor.cs +++ b/Source/Blazorise/Components/Card/CardSubtitle.razor.cs @@ -34,7 +34,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// /// Indicates if the subtitle is placed inside if card header. /// - protected bool InsideHeader => ParentCardHeader != null; + protected bool InsideHeader => ParentCardHeader is not null; /// /// Number from 1 to 6 that defines the subtitle size where the smaller number means larger text. diff --git a/Source/Blazorise/Components/Card/CardTitle.razor b/Source/Blazorise/Components/Card/CardTitle.razor index 0f2ba63396..525ddc6905 100644 --- a/Source/Blazorise/Components/Card/CardTitle.razor +++ b/Source/Blazorise/Components/Card/CardTitle.razor @@ -1,6 +1,6 @@ @namespace Blazorise @inherits BaseTypographyComponent -@if ( Size != null ) +@if ( Size is not null ) { @ChildContent diff --git a/Source/Blazorise/Components/Card/CardTitle.razor.cs b/Source/Blazorise/Components/Card/CardTitle.razor.cs index f73e424e68..a7597be98f 100644 --- a/Source/Blazorise/Components/Card/CardTitle.razor.cs +++ b/Source/Blazorise/Components/Card/CardTitle.razor.cs @@ -34,7 +34,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// /// Indicates if the title is placed inside if card header. /// - protected bool InsideHeader => ParentCardHeader != null; + protected bool InsideHeader => ParentCardHeader is not null; /// /// Number from 1 to 6 that defines the title size where the smaller number means larger text. diff --git a/Source/Blazorise/Components/Carousel/Carousel.razor.cs b/Source/Blazorise/Components/Carousel/Carousel.razor.cs index 6b6a1d969a..e370c424f4 100644 --- a/Source/Blazorise/Components/Carousel/Carousel.razor.cs +++ b/Source/Blazorise/Components/Carousel/Carousel.razor.cs @@ -74,7 +74,7 @@ protected override void OnInitialized() { SetTimer(); - if ( TransitionTimer == null ) + if ( TransitionTimer is null ) { InitializeTransitionTimer(); } @@ -304,7 +304,7 @@ private void SetTimer() { TimerEnabled = ( Interval > 0 ); - if ( Timer == null && TimerEnabled ) + if ( Timer is null && TimerEnabled ) { InitializeTimer(); } @@ -317,7 +317,7 @@ private void SetTimer() private void ResetTimer() { - if ( Timer != null ) + if ( Timer is not null ) { Timer.Stop(); @@ -333,7 +333,7 @@ private void ResetTimer() private void ResetTransitionTimer() { - if ( TransitionTimer != null ) + if ( TransitionTimer is not null ) { TransitionTimer.Stop(); // Avoid an System.ObjectDisposedException due to the timer being disposed. This occurs when the Enabled property of the timer is set to false by the call to Stop() above. @@ -588,7 +588,7 @@ protected string PreviousButtonString { var localizationString = "Previous"; - if ( PreviousButtonLocalizer != null ) + if ( PreviousButtonLocalizer is not null ) return PreviousButtonLocalizer.Invoke( localizationString ); return Localizer[localizationString]; @@ -604,7 +604,7 @@ protected string NextButtonString { var localizationString = "Next"; - if ( PreviousButtonLocalizer != null ) + if ( PreviousButtonLocalizer is not null ) return PreviousButtonLocalizer.Invoke( localizationString ); return Localizer[localizationString]; diff --git a/Source/Blazorise/Components/Carousel/CarouselSlide.razor.cs b/Source/Blazorise/Components/Carousel/CarouselSlide.razor.cs index 31ac269469..b834d51849 100644 --- a/Source/Blazorise/Components/Carousel/CarouselSlide.razor.cs +++ b/Source/Blazorise/Components/Carousel/CarouselSlide.razor.cs @@ -45,7 +45,7 @@ public CarouselSlide() /// protected override void OnInitialized() { - if ( ParentCarousel != null ) + if ( ParentCarousel is not null ) { ParentCarousel.AddSlide( this ); diff --git a/Source/Blazorise/Components/Check/Check.razor.cs b/Source/Blazorise/Components/Check/Check.razor.cs index 79327ef8fe..f67d43613f 100644 --- a/Source/Blazorise/Components/Check/Check.razor.cs +++ b/Source/Blazorise/Components/Check/Check.razor.cs @@ -36,7 +36,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( CheckedExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/Collapse/Collapse.razor.cs b/Source/Blazorise/Components/Collapse/Collapse.razor.cs index b2e2eda2e9..a8fb8ecd96 100644 --- a/Source/Blazorise/Components/Collapse/Collapse.razor.cs +++ b/Source/Blazorise/Components/Collapse/Collapse.razor.cs @@ -84,7 +84,7 @@ private void RaiseEvents( bool visible ) /// /// Determines if the collapse is placed inside of accordion component. /// - public bool InsideAccordion => ParentAccordion != null; + public bool InsideAccordion => ParentAccordion is not null; /// /// Determines if the collapse is placed inside of accordion component as the first item. diff --git a/Source/Blazorise/Components/Collapse/CollapseHeader.razor.cs b/Source/Blazorise/Components/Collapse/CollapseHeader.razor.cs index 11fa6fd23f..63fc6ab6c1 100644 --- a/Source/Blazorise/Components/Collapse/CollapseHeader.razor.cs +++ b/Source/Blazorise/Components/Collapse/CollapseHeader.razor.cs @@ -33,7 +33,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// A task that represents the asynchronous operation. protected async Task ClickHandler( MouseEventArgs eventArgs ) { - if ( ParentCollapse != null ) + if ( ParentCollapse is not null ) await ParentCollapse.Toggle(); await Clicked.InvokeAsync( eventArgs ); diff --git a/Source/Blazorise/Components/ColorEdit/ColorEdit.razor.cs b/Source/Blazorise/Components/ColorEdit/ColorEdit.razor.cs index a9adc5dd38..0c2c223ae8 100644 --- a/Source/Blazorise/Components/ColorEdit/ColorEdit.razor.cs +++ b/Source/Blazorise/Components/ColorEdit/ColorEdit.razor.cs @@ -33,7 +33,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( ColorExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/ColorPicker/ColorPicker.razor.cs b/Source/Blazorise/Components/ColorPicker/ColorPicker.razor.cs index ef81e52399..57832160a3 100644 --- a/Source/Blazorise/Components/ColorPicker/ColorPicker.razor.cs +++ b/Source/Blazorise/Components/ColorPicker/ColorPicker.razor.cs @@ -69,7 +69,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( ColorExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); @@ -94,7 +94,7 @@ protected override void OnInitialized() private async void OnLocalizationChanged( object sender, EventArgs eventArgs ) { // no need to refresh if we're using custom localization - if ( PickerLocalizer != null ) + if ( PickerLocalizer is not null ) return; ExecuteAfterRender( async () => await JSModule.UpdateLocalization( ElementRef, ElementId, Localizer.GetStrings() ) ); diff --git a/Source/Blazorise/Components/DateEdit/DateEdit.razor.cs b/Source/Blazorise/Components/DateEdit/DateEdit.razor.cs index a2194bdad7..f8ea5fe8bf 100644 --- a/Source/Blazorise/Components/DateEdit/DateEdit.razor.cs +++ b/Source/Blazorise/Components/DateEdit/DateEdit.razor.cs @@ -31,7 +31,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( DateExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/DatePicker/DatePicker.razor.cs b/Source/Blazorise/Components/DatePicker/DatePicker.razor.cs index 90f59eb81b..cdc183f6ae 100644 --- a/Source/Blazorise/Components/DatePicker/DatePicker.razor.cs +++ b/Source/Blazorise/Components/DatePicker/DatePicker.razor.cs @@ -100,7 +100,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) // Let blazor do its thing! await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( DateExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); @@ -216,13 +216,13 @@ protected override Task OnInternalValueChanged( IReadOnlyList value ) if ( SelectionMode != DateInputSelectionMode.Single ) return DatesChanged.InvokeAsync( value ); else - return DateChanged.InvokeAsync( value == null ? default : value.FirstOrDefault() ); + return DateChanged.InvokeAsync( value is null ? default : value.FirstOrDefault() ); } /// protected override string FormatValueAsString( IReadOnlyList values ) { - if ( values == null || values.Count == 0 ) + if ( values is null || values.Count == 0 ) return null; if ( SelectionMode != DateInputSelectionMode.Single ) @@ -238,7 +238,7 @@ protected override string FormatValueAsString( IReadOnlyList values ) } else { - if ( values[0] == null ) + if ( values[0] is null ) return null; return Formaters.FormatDateValueAsString( values[0], DateFormat ); @@ -471,7 +471,7 @@ protected override IReadOnlyList InternalValue } else { - Date = value == null ? default : value.FirstOrDefault(); + Date = value is null ? default : value.FirstOrDefault(); } } } diff --git a/Source/Blazorise/Components/Divider/Divider.razor.cs b/Source/Blazorise/Components/Divider/Divider.razor.cs index f8478a0f90..79c6796cbf 100644 --- a/Source/Blazorise/Components/Divider/Divider.razor.cs +++ b/Source/Blazorise/Components/Divider/Divider.razor.cs @@ -26,7 +26,7 @@ public partial class Divider : BaseComponent, IDisposable /// protected override void OnInitialized() { - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed += OnThemeChanged; } @@ -39,7 +39,7 @@ protected override void Dispose( bool disposing ) { if ( disposing ) { - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed -= OnThemeChanged; } diff --git a/Source/Blazorise/Components/Dropdown/Dropdown.razor.cs b/Source/Blazorise/Components/Dropdown/Dropdown.razor.cs index 1749120581..b5b271a9a5 100644 --- a/Source/Blazorise/Components/Dropdown/Dropdown.razor.cs +++ b/Source/Blazorise/Components/Dropdown/Dropdown.razor.cs @@ -53,7 +53,7 @@ public partial class Dropdown : BaseComponent, IAsyncDisposable /// protected override void OnInitialized() { - if ( ParentDropdown != null ) + if ( ParentDropdown is not null ) { ParentDropdown.NotifyChildDropdownInitialized( this ); } @@ -126,7 +126,7 @@ protected override async ValueTask DisposeAsync( bool disposing ) { if ( disposing ) { - if ( ParentDropdown != null ) + if ( ParentDropdown is not null ) { ParentDropdown.NotifyChildDropdownRemoved( this ); } @@ -245,7 +245,7 @@ internal void SetSelectedDropdownElementId( string dropdownToggleElementId ) /// Reference to the that is placed inside of this . internal protected void NotifyButtonInitialized( Button button ) { - if ( button == null ) + if ( button is null ) return; childrenButtonList ??= new(); @@ -262,10 +262,10 @@ internal protected void NotifyButtonInitialized( Button button ) /// Reference to the that is placed inside of this . internal protected void NotifyButtonRemoved( Button button ) { - if ( button == null ) + if ( button is null ) return; - if ( childrenButtonList != null && childrenButtonList.Contains( button ) ) + if ( childrenButtonList is not null && childrenButtonList.Contains( button ) ) { childrenButtonList.Remove( button ); } @@ -277,7 +277,7 @@ internal protected void NotifyButtonRemoved( Button button ) /// Reference to the that is placed inside of this . internal protected void NotifyChildDropdownInitialized( Dropdown dropdown ) { - if ( childDropdown == null ) + if ( childDropdown is null ) childDropdown = dropdown; } @@ -296,7 +296,7 @@ internal protected void NotifyChildDropdownRemoved( Dropdown dropdown ) /// Reference to the that is placed inside of this . internal protected void NotifyDropdownMenuInitialized( DropdownMenu dropdownMenu ) { - if ( dropdownMenu == null ) + if ( dropdownMenu is null ) return; childrenDropdownMenus ??= new(); @@ -316,7 +316,7 @@ internal protected bool NotifyDropdownMenuRemoved( DropdownMenu dropdownMenu ) /// Reference to the that is placed inside of this . internal protected void NotifyDropdownToggleInitialized( DropdownToggle dropdownToggle ) { - if ( dropdownToggle == null ) + if ( dropdownToggle is null ) return; childrenDropdownToggles ??= new(); @@ -382,17 +382,17 @@ private void HandleVisibilityEvents( bool visible ) /// /// Makes the drop down to behave as a group for buttons(used for the split-button behaviour). /// - protected internal bool IsGroup => ParentButtons != null || childrenButtonList?.Count >= 1; + protected internal bool IsGroup => ParentButtons is not null || childrenButtonList?.Count >= 1; /// /// Returns true if the dropdown is placed inside of another dropdown. /// - protected internal bool IsDropdownSubmenu => ParentDropdown != null; + protected internal bool IsDropdownSubmenu => ParentDropdown is not null; /// /// Returns true if this dropdown contains any child dropdown. /// - protected internal bool HasSubmenu => childDropdown != null; + protected internal bool HasSubmenu => childDropdown is not null; /// /// Tracks the last DropdownToggle Element Id that acted. diff --git a/Source/Blazorise/Components/Dropdown/DropdownMenu.razor.cs b/Source/Blazorise/Components/Dropdown/DropdownMenu.razor.cs index b1e4de7d15..c0cedefc09 100644 --- a/Source/Blazorise/Components/Dropdown/DropdownMenu.razor.cs +++ b/Source/Blazorise/Components/Dropdown/DropdownMenu.razor.cs @@ -51,7 +51,7 @@ protected override void Dispose( bool disposing ) protected override void BuildClasses( ClassBuilder builder ) { builder.Append( ClassProvider.DropdownMenu() ); - builder.Append( ClassProvider.DropdownMenuScrollable(), MaxMenuHeight != null ); + builder.Append( ClassProvider.DropdownMenuScrollable(), MaxMenuHeight is not null ); builder.Append( ClassProvider.DropdownMenuVisible( ParentDropdownState.Visible ) ); builder.Append( ClassProvider.DropdownMenuRight(), ParentDropdownState.RightAligned ); builder.Append( ClassProvider.DropdownMenuPositionStrategy( ParentDropdown.PositionStrategy ) ); @@ -62,7 +62,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// protected override void BuildStyles( StyleBuilder builder ) { - if ( MaxMenuHeight != null ) + if ( MaxMenuHeight is not null ) builder.Append( $"--dropdown-list-menu-max-height: {MaxMenuHeight};" ); base.BuildStyles( builder ); diff --git a/Source/Blazorise/Components/Dropdown/DropdownToggle.razor.cs b/Source/Blazorise/Components/Dropdown/DropdownToggle.razor.cs index d578fe7758..5144a002ba 100644 --- a/Source/Blazorise/Components/Dropdown/DropdownToggle.razor.cs +++ b/Source/Blazorise/Components/Dropdown/DropdownToggle.razor.cs @@ -40,7 +40,7 @@ protected override void OnInitialized() ParentDropdown.NotifyDropdownToggleInitialized( this ); } - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed += OnThemeChanged; } @@ -103,7 +103,7 @@ protected override async ValueTask DisposeAsync( bool disposing ) ParentDropdown.NotifyDropdownToggleRemoved( this ); } - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed -= OnThemeChanged; } @@ -122,7 +122,7 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) if ( Disabled ) return; - if ( ParentDropdown != null ) + if ( ParentDropdown is not null ) await ParentDropdown.Toggle( ElementId ); await Clicked.InvokeAsync( eventArgs ); @@ -150,7 +150,7 @@ public Task IsSafeToClose( string elementId, CloseReason closeReason, bool /// Returns the awaitable task. public Task Close( CloseReason closeReason ) { - if ( ParentDropdown != null ) + if ( ParentDropdown is not null ) return ParentDropdown.Hide(); return Task.CompletedTask; diff --git a/Source/Blazorise/Components/Droppable/DraggableTransaction.cs b/Source/Blazorise/Components/Droppable/DraggableTransaction.cs index 881fe9fa52..2ba54e0d1f 100644 --- a/Source/Blazorise/Components/Droppable/DraggableTransaction.cs +++ b/Source/Blazorise/Components/Droppable/DraggableTransaction.cs @@ -51,7 +51,7 @@ public DraggableTransaction( TItem item, string sourceZoneName, int index, Func< /// A task that represents the asynchronous operation. public Task Cancel() { - if ( Canceled != null ) + if ( Canceled is not null ) return Canceled.Invoke(); return Task.CompletedTask; @@ -63,7 +63,7 @@ public Task Cancel() /// A task that represents the asynchronous operation. public Task Commit() { - if ( Commited != null ) + if ( Commited is not null ) return Commited.Invoke(); return Task.CompletedTask; diff --git a/Source/Blazorise/Components/Droppable/DropContainer.razor.cs b/Source/Blazorise/Components/Droppable/DropContainer.razor.cs index ae0fc7659e..9e2a37e97e 100644 --- a/Source/Blazorise/Components/Droppable/DropContainer.razor.cs +++ b/Source/Blazorise/Components/Droppable/DropContainer.razor.cs @@ -174,7 +174,7 @@ public bool HasTransactionIndexChanged { get { - if ( transaction == null ) + if ( transaction is null ) return false; return transaction.CurrentZoneName != transaction.SourceZoneName || transaction.Index != transaction.SourceIndex; @@ -189,7 +189,7 @@ public bool HasTransactionIndexChanged /// True if the zone and index matches the current transaction. public bool IsOrigin( int index, string zoneName ) { - if ( transaction == null ) + if ( transaction is null ) { return false; } @@ -224,7 +224,7 @@ public bool IsTransactionOriginatedFromInside( string zoneName ) /// True if the drag transaction is in process. /// public bool TransactionInProgress - => transaction != null; + => transaction is not null; /// /// Gets the name of the dropzone that started the transaction. diff --git a/Source/Blazorise/Components/Droppable/DropZone.razor b/Source/Blazorise/Components/Droppable/DropZone.razor index c3e7ef6d7e..785e287dcb 100644 --- a/Source/Blazorise/Components/Droppable/DropZone.razor +++ b/Source/Blazorise/Components/Droppable/DropZone.razor @@ -54,7 +54,7 @@ var renderer = ItemTemplate ?? ParentContainer?.ItemTemplate; } - @if ( renderer != null ) + @if ( renderer is not null ) { @renderer(item) } diff --git a/Source/Blazorise/Components/Droppable/DropZone.razor.cs b/Source/Blazorise/Components/Droppable/DropZone.razor.cs index 130c13440e..1ca11b6449 100644 --- a/Source/Blazorise/Components/Droppable/DropZone.razor.cs +++ b/Source/Blazorise/Components/Droppable/DropZone.razor.cs @@ -58,7 +58,7 @@ public DropZone() /// protected override void OnInitialized() { - if ( ParentContainer != null ) + if ( ParentContainer is not null ) { ParentContainer.TransactionStarted += OnContainerTransactionStarted; ParentContainer.TransactionEnded += OnContainerTransactionEnded; @@ -122,7 +122,7 @@ protected override async ValueTask DisposeAsync( bool disposing ) await JSModule.SafeDestroy( ElementRef, ElementId ); } - if ( ParentContainer != null ) + if ( ParentContainer is not null ) { ParentContainer.TransactionStarted -= OnContainerTransactionStarted; ParentContainer.TransactionEnded -= OnContainerTransactionEnded; @@ -212,7 +212,7 @@ private void OnDragEnterHandler() var (context, canBeDropped) = ItemCanBeDropped(); - if ( context == null ) + if ( context is null ) { return; } @@ -230,7 +230,7 @@ private void OnDragLeaveHandler() var (context, _) = ItemCanBeDropped(); - if ( context == null ) + if ( context is null ) { return; } @@ -242,7 +242,7 @@ private async Task OnDropHandler() { var (context, canBeDropped) = ItemCanBeDropped(); - if ( context == null ) + if ( context is null ) { return; } @@ -310,21 +310,21 @@ private async Task OnDropHandler() private (TItem, bool) ItemCanBeDropped() { - if ( ParentContainer == null || ParentContainer.TransactionInProgress == false ) + if ( ParentContainer is null || ParentContainer.TransactionInProgress == false ) return (default( TItem ), false); var item = ParentContainer.GetTransactionItem(); - if ( item == null ) + if ( item is null ) return (default( TItem ), false); var canBeDropped = true; - if ( DropAllowed != null ) + if ( DropAllowed is not null ) { canBeDropped = DropAllowed( item ); } - else if ( ParentContainer.DropAllowed != null ) + else if ( ParentContainer.DropAllowed is not null ) { canBeDropped = ParentContainer.DropAllowed( item, Name ); } @@ -354,7 +354,7 @@ private IEnumerable GetItems() Func predicate = ( item ) => ParentContainer.ItemsFilter( item, Name ?? string.Empty ); - if ( ItemsFilter != null ) + if ( ItemsFilter is not null ) { predicate = ItemsFilter; } @@ -371,7 +371,7 @@ private bool GetItemDisabled( TItem item ) var predicate = ItemDisabled ?? ParentContainer?.ItemDisabled; - if ( predicate != null ) + if ( predicate is not null ) { disabled = predicate( item ); } diff --git a/Source/Blazorise/Components/Droppable/_Draggable.razor.cs b/Source/Blazorise/Components/Droppable/_Draggable.razor.cs index c33c66588e..5a60d234f6 100644 --- a/Source/Blazorise/Components/Droppable/_Draggable.razor.cs +++ b/Source/Blazorise/Components/Droppable/_Draggable.razor.cs @@ -36,7 +36,7 @@ protected override void BuildClasses( ClassBuilder builder ) private async Task OnDragStartHandler() { - if ( ParentContainer == null ) + if ( ParentContainer is null ) return; dragging = true; @@ -64,7 +64,7 @@ private async Task OnDragEndHandler( DragEventArgs e ) private void OnDragEnterHandler() { - if ( ParentContainer == null || ParentContainer.TransactionInProgress == false ) + if ( ParentContainer is null || ParentContainer.TransactionInProgress == false ) return; ParentContainer.UpdateTransactionIndex( Index ); diff --git a/Source/Blazorise/Components/Field/Field.razor.cs b/Source/Blazorise/Components/Field/Field.razor.cs index c13ff8a897..f296dad3a0 100644 --- a/Source/Blazorise/Components/Field/Field.razor.cs +++ b/Source/Blazorise/Components/Field/Field.razor.cs @@ -69,7 +69,7 @@ protected override void Dispose( bool disposing ) /// private void DetachValidationStatusChangedListener() { - if ( previousParentValidation != null ) + if ( previousParentValidation is not null ) { previousParentValidation.ValidationStatusChanged -= OnValidationStatusChanged; } @@ -81,7 +81,7 @@ protected override void BuildClasses( ClassBuilder builder ) builder.Append( ClassProvider.Field() ); builder.Append( ClassProvider.FieldHorizontal(), Horizontal ); builder.Append( ClassProvider.FieldJustifyContent( JustifyContent ), JustifyContent != JustifyContent.Default ); - builder.Append( ClassProvider.FieldValidation( ParentValidation?.Status ?? ValidationStatus.None ), ParentValidation != null ); + builder.Append( ClassProvider.FieldValidation( ParentValidation?.Status ?? ValidationStatus.None ), ParentValidation is not null ); base.BuildClasses( builder ); } @@ -126,7 +126,7 @@ internal void UnHook( BaseComponent component ) /// /// Determines if the field is inside of component. /// - protected bool IsFields => ParentFields != null; + protected bool IsFields => ParentFields is not null; /// /// Aligns the controls for horizontal form. diff --git a/Source/Blazorise/Components/Field/FieldHelp.razor.cs b/Source/Blazorise/Components/Field/FieldHelp.razor.cs index a17edf5210..f62d452849 100644 --- a/Source/Blazorise/Components/Field/FieldHelp.razor.cs +++ b/Source/Blazorise/Components/Field/FieldHelp.razor.cs @@ -27,7 +27,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// /// True if the parent is in horizontal mode. /// - protected virtual bool ParentIsFieldBody => ParentFieldBody != null; + protected virtual bool ParentIsFieldBody => ParentFieldBody is not null; /// /// Specifies the content to be rendered inside this . diff --git a/Source/Blazorise/Components/Field/Fields.razor b/Source/Blazorise/Components/Field/Fields.razor index be92335ba4..ba8c843bdb 100644 --- a/Source/Blazorise/Components/Field/Fields.razor +++ b/Source/Blazorise/Components/Field/Fields.razor @@ -1,14 +1,14 @@ @namespace Blazorise @inherits BaseColumnComponent - @if ( Label != null ) + @if ( Label is not null ) { }
@ChildContent
- @if ( Help != null ) + @if ( Help is not null ) { @Help } diff --git a/Source/Blazorise/Components/Field/Fields.razor.cs b/Source/Blazorise/Components/Field/Fields.razor.cs index 64bb6e9b94..552f9b41ee 100644 --- a/Source/Blazorise/Components/Field/Fields.razor.cs +++ b/Source/Blazorise/Components/Field/Fields.razor.cs @@ -27,7 +27,7 @@ protected override void BuildClasses( ClassBuilder builder ) { builder.Append( ClassProvider.Fields() ); - if ( ColumnSize != null ) + if ( ColumnSize is not null ) { builder.Append( ClassProvider.FieldsColumn() ); } diff --git a/Source/Blazorise/Components/FileEdit/FileEdit.razor.cs b/Source/Blazorise/Components/FileEdit/FileEdit.razor.cs index d8643f4aac..30de8e1ee9 100644 --- a/Source/Blazorise/Components/FileEdit/FileEdit.razor.cs +++ b/Source/Blazorise/Components/FileEdit/FileEdit.razor.cs @@ -50,7 +50,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) { await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { await InitializeValidation(); } @@ -72,7 +72,7 @@ protected override void OnInitialized() private async void OnLocalizationChanged( object sender, EventArgs eventArgs ) { // no need to refresh if we're using custom localization - if ( BrowseButtonLocalizer != null ) + if ( BrowseButtonLocalizer is not null ) return; await InvokeAsync( StateHasChanged ); @@ -144,7 +144,7 @@ public async Task NotifyChange( FileEntry[] files ) InternalValue = updatedFiles.ToArray(); // send the value to the validation for processing - if ( ParentValidation != null ) + if ( ParentValidation is not null ) await ParentValidation.NotifyInputChanged( files ); await Changed.InvokeAsync( new( files ) ); @@ -326,7 +326,7 @@ protected string BrowseButtonString ? $"Choose {uploadTypeString}s" : $"Choose {uploadTypeString}"; - if ( BrowseButtonLocalizer != null ) + if ( BrowseButtonLocalizer is not null ) return BrowseButtonLocalizer.Invoke( localizationString ); return Localizer[localizationString]; diff --git a/Source/Blazorise/Components/Icon/Icon.razor b/Source/Blazorise/Components/Icon/Icon.razor index e446d000c1..bd00773af4 100644 --- a/Source/Blazorise/Components/Icon/Icon.razor +++ b/Source/Blazorise/Components/Icon/Icon.razor @@ -1,7 +1,7 @@ @namespace Blazorise @inherits BaseComponent - @if ( IconProvider.IconNameAsContent && Name != null ) + @if ( IconProvider.IconNameAsContent && Name is not null ) { if ( Name is IconName ) { diff --git a/Source/Blazorise/Components/InputMask/InputMask.razor.cs b/Source/Blazorise/Components/InputMask/InputMask.razor.cs index ef09fac2a8..f0c66a7010 100644 --- a/Source/Blazorise/Components/InputMask/InputMask.razor.cs +++ b/Source/Blazorise/Components/InputMask/InputMask.razor.cs @@ -40,7 +40,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( ValueExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/Layout/Layout.razor b/Source/Blazorise/Components/Layout/Layout.razor index 84645f58f1..754dd05081 100644 --- a/Source/Blazorise/Components/Layout/Layout.razor +++ b/Source/Blazorise/Components/Layout/Layout.razor @@ -4,7 +4,7 @@
@if ( Loading ) { - @if ( LoadingTemplate != null ) + @if ( LoadingTemplate is not null ) { @LoadingTemplate } diff --git a/Source/Blazorise/Components/Layout/Layout.razor.cs b/Source/Blazorise/Components/Layout/Layout.razor.cs index 8c695b094e..3f24069141 100644 --- a/Source/Blazorise/Components/Layout/Layout.razor.cs +++ b/Source/Blazorise/Components/Layout/Layout.razor.cs @@ -39,7 +39,7 @@ protected override void BuildClasses( ClassBuilder builder ) { builder.Append( ClassProvider.Layout() ); builder.Append( ClassProvider.LayoutHasSider(), Sider ); - builder.Append( ClassProvider.LayoutRoot(), ParentLayout == null ); + builder.Append( ClassProvider.LayoutRoot(), ParentLayout is null ); base.BuildClasses( builder ); } diff --git a/Source/Blazorise/Components/ListGroup/ListGroupItem.razor.cs b/Source/Blazorise/Components/ListGroup/ListGroupItem.razor.cs index 7218e637a5..f5815a387b 100644 --- a/Source/Blazorise/Components/ListGroup/ListGroupItem.razor.cs +++ b/Source/Blazorise/Components/ListGroup/ListGroupItem.razor.cs @@ -56,7 +56,7 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) if ( Disabled ) return; - if ( ParentListGroup != null ) + if ( ParentListGroup is not null ) await ParentListGroup.SelectItem( Name ); await Clicked.InvokeAsync( eventArgs ); diff --git a/Source/Blazorise/Components/MemoEdit/MemoEdit.razor.cs b/Source/Blazorise/Components/MemoEdit/MemoEdit.razor.cs index f0f69471bc..ac891d9961 100644 --- a/Source/Blazorise/Components/MemoEdit/MemoEdit.razor.cs +++ b/Source/Blazorise/Components/MemoEdit/MemoEdit.razor.cs @@ -64,7 +64,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( TextExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/MessageAlert/MessageAlert.razor b/Source/Blazorise/Components/MessageAlert/MessageAlert.razor index 8ba1a8f239..3b398a0a59 100644 --- a/Source/Blazorise/Components/MessageAlert/MessageAlert.razor +++ b/Source/Blazorise/Components/MessageAlert/MessageAlert.razor @@ -26,14 +26,14 @@ @if ( IsConfirmation ) {
protected string IndicatorStyleNames - => Value == null ? null : $"width: {Value}%;"; + => Value is null ? null : $"width: {Value}%;"; /// /// Defines the visibility of progress bar. diff --git a/Source/Blazorise/Components/Progress/PageProgressAlert.razor.cs b/Source/Blazorise/Components/Progress/PageProgressAlert.razor.cs index 4b95d28a42..c0eca86721 100644 --- a/Source/Blazorise/Components/Progress/PageProgressAlert.razor.cs +++ b/Source/Blazorise/Components/Progress/PageProgressAlert.razor.cs @@ -26,7 +26,7 @@ protected override void Dispose( bool disposing ) { if ( disposing ) { - if ( PageProgressService != null ) + if ( PageProgressService is not null ) { PageProgressService.ProgressChanged -= OnProgressChanged; } @@ -39,7 +39,7 @@ protected override void Dispose( bool disposing ) private async void OnProgressChanged( object sender, PageProgressEventArgs eventArgs ) { Percentage = eventArgs.Percentage; - Visible = eventArgs.Percentage == null || ( eventArgs.Percentage >= 0 && eventArgs.Percentage <= 100 ); + Visible = eventArgs.Percentage is null || ( eventArgs.Percentage >= 0 && eventArgs.Percentage <= 100 ); Color = eventArgs.Options.Color; await PageProgressRef.SetValueAsync( eventArgs.Percentage ); diff --git a/Source/Blazorise/Components/Progress/Progress.razor.cs b/Source/Blazorise/Components/Progress/Progress.razor.cs index a5d2fa5a55..6a64d4e5b1 100644 --- a/Source/Blazorise/Components/Progress/Progress.razor.cs +++ b/Source/Blazorise/Components/Progress/Progress.razor.cs @@ -50,7 +50,7 @@ public Progress() /// protected override void OnInitialized() { - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed += OnThemeChanged; } @@ -63,7 +63,7 @@ protected override void Dispose( bool disposing ) { if ( disposing ) { - if ( Theme != null ) + if ( Theme is not null ) { Theme.Changed -= OnThemeChanged; } @@ -106,7 +106,7 @@ private void BuildProgressBarClasses( ClassBuilder builder ) /// Styles builder used to append the styles. private void BuildProgressBarStyles( StyleBuilder builder ) { - if ( Percentage != null ) + if ( Percentage is not null ) builder.Append( StyleProvider.ProgressBarValue( Percentage ?? 0 ) ); builder.Append( StyleProvider.ProgressBarSize( ThemeSize ) ); diff --git a/Source/Blazorise/Components/Progress/ProgressBar.razor b/Source/Blazorise/Components/Progress/ProgressBar.razor index 04ceaa0505..3da4e384e6 100644 --- a/Source/Blazorise/Components/Progress/ProgressBar.razor +++ b/Source/Blazorise/Components/Progress/ProgressBar.razor @@ -1,7 +1,7 @@ @namespace Blazorise @inherits BaseComponent
- @if ( ChildContent != null ) + @if ( ChildContent is not null ) { @ChildContent } diff --git a/Source/Blazorise/Components/Progress/ProgressBar.razor.cs b/Source/Blazorise/Components/Progress/ProgressBar.razor.cs index 494244e63e..96bb562f12 100644 --- a/Source/Blazorise/Components/Progress/ProgressBar.razor.cs +++ b/Source/Blazorise/Components/Progress/ProgressBar.razor.cs @@ -51,7 +51,7 @@ protected override void BuildClasses( ClassBuilder builder ) /// protected override void BuildStyles( StyleBuilder builder ) { - if ( Percentage != null ) + if ( Percentage is not null ) builder.Append( StyleProvider.ProgressBarValue( Percentage ?? 0 ) ); builder.Append( StyleProvider.ProgressBarSize( ParentProgress?.ThemeSize ?? Size.Default ) ); diff --git a/Source/Blazorise/Components/Radio/Radio.razor.cs b/Source/Blazorise/Components/Radio/Radio.razor.cs index 9c6196d917..98d1cd678f 100644 --- a/Source/Blazorise/Components/Radio/Radio.razor.cs +++ b/Source/Blazorise/Components/Radio/Radio.razor.cs @@ -38,7 +38,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) // Individual Radio can have validation ONLY of it's not placed inside // of a RadioGroup - if ( ParentValidation != null && ParentRadioGroup == null ) + if ( ParentValidation is not null && ParentRadioGroup is null ) { if ( parameters.TryGetValue>>( nameof( CheckedExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); @@ -50,7 +50,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) /// protected override void OnInitialized() { - if ( ParentRadioGroup != null ) + if ( ParentRadioGroup is not null ) { Checked = ParentRadioGroup.CheckedValue.IsEqual( Value ); @@ -83,7 +83,7 @@ protected override void Dispose( bool disposing ) { if ( disposing ) { - if ( ParentRadioGroup != null ) + if ( ParentRadioGroup is not null ) { ParentRadioGroup.RadioCheckedChanged -= OnRadioChanged; } @@ -95,7 +95,7 @@ protected override void Dispose( bool disposing ) /// protected override Task OnChangeHandler( ChangeEventArgs eventArgs ) { - if ( ParentRadioGroup != null ) + if ( ParentRadioGroup is not null ) return ParentRadioGroup.NotifyRadioChanged( this ); // Radio should always be inside of RadioGroup or otherwise it's "checked" state will not @@ -128,7 +128,7 @@ private async void OnRadioChanged( object sender, RadioCheckedChangedEventArgs /// True if radio belongs to the . ///
- protected bool ParentIsRadioGroup => ParentRadioGroup != null; + protected bool ParentIsRadioGroup => ParentRadioGroup is not null; /// /// True if radio should look as a regular button. diff --git a/Source/Blazorise/Components/Radio/RadioGroup.razor.cs b/Source/Blazorise/Components/Radio/RadioGroup.razor.cs index f8374bccf2..0e53ea0207 100644 --- a/Source/Blazorise/Components/Radio/RadioGroup.razor.cs +++ b/Source/Blazorise/Components/Radio/RadioGroup.razor.cs @@ -50,7 +50,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( CheckedValueExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/Repeater/Repeater.cs b/Source/Blazorise/Components/Repeater/Repeater.cs index 0178dcdfeb..4c68ff56c0 100644 --- a/Source/Blazorise/Components/Repeater/Repeater.cs +++ b/Source/Blazorise/Components/Repeater/Repeater.cs @@ -56,7 +56,7 @@ public void Dispose() /// true when disposing, false when finalizing protected virtual void Dispose( bool disposing ) { - if ( disposing && collection != null ) + if ( disposing && collection is not null ) { collection.CollectionChanged -= OnCollectionChanged; collection = null; @@ -76,7 +76,7 @@ public virtual Task SetParametersAsync( ParameterView parameters ) } else { - if ( collection != null ) + if ( collection is not null ) { collection.CollectionChanged -= OnCollectionChanged; collection = null; @@ -129,7 +129,7 @@ public virtual void RenderItems() { renderHandle.Render( builder => { - if ( Items == null ) + if ( Items is null ) { return; } diff --git a/Source/Blazorise/Components/Row/Row.razor.cs b/Source/Blazorise/Components/Row/Row.razor.cs index 60ca1a1886..396dc9fc1b 100644 --- a/Source/Blazorise/Components/Row/Row.razor.cs +++ b/Source/Blazorise/Components/Row/Row.razor.cs @@ -25,7 +25,7 @@ protected override void BuildClasses( ClassBuilder builder ) builder.Append( ClassProvider.Row() ); builder.Append( ClassProvider.RowNoGutters( NoGutters ) ); - if ( RowColumns != null && RowColumns.HasSizes ) + if ( RowColumns is not null && RowColumns.HasSizes ) builder.Append( RowColumns.Class( ClassProvider ) ); base.BuildClasses( builder ); diff --git a/Source/Blazorise/Components/Select/Select.razor.cs b/Source/Blazorise/Components/Select/Select.razor.cs index fa60439ca5..a5aad0e425 100644 --- a/Source/Blazorise/Components/Select/Select.razor.cs +++ b/Source/Blazorise/Components/Select/Select.razor.cs @@ -55,7 +55,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( Multiple ) { @@ -103,7 +103,7 @@ protected override Task OnInternalValueChanged( IReadOnlyList value ) if ( Multiple ) return SelectedValuesChanged.InvokeAsync( value ); else - return SelectedValueChanged.InvokeAsync( value == null ? default : value.FirstOrDefault() ); + return SelectedValueChanged.InvokeAsync( value is null ? default : value.FirstOrDefault() ); } /// @@ -112,7 +112,7 @@ protected override object PrepareValueForValidation( IReadOnlyList value if ( Multiple ) return value; else - return value == null ? default : value.FirstOrDefault(); + return value is null ? default : value.FirstOrDefault(); } /// @@ -149,7 +149,7 @@ protected override Task>> ParseValueFromStringA /// protected override string FormatValueAsString( IReadOnlyList value ) { - if ( value == null || value.Count == 0 ) + if ( value is null || value.Count == 0 ) return string.Empty; if ( Multiple ) @@ -159,7 +159,7 @@ protected override string FormatValueAsString( IReadOnlyList value ) } else { - if ( value[0] == null ) + if ( value[0] is null ) return string.Empty; return value[0].ToString(); @@ -175,7 +175,7 @@ public bool ContainsValue( TValue value ) { var currentValue = CurrentValue; - if ( currentValue != null ) + if ( currentValue is not null ) { var result = currentValue.Any( x => x.IsEqual( value ) ); @@ -187,7 +187,7 @@ public bool ContainsValue( TValue value ) internal void NotifySelectItemInitialized( ISelectItem selectItem ) { - if ( selectItem == null ) + if ( selectItem is null ) return; if ( !selectItems.Contains( selectItem ) ) @@ -196,7 +196,7 @@ internal void NotifySelectItemInitialized( ISelectItem selectItem ) internal void NotifySelectItemRemoved( ISelectItem selectItem ) { - if ( selectItem == null ) + if ( selectItem is null ) return; if ( selectItems.Contains( selectItem ) ) @@ -215,7 +215,7 @@ public override object ValidationValue if ( Multiple ) return InternalValue; else - return InternalValue == null ? default : InternalValue.FirstOrDefault(); + return InternalValue is null ? default : InternalValue.FirstOrDefault(); } } @@ -231,7 +231,7 @@ protected override IReadOnlyList InternalValue } else { - SelectedValue = value == null ? default : value.FirstOrDefault(); + SelectedValue = value is null ? default : value.FirstOrDefault(); } } } diff --git a/Source/Blazorise/Components/Slider/Slider.razor.cs b/Source/Blazorise/Components/Slider/Slider.razor.cs index b049c21c58..e1e98bef7c 100644 --- a/Source/Blazorise/Components/Slider/Slider.razor.cs +++ b/Source/Blazorise/Components/Slider/Slider.razor.cs @@ -31,7 +31,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( ValueExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/Steps/Step.razor b/Source/Blazorise/Components/Steps/Step.razor index ec87e626d3..be8aaad2b2 100644 --- a/Source/Blazorise/Components/Steps/Step.razor +++ b/Source/Blazorise/Components/Steps/Step.razor @@ -2,15 +2,15 @@ @inherits BaseComponent
  • - @if ( Marker != null || Caption != null ) + @if ( Marker is not null || Caption is not null ) { - @if ( Marker != null ) + @if ( Marker is not null ) { @Marker } - @if ( Caption != null ) + @if ( Caption is not null ) { @Caption diff --git a/Source/Blazorise/Components/Steps/Step.razor.cs b/Source/Blazorise/Components/Steps/Step.razor.cs index cb72d3d209..161ca3d189 100644 --- a/Source/Blazorise/Components/Steps/Step.razor.cs +++ b/Source/Blazorise/Components/Steps/Step.razor.cs @@ -106,7 +106,7 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) { await Clicked.InvokeAsync( eventArgs ); - if ( ParentSteps != null ) + if ( ParentSteps is not null ) await ParentSteps.SelectStep( Name ); } diff --git a/Source/Blazorise/Components/Steps/Steps.razor b/Source/Blazorise/Components/Steps/Steps.razor index d7bd8d583f..c9f53b8496 100644 --- a/Source/Blazorise/Components/Steps/Steps.razor +++ b/Source/Blazorise/Components/Steps/Steps.razor @@ -2,7 +2,7 @@ @inherits BaseComponent - @if ( Items != null && Content != null ) + @if ( Items is not null && Content is not null ) {
      @Items diff --git a/Source/Blazorise/Components/Switch/Switch.razor.cs b/Source/Blazorise/Components/Switch/Switch.razor.cs index abc7144f84..c6d37a9828 100644 --- a/Source/Blazorise/Components/Switch/Switch.razor.cs +++ b/Source/Blazorise/Components/Switch/Switch.razor.cs @@ -43,7 +43,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( CheckedExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/Tabs/Tab.razor.cs b/Source/Blazorise/Components/Tabs/Tab.razor.cs index 2c72f5ea0c..d2425e870e 100644 --- a/Source/Blazorise/Components/Tabs/Tab.razor.cs +++ b/Source/Blazorise/Components/Tabs/Tab.razor.cs @@ -92,7 +92,7 @@ protected async Task ClickHandler( MouseEventArgs eventArgs ) await Clicked.InvokeAsync( eventArgs ); - if ( ParentTabs != null ) + if ( ParentTabs is not null ) await ParentTabs.SelectTab( Name ); } diff --git a/Source/Blazorise/Components/Tabs/Tabs.razor b/Source/Blazorise/Components/Tabs/Tabs.razor index 746677a484..ec24d6b1ab 100644 --- a/Source/Blazorise/Components/Tabs/Tabs.razor +++ b/Source/Blazorise/Components/Tabs/Tabs.razor @@ -4,13 +4,13 @@ @if ( TabPosition == TabPosition.Top ) { - @if ( Items != null ) + @if ( Items is not null ) {
        @Items
      } - @if ( Content != null ) + @if ( Content is not null ) {
      @Content @@ -19,13 +19,13 @@ } else if ( TabPosition == TabPosition.Bottom ) { - @if ( Content != null ) + @if ( Content is not null ) {
      @Content
      } - @if ( Items != null ) + @if ( Items is not null ) {
        @Items @@ -36,7 +36,7 @@ { - @if ( Items != null ) + @if ( Items is not null ) {
          @Items @@ -44,7 +44,7 @@ } - @if ( Content != null ) + @if ( Content is not null ) {
          @Content @@ -57,7 +57,7 @@ { - @if ( Content != null ) + @if ( Content is not null ) {
          @Content @@ -65,7 +65,7 @@ } - @if ( Items != null ) + @if ( Items is not null ) {
            @Items diff --git a/Source/Blazorise/Components/Tabs/Tabs.razor.cs b/Source/Blazorise/Components/Tabs/Tabs.razor.cs index bab9cbfc45..5fa6bedc2b 100644 --- a/Source/Blazorise/Components/Tabs/Tabs.razor.cs +++ b/Source/Blazorise/Components/Tabs/Tabs.razor.cs @@ -134,7 +134,7 @@ public Task SelectTab( string tabName ) /// /// True if is placed inside of component. /// - protected bool IsCards => CardHeader != null; + protected bool IsCards => CardHeader is not null; /// /// Gets or sets the class builder for the content container element. diff --git a/Source/Blazorise/Components/TextEdit/TextEdit.razor.cs b/Source/Blazorise/Components/TextEdit/TextEdit.razor.cs index 5825fc6745..330f0d4413 100644 --- a/Source/Blazorise/Components/TextEdit/TextEdit.razor.cs +++ b/Source/Blazorise/Components/TextEdit/TextEdit.razor.cs @@ -30,7 +30,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( TextExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/ThemeProvider/ThemeProvider.razor.cs b/Source/Blazorise/Components/ThemeProvider/ThemeProvider.razor.cs index 5ad965efa4..26d5afe529 100644 --- a/Source/Blazorise/Components/ThemeProvider/ThemeProvider.razor.cs +++ b/Source/Blazorise/Components/ThemeProvider/ThemeProvider.razor.cs @@ -22,7 +22,7 @@ public partial class ThemeProvider : ComponentBase, IDisposable /// public void Dispose() { - if ( theme != null ) + if ( theme is not null ) { theme.Changed -= OnOptionsChanged; } @@ -94,14 +94,14 @@ public Theme Theme return; } - if ( theme != null ) + if ( theme is not null ) { theme.Changed -= OnOptionsChanged; } theme = value; - if ( theme != null ) + if ( theme is not null ) { theme.Changed += OnOptionsChanged; } diff --git a/Source/Blazorise/Components/TimeEdit/TimeEdit.razor.cs b/Source/Blazorise/Components/TimeEdit/TimeEdit.razor.cs index 9870fc3f5d..2f1764a24f 100644 --- a/Source/Blazorise/Components/TimeEdit/TimeEdit.razor.cs +++ b/Source/Blazorise/Components/TimeEdit/TimeEdit.razor.cs @@ -31,7 +31,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( TimeExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/TimePicker/TimePicker.razor.cs b/Source/Blazorise/Components/TimePicker/TimePicker.razor.cs index 64a07cb67b..ee434a7ede 100644 --- a/Source/Blazorise/Components/TimePicker/TimePicker.razor.cs +++ b/Source/Blazorise/Components/TimePicker/TimePicker.razor.cs @@ -73,7 +73,7 @@ public override async Task SetParametersAsync( ParameterView parameters ) // Let blazor do its thing! await base.SetParametersAsync( parameters ); - if ( ParentValidation != null ) + if ( ParentValidation is not null ) { if ( parameters.TryGetValue>>( nameof( TimeExpression ), out var expression ) ) await ParentValidation.InitializeInputExpression( expression ); diff --git a/Source/Blazorise/Components/Typography/DescriptionListDefinition.razor.cs b/Source/Blazorise/Components/Typography/DescriptionListDefinition.razor.cs index 71f611b3bb..ffdc7fd9de 100644 --- a/Source/Blazorise/Components/Typography/DescriptionListDefinition.razor.cs +++ b/Source/Blazorise/Components/Typography/DescriptionListDefinition.razor.cs @@ -24,7 +24,7 @@ protected override void BuildClasses( ClassBuilder builder ) { builder.Append( ClassProvider.DescriptionListDefinition() ); - if ( ColumnSize != null ) + if ( ColumnSize is not null ) builder.Append( ColumnSize.Class( false, ClassProvider ) ); base.BuildClasses( builder ); diff --git a/Source/Blazorise/Components/Typography/DescriptionListTerm.razor.cs b/Source/Blazorise/Components/Typography/DescriptionListTerm.razor.cs index b50714ff93..872179ec3a 100644 --- a/Source/Blazorise/Components/Typography/DescriptionListTerm.razor.cs +++ b/Source/Blazorise/Components/Typography/DescriptionListTerm.razor.cs @@ -24,7 +24,7 @@ protected override void BuildClasses( ClassBuilder builder ) { builder.Append( ClassProvider.DescriptionListTerm() ); - if ( ColumnSize != null ) + if ( ColumnSize is not null ) builder.Append( ColumnSize.Class( false, ClassProvider ) ); base.BuildClasses( builder ); diff --git a/Source/Blazorise/Components/Validation/EditContextValidator.cs b/Source/Blazorise/Components/Validation/EditContextValidator.cs index bee9ce02e9..af584dbbe8 100644 --- a/Source/Blazorise/Components/Validation/EditContextValidator.cs +++ b/Source/Blazorise/Components/Validation/EditContextValidator.cs @@ -94,7 +94,7 @@ public EditContextValidator( IValidationMessageLocalizerAttributeFinder validati /// public virtual void ValidateField( EditContext editContext, ValidationMessageStore messages, in FieldIdentifier fieldIdentifier, Func, string> messageLocalizer ) { - if ( TryGetValidatableProperty( fieldIdentifier, out var validationPropertyInfo, messageLocalizer != null ) ) + if ( TryGetValidatableProperty( fieldIdentifier, out var validationPropertyInfo, messageLocalizer is not null ) ) { var propertyValue = validationPropertyInfo.PropertyInfo.GetValue( fieldIdentifier.Model ); var validationContext = new ValidationContext( fieldIdentifier.Model, serviceProvider, null ) @@ -109,7 +109,7 @@ public virtual void ValidateField( EditContext editContext, ValidationMessageSto // Clear any previous message for the given field. editContext.ClearValidationMessages( fieldIdentifier ); - if ( messageLocalizer != null ) + if ( messageLocalizer is not null ) { // In this case we need to validate by using TryValidateValue because we need // to have custom messages on validation attributes @@ -198,7 +198,7 @@ protected virtual bool TryGetValidatableProperty( in FieldIdentifier fieldIdenti // is also set. // In case a custom ErrorMessage in the DataAnnotation like [Required(ErrorMessage="{0} is very important"] // the ErrorMessage is not initialized with null. - if ( validationAttribute.ErrorMessageResourceName == null ) + if ( validationAttribute.ErrorMessageResourceName is null ) { ValidationAttributeHelper.SetDefaultErrorMessage( validationAttribute ); } @@ -217,7 +217,7 @@ protected virtual bool TryGetValidatableProperty( in FieldIdentifier fieldIdenti } } - return validationPropertyInfo != null; + return validationPropertyInfo is not null; } #endregion diff --git a/Source/Blazorise/Components/Validation/Handlers/ValidatorValidationHandler.cs b/Source/Blazorise/Components/Validation/Handlers/ValidatorValidationHandler.cs index 89103e06dd..433378d5c0 100644 --- a/Source/Blazorise/Components/Validation/Handlers/ValidatorValidationHandler.cs +++ b/Source/Blazorise/Components/Validation/Handlers/ValidatorValidationHandler.cs @@ -37,7 +37,7 @@ public void Validate( IValidation validation, object newValidationValue ) cancellationToken.ThrowIfCancellationRequested(); - if ( validation.AsyncValidator != null ) + if ( validation.AsyncValidator is not null ) await validation.AsyncValidator( validatorEventArgs, cancellationToken ); else validation.Validator?.Invoke( validatorEventArgs ); diff --git a/Source/Blazorise/Components/Validation/Validation.razor.cs b/Source/Blazorise/Components/Validation/Validation.razor.cs index 540c8bb866..396d9ab90f 100644 --- a/Source/Blazorise/Components/Validation/Validation.razor.cs +++ b/Source/Blazorise/Components/Validation/Validation.razor.cs @@ -168,7 +168,7 @@ internal Task NotifyInputChanged( T newExpressionValue, bool overrideNewValue ? newExpressionValue : inputComponent.ValidationValue; - if ( EditContext != null && hasFieldIdentifier ) + if ( EditContext is not null && hasFieldIdentifier ) { EditContext.NotifyFieldChanged( fieldIdentifier ); } @@ -189,7 +189,7 @@ private void OnClearingAll() /// public ValidationStatus Validate() { - if ( inputComponent == null ) + if ( inputComponent is null ) throw new ArgumentNullException( nameof( inputComponent ), "Input component is not assigned." ); return Validate( inputComponent.ValidationValue ); @@ -218,7 +218,7 @@ public ValidationStatus Validate( object newValidationValue ) /// public Task ValidateAsync() { - if ( inputComponent == null ) + if ( inputComponent is null ) throw new ArgumentNullException( nameof( inputComponent ), "Input component is not assigned." ); return ValidateAsync( inputComponent.ValidationValue ); diff --git a/Source/Blazorise/Components/Validation/ValidationError.razor b/Source/Blazorise/Components/Validation/ValidationError.razor index 8f5d226634..e83349121f 100644 --- a/Source/Blazorise/Components/Validation/ValidationError.razor +++ b/Source/Blazorise/Components/Validation/ValidationError.razor @@ -7,7 +7,7 @@ { @ChildContent } - else if ( ErrorMessages != null && ErrorMessages.Any() ) + else if ( ErrorMessages is not null && ErrorMessages.Any() ) { @if ( Multiline ) { diff --git a/Source/Blazorise/Components/Validation/ValidationHandlerFactory.cs b/Source/Blazorise/Components/Validation/ValidationHandlerFactory.cs index ce47392d9d..968667aded 100644 --- a/Source/Blazorise/Components/Validation/ValidationHandlerFactory.cs +++ b/Source/Blazorise/Components/Validation/ValidationHandlerFactory.cs @@ -47,7 +47,7 @@ protected virtual IValidationHandler CreateImpl( Type handlerType ) { var validationHandler = serviceProvider.GetService( handlerType ) as IValidationHandler; - if ( validationHandler == null ) + if ( validationHandler is null ) { throw new ArgumentNullException( nameof( validationHandler ), "Validation handler is not supported or it is not implemented." ); diff --git a/Source/Blazorise/Components/Validation/ValidationNone.razor b/Source/Blazorise/Components/Validation/ValidationNone.razor index a9dadbe63d..ae2fbd0039 100644 --- a/Source/Blazorise/Components/Validation/ValidationNone.razor +++ b/Source/Blazorise/Components/Validation/ValidationNone.razor @@ -1,6 +1,6 @@ @namespace Blazorise @inherits BaseValidationResult -@if ( ParentValidation?.Status == ValidationStatus.None && ChildContent != null ) +@if ( ParentValidation?.Status == ValidationStatus.None && ChildContent is not null ) { @ChildContent diff --git a/Source/Blazorise/Components/Validation/ValidationRule.cs b/Source/Blazorise/Components/Validation/ValidationRule.cs index cf1eb1a5f8..c6eaa0d858 100644 --- a/Source/Blazorise/Components/Validation/ValidationRule.cs +++ b/Source/Blazorise/Components/Validation/ValidationRule.cs @@ -29,7 +29,7 @@ public static class ValidationRule /// Minimum length allowed. /// Maximum length allowed. /// True if string length is in the range. - public static bool IsLength( string value, int min, int max ) => value != null && value.Length >= min && value.Length <= max; + public static bool IsLength( string value, int min, int max ) => value is not null && value.Length >= min && value.Length <= max; /// /// Check if the string is null or empty. @@ -50,28 +50,28 @@ public static class ValidationRule /// /// /// - public static bool IsEmail( string value ) => value != null && Regex.IsMatch( value, @"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$", RegexOptions.IgnoreCase ); + public static bool IsEmail( string value ) => value is not null && Regex.IsMatch( value, @"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$", RegexOptions.IgnoreCase ); /// /// Check if the string contains only letters (a-zA-Z). /// /// /// - public static bool IsAlpha( string value ) => value != null && Regex.IsMatch( value, @"^[a-zA-Z]+$" ); + public static bool IsAlpha( string value ) => value is not null && Regex.IsMatch( value, @"^[a-zA-Z]+$" ); /// /// Check if the string contains only letters and numbers. /// /// /// - public static bool IsAlphanumeric( string value ) => value != null && Regex.IsMatch( value, @"^[a-zA-Z0-9]+$" ); + public static bool IsAlphanumeric( string value ) => value is not null && Regex.IsMatch( value, @"^[a-zA-Z0-9]+$" ); /// /// Check if the string contains only letters, numbers and underscore. /// /// /// - public static bool IsAlphanumericWithUnderscore( string value ) => value != null && Regex.IsMatch( value, "^[a-zA-Z0-9_]+$" ); + public static bool IsAlphanumericWithUnderscore( string value ) => value is not null && Regex.IsMatch( value, "^[a-zA-Z0-9_]+$" ); /// /// Check if the string is uppercase. diff --git a/Source/Blazorise/Components/Validation/ValidationSuccess.razor b/Source/Blazorise/Components/Validation/ValidationSuccess.razor index f80523d15c..a086d7f406 100644 --- a/Source/Blazorise/Components/Validation/ValidationSuccess.razor +++ b/Source/Blazorise/Components/Validation/ValidationSuccess.razor @@ -1,6 +1,6 @@ @namespace Blazorise @inherits BaseValidationResult -@if ( ParentValidation?.Status == ValidationStatus.Success && ChildContent != null ) +@if ( ParentValidation?.Status == ValidationStatus.Success && ChildContent is not null ) {
            @ChildContent diff --git a/Source/Blazorise/Components/Validation/ValidationSummary.razor.cs b/Source/Blazorise/Components/Validation/ValidationSummary.razor.cs index a95ac3d4c6..45c3504e5c 100644 --- a/Source/Blazorise/Components/Validation/ValidationSummary.razor.cs +++ b/Source/Blazorise/Components/Validation/ValidationSummary.razor.cs @@ -79,7 +79,7 @@ protected override void OnParametersSet() private void DetachAllListener() { - if ( previousParentValidations != null ) + if ( previousParentValidations is not null ) { previousParentValidations._StatusChanged -= OnValidationsStatusChanged; } diff --git a/Source/Blazorise/Components/Validation/Validations.razor.cs b/Source/Blazorise/Components/Validation/Validations.razor.cs index 14cfa5ef08..3bd13f6398 100644 --- a/Source/Blazorise/Components/Validation/Validations.razor.cs +++ b/Source/Blazorise/Components/Validation/Validations.razor.cs @@ -43,14 +43,14 @@ public partial class Validations : ComponentBase /// protected override void OnParametersSet() { - if ( hasSetEditContextExplicitly && Model != null ) + if ( hasSetEditContextExplicitly && Model is not null ) { throw new InvalidOperationException( $"{nameof( Validations )} requires a {nameof( Model )} parameter, or an {nameof( EditContext )} parameter, but not both." ); } // Update editContext if we don't have one yet, or if they are supplying a // potentially new EditContext, or if they are supplying a different Model - if ( Model != null && Model != editContext?.Model ) + if ( Model is not null && Model != editContext?.Model ) { editContext = new( Model ); } @@ -184,7 +184,7 @@ public EditContext EditContext { editContext = value; - hasSetEditContextExplicitly = value != null; + hasSetEditContextExplicitly = value is not null; } } @@ -244,7 +244,7 @@ private IReadOnlyCollection FailedValidations .Concat( // In case there are some fields that do not have error message we need to combine them all under one message. validations.Any( v => v.Status == ValidationStatus.Error - && ( v.Messages == null || v.Messages.Count() == 0 ) + && ( v.Messages is null || v.Messages.Count() == 0 ) && !validations.Where( v2 => v2.Status == ValidationStatus.Error && v2.Messages?.Count() > 0 ).Contains( v ) ) ? new string[] { MissingFieldsErrorMessage ?? "One or more fields have an error. Please check and try again." } : Array.Empty() ) diff --git a/Source/Blazorise/Enums/Enumeration.cs b/Source/Blazorise/Enums/Enumeration.cs index 1fc5cc588c..fab346bb0b 100644 --- a/Source/Blazorise/Enums/Enumeration.cs +++ b/Source/Blazorise/Enums/Enumeration.cs @@ -54,7 +54,7 @@ private string BuildName() { var sb = new StringBuilder(); - if ( ParentEnumeration != null ) + if ( ParentEnumeration is not null ) sb.Append( ParentEnumeration.Name ).Append( ' ' ); sb.Append( name ); @@ -73,7 +73,7 @@ public string Name { get { - if ( cachedName == null ) + if ( cachedName is null ) cachedName = BuildName(); return cachedName; diff --git a/Source/Blazorise/Extensions/EnumExtensions.cs b/Source/Blazorise/Extensions/EnumExtensions.cs index 7f66a1a99e..24fdd01bb7 100644 --- a/Source/Blazorise/Extensions/EnumExtensions.cs +++ b/Source/Blazorise/Extensions/EnumExtensions.cs @@ -151,6 +151,6 @@ public static string ToDateInputSelectionMode( this DateInputSelectionMode dateI /// Enum to test. /// True if the value parameter is null or a default value; otherwise, false. public static bool IsNullOrDefault( this Size? size ) - => size == null || size == Size.Default; + => size is null || size == Size.Default; } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member \ No newline at end of file diff --git a/Source/Blazorise/Extensions/ObjectExtensions.cs b/Source/Blazorise/Extensions/ObjectExtensions.cs index 5e6429fd70..05b62e1edd 100644 --- a/Source/Blazorise/Extensions/ObjectExtensions.cs +++ b/Source/Blazorise/Extensions/ObjectExtensions.cs @@ -21,10 +21,10 @@ public static class ObjectExtensions /// True if the specified objects are equal; otherwise, false. public static bool IsEqual( this T x, T y ) { - if ( x == null && y == null ) + if ( x is null && y is null ) return true; - if ( x == null || y == null ) + if ( x is null || y is null ) return false; return EqualityComparer.Default.Equals( x, y ); diff --git a/Source/Blazorise/Fluent/FluentBorder.cs b/Source/Blazorise/Fluent/FluentBorder.cs index 30b8d1e71b..90ea3c6508 100644 --- a/Source/Blazorise/Fluent/FluentBorder.cs +++ b/Source/Blazorise/Fluent/FluentBorder.cs @@ -281,7 +281,7 @@ public string Class( IClassProvider classProvider ) { void BuildClasses( ClassBuilder builder ) { - if ( rules != null ) + if ( rules is not null ) { if ( rules.Count > 0 ) builder.Append( rules.Select( r => classProvider.Border( r.Key, r.Value.Select( v => (v.Side, v.Color) ) ) ) ); diff --git a/Source/Blazorise/Fluent/FluentColumn.cs b/Source/Blazorise/Fluent/FluentColumn.cs index 681d5959f0..d96fe7b742 100644 --- a/Source/Blazorise/Fluent/FluentColumn.cs +++ b/Source/Blazorise/Fluent/FluentColumn.cs @@ -303,7 +303,7 @@ public IFluentColumnOnBreakpointWithOffsetAndSize WithColumnSize( ColumnWidth co /// Next rule reference. public IFluentColumnWithSize WithColumnSize( string value ) { - if ( customRules == null ) + if ( customRules is null ) customRules = new() { value }; else customRules.Add( value ); diff --git a/Source/Blazorise/Fluent/FluentFlex.cs b/Source/Blazorise/Fluent/FluentFlex.cs index 2f31626cd9..471d8892c0 100644 --- a/Source/Blazorise/Fluent/FluentFlex.cs +++ b/Source/Blazorise/Fluent/FluentFlex.cs @@ -627,11 +627,11 @@ public string Class( IClassProvider classProvider ) { void BuildClasses( ClassBuilder builder ) { - if ( rules != null && rules.Count > 0 ) + if ( rules is not null && rules.Count > 0 ) { builder.Append( rules.Select( r => classProvider.Flex( r.Key, r.Value.Where( x => x.Condition ?? true ).Select( v => v ) ) ) ); } - else if ( currentFlexDefinition != null && currentFlexDefinition != FlexDefinition.Empty && ( currentFlexDefinition.Condition ?? true ) ) + else if ( currentFlexDefinition is not null && currentFlexDefinition != FlexDefinition.Empty && ( currentFlexDefinition.Condition ?? true ) ) { builder.Append( classProvider.Flex( currentFlexDefinition ) ); } @@ -680,7 +680,7 @@ public IFluentFlexAll WithFlexType( FlexType flexType ) /// Current definition or new if none was found. private FlexDefinition GetDefinition() { - if ( currentFlexDefinition == null ) + if ( currentFlexDefinition is null ) currentFlexDefinition = CreateDefinition(); return currentFlexDefinition; diff --git a/Source/Blazorise/Fluent/FluentGap.cs b/Source/Blazorise/Fluent/FluentGap.cs index 18b7546f0a..bebb4ee01f 100644 --- a/Source/Blazorise/Fluent/FluentGap.cs +++ b/Source/Blazorise/Fluent/FluentGap.cs @@ -198,7 +198,7 @@ public IFluentGapWithSideAndSize WithSide( GapSide side ) private IFluentGapWithSize WithSize( string value ) { - if ( customRules == null ) + if ( customRules is null ) customRules = new() { value }; else customRules.Add( value ); diff --git a/Source/Blazorise/Fluent/FluentSizing.cs b/Source/Blazorise/Fluent/FluentSizing.cs index c220b68ea7..a68be92de0 100644 --- a/Source/Blazorise/Fluent/FluentSizing.cs +++ b/Source/Blazorise/Fluent/FluentSizing.cs @@ -192,7 +192,7 @@ public string Class( IClassProvider classProvider ) { void BuildClasses( ClassBuilder builder ) { - if ( currentSizingSize != SizingSize.Default && currentSizingDefinition != null ) + if ( currentSizingSize != SizingSize.Default && currentSizingDefinition is not null ) { builder.Append( classProvider.Sizing( sizingType, currentSizingSize, currentSizingDefinition ) ); } diff --git a/Source/Blazorise/Fluent/FluentSpacing.cs b/Source/Blazorise/Fluent/FluentSpacing.cs index 4d82e9d63c..39709cae26 100644 --- a/Source/Blazorise/Fluent/FluentSpacing.cs +++ b/Source/Blazorise/Fluent/FluentSpacing.cs @@ -285,7 +285,7 @@ public IFluentSpacingOnBreakpointWithSideAndSize WithBreakpoint( Breakpoint brea private IFluentSpacingWithSize WithSize( string value ) { - if ( customRules == null ) + if ( customRules is null ) customRules = new() { value }; else customRules.Add( value ); diff --git a/Source/Blazorise/Localization/TextLocalizer.cs b/Source/Blazorise/Localization/TextLocalizer.cs index ae8eafb1e6..53aad0573d 100644 --- a/Source/Blazorise/Localization/TextLocalizer.cs +++ b/Source/Blazorise/Localization/TextLocalizer.cs @@ -149,19 +149,19 @@ protected virtual IReadOnlyDictionary GetTranslations() // 5. Invariant culture (defaults to "en") IReadOnlyDictionary result; - if ( localizerService.SelectedCulture != null + if ( localizerService.SelectedCulture is not null && translationsByCulture.TryGetValue( localizerService.SelectedCulture.Name, out result ) ) return result; - if ( localizerService.SelectedCulture?.Parent != null && !localizerService.SelectedCulture.IsNeutralCulture + if ( localizerService.SelectedCulture?.Parent is not null && !localizerService.SelectedCulture.IsNeutralCulture && translationsByCulture.TryGetValue( localizerService.SelectedCulture.Parent.Name, out result ) ) return result; - if ( CultureInfo.CurrentUICulture != null + if ( CultureInfo.CurrentUICulture is not null && translationsByCulture.TryGetValue( CultureInfo.CurrentUICulture.Name, out result ) ) return result; - if ( CultureInfo.CurrentUICulture?.Parent != null && !CultureInfo.CurrentUICulture.IsNeutralCulture + if ( CultureInfo.CurrentUICulture?.Parent is not null && !CultureInfo.CurrentUICulture.IsNeutralCulture && translationsByCulture.TryGetValue( CultureInfo.CurrentUICulture.Parent.Name, out result ) ) return result; @@ -176,7 +176,7 @@ public virtual string GetString( string name, params object[] arguments ) { var translations = GetTranslations(); - if ( translations == null || !translations.TryGetValue( name, out var value ) ) + if ( translations is null || !translations.TryGetValue( name, out var value ) ) value = name; if ( arguments.Length > 0 ) diff --git a/Source/Blazorise/Modules/BaseJSModule.cs b/Source/Blazorise/Modules/BaseJSModule.cs index 03377bdf51..06024d5c4b 100644 --- a/Source/Blazorise/Modules/BaseJSModule.cs +++ b/Source/Blazorise/Modules/BaseJSModule.cs @@ -92,7 +92,7 @@ protected virtual async ValueTask DisposeAsync( bool disposing ) if ( disposing ) { - if ( moduleTask != null ) + if ( moduleTask is not null ) { var moduleInstance = await moduleTask; await moduleInstance.SafeDisposeAsync(); @@ -169,7 +169,7 @@ private Task GetModule() /// /// Returns true if module was already being destroyed. /// - protected bool IsUnsafe => AsyncDisposed || moduleTask == null; + protected bool IsUnsafe => AsyncDisposed || moduleTask is null; /// /// Indicates if the component is already fully disposed (asynchronously). diff --git a/Source/Blazorise/Providers/BaseIconProvider.cs b/Source/Blazorise/Providers/BaseIconProvider.cs index 2bf9c94bac..a9df44a9b4 100644 --- a/Source/Blazorise/Providers/BaseIconProvider.cs +++ b/Source/Blazorise/Providers/BaseIconProvider.cs @@ -24,7 +24,7 @@ public virtual string Icon( object name, IconStyle style ) // Some icons must be placed inside of an icon tag element so just return // the style name. The actual icon name will be defined in the Icon.razor file. - if ( IconNameAsContent || name == null ) + if ( IconNameAsContent || name is null ) return iconStyle; if ( name is IconName iconEnum ) diff --git a/Source/Blazorise/Themes/Options/ThemeInputOptions.cs b/Source/Blazorise/Themes/Options/ThemeInputOptions.cs index e68ef8ebd7..ad1d4dbf27 100644 --- a/Source/Blazorise/Themes/Options/ThemeInputOptions.cs +++ b/Source/Blazorise/Themes/Options/ThemeInputOptions.cs @@ -31,7 +31,7 @@ public override bool HasOptions() return !string.IsNullOrEmpty( Color ) || !string.IsNullOrEmpty( CheckColor ) || !string.IsNullOrEmpty( SliderColor ) - || Size != null + || Size is not null || base.HasOptions(); } } \ No newline at end of file diff --git a/Source/Blazorise/Themes/ThemeGenerator.cs b/Source/Blazorise/Themes/ThemeGenerator.cs index ad3af518ee..f38b6eb761 100644 --- a/Source/Blazorise/Themes/ThemeGenerator.cs +++ b/Source/Blazorise/Themes/ThemeGenerator.cs @@ -63,16 +63,16 @@ public virtual string GenerateVariables( Theme theme ) foreach ( var (name, color) in theme.ValidTextColors ) GenerateTextColorVariables( theme, name, color ); - if ( theme.SidebarOptions != null ) + if ( theme.SidebarOptions is not null ) GenerateSidebarVariables( theme, theme.SidebarOptions ); - if ( theme.BarOptions != null ) + if ( theme.BarOptions is not null ) GenerateBarVariables( theme, theme.BarOptions ); - if ( theme.SnackbarOptions != null ) + if ( theme.SnackbarOptions is not null ) GenerateSnackbarVariables( theme, theme.SnackbarOptions ); - if ( theme.DividerOptions != null ) + if ( theme.DividerOptions is not null ) GenerateDividerVariables( theme, theme.DividerOptions ); GenerateTooltipVariables( theme, theme.TooltipOptions ); @@ -348,13 +348,13 @@ protected virtual void GenerateTextColorVariables( Theme theme, string variant, /// Sidebar options. protected virtual void GenerateSidebarVariables( Theme theme, ThemeSidebarOptions sidebarOptions ) { - if ( sidebarOptions.Width != null ) + if ( sidebarOptions.Width is not null ) Variables[ThemeVariables.SidebarWidth] = sidebarOptions.Width; - if ( sidebarOptions.BackgroundColor != null ) + if ( sidebarOptions.BackgroundColor is not null ) Variables[ThemeVariables.SidebarBackground] = ToHex( ParseColor( sidebarOptions.BackgroundColor ) ); - if ( sidebarOptions.Color != null ) + if ( sidebarOptions.Color is not null ) Variables[ThemeVariables.SidebarColor] = ToHex( ParseColor( sidebarOptions.Color ) ); } @@ -380,7 +380,7 @@ protected virtual void GenerateBarVariables( Theme theme, ThemeBarOptions barOpt if ( !string.IsNullOrEmpty( barOptions.HorizontalHeight ) ) Variables[ThemeVariables.HorizontalBarHeight] = barOptions.HorizontalHeight; - if ( barOptions?.DarkColors != null ) + if ( barOptions?.DarkColors is not null ) { if ( !string.IsNullOrEmpty( barOptions.DarkColors.BackgroundColor ) ) Variables[ThemeVariables.BarDarkBackground] = GetGradientBgValue( theme, barOptions.DarkColors.BackgroundColor, barOptions.DarkColors.GradientBlendPercentage ); @@ -388,7 +388,7 @@ protected virtual void GenerateBarVariables( Theme theme, ThemeBarOptions barOpt if ( !string.IsNullOrEmpty( barOptions.DarkColors.Color ) ) Variables[ThemeVariables.BarDarkColor] = ToHex( ParseColor( barOptions.DarkColors.Color ) ); - if ( barOptions.DarkColors.ItemColorOptions != null ) + if ( barOptions.DarkColors.ItemColorOptions is not null ) { if ( !string.IsNullOrEmpty( barOptions.DarkColors.ItemColorOptions.ActiveBackgroundColor ) ) Variables[ThemeVariables.BarItemDarkActiveBackground] = ToHex( ParseColor( barOptions.DarkColors.ItemColorOptions.ActiveBackgroundColor ) ); @@ -410,7 +410,7 @@ protected virtual void GenerateBarVariables( Theme theme, ThemeBarOptions barOpt Variables[ThemeVariables.BarBrandDarkBackground] = ToHex( ParseColor( barOptions.DarkColors.BrandColorOptions.BackgroundColor ) ); } - if ( barOptions?.LightColors != null ) + if ( barOptions?.LightColors is not null ) { if ( !string.IsNullOrEmpty( barOptions.LightColors.BackgroundColor ) ) Variables[ThemeVariables.BarLightBackground] = GetGradientBgValue( theme, barOptions.LightColors.BackgroundColor, barOptions.LightColors.GradientBlendPercentage ); @@ -418,7 +418,7 @@ protected virtual void GenerateBarVariables( Theme theme, ThemeBarOptions barOpt if ( !string.IsNullOrEmpty( barOptions.LightColors.Color ) ) Variables[ThemeVariables.BarLightColor] = ToHex( ParseColor( barOptions.LightColors.Color ) ); - if ( barOptions.LightColors.ItemColorOptions != null ) + if ( barOptions.LightColors.ItemColorOptions is not null ) { if ( !string.IsNullOrEmpty( barOptions.LightColors.ItemColorOptions.ActiveBackgroundColor ) ) Variables[ThemeVariables.BarItemLightActiveBackground] = ToHex( ParseColor( barOptions.LightColors.ItemColorOptions.ActiveBackgroundColor ) ); @@ -448,16 +448,16 @@ protected virtual void GenerateBarVariables( Theme theme, ThemeBarOptions barOpt /// Snackbar options protected virtual void GenerateSnackbarVariables( Theme theme, ThemeSnackbarOptions snackbarOptions ) { - if ( snackbarOptions?.BackgroundColor != null ) + if ( snackbarOptions?.BackgroundColor is not null ) Variables[ThemeVariables.SnackbarBackground] = ToHex( ParseColor( snackbarOptions.BackgroundColor ) ); - if ( snackbarOptions?.TextColor != null ) + if ( snackbarOptions?.TextColor is not null ) Variables[ThemeVariables.SnackbarTextColor] = ToHex( ParseColor( snackbarOptions.TextColor ) ); - if ( snackbarOptions?.ButtonColor != null ) + if ( snackbarOptions?.ButtonColor is not null ) Variables[ThemeVariables.SnackbarButtonColor] = ToHex( ParseColor( snackbarOptions.ButtonColor ) ); - if ( snackbarOptions?.ButtonHoverColor != null ) + if ( snackbarOptions?.ButtonHoverColor is not null ) Variables[ThemeVariables.SnackbarButtonHoverColor] = ToHex( ParseColor( snackbarOptions.ButtonHoverColor ) ); } @@ -468,13 +468,13 @@ protected virtual void GenerateSnackbarVariables( Theme theme, ThemeSnackbarOpti /// Divider options protected virtual void GenerateDividerVariables( Theme theme, ThemeDividerOptions dividerOptions ) { - if ( dividerOptions.Color != null ) + if ( dividerOptions.Color is not null ) Variables[ThemeVariables.DividerColor] = ToHex( ParseColor( dividerOptions.Color ) ); - if ( dividerOptions.Color != null ) + if ( dividerOptions.Color is not null ) Variables[ThemeVariables.DividerThickness] = dividerOptions.Thickness; - if ( dividerOptions.Color != null ) + if ( dividerOptions.Color is not null ) Variables[ThemeVariables.DividerTextSize] = dividerOptions.TextSize; } @@ -485,7 +485,7 @@ protected virtual void GenerateDividerVariables( Theme theme, ThemeDividerOption /// Tooltip options protected virtual void GenerateTooltipVariables( Theme theme, ThemeTooltipOptions tooltipOptions ) { - if ( tooltipOptions?.BackgroundColor != null ) + if ( tooltipOptions?.BackgroundColor is not null ) { var backgroundColor = ParseColor( tooltipOptions.BackgroundColor ); @@ -495,34 +495,34 @@ protected virtual void GenerateTooltipVariables( Theme theme, ThemeTooltipOption Variables[ThemeVariables.TooltipBackgroundOpacity] = ( backgroundColor.A / 255f ).ToString( "n2", CultureInfo.InvariantCulture ); } - if ( tooltipOptions?.Color != null ) + if ( tooltipOptions?.Color is not null ) { Variables[ThemeVariables.TooltipColor] = tooltipOptions.Color; } - if ( tooltipOptions?.FontSize != null ) + if ( tooltipOptions?.FontSize is not null ) { Variables[ThemeVariables.TooltipFontSize] = tooltipOptions.FontSize; } Variables[ThemeVariables.TooltipBorderRadius] = GetBorderRadius( theme, tooltipOptions?.BorderRadius, Var( ThemeVariables.BorderRadius ) ); - if ( tooltipOptions?.FadeTime != null ) + if ( tooltipOptions?.FadeTime is not null ) { Variables[ThemeVariables.TooltipFadeTime] = tooltipOptions.FadeTime; } - if ( tooltipOptions?.MaxWidth != null ) + if ( tooltipOptions?.MaxWidth is not null ) { Variables[ThemeVariables.TooltipMaxWidth] = tooltipOptions.MaxWidth; } - if ( tooltipOptions?.Padding != null ) + if ( tooltipOptions?.Padding is not null ) { Variables[ThemeVariables.TooltipPadding] = tooltipOptions.Padding; } - if ( tooltipOptions?.ZIndex != null ) + if ( tooltipOptions?.ZIndex is not null ) { Variables[ThemeVariables.TooltipZIndex] = tooltipOptions.ZIndex; } @@ -548,7 +548,7 @@ protected virtual void GenerateBreadcrumbVariables( Theme theme, ThemeBreadcrumb /// Steps options. protected virtual void GenerateStepsVariables( Theme theme, ThemeStepsOptions stepsOptions ) { - if ( stepsOptions != null ) + if ( stepsOptions is not null ) { if ( !string.IsNullOrEmpty( stepsOptions.StepsItemIconColor ) ) { @@ -1622,7 +1622,7 @@ protected static bool FirstNotEmpty( out string first, params string[] values ) { first = values?.FirstOrDefault( x => !string.IsNullOrEmpty( x ) ); - return first != null; + return first is not null; } /// diff --git a/Source/Blazorise/Utilities/AsyncDisposable.cs b/Source/Blazorise/Utilities/AsyncDisposable.cs index 40ca63a5e9..9a291732ed 100644 --- a/Source/Blazorise/Utilities/AsyncDisposable.cs +++ b/Source/Blazorise/Utilities/AsyncDisposable.cs @@ -44,7 +44,7 @@ public static IAsyncDisposable Create( Func action ) /// public ValueTask DisposeAsync() { - if ( action != null ) + if ( action is not null ) { return action.Invoke(); } diff --git a/Source/Blazorise/Utilities/ClassBuilder.cs b/Source/Blazorise/Utilities/ClassBuilder.cs index 7aef3672dc..aee5130425 100644 --- a/Source/Blazorise/Utilities/ClassBuilder.cs +++ b/Source/Blazorise/Utilities/ClassBuilder.cs @@ -47,7 +47,7 @@ public ClassBuilder( Action buildClasses ) /// The string to append. public void Append( string value ) { - if ( value == null ) + if ( value is null ) return; builder.Append( value ).Append( Delimiter ); @@ -60,7 +60,7 @@ public void Append( string value ) /// Condition that must be true. public void Append( string value, bool condition ) { - if ( condition && value != null ) + if ( condition && value is not null ) builder.Append( value ).Append( Delimiter ); } diff --git a/Source/Blazorise/Utilities/CompositeDisposable.cs b/Source/Blazorise/Utilities/CompositeDisposable.cs index f497cc8164..6330953a1f 100644 --- a/Source/Blazorise/Utilities/CompositeDisposable.cs +++ b/Source/Blazorise/Utilities/CompositeDisposable.cs @@ -29,10 +29,10 @@ public static class CompositeDisposableEx public static T DisposeWith( this T disposable, CompositeDisposable cleanup ) where T : IDisposable { - if ( disposable == null ) + if ( disposable is null ) throw new ArgumentNullException( nameof( disposable ) ); - if ( cleanup == null ) + if ( cleanup is null ) throw new ArgumentNullException( nameof( cleanup ) ); cleanup.Add( disposable ); diff --git a/Source/Blazorise/Utilities/Converters.cs b/Source/Blazorise/Utilities/Converters.cs index d326873f74..e29e375577 100644 --- a/Source/Blazorise/Utilities/Converters.cs +++ b/Source/Blazorise/Utilities/Converters.cs @@ -46,7 +46,7 @@ public static class Converters /// Dictionary public static IDictionary ToDictionary( object source, bool addEmptyObjects = true, bool forceCamelCase = true ) { - if ( source == null ) + if ( source is null ) { return null; } @@ -55,7 +55,7 @@ public static IDictionary ToDictionary( object source, bool addE object ProcessValue( object value, bool emitDefaultValue ) { - if ( value != null && ( emitDefaultValue || !IsEqualToDefaultValue( value ) ) ) + if ( value is not null && ( emitDefaultValue || !IsEqualToDefaultValue( value ) ) ) { var type = value.GetType(); @@ -102,7 +102,7 @@ object ProcessValue( object value, bool emitDefaultValue ) propertyName = propertyName.ToCamelcase(); } - if ( value != null && ( emitDefaultValue || !IsEqualToDefaultValue( value ) ) ) + if ( value is not null && ( emitDefaultValue || !IsEqualToDefaultValue( value ) ) ) { dictionary.Add( propertyName, ProcessValue( value, emitDefaultValue ) ); } @@ -225,7 +225,7 @@ public static bool TryParseAndLimitLargeNumber( string value, out TValue // modified version of https://stackoverflow.com/a/11521834/833106 public static bool EnumTryParse( string input, Type conversionType, out TValue theEnum ) { - if ( input != null ) + if ( input is not null ) { foreach ( string en in Enum.GetNames( conversionType ) ) { @@ -259,7 +259,7 @@ public static bool EnumTryParse( string input, Type conversionType, out public static string FormatValue( float value, CultureInfo culture = null, int? decimals = null ) { - if ( decimals != null ) + if ( decimals is not null ) value = (float)Math.Round( (double)value, decimals.Value, MidpointRounding.AwayFromZero ); return value.ToString( culture ?? CultureInfo.CurrentCulture ); @@ -267,7 +267,7 @@ public static string FormatValue( float value, CultureInfo culture = null, int? public static string FormatValue( float? value, CultureInfo culture = null, int? decimals = null ) { - if ( value != null && decimals != null ) + if ( value is not null && decimals is not null ) value = (float)Math.Round( (double)value.Value, decimals.Value, MidpointRounding.AwayFromZero ); return value?.ToString( culture ?? CultureInfo.CurrentCulture ); @@ -275,7 +275,7 @@ public static string FormatValue( float? value, CultureInfo culture = null, int? public static string FormatValue( double value, CultureInfo culture = null, int? decimals = null ) { - if ( decimals != null ) + if ( decimals is not null ) value = Math.Round( value, decimals.Value, MidpointRounding.AwayFromZero ); return value.ToString( culture ?? CultureInfo.CurrentCulture ); @@ -283,7 +283,7 @@ public static string FormatValue( double value, CultureInfo culture = null, int? public static string FormatValue( double? value, CultureInfo culture = null, int? decimals = null ) { - if ( value != null && decimals != null ) + if ( value is not null && decimals is not null ) value = Math.Round( value.Value, decimals.Value, MidpointRounding.AwayFromZero ); return value?.ToString( culture ?? CultureInfo.CurrentCulture ); @@ -291,7 +291,7 @@ public static string FormatValue( double? value, CultureInfo culture = null, int public static string FormatValue( decimal value, CultureInfo culture = null, int? decimals = null ) { - if ( decimals != null ) + if ( decimals is not null ) value = Math.Round( value, decimals.Value, MidpointRounding.AwayFromZero ); return value.ToString( culture ?? CultureInfo.CurrentCulture ); @@ -299,7 +299,7 @@ public static string FormatValue( decimal value, CultureInfo culture = null, int public static string FormatValue( decimal? value, CultureInfo culture = null, int? decimals = null ) { - if ( value != null && decimals != null ) + if ( value is not null && decimals is not null ) value = Math.Round( value.Value, decimals.Value, MidpointRounding.AwayFromZero ); return value?.ToString( culture ?? CultureInfo.CurrentCulture ); @@ -377,7 +377,7 @@ private static bool IsEqualToDefaultValue( T argument ) { // deal with non-null nullables Type methodType = typeof( T ); - if ( Nullable.GetUnderlyingType( methodType ) != null ) + if ( Nullable.GetUnderlyingType( methodType ) is not null ) { return false; } diff --git a/Source/Blazorise/Utilities/CountdownTimer.cs b/Source/Blazorise/Utilities/CountdownTimer.cs index 501fc36f30..bdc07934ea 100644 --- a/Source/Blazorise/Utilities/CountdownTimer.cs +++ b/Source/Blazorise/Utilities/CountdownTimer.cs @@ -97,7 +97,7 @@ protected virtual void Dispose( bool disposing ) { if ( !Disposed ) { - if ( timer != null ) + if ( timer is not null ) { timer.Stop(); timer.Elapsed -= OnElapsed; diff --git a/Source/Blazorise/Utilities/DateTimeFormatConverter.cs b/Source/Blazorise/Utilities/DateTimeFormatConverter.cs index 29822e0875..077168cc3f 100644 --- a/Source/Blazorise/Utilities/DateTimeFormatConverter.cs +++ b/Source/Blazorise/Utilities/DateTimeFormatConverter.cs @@ -82,7 +82,7 @@ private IList ParseTokens( string format ) { if ( !char.IsLetter( c ) ) { - if ( tempToken != null ) + if ( tempToken is not null ) tokens.Add( tempToken ); tokens.Add( c.ToString() ); @@ -92,7 +92,7 @@ private IList ParseTokens( string format ) continue; } - if ( last == null || ( last != null && last == c ) ) + if ( last is null || ( last is not null && last == c ) ) { tempToken ??= string.Empty; diff --git a/Source/Blazorise/Utilities/EventArgsMapper.cs b/Source/Blazorise/Utilities/EventArgsMapper.cs index dad8d8b554..9a7ce44fae 100644 --- a/Source/Blazorise/Utilities/EventArgsMapper.cs +++ b/Source/Blazorise/Utilities/EventArgsMapper.cs @@ -8,7 +8,7 @@ internal static class EventArgsMapper { public static BLMouseEventArgs ToMouseEventArgs( MouseEventArgs e ) { - if ( e == null ) + if ( e is null ) return null; return new( ToMouseButton( e.Button ), diff --git a/Source/Blazorise/Utilities/ExpressionConverter.cs b/Source/Blazorise/Utilities/ExpressionConverter.cs index a08f91b5c5..08784a2b36 100644 --- a/Source/Blazorise/Utilities/ExpressionConverter.cs +++ b/Source/Blazorise/Utilities/ExpressionConverter.cs @@ -16,7 +16,7 @@ public static class ExpressionConverter /// The Templated String Literal public static string ToTemplatedStringLiteral( LambdaExpression expression ) { - if ( expression == null ) + if ( expression is null ) { throw new ArgumentNullException( nameof( expression ) ); } @@ -76,7 +76,7 @@ static void HandleExpression( List arguments, Expression expression, boo private static void HandleBinaryExpression( List arguments, BinaryExpression be, bool interpolateVariable ) { var @operator = GetOperator( be.NodeType, out var useStringFormat ); - if ( @operator != null ) + if ( @operator is not null ) { var beArgs = new List(); HandleExpression( beArgs, be.Left, false ); diff --git a/Source/Blazorise/Utilities/ValidationAttributeHelper.cs b/Source/Blazorise/Utilities/ValidationAttributeHelper.cs index e950a961a1..ff180f3add 100644 --- a/Source/Blazorise/Utilities/ValidationAttributeHelper.cs +++ b/Source/Blazorise/Utilities/ValidationAttributeHelper.cs @@ -63,7 +63,7 @@ public static void SetDefaultErrorMessage( ValidationAttribute validationAttribu /// Returns the formatted string. public static string SetErrorMessagePlaceholders( string errorMessage ) { - if ( errorMessage != null ) + if ( errorMessage is not null ) { errorMessage = errorMessage.Replace( PlaceholderPrefix, TempPlaceholderPrefix ); errorMessage = errorMessage.Replace( PlaceholderSuffix, TempPlaceholderSuffix ); @@ -79,7 +79,7 @@ public static string SetErrorMessagePlaceholders( string errorMessage ) /// Returns the formatted string. public static string RevertErrorMessagePlaceholders( string errorMessage ) { - if ( errorMessage != null ) + if ( errorMessage is not null ) { errorMessage = errorMessage.Replace( TempPlaceholderPrefix, PlaceholderPrefix ); errorMessage = errorMessage.Replace( TempPlaceholderSuffix, PlaceholderSuffix ); diff --git a/Source/Blazorise/Utilities/ValidationMessageLocalizerAttributeFinder.cs b/Source/Blazorise/Utilities/ValidationMessageLocalizerAttributeFinder.cs index ec4ad9aeea..9ccd230756 100644 --- a/Source/Blazorise/Utilities/ValidationMessageLocalizerAttributeFinder.cs +++ b/Source/Blazorise/Utilities/ValidationMessageLocalizerAttributeFinder.cs @@ -31,7 +31,7 @@ public class ValidationMessageLocalizerAttributeFinder : IValidationMessageLocal var firstList = first?.Split( ' ' ); var secondList = second?.Split( ' ' ); - if ( firstList != null && secondList != null && firstList.Length == secondList.Length ) + if ( firstList is not null && secondList is not null && firstList.Length == secondList.Length ) { for ( int i = 0; i < firstList.Length; ++i ) { diff --git a/Source/Blazorise/Utilities/ValueDebouncer.cs b/Source/Blazorise/Utilities/ValueDebouncer.cs index 26518cd1d0..8c29658bfc 100644 --- a/Source/Blazorise/Utilities/ValueDebouncer.cs +++ b/Source/Blazorise/Utilities/ValueDebouncer.cs @@ -102,7 +102,7 @@ public void Flush() /// public void Dispose() { - if ( timer != null ) + if ( timer is not null ) { timer.Stop(); timer.Elapsed -= OnElapsed;