public class UserInfo
: System.IEquatable<UserInfo>
{
public string UserName { get; private set; }
public string MachineName { get; private set; }
public UserInfo(string userName, string machineName)
{
this.UserName = userName;
this.MachineName = machineName;
}
public bool Equals(UserInfo other)
{
if (Object.ReferenceEquals(other, null))
return false;
if (object.ReferenceEquals(this, other))
return true;
if (this.GetType() != other.GetType())
return false;
return (this.UserName == other.UserName)
&& (this.MachineName == other.MachineName);
}
public override bool Equals(object obj)
{
return this.Equals(obj as UserInfo);
}
public override int GetHashCode()
{
return this.UserName.GetHashCode() ^ this.MachineName.GetHashCode();
}
public override string ToString()
{
return string.Concat("ユーザー名:", this.UserName, "(", this.MachineName, ")");
}
public static bool operator ==(UserInfo lhs, UserInfo rhs)
{
if (Object.ReferenceEquals(lhs, null))
{
if (Object.ReferenceEquals(rhs, null))
return true;
else
return false;
}
return lhs.Equals(rhs);
}
public static bool operator !=(UserInfo lhs, UserInfo rhs)
{
return !(lhs == rhs);
}
}