public object AsObject() { switch (TypeCode) { case ElaTypeCode.Boolean: return(I4 == 1); case ElaTypeCode.Char: return((Char)I4); case ElaTypeCode.Double: return(Ref.AsDouble()); case ElaTypeCode.Integer: return(I4); case ElaTypeCode.Long: return(Ref.AsLong()); case ElaTypeCode.Single: return(DirectGetSingle()); case ElaTypeCode.String: return(DirectGetString()); case ElaTypeCode.Unit: return(null); case ElaTypeCode.Lazy: return(Ref.Force(this, ElaObject.DummyContext).Ref); default: return(Ref); } }
internal double GetDouble() { return(TypeCode == ElaTypeCode.Double ? Ref.AsDouble() : TypeCode == ElaTypeCode.Single ? DirectGetSingle() : TypeCode == ElaTypeCode.Long ? Ref.AsLong() : (Double)I4); }
internal bool GetBool() { if (TypeCode == ElaTypeCode.Long) { return(Ref.AsLong() != 0); } return(I4 != 0); }
public long AsInt64() { if (TypeCode == ElaTypeCode.Long) { return(Ref.AsLong()); } throw InvalidCast(typeof(Int64)); }
internal char GetChar() { if (TypeCode == ElaTypeCode.Long) { return((Char)Ref.AsLong()); } else if (TypeCode == ElaTypeCode.String) { var s = DirectGetString(); return(s.Length == 0 ? '\0' : s[0]); } return((Char)I4); }
internal int GetInt() { if (TypeCode == ElaTypeCode.Long) { return((Int32)Ref.AsLong()); } else if (TypeCode == ElaTypeCode.Double) { return((Int32)Ref.AsDouble()); } else if (TypeCode == ElaTypeCode.Single) { return((Int32)DirectGetSingle()); } return(I4); }
internal long GetLong() { if (TypeCode == ElaTypeCode.Long) { return(Ref.AsLong()); } else if (TypeCode == ElaTypeCode.Double) { return((Int64)Ref.AsDouble()); } else if (TypeCode == ElaTypeCode.Single) { return((Int64)DirectGetSingle()); } return((Int64)I4); }
internal float GetSingle() { if (TypeCode == ElaTypeCode.Integer) { return((Single)I4); } else if (TypeCode == ElaTypeCode.Long) { return((Single)Ref.AsLong()); } else if (TypeCode == ElaTypeCode.Double) { return((Single)Ref.AsDouble()); } return(DirectGetSingle()); }