Skip to content

Commit

Permalink
Remplaced != null by is not null in whole solution
Browse files Browse the repository at this point in the history
  • Loading branch information
abbaye committed Mar 3, 2021
1 parent 53ed7fb commit 14ba6fe
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void SaveAsMenu_Click(object sender, RoutedEventArgs e)
{
var fileDialog = new SaveFileDialog();

if (fileDialog.ShowDialog() != null)
if (fileDialog.ShowDialog() is not null)
HexEdit.SubmitChanges(fileDialog.FileName, true);
}

Expand Down
18 changes: 9 additions & 9 deletions Sources/WPFHexaEditor/BaseByte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public IByte Byte

UpdateTextRenderFromByte();

if (value != null)
if (value is not null)
_byte.del_ByteOnChange += OnByteChange;
}
}
Expand Down Expand Up @@ -299,9 +299,9 @@ public virtual void UpdateVisual()
{
var cbb = _parent.GetCustomBackgroundBlock(BytePositionInStream);

Description = cbb != null ? cbb.Description : "";
Description = cbb is not null ? cbb.Description : "";

Background = cbb != null ? cbb.Color : Brushes.Transparent;
Background = cbb is not null ? cbb.Color : Brushes.Transparent;

Foreground = _parent.GetColumnNumber(BytePositionInStream) % 2 == 0
? _parent.Foreground
Expand All @@ -320,8 +320,8 @@ public virtual void UpdateVisual()
/// </summary>
protected void UpdateAutoHighLiteSelectionByteVisual()
{
if (_parent.AllowAutoHighLightSelectionByte && _parent.SelectionByte != null &&
Byte != null && Byte.IsEqual(new byte[] { _parent.SelectionByte.Value }) && !IsSelected)
if (_parent.AllowAutoHighLightSelectionByte && _parent.SelectionByte is not null &&
Byte is not null && Byte.IsEqual(new byte[] { _parent.SelectionByte.Value }) && !IsSelected)
Background = _parent.AutoHighLiteSelectionByteBrush;
}

Expand Down Expand Up @@ -354,7 +354,7 @@ public virtual void Clear()
protected override void OnRender(DrawingContext dc)
{
//Draw background
if (Background != null)
if (Background is not null)
dc.DrawRectangle(Background, null, new Rect(0, 0, RenderSize.Width, RenderSize.Height));

//Draw text
Expand All @@ -371,7 +371,7 @@ protected override void OnRender(DrawingContext dc)

protected override void OnMouseEnter(MouseEventArgs e)
{
if (Byte != null && !IsSelected && !IsHighLight &&
if (Byte is not null && !IsSelected && !IsHighLight &&
Action != ByteAction.Modified &&
Action != ByteAction.Deleted &&
Action != ByteAction.Added)
Expand All @@ -391,13 +391,13 @@ protected override void OnMouseLeave(MouseEventArgs e)
{
var cbb = _parent.GetCustomBackgroundBlock(BytePositionInStream);

if (Byte != null && !IsSelected && !IsHighLight &&
if (Byte is not null && !IsSelected && !IsHighLight &&
Action != ByteAction.Modified &&
Action != ByteAction.Deleted &&
Action != ByteAction.Added)
Background = Brushes.Transparent;

if (cbb != null && !IsSelected && !IsHighLight &&
if (cbb is not null && !IsSelected && !IsHighLight &&
Action != ByteAction.Modified &&
Action != ByteAction.Deleted &&
Action != ByteAction.Added)
Expand Down
4 changes: 2 additions & 2 deletions Sources/WPFHexaEditor/Core/Bytes/ByteModified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ByteModified(byte? val, ByteAction action, long bytePositionInStream, lon
/// <summary>
/// Check if the object is valid and data can be used for action
/// </summary>
public bool IsValid => BytePositionInStream > -1 && Action != ByteAction.Nothing && Byte != null;
public bool IsValid => BytePositionInStream > -1 && Action != ByteAction.Nothing && Byte is not null;

/// <summary>
/// String representation of byte
Expand Down Expand Up @@ -91,7 +91,7 @@ public void Clear()
/// <summary>
/// Get if bytemodified is valid
/// </summary>
public static bool CheckIsValid(ByteModified byteModified) => byteModified != null && byteModified.IsValid;
public static bool CheckIsValid(ByteModified byteModified) => byteModified is not null && byteModified.IsValid;

#endregion Methods
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/WPFHexaEditor/Core/Bytes/ByteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public long Position
/// <summary>
/// Get if file is open
/// </summary>
public bool IsOpen => _stream != null;
public bool IsOpen => _stream is not null;

/// <summary>
/// Get if the provider is open
Expand Down Expand Up @@ -879,7 +879,7 @@ public void CopyToClipboard(CopyPasteMode copypastemode,
{
case CopyPasteMode.Byte:
throw new NotImplementedException();
case CopyPasteMode.TblString when tbl != null:
case CopyPasteMode.TblString when tbl is not null:
sBuffer = tbl.ToTblString(buffer);
da.SetText(sBuffer, TextDataFormat.Text);
break;
Expand Down Expand Up @@ -1363,17 +1363,17 @@ public bool CanCopy(long selectionStart, long selectionStop) =>
/// <summary>
/// Update a value indicating whether the current stream is supporting writing.
/// </summary>
public bool CanWrite => _stream != null && !ReadOnlyMode && _stream.CanWrite;
public bool CanWrite => _stream is not null && !ReadOnlyMode && _stream.CanWrite;

/// <summary>
/// Update a value indicating whether the current stream is supporting reading.
/// </summary>
public bool CanRead => _stream != null && _stream.CanRead;
public bool CanRead => _stream is not null && _stream.CanRead;

/// <summary>
/// Update a value indicating whether the current stream is supporting seeking.
/// </summary>
public bool CanSeek => _stream != null && _stream.CanSeek;
public bool CanSeek => _stream is not null && _stream.CanSeek;

#endregion Can do property...

Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/Core/Bytes/Byte_32bit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void ChangeByte(int index, byte value, ByteOrderType byteOrder = ByteOrde
break;
}

if (_newByte != null && _newByte.Count == 4)
if (_newByte is not null && _newByte.Count == 4)
{
for (int i = 0; i < 4; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/Core/Caret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Caret(Brush brush)
/// <summary>
/// Get is caret is running
/// </summary>
public bool IsEnable => _timer != null;
public bool IsEnable => _timer is not null;

/// <summary>
/// Propertie used when caret is blinking
Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/Core/CharacterTable/DTE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Dte(string entry, string value, DteType type)
/// </summary>
public string Entry
{
set => _entry = value != null
set => _entry = value is not null
? value.ToUpperInvariant()
: string.Empty;
get => _entry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

try
{
val = value != null && (bool)value;
val = value is not null && (bool)value;
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class ByteToHexStringConverter : IValueConverter
public bool Show0xTag { get; set; } = true;

public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value != null
value is not null
? (byte.TryParse(value.ToString(), out var byteValue)
? (byteValue >= 0
? (Show0xTag ? "0x" : "") + byteValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace WpfHexaEditor.Core.Converters
public sealed class LongToHexStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value != null
value is not null
? (long.TryParse(value.ToString(), out var longValue)
? (longValue > -1
? "0x" + longValue
Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/Dialog/FindReplaceWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void InitializeMStream(HexEditor hexeditor, byte[] findData = null)

var ms = new MemoryStream(1);

if (findData != null && findData.Length > 0)
if (findData is not null && findData.Length > 0)
foreach (byte b in findData)
ms.WriteByte(b);
else
Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/Dialog/FindWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void InitializeMStream(byte[] findData = null)

_findMs = new MemoryStream(1);

if (findData != null && findData.Length > 0)
if (findData is not null && findData.Length > 0)
foreach (byte b in findData)
_findMs.WriteByte(b);
else
Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/FastTextLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public Point RenderPoint
protected override void OnRender(DrawingContext dc)
{
//Draw background
if (Background != null)
if (Background is not null)
dc.DrawRectangle(Background, null, new Rect(0, 0, RenderSize.Width, RenderSize.Height));

//Draw text
Expand Down
2 changes: 1 addition & 1 deletion Sources/WPFHexaEditor/HexByte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public HexByte(HexEditor parent) : base(parent)
/// Update the render of text derived bytecontrol from byte property
/// </summary>
public override void UpdateTextRenderFromByte() =>
Text = Byte != null
Text = Byte is not null
? Byte.GetText(_parent.DataStringVisual, _parent.DataStringState, _parent.ByteOrder)
: string.Empty;

Expand Down
19 changes: 10 additions & 9 deletions Sources/WPFHexaEditor/HexEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ private static void Stream_PropertyChanged(DependencyObject d, DependencyPropert

ctrl.CloseProvider();

if (e.NewValue != null)
if (e.NewValue is not null)
{
ctrl.OpenStream((Stream)e.NewValue);
ctrl.IsFileOrStreamLoaded = true;
Expand Down Expand Up @@ -2909,7 +2909,7 @@ private void UpdateViewers(bool controlResize)

if (controlResize)
{
if (_viewBuffer != null)
if (_viewBuffer is not null)
{
BuildDataLines(MaxVisibleLine, MaxLinePreloaded < MaxVisibleLine);

Expand Down Expand Up @@ -3891,7 +3891,7 @@ private void UpdateStatusBar(bool updateFilelength = true)

#region Byte count of selectionStart

if (AllowByteCount && _bytecount != null && SelectionStart > -1)
if (AllowByteCount && _bytecount is not null && SelectionStart > -1)
{
ByteCountPanel.Visibility = Visibility.Visible;

Expand Down Expand Up @@ -4181,7 +4181,7 @@ private void Control_RightClick(object sender, EventArgs e)

}

if (_tblCharacterTable != null)
if (_tblCharacterTable is not null)
CopyTblcMenu.IsEnabled = true;
}

Expand Down Expand Up @@ -4520,6 +4520,7 @@ protected virtual void Dispose(bool disposing)
_provider?.Dispose();
_tblCharacterTable?.Dispose();
_viewBuffer = null;
_viewBufferBytePosition = null;
_markedPositionList = null;
}

Expand Down Expand Up @@ -4771,7 +4772,7 @@ private void Control_Drop(object sender, DragEventArgs e)
#region Text Dropping

var textDrop = e.Data.GetData(DataFormats.Text);
if (textDrop != null && AllowTextDrop)
if (textDrop is not null && AllowTextDrop)
{
var textDropped = textDrop as string;

Expand Down Expand Up @@ -4805,7 +4806,7 @@ private void Control_Drop(object sender, DragEventArgs e)
#region File dropping (Only open first selected file catched in GetData)

var fileDrop = e.Data.GetData(DataFormats.FileDrop);
if (fileDrop != null && AllowFileDrop)
if (fileDrop is not null && AllowFileDrop)
{
var filename = fileDrop as string[];

Expand Down Expand Up @@ -4894,7 +4895,7 @@ private XDocument GetState()
new XAttribute(nameof(ReadOnlyMode), ReadOnlyMode),
new XElement("ByteModifieds", new XAttribute("Count", _provider.GetByteModifieds(ByteAction.All).Count)),
new XElement("BookMarks", new XAttribute("Count", BookMarks.Count())),
new XElement("TBL", new XAttribute("Loaded", _tblCharacterTable != null)),
new XElement("TBL", new XAttribute("Loaded", _tblCharacterTable is not null)),
new XElement("HighLights", new XAttribute("Count", _markedPositionList.Count))));

#region Create ByteModifieds tag
Expand Down Expand Up @@ -4931,7 +4932,7 @@ private XDocument GetState()

#region Create TBL tag

if (_tblCharacterTable != null)
if (_tblCharacterTable is not null)
doc.Element("WpfHexEditor")
.Element("TBL")
.Add(new XElement("TBLData",
Expand Down Expand Up @@ -5361,7 +5362,7 @@ public bool AllowZoom
/// </summary>
private void InitialiseZoom()
{
if (_scaler != null) return;
if (_scaler is not null) return;

_scaler = new ScaleTransform(ZoomScale, ZoomScale);

Expand Down
10 changes: 5 additions & 5 deletions Sources/WPFHexaEditor/StringByte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public bool TblShowMte
/// </summary>
public override void UpdateTextRenderFromByte()
{
if (Byte != null)
if (Byte is not null)
{
var dteType = DteType.Invalid;

Expand All @@ -95,7 +95,7 @@ public override void UpdateTextRenderFromByte()
Text = ByteConverters.ByteToChar(Byte.Byte[0]).ToString();
break;
case CharacterTableType.TblFile:
if (TblCharacterTable != null)
if (TblCharacterTable is not null)
{
ReadOnlyMode = !TblCharacterTable.AllowEdit;

Expand Down Expand Up @@ -162,9 +162,9 @@ public override void UpdateVisual()
#region TBL COLORING
var cbb = _parent.GetCustomBackgroundBlock(BytePositionInStream);

Description = cbb != null ? cbb.Description : "";
Description = cbb is not null ? cbb.Description : "";

Background = cbb != null ? cbb.Color : Brushes.Transparent;
Background = cbb is not null ? cbb.Color : Brushes.Transparent;
FontWeight = _parent.FontWeight;
Foreground = _parent.Foreground;

Expand Down Expand Up @@ -198,7 +198,7 @@ protected override void OnRender(DrawingContext dc)

#region Draw control
//Draw background
if (Background != null)
if (Background is not null)
dc.DrawRectangle(Background, null, new Rect(0, 0, RenderSize.Width, RenderSize.Height));

//Prevent drawing wrong graph
Expand Down

0 comments on commit 14ba6fe

Please sign in to comment.