@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 a1bf352179..899822b79d 100644
--- a/Source/Blazorise/Components/TimePicker/TimePicker.razor.cs
+++ b/Source/Blazorise/Components/TimePicker/TimePicker.razor.cs
@@ -74,7 +74,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/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/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
public void Dispose()
{
- if ( timer != null )
+ if ( timer is not null )
{
timer.Stop();
timer.Elapsed -= OnElapsed;