// --------------------------------------------------------------------------------------------------------------------
//
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
//
//
// Stores meta information about a image, like the name of the author,
// the copyright information, the date, where the image was created
// or some other information.
//
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
using System;
///
/// Stores meta information about a image, like the name of the author,
/// the copyright information, the date, where the image was created
/// or some other information.
///
public struct ImageProperty : IEquatable
{
///
/// Gets the name of this indicating which kind of
/// information this property stores.
///
///
/// Typical properties are the author, copyright
/// information or other meta information.
///
public string Name { get; }
///
/// The value of this .
///
public string Value { get; }
///
/// Initializes a new instance of the struct.
///
///
/// The name of the property.
///
///
/// The value of the property.
///
public ImageProperty(string name, string value)
{
this.Name = name;
this.Value = value;
}
///
/// Compares two objects. The result specifies whether the values
/// of the or properties of the two
/// objects are equal.
///
///
/// The on the left side of the operand.
///
///
/// The on the right side of the operand.
///
///
/// True if the current left is equal to the parameter; otherwise, false.
///
public static bool operator ==(ImageProperty left, ImageProperty right)
{
return left.Equals(right);
}
///
/// Compares two objects. The result specifies whether the values
/// of the or properties of the two
/// objects are unequal.
///
///
/// The on the left side of the operand.
///
///
/// The on the right side of the operand.
///
///
/// True if the current left is unequal to the parameter; otherwise, false.
///
public static bool operator !=(ImageProperty left, ImageProperty right)
{
return !left.Equals(right);
}
///
/// Indicates whether this instance and a specified object are equal.
///
///
/// The object to compare with the current instance.
///
///
/// true if and this instance are the same type and represent the
/// same value; otherwise, false.
///
public override bool Equals(object obj)
{
if (!(obj is ImageProperty))
{
return false;
}
ImageProperty other = (ImageProperty)obj;
return other.Name == this.Name && other.Value == this.Value;
}
///
/// Returns the hash code for this instance.
///
///
/// A 32-bit signed integer that is the hash code for this instance.
///
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Name.GetHashCode();
hashCode = (hashCode * 397) ^ this.Value.GetHashCode();
return hashCode;
}
}
///
/// Returns the fully qualified type name of this instance.
///
///
/// A containing a fully qualified type name.
///
public override string ToString()
{
return $"ImageProperty [ Name={this.Name}, Value={this.Value} ]";
}
///
/// Indicates whether the current object is equal to another object of the same type.
///
///
/// True if the current object is equal to the parameter; otherwise, false.
///
/// An object to compare with this object.
public bool Equals(ImageProperty other)
{
return this.Name.Equals(other.Name) && this.Value.Equals(other.Value);
}
}
}