Browse Source

Make IccProfileDescription a struct

pull/541/head
Jason Nelson 8 years ago
parent
commit
df3248ddf0
  1. 5
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
  2. 50
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

5
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs

@ -686,8 +686,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int WriteProfileSequenceDescTagDataEntry(IccProfileSequenceDescTagDataEntry value) public int WriteProfileSequenceDescTagDataEntry(IccProfileSequenceDescTagDataEntry value)
{ {
int count = this.WriteUInt32((uint)value.Descriptions.Length); int count = this.WriteUInt32((uint)value.Descriptions.Length);
foreach (IccProfileDescription desc in value.Descriptions)
for (int i = 0; i < value.Descriptions.Length; i++)
{ {
ref IccProfileDescription desc = ref value.Descriptions[i];
count += this.WriteProfileDescription(desc); count += this.WriteProfileDescription(desc);
} }

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

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <summary> /// <summary>
/// ICC Profile description /// ICC Profile description
/// </summary> /// </summary>
internal sealed class IccProfileDescription : IEquatable<IccProfileDescription> internal readonly struct IccProfileDescription : IEquatable<IccProfileDescription>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccProfileDescription"/> class. /// Initializes a new instance of the <see cref="IccProfileDescription"/> class.
@ -40,69 +40,47 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
/// <summary> /// <summary>
/// Gets the device manufacturer /// Gets the device manufacturer.
/// </summary> /// </summary>
public uint DeviceManufacturer { get; } public uint DeviceManufacturer { get; }
/// <summary> /// <summary>
/// Gets the device model /// Gets the device model.
/// </summary> /// </summary>
public uint DeviceModel { get; } public uint DeviceModel { get; }
/// <summary> /// <summary>
/// Gets the device attributes /// Gets the device attributes.
/// </summary> /// </summary>
public IccDeviceAttribute DeviceAttributes { get; } public IccDeviceAttribute DeviceAttributes { get; }
/// <summary> /// <summary>
/// Gets the technology information /// Gets the technology information.
/// </summary> /// </summary>
public IccProfileTag TechnologyInformation { get; } public IccProfileTag TechnologyInformation { get; }
/// <summary> /// <summary>
/// Gets the device manufacturer info /// Gets the device manufacturer info.
/// </summary> /// </summary>
public IccLocalizedString[] DeviceManufacturerInfo { get; } public IccLocalizedString[] DeviceManufacturerInfo { get; }
/// <summary> /// <summary>
/// Gets the device model info /// Gets the device model info.
/// </summary> /// </summary>
public IccLocalizedString[] DeviceModelInfo { get; } public IccLocalizedString[] DeviceModelInfo { get; }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(IccProfileDescription other) public bool Equals(IccProfileDescription other) =>
{ this.DeviceManufacturer == other.DeviceManufacturer &&
if (other == null) this.DeviceModel == other.DeviceModel &&
{ this.DeviceAttributes == other.DeviceAttributes &&
return false; this.TechnologyInformation == other.TechnologyInformation &&
} this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo) &&
this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
if (ReferenceEquals(this, other))
{
return true;
}
return this.DeviceManufacturer == other.DeviceManufacturer
&& this.DeviceModel == other.DeviceModel
&& this.DeviceAttributes == other.DeviceAttributes
&& this.TechnologyInformation == other.TechnologyInformation
&& this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo)
&& this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
}
/// <inheritdoc /> /// <inheritdoc />
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj == null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileDescription other && this.Equals(other); return obj is IccProfileDescription other && this.Equals(other);
} }

Loading…
Cancel
Save