Exemple #1
0
        public static Bincoding ParseValue <T>(T value)
        {
            if (value is Bincoding)
            {
                return((Bincoding)(object)value);
            }
            else if (value is bool)
            {
                return(Bincoding.ParseValue((bool)(object)value));
            }
            else if (value is byte)
            {
                return(Bincoding.ParseValue((byte)(object)value));
            }
            else if (value is short)
            {
                return(Bincoding.ParseValue((short)(object)value));
            }
            else if (value is int)
            {
                return(Bincoding.ParseValue((int)(object)value));
            }
            else if (value is long)
            {
                return(Bincoding.ParseValue((long)(object)value));
            }
            else if (value is ushort)
            {
                return(Bincoding.ParseValue((ushort)(object)value));
            }
            else if (value is uint)
            {
                return(Bincoding.ParseValue((uint)(object)value));
            }
            else if (value is ulong)
            {
                return(Bincoding.ParseValue((ulong)(object)value));
            }
            else if (value is byte[])
            {
                return(Bincoding.ParseValue((byte[])(object)value));
            }
            else if (value is string)
            {
                return(Bincoding.ParseValue((string)(object)value, false));
            }
            else if (value is Stream)
            {
                return(Bincoding.ParseValue((Stream)(object)value));
            }
            else if (value is DateTime)
            {
                return(Bincoding.ParseValue((DateTime)(object)value));
            }
            else if (value is object)
            {
                if (value == null)
                {
                    return(Bincoding.GetNullValue());
                }

                throw new IOException("Type not supported.");
            }
            else
            {
                throw new IOException("Type not supported.");
            }
        }