Mercurial > hg > ucis.core
comparison Pml/Elements/Binary.cs @ 0:3ab940a0c7a0
Initial commit
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Tue, 11 Sep 2012 16:28:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3ab940a0c7a0 |
---|---|
1 using System; | |
2 using System.Text; | |
3 | |
4 namespace UCIS.Pml { | |
5 public class PmlBinary : PmlElement { | |
6 private byte[] _Value; | |
7 | |
8 public PmlBinary(byte[] Value) { | |
9 _Value = Value; | |
10 } | |
11 | |
12 public override PmlType Type { get { return PmlType.Binary; } } | |
13 | |
14 public override object ToObject() { return _Value; } | |
15 public override string ToString() { return Encoding.UTF8.GetString(_Value); } | |
16 public override bool ToBoolean() { return BitConverter.ToBoolean(_Value, 0); } | |
17 public override byte ToByte() { return _Value[0]; } | |
18 public override decimal ToDecimal() { return _Value.Length == 4 ? (Decimal)BitConverter.ToSingle(_Value, 0) : (Decimal)BitConverter.ToDouble(_Value, 0); } | |
19 public override double ToDouble() { return BitConverter.ToDouble(_Value, 0); } | |
20 public override short ToInt16() { return BitConverter.ToInt16(_Value, 0); } | |
21 public override int ToInt32() { return BitConverter.ToInt32(_Value, 0); } | |
22 public override long ToInt64() { return BitConverter.ToInt64(_Value, 0); } | |
23 public override sbyte ToSByte() { return (SByte)_Value[0]; } | |
24 public override float ToSingle() { return BitConverter.ToSingle(_Value, 0); } | |
25 public override ushort ToUInt16() { return BitConverter.ToUInt16(_Value, 0); } | |
26 public override uint ToUInt32() { return BitConverter.ToUInt32(_Value, 0); } | |
27 public override ulong ToUInt64() { return BitConverter.ToUInt64(_Value, 0); } | |
28 public override char ToChar() { return BitConverter.ToChar(_Value, 0); } | |
29 public override byte[] ToByteArray() { return _Value; } | |
30 } | |
31 } |