Browse Source

Document ExifValue

pull/33/head
James Jackson-South 9 years ago
parent
commit
be133dfd2b
  1. 92
      src/ImageSharp/Profiles/Exif/ExifValue.cs

92
src/ImageSharp/Profiles/Exif/ExifValue.cs

@ -10,10 +10,13 @@ namespace ImageSharp
using System.Text; using System.Text;
/// <summary> /// <summary>
/// A value of the exif profile. /// Represent the value of the EXIF profile.
/// </summary> /// </summary>
public sealed class ExifValue : IEquatable<ExifValue> public sealed class ExifValue : IEquatable<ExifValue>
{ {
/// <summary>
/// The exif value.
/// </summary>
private object exifValue; private object exifValue;
/// <summary> /// <summary>
@ -41,6 +44,12 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="ExifValue"/> class.
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="dataType">The data type.</param>
/// <param name="isArray">Whether the value is an array.</param>
internal ExifValue(ExifTag tag, ExifDataType dataType, bool isArray) internal ExifValue(ExifTag tag, ExifDataType dataType, bool isArray)
{ {
this.Tag = tag; this.Tag = tag;
@ -53,6 +62,13 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="ExifValue"/> class.
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="dataType">The data type.</param>
/// <param name="value">The value.</param>
/// <param name="isArray">Whether the value is an array.</param>
internal ExifValue(ExifTag tag, ExifDataType dataType, object value, bool isArray) internal ExifValue(ExifTag tag, ExifDataType dataType, object value, bool isArray)
: this(tag, dataType, isArray) : this(tag, dataType, isArray)
{ {
@ -92,6 +108,7 @@ namespace ImageSharp
{ {
return this.exifValue; return this.exifValue;
} }
set set
{ {
this.CheckValue(value); this.CheckValue(value);
@ -99,6 +116,9 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Gets a value indicating whether the EXIF value has a value.
/// </summary>
internal bool HasValue internal bool HasValue
{ {
get get
@ -117,6 +137,9 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Gets the length of the EXIF value
/// </summary>
internal int Length internal int Length
{ {
get get
@ -132,6 +155,9 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Gets the number of components.
/// </summary>
internal int NumberOfComponents internal int NumberOfComponents
{ {
get get
@ -151,25 +177,37 @@ namespace ImageSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified ExifValue instances are considered equal. /// Compares two <see cref="ExifValue"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left">The first ExifValue to compare.</param> /// <param name="left">
/// <param name="right"> The second ExifValue to compare.</param> /// The <see cref="ExifValue"/> on the left side of the operand.
/// <returns>The <see cref="bool"/></returns> /// </param>
/// <param name="right">
/// The <see cref="ExifValue"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator ==(ExifValue left, ExifValue right) public static bool operator ==(ExifValue left, ExifValue right)
{ {
return Equals(left, right); return ExifValue.Equals(left, right);
} }
/// <summary> /// <summary>
/// Determines whether the specified ExifValue instances are not considered equal. /// Compares two <see cref="ExifValue"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left">The first ExifValue to compare.</param> /// <param name="left">
/// <param name="right"> The second ExifValue to compare.</param> /// The <see cref="ExifValue"/> on the left side of the operand.
/// <returns></returns> /// </param>
/// <param name="right">
/// The <see cref="ExifValue"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator !=(ExifValue left, ExifValue right) public static bool operator !=(ExifValue left, ExifValue right)
{ {
return !Equals(left, right); return !ExifValue.Equals(left, right);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -236,6 +274,17 @@ namespace ImageSharp
return sb.ToString(); return sb.ToString();
} }
/// <summary>
/// Creates a new <see cref="ExifValue"/>
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="value">The value.</param>
/// <returns>
/// The <see cref="ExifValue"/>.
/// </returns>
/// <exception cref="NotSupportedException">
/// Thrown if the tag is not supported.
/// </exception>
internal static ExifValue Create(ExifTag tag, object value) internal static ExifValue Create(ExifTag tag, object value)
{ {
Guard.IsFalse(tag == ExifTag.Unknown, nameof(tag), "Invalid Tag"); Guard.IsFalse(tag == ExifTag.Unknown, nameof(tag), "Invalid Tag");
@ -578,6 +627,15 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Returns an EXIF value with a numeric type for the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="type">The numeric type.</param>
/// <param name="isArray">Whether the value is an array.</param>
/// <returns>
/// The <see cref="ExifValue"/>.
/// </returns>
private static ExifValue CreateNumber(ExifTag tag, Type type, bool isArray) private static ExifValue CreateNumber(ExifTag tag, Type type, bool isArray)
{ {
if (type == null || type == typeof(ushort)) if (type == null || type == typeof(ushort))
@ -598,6 +656,13 @@ namespace ImageSharp
return new ExifValue(tag, ExifDataType.SignedLong, isArray); return new ExifValue(tag, ExifDataType.SignedLong, isArray);
} }
/// <summary>
/// Checks the value type of the given object.
/// </summary>
/// <param name="value">The value to check.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the object type is not supported.
/// </exception>
private void CheckValue(object value) private void CheckValue(object value)
{ {
if (value == null) if (value == null)
@ -663,6 +728,11 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Converts the object value of this instance to its equivalent string representation
/// </summary>
/// <param name="value">The value</param>
/// <returns>The <see cref="string"/></returns>
private string ToString(object value) private string ToString(object value)
{ {
string description = ExifTagDescriptionAttribute.GetDescription(this.Tag, value); string description = ExifTagDescriptionAttribute.GetDescription(this.Tag, value);

Loading…
Cancel
Save