32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
// 定义设备数据类
|
||
|
|
[System.Serializable]
|
||
|
|
public class DeviceData:IEquatable<DeviceData>
|
||
|
|
{
|
||
|
|
public string deviceType; // 设备类型
|
||
|
|
public string deviceName; // 设备名称
|
||
|
|
public string deviceModel; // 设备型号
|
||
|
|
public string deviceStatus; // 设备状态
|
||
|
|
|
||
|
|
// 实现IEquatable接口的Equals方法以及重写GetHashCode方法以及ToString方法
|
||
|
|
public bool Equals(DeviceData other)
|
||
|
|
{
|
||
|
|
if (other is null) return false;
|
||
|
|
if (ReferenceEquals(this, other)) return true;
|
||
|
|
return deviceType == other.deviceType && deviceName == other.deviceName && deviceModel == other.deviceModel && deviceStatus == other.deviceStatus;
|
||
|
|
}
|
||
|
|
public override int GetHashCode()
|
||
|
|
{
|
||
|
|
return HashCode.Combine(deviceType, deviceName, deviceModel, deviceStatus);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override string ToString()
|
||
|
|
{
|
||
|
|
return $"设备类型: {deviceType}, 设备名称: {deviceName}, 设备型号: {deviceModel}, 设备状态: {deviceStatus}";
|
||
|
|
}
|
||
|
|
}
|