-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handling for StatusAddresses in GameServerStatus for the Unity SDK (
- Loading branch information
1 parent
0e6d2d8
commit 8c56546
Showing
3 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Agones.Model | ||
{ | ||
/// <summary> | ||
/// StatusAddresses represents an address with a specific type. | ||
/// </summary> | ||
public class StatusAddresses : IEquatable<StatusAddresses> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="StatusAddresses" /> class. | ||
/// </summary> | ||
/// <param name="data">The data dictionary containing the address and type.</param> | ||
public StatusAddresses(IReadOnlyDictionary<string, object> data) | ||
{ | ||
this.Address = (string)data["address"]; | ||
this.Type = (string)data["type"]; | ||
} | ||
|
||
public string Address { get; } | ||
public string Type { get; } | ||
|
||
/// <summary> | ||
/// Returns the string presentation of the object | ||
/// </summary> | ||
/// <returns>String presentation of the object</returns> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class StatusAddresses {\n"); | ||
sb.Append(" Address: ").Append(Address).Append("\n"); | ||
sb.Append(" Type: ").Append(Type).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if objects are equal | ||
/// </summary> | ||
/// <param name="input">Object to be compared</param> | ||
/// <returns>Boolean</returns> | ||
public override bool Equals(object input) | ||
{ | ||
return this.Equals(input as StatusAddresses); | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if StatusAddresses instances are equal | ||
/// </summary> | ||
/// <param name="input">Instance of StatusAddresses to be compared</param> | ||
/// <returns>Boolean</returns> | ||
public bool Equals(StatusAddresses input) | ||
{ | ||
if (input == null) | ||
return false; | ||
|
||
return | ||
( | ||
this.Address == input.Address || | ||
(this.Address != null && | ||
this.Address.Equals(input.Address)) | ||
) && | ||
( | ||
this.Type == input.Type || | ||
(this.Type != null && | ||
this.Type.Equals(input.Type)) | ||
); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the hash code | ||
/// </summary> | ||
/// <returns>Hash code</returns> | ||
public override int GetHashCode() | ||
{ | ||
unchecked // Overflow is fine, just wrap | ||
{ | ||
int hashCode = 41; | ||
if (this.Address != null) | ||
hashCode = hashCode * 59 + this.Address.GetHashCode(); | ||
if (this.Type != null) | ||
hashCode = hashCode * 59 + this.Type.GetHashCode(); | ||
return hashCode; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.