Files
sockeye/server/biz/SockTypeId.cs
2022-12-16 06:01:23 +00:00

114 lines
2.4 KiB
C#

using System;
using Sockeye.Models;
namespace Sockeye.Biz
{
public class SockTypeId : System.Object
{
private long _id;
private SockType _sockType;
public long ObjectId
{
get
{
return _id;
}
}
public SockType SockType
{
get
{
return _sockType;
}
}
public int ATypeAsInt
{
get
{
return (int)_sockType;
}
}
public SockTypeId(SockType aType, long Id)
{
_id = Id;
_sockType = aType;
}
[Newtonsoft.Json.JsonConstructor]
public SockTypeId(string sAType, string sId)
{
_id = long.Parse(sId);
int nType = int.Parse(sAType);
if (!SockTypeExists(nType))
_sockType = SockType.NoType;
else
_sockType = (SockType)Enum.Parse(typeof(SockType), sAType);
}
public bool Equals(SockTypeId x, SockTypeId y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;
//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
//Check whether the products' properties are equal.
return x.ObjectId == y.ObjectId && x.SockType == y.SockType;
}
public bool IsEmpty
{
get
{
return (_sockType == SockType.NoType) || (_id == 0);
}
}
/// <summary>
/// Check if the numeric or name type value is an actual enum value
/// </summary>
/// <param name="enumNumber"></param>
/// <returns></returns>
public bool SockTypeExists(int enumNumber)
{
return Enum.IsDefined(typeof(SockType), enumNumber);
}
//Custom attribute checking
/// <summary>
/// Is object a core biz object
/// </summary>
/// <returns></returns>
public bool IsCoreBizObject
{
get
{
return this.SockType.HasAttribute(typeof(CoreBizObjectAttribute));
}
}
}//eoc
}//eons