You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Network/Models/ServiceEndpointsInfo.cs

58 lines
2.2 KiB

6 years ago
using System;
using System.Collections.Generic;
using ZeroLevel.Services.Serialization;
6 years ago
namespace ZeroLevel.Network
6 years ago
{
/// <summary>
6 years ago
/// Information about service connection points
6 years ago
/// </summary>
public class ServiceEndpointsInfo :
IEquatable<ServiceEndpointsInfo>, IBinarySerializable
6 years ago
{
public string ServiceKey { get; set; }
public string Version { get; set; }
public string ServiceGroup { get; set; }
public string ServiceType { get; set; }
6 years ago
public List<string> Endpoints { get; set; }
6 years ago
public bool Equals(ServiceEndpointsInfo other)
{
if (other == null) return false;
if (string.Compare(this.ServiceKey, other.ServiceKey, true) != 0) return false;
if (string.Compare(this.Version, other.Version, true) != 0) return false;
if (string.Compare(this.ServiceGroup, other.ServiceGroup, true) != 0) return false;
if (string.Compare(this.ServiceType, other.ServiceType, true) != 0) return false;
6 years ago
if (!CollectionComparsionExtensions.NoOrderingEquals(this.Endpoints, other.Endpoints, (a, b) => a.Equals(b))) return false;
6 years ago
return true;
}
public override bool Equals(object obj)
{
return this.Equals(obj as ServiceEndpointsInfo);
}
public override int GetHashCode()
{
return ServiceKey?.GetHashCode() ?? 0 ^ Version?.GetHashCode() ?? 0 ^ ServiceGroup?.GetHashCode() ?? 0 ^ ServiceType?.GetHashCode() ?? 0;
}
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(this.ServiceKey);
writer.WriteString(this.Version);
writer.WriteString(this.ServiceGroup);
writer.WriteString(this.ServiceType);
writer.WriteCollection(this.Endpoints);
}
public void Deserialize(IBinaryReader reader)
{
this.ServiceKey = reader.ReadString();
this.Version = reader.ReadString();
this.ServiceGroup = reader.ReadString();
this.ServiceType = reader.ReadString();
6 years ago
this.Endpoints = reader.ReadStringCollection();
}
6 years ago
}
}

Powered by TurnKey Linux.