mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 20:54:58 +00:00
Created S# .sln and moved project to src folder
This commit is contained in:
40
ICD.Common/Attributes/AbstractIcdAttribute.cs
Normal file
40
ICD.Common/Attributes/AbstractIcdAttribute.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace ICD.Common.Attributes
|
||||
{
|
||||
/// <summary>
|
||||
/// AbstractIcdAttribute is the base class for all ICD attributes.
|
||||
/// It provides a global cache for looking up symbols via an attribute type.
|
||||
/// </summary>
|
||||
public abstract class AbstractIcdAttribute : Attribute
|
||||
{
|
||||
private readonly int m_HashCode;
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
protected AbstractIcdAttribute()
|
||||
{
|
||||
// Duplicate attributes (E.g. [A, A]) are considered to be the same instance by reflection.
|
||||
// We get around this by using a GUID for the hash code.
|
||||
m_HashCode = Guid.NewGuid().GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code for the instance.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return m_HashCode;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user