76 lines
2.4 KiB
C#
76 lines
2.4 KiB
C#
// /**
|
|
// * File: ODBValue.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
using System.Text;
|
|
namespace ln.objects.catalog
|
|
{
|
|
/// <summary>
|
|
/// The base type of all immutable ODB types
|
|
/// </summary>
|
|
public abstract class ODBValue : ODBEntity
|
|
{
|
|
public object Value { get; protected set; }
|
|
|
|
public override ODBValue Identity => this;
|
|
public override ODBEntity Clone() => this;
|
|
|
|
protected ODBValue(int storageTypeCode, object value)
|
|
: base(storageTypeCode)
|
|
{
|
|
Value = value;
|
|
}
|
|
|
|
public override int GetHashCode() => Value.GetHashCode();
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (GetType().Equals(obj.GetType()))
|
|
{
|
|
if (obj is ODBValue)
|
|
return Equals(Value, (obj as ODBValue).Value);
|
|
if (obj is ODBEntity)
|
|
return Equals(Identity, (obj as ODBEntity).Identity);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("[{0} Value={1}]", GetType().Name, Value);
|
|
}
|
|
|
|
public override string ToTreeString(int indent)
|
|
{
|
|
return string.Format("{0} Value={1}", GetType().Name, Value);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//public virtual string AsString => As<string>();
|
|
//public virtual bool AsBool => As<bool>();
|
|
//public virtual byte AsByte => As<byte>();
|
|
//public virtual char AsChar => (char)Value;
|
|
//public virtual short AsShort => Convert.ToInt16(Value);
|
|
//public virtual int AsInt => Convert.ToInt32(Value);
|
|
//public virtual long AsLong => Convert.ToInt64(Value);
|
|
//public virtual ushort AsUShort => Convert.ToUInt16(Value);
|
|
//public virtual uint AsUInt => (uint)Value;
|
|
//public virtual ulong AsULong => (ulong)Value;
|
|
|
|
//public virtual double AsDouble => (double)Value;
|
|
//public virtual float AsFloat => (float)Value;
|
|
|
|
//public virtual Guid AsGuid => (Guid)Value;
|
|
//public virtual DateTime AsDateTime => (DateTime)Mapper.Default.UnmapValue(typeof(DateTime), this);
|
|
//public virtual TimeSpan AsTimeSpan => (TimeSpan)Mapper.Default.UnmapValue(typeof(TimeSpan), this);
|
|
}
|
|
}
|