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;
/// <summary>
/// A value of the exif profile.
/// Represent the value of the EXIF profile.
/// </summary>
public sealed class ExifValue : IEquatable<ExifValue>
{
/// <summary>
/// The exif value.
/// </summary>
private object exifValue;
/// <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)
{
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)
: this(tag, dataType, isArray)
{
@ -92,6 +108,7 @@ namespace ImageSharp
{
return this.exifValue;
}
set
{
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
{
get
@ -117,6 +137,9 @@ namespace ImageSharp
}
}
/// <summary>
/// Gets the length of the EXIF value
/// </summary>
internal int Length
{
get
@ -132,6 +155,9 @@ namespace ImageSharp
}
}
/// <summary>
/// Gets the number of components.
/// </summary>
internal int NumberOfComponents
{
get
@ -151,25 +177,37 @@ namespace ImageSharp
}
/// <summary>
/// Determines whether the specified ExifValue instances are considered equal.
/// Compares two <see cref="ExifValue"/> objects for equality.
/// </summary>
/// <param name="left">The first ExifValue to compare.</param>
/// <param name="right"> The second ExifValue to compare.</param>
/// <returns>The <see cref="bool"/></returns>
/// <param name="left">
/// The <see cref="ExifValue"/> on the left side of the operand.
/// </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)
{
return Equals(left, right);
return ExifValue.Equals(left, right);
}
/// <summary>
/// Determines whether the specified ExifValue instances are not considered equal.
/// Compares two <see cref="ExifValue"/> objects for equality.
/// </summary>
/// <param name="left">The first ExifValue to compare.</param>
/// <param name="right"> The second ExifValue to compare.</param>
/// <returns></returns>
/// <param name="left">
/// The <see cref="ExifValue"/> on the left side of the operand.
/// </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)
{
return !Equals(left, right);
return !ExifValue.Equals(left, right);
}
/// <inheritdoc />
@ -236,6 +274,17 @@ namespace ImageSharp
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)
{
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)
{
if (type == null || type == typeof(ushort))
@ -598,6 +656,13 @@ namespace ImageSharp
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)
{
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)
{
string description = ExifTagDescriptionAttribute.GetDescription(this.Tag, value);

Loading…
Cancel
Save