mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-01-23 08:16:25 +00:00
Add some simplifications for argument null exception handling
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Fuse
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
public class Lines
|
||||
@@ -24,6 +25,7 @@ namespace Fuse
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
Debug.Assert(line != null);
|
||||
var ignored = line.StartsWith(";", StringComparison.OrdinalIgnoreCase);
|
||||
if (!ignored)
|
||||
{
|
||||
|
||||
@@ -17,21 +17,14 @@ namespace Fuse
|
||||
|
||||
public void Parse(string line)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
}
|
||||
|
||||
ArgumentNullException.ThrowIfNullOrWhiteSpace(line);
|
||||
var tokens = line.Split(new char[] { ' ', '\t' });
|
||||
this.Parse(tokens);
|
||||
}
|
||||
|
||||
public void Parse(string[] tokens)
|
||||
{
|
||||
if (tokens == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tokens));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(tokens);
|
||||
|
||||
this.Address = Convert.ToUInt16(tokens[0], 16);
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ namespace Fuse
|
||||
|
||||
public bool TryParse(Lines lines)
|
||||
{
|
||||
if (lines == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(lines));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(lines);
|
||||
|
||||
while (!lines.EndOfFile && string.IsNullOrWhiteSpace(this.Description))
|
||||
{
|
||||
|
||||
@@ -19,10 +19,7 @@ namespace Fuse
|
||||
|
||||
public bool TryParse(Lines lines)
|
||||
{
|
||||
if (lines == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(lines));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(lines);
|
||||
|
||||
while (!lines.EndOfFile && string.IsNullOrEmpty(this.Description))
|
||||
{
|
||||
|
||||
@@ -37,10 +37,7 @@ namespace Fuse
|
||||
|
||||
public bool TryParse(Lines lines)
|
||||
{
|
||||
if (lines == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(lines));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(lines);
|
||||
|
||||
var returned = this.TryParseLine(lines.ReadLine());
|
||||
if (!returned)
|
||||
|
||||
Reference in New Issue
Block a user