@@ -94,5 +94,44 @@ namespace Discord | |||
/// </summary> | |||
public override string ToString() => Title; | |||
private string DebuggerDisplay => $"{Title} ({Type})"; | |||
public static bool operator ==(Embed left, Embed right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(Embed left, Embed right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="Embed"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="Embed"/>, <see cref="Equals(Embed)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="Embed"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is Embed embed && Equals(embed); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="Embed"/> is equal to the current <see cref="Embed"/> | |||
/// </summary> | |||
/// <param name="embed">The <see cref="Embed"/> to compare with the current <see cref="Embed"/></param> | |||
/// <returns></returns> | |||
public bool Equals(Embed embed) | |||
=> GetHashCode() == embed?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
{ | |||
unchecked | |||
{ | |||
var hash = 17; | |||
hash = hash * 23 + (Type, Title, Description, Timestamp, Color, Image, Video, Author, Footer, Provider, Thumbnail).GetHashCode(); | |||
foreach(var field in Fields) | |||
hash = hash * 23 + field.GetHashCode(); | |||
return hash; | |||
} | |||
} | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -41,5 +42,35 @@ namespace Discord | |||
/// | |||
/// </returns> | |||
public override string ToString() => Name; | |||
public static bool operator ==(EmbedAuthor? left, EmbedAuthor? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedAuthor? left, EmbedAuthor? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedAuthor"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedAuthor"/>, <see cref="Equals(EmbedAuthor?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedAuthor"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedAuthor embedAuthor && Equals(embedAuthor); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedAuthor"/> is equal to the current <see cref="EmbedAuthor"/> | |||
/// </summary> | |||
/// <param name="embedAuthor">The <see cref="EmbedAuthor"/> to compare with the current <see cref="EmbedAuthor"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedAuthor? embedAuthor) | |||
=> GetHashCode() == embedAuthor?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Name, Url, IconUrl).GetHashCode(); | |||
} | |||
} |
@@ -481,6 +481,55 @@ namespace Discord | |||
return new Embed(EmbedType.Rich, Title, Description, Url, Timestamp, Color, _image, null, Author?.Build(), Footer?.Build(), null, _thumbnail, fields.ToImmutable()); | |||
} | |||
public static bool operator ==(EmbedBuilder left, EmbedBuilder right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedBuilder left, EmbedBuilder right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedBuilder"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedBuilder"/>, <see cref="Equals(EmbedBuilder)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedBuilder"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedBuilder embedBuilder && Equals(embedBuilder); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedBuilder"/> is equal to the current <see cref="EmbedBuilder"/> | |||
/// </summary> | |||
/// <param name="embedBuilder">The <see cref="EmbedBuilder"/> to compare with the current <see cref="EmbedBuilder"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedBuilder embedBuilder) | |||
{ | |||
if (embedBuilder is null) | |||
return false; | |||
if (Fields.Count != embedBuilder.Fields.Count) | |||
return false; | |||
for (var i = 0; i < _fields.Count; i++) | |||
if (_fields[i] != embedBuilder._fields[i]) | |||
return false; | |||
return _title == embedBuilder?._title | |||
&& _description == embedBuilder?._description | |||
&& _image == embedBuilder?._image | |||
&& _thumbnail == embedBuilder?._thumbnail | |||
&& Timestamp == embedBuilder?.Timestamp | |||
&& Color == embedBuilder?.Color | |||
&& Author == embedBuilder?.Author | |||
&& Footer == embedBuilder?.Footer | |||
&& Url == embedBuilder?.Url; | |||
} | |||
/// <inheritdoc /> | |||
public override int GetHashCode() => base.GetHashCode(); | |||
} | |||
/// <summary> | |||
@@ -597,6 +646,37 @@ namespace Discord | |||
/// </exception> | |||
public EmbedField Build() | |||
=> new EmbedField(Name, Value.ToString(), IsInline); | |||
public static bool operator ==(EmbedFieldBuilder left, EmbedFieldBuilder right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedFieldBuilder left, EmbedFieldBuilder right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedFieldBuilder"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedFieldBuilder"/>, <see cref="Equals(EmbedFieldBuilder)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedFieldBuilder"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedFieldBuilder embedFieldBuilder && Equals(embedFieldBuilder); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedFieldBuilder"/> is equal to the current <see cref="EmbedFieldBuilder"/> | |||
/// </summary> | |||
/// <param name="embedFieldBuilder">The <see cref="EmbedFieldBuilder"/> to compare with the current <see cref="EmbedFieldBuilder"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedFieldBuilder embedFieldBuilder) | |||
=> _name == embedFieldBuilder?._name | |||
&& _value == embedFieldBuilder?._value | |||
&& IsInline == embedFieldBuilder?.IsInline; | |||
/// <inheritdoc /> | |||
public override int GetHashCode() => base.GetHashCode(); | |||
} | |||
/// <summary> | |||
@@ -697,6 +777,37 @@ namespace Discord | |||
/// </returns> | |||
public EmbedAuthor Build() | |||
=> new EmbedAuthor(Name, Url, IconUrl, null); | |||
public static bool operator ==(EmbedAuthorBuilder left, EmbedAuthorBuilder right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedAuthorBuilder left, EmbedAuthorBuilder right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedAuthorBuilder"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedAuthorBuilder"/>, <see cref="Equals(EmbedAuthorBuilder)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedAuthorBuilder"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedAuthorBuilder embedAuthorBuilder && Equals(embedAuthorBuilder); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedAuthorBuilder"/> is equals to the current <see cref="EmbedAuthorBuilder"/> | |||
/// </summary> | |||
/// <param name="embedAuthorBuilder">The <see cref="EmbedAuthorBuilder"/> to compare with the current <see cref="EmbedAuthorBuilder"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedAuthorBuilder embedAuthorBuilder) | |||
=> _name == embedAuthorBuilder?._name | |||
&& Url == embedAuthorBuilder?.Url | |||
&& IconUrl == embedAuthorBuilder?.IconUrl; | |||
/// <inheritdoc /> | |||
public override int GetHashCode() => base.GetHashCode(); | |||
} | |||
/// <summary> | |||
@@ -777,5 +888,35 @@ namespace Discord | |||
/// </returns> | |||
public EmbedFooter Build() | |||
=> new EmbedFooter(Text, IconUrl, null); | |||
public static bool operator ==(EmbedFooterBuilder left, EmbedFooterBuilder right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedFooterBuilder left, EmbedFooterBuilder right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedFooterBuilder"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedFooterBuilder"/>, <see cref="Equals(EmbedFooterBuilder)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedFooterBuilder"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedFooterBuilder embedFooterBuilder && Equals(embedFooterBuilder); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedFooterBuilder"/> is equal to the current <see cref="EmbedFooterBuilder"/> | |||
/// </summary> | |||
/// <param name="embedFooterBuilder">The <see cref="EmbedFooterBuilder"/> to compare with the current <see cref="EmbedFooterBuilder"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedFooterBuilder embedFooterBuilder) | |||
=> _text == embedFooterBuilder?._text | |||
&& IconUrl == embedFooterBuilder?.IconUrl; | |||
/// <inheritdoc /> | |||
public override int GetHashCode() => base.GetHashCode(); | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -36,5 +37,35 @@ namespace Discord | |||
/// A string that resolves to <see cref="EmbedField.Name"/>. | |||
/// </returns> | |||
public override string ToString() => Name; | |||
public static bool operator ==(EmbedField? left, EmbedField? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedField? left, EmbedField? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedField"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedField"/>, <see cref="Equals(EmbedField?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current object</param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedField embedField && Equals(embedField); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedField"/> is equal to the current <see cref="EmbedField"/> | |||
/// </summary> | |||
/// <param name="embedField"></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedField? embedField) | |||
=> GetHashCode() == embedField?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Name, Value, Inline).GetHashCode(); | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -43,5 +44,35 @@ namespace Discord | |||
/// A string that resolves to <see cref="Discord.EmbedFooter.Text"/>. | |||
/// </returns> | |||
public override string ToString() => Text; | |||
public static bool operator ==(EmbedFooter? left, EmbedFooter? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedFooter? left, EmbedFooter? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedFooter"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedFooter"/>, <see cref="Equals(EmbedFooter?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedFooter"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedFooter embedFooter && Equals(embedFooter); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedFooter"/> is equal to the current <see cref="EmbedFooter"/> | |||
/// </summary> | |||
/// <param name="embedFooter">The <see cref="EmbedFooter"/> to compare with the current <see cref="EmbedFooter"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedFooter? embedFooter) | |||
=> GetHashCode() == embedFooter?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Text, IconUrl, ProxyUrl).GetHashCode(); | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -53,5 +54,35 @@ namespace Discord | |||
/// A string that resolves to <see cref="Discord.EmbedImage.Url"/> . | |||
/// </returns> | |||
public override string ToString() => Url; | |||
public static bool operator ==(EmbedImage? left, EmbedImage? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedImage? left, EmbedImage? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedImage"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedImage"/>, <see cref="Equals(EmbedImage?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedImage"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedImage embedImage && Equals(embedImage); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedImage"/> is equal to the current <see cref="EmbedImage"/> | |||
/// </summary> | |||
/// <param name="embedImage">The <see cref="EmbedImage"/> to compare with the current <see cref="EmbedImage"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedImage? embedImage) | |||
=> GetHashCode() == embedImage?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Height, Width, Url, ProxyUrl).GetHashCode(); | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -35,5 +36,35 @@ namespace Discord | |||
/// A string that resolves to <see cref="Discord.EmbedProvider.Name" />. | |||
/// </returns> | |||
public override string ToString() => Name; | |||
public static bool operator ==(EmbedProvider? left, EmbedProvider? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedProvider? left, EmbedProvider? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedProvider"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedProvider"/>, <see cref="Equals(EmbedProvider?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedProvider"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedProvider embedProvider && Equals(embedProvider); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedProvider"/> is equal to the current <see cref="EmbedProvider"/> | |||
/// </summary> | |||
/// <param name="embedProvider">The <see cref="EmbedProvider"/> to compare with the current <see cref="EmbedProvider"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedProvider? embedProvider) | |||
=> GetHashCode() == embedProvider?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Name, Url).GetHashCode(); | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -53,5 +54,35 @@ namespace Discord | |||
/// A string that resolves to <see cref="Discord.EmbedThumbnail.Url" />. | |||
/// </returns> | |||
public override string ToString() => Url; | |||
public static bool operator ==(EmbedThumbnail? left, EmbedThumbnail? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedThumbnail? left, EmbedThumbnail? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedThumbnail"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedThumbnail"/>, <see cref="Equals(EmbedThumbnail?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedThumbnail"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedThumbnail embedThumbnail && Equals(embedThumbnail); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedThumbnail"/> is equal to the current <see cref="EmbedThumbnail"/> | |||
/// </summary> | |||
/// <param name="embedThumbnail">The <see cref="EmbedThumbnail"/> to compare with the current <see cref="EmbedThumbnail"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedThumbnail? embedThumbnail) | |||
=> GetHashCode() == embedThumbnail?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Width, Height, Url, ProxyUrl).GetHashCode(); | |||
} | |||
} |
@@ -1,3 +1,4 @@ | |||
using System; | |||
using System.Diagnostics; | |||
namespace Discord | |||
@@ -47,5 +48,35 @@ namespace Discord | |||
/// A string that resolves to <see cref="Url"/>. | |||
/// </returns> | |||
public override string ToString() => Url; | |||
public static bool operator ==(EmbedVideo? left, EmbedVideo? right) | |||
=> left is null ? right is null | |||
: left.Equals(right); | |||
public static bool operator !=(EmbedVideo? left, EmbedVideo? right) | |||
=> !(left == right); | |||
/// <summary> | |||
/// Determines whether the specified object is equal to the current <see cref="EmbedVideo"/>. | |||
/// </summary> | |||
/// <remarks> | |||
/// If the object passes is an <see cref="EmbedVideo"/>, <see cref="Equals(EmbedVideo?)"/> will be called to compare the 2 instances | |||
/// </remarks> | |||
/// <param name="obj">The object to compare with the current <see cref="EmbedVideo"/></param> | |||
/// <returns></returns> | |||
public override bool Equals(object obj) | |||
=> obj is EmbedVideo embedVideo && Equals(embedVideo); | |||
/// <summary> | |||
/// Determines whether the specified <see cref="EmbedVideo"/> is equal to the current <see cref="EmbedVideo"/> | |||
/// </summary> | |||
/// <param name="embedVideo">The <see cref="EmbedVideo"/> to compare with the current <see cref="EmbedVideo"/></param> | |||
/// <returns></returns> | |||
public bool Equals(EmbedVideo? embedVideo) | |||
=> GetHashCode() == embedVideo?.GetHashCode(); | |||
/// <inheritdoc /> | |||
public override int GetHashCode() | |||
=> (Width, Height, Url).GetHashCode(); | |||
} | |||
} |