34 lines
953 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace EasyInject.Models
{
public class ShelvedInstance
{
public readonly object Instance;
public readonly string BeanName;
public ShelvedInstance(string beanName, object instance)
{
Instance = instance;
BeanName = beanName;
}
/// <summary>
/// 重写Equals方法用于比较两个ShelvedInstance是否相等
/// </summary>
/// <param name="obj">另一个ShelvedInstance</param>
/// <returns>是否相等</returns>
public override bool Equals(object obj)
{
if (obj is ShelvedInstance shelvedInstance)
{
return Instance == shelvedInstance.Instance && BeanName == shelvedInstance.BeanName;
}
return false;
}
public override int GetHashCode()
{
return Instance.GetHashCode() ^ BeanName.GetHashCode();
}
}
}