Browse Source

Use pattern matching

af/merge-core
Jason Nelson 8 years ago
parent
commit
2280d40bfe
  1. 4
      src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
  2. 7
      src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
  3. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  4. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
  5. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
  6. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
  7. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
  8. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  9. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  10. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  11. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  12. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
  13. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
  14. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
  15. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  16. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
  17. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
  18. 7
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
  19. 9
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
  20. 3
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
  21. 2
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

4
src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs

@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private IccTagDataEntry[] ReadTagData(IccDataReader reader) private IccTagDataEntry[] ReadTagData(IccDataReader reader)
{ {
IccTagTableEntry[] tagTable = this.ReadTagTable(reader); IccTagTableEntry[] tagTable = this.ReadTagTable(reader);
IccTagDataEntry[] entries = new IccTagDataEntry[tagTable.Length]; var entries = new IccTagDataEntry[tagTable.Length];
var store = new Dictionary<uint, IccTagDataEntry>(); var store = new Dictionary<uint, IccTagDataEntry>();
for (int i = 0; i < tagTable.Length; i++) for (int i = 0; i < tagTable.Length; i++)
{ {
@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
reader.SetIndex(128); // An ICC header is 128 bytes long reader.SetIndex(128); // An ICC header is 128 bytes long
uint tagCount = reader.ReadUInt32(); uint tagCount = reader.ReadUInt32();
IccTagTableEntry[] table = new IccTagTableEntry[tagCount]; var table = new IccTagTableEntry[tagCount];
for (int i = 0; i < tagCount; i++) for (int i = 0; i < tagCount; i++)
{ {

7
src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -54,8 +54,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
var entry = obj as IccTagDataEntry; return obj is IccTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -70,7 +69,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public virtual bool Equals(IccTagDataEntry other) public virtual bool Equals(IccTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs

@ -82,8 +82,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccChromaticityTagDataEntry; return other is IccChromaticityTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs

@ -88,14 +88,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccCrdInfoTagDataEntry; return other is IccCrdInfoTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccCrdInfoTagDataEntry other) public bool Equals(IccCrdInfoTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs

@ -67,8 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccDataTagDataEntry; return other is IccDataTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs

@ -38,8 +38,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccDateTimeTagDataEntry; return other is IccDateTimeTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>

7
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccFix16ArrayTagDataEntry; return other is IccFix16ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccFix16ArrayTagDataEntry other) public bool Equals(IccFix16ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

7
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs

@ -111,14 +111,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLut16TagDataEntry; return other is IccLut16TagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut16TagDataEntry other) public bool Equals(IccLut16TagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -138,7 +137,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

7
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs

@ -114,14 +114,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLut8TagDataEntry; return other is IccLut8TagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLut8TagDataEntry other) public bool Equals(IccLut8TagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -141,7 +140,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs

@ -147,14 +147,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLutAToBTagDataEntry; return other is IccLutAToBTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLutAToBTagDataEntry other) public bool Equals(IccLutAToBTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

9
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs

@ -147,14 +147,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccLutBToATagDataEntry; return other is IccLutBToATagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccLutBToATagDataEntry other) public bool Equals(IccLutBToATagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -178,7 +177,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -188,7 +187,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccLutBToATagDataEntry && this.Equals((IccLutBToATagDataEntry)obj); return obj is IccLutBToATagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>

7
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs

@ -73,18 +73,17 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccMeasurementTagDataEntry; return other is IccMeasurementTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMeasurementTagDataEntry other) public bool Equals(IccMeasurementTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
if (ReferenceEquals(this, other)) if (ReferenceEquals(this, other))
{ {
return true; return true;

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs

@ -41,14 +41,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccMultiLocalizedUnicodeTagDataEntry; return other is IccMultiLocalizedUnicodeTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other) public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

7
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs

@ -42,8 +42,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccProfileSequenceDescTagDataEntry; return other is IccProfileSequenceDescTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -65,7 +64,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -75,7 +74,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccProfileSequenceDescTagDataEntry && this.Equals((IccProfileSequenceDescTagDataEntry)obj); return obj is IccProfileSequenceDescTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc /> /// <inheritdoc />

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs

@ -133,8 +133,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccTextDescriptionTagDataEntry; return other is IccTextDescriptionTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -161,7 +160,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc /> /// <inheritdoc />
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt32ArrayTagDataEntry; return other is IccUInt32ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt32ArrayTagDataEntry other) public bool Equals(IccUInt32ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt64ArrayTagDataEntry; return other is IccUInt64ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt64ArrayTagDataEntry other) public bool Equals(IccUInt64ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

7
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUInt8ArrayTagDataEntry; return other is IccUInt8ArrayTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUInt8ArrayTagDataEntry other) public bool Equals(IccUInt8ArrayTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUInt8ArrayTagDataEntry && this.Equals((IccUInt8ArrayTagDataEntry)obj); return obj is IccUInt8ArrayTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>

9
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs

@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccUnknownTagDataEntry; return other is IccUnknownTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccUnknownTagDataEntry other) public bool Equals(IccUnknownTagDataEntry other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }
@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) if (obj == null)
{ {
return false; return false;
} }
@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true; return true;
} }
return obj is IccUnknownTagDataEntry && this.Equals((IccUnknownTagDataEntry)obj); return obj is IccUnknownTagDataEntry other && this.Equals(other);
} }
/// <inheritdoc/> /// <inheritdoc/>

3
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs

@ -55,8 +55,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)
{ {
var entry = other as IccViewingConditionsTagDataEntry; return other is IccViewingConditionsTagDataEntry entry && this.Equals(entry);
return entry != null && this.Equals(entry);
} }
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccProfileDescription other) public bool Equals(IccProfileDescription other)
{ {
if (ReferenceEquals(null, other)) if (other == null)
{ {
return false; return false;
} }

Loading…
Cancel
Save