Beispiel #1
0
        private static T ProtobufDeSerialize <T>(Stream src)
        {
            if (src == null)
            {
                return(default(T));
            }

            if (typeof(T) == typeof(DataSet))
            {
                return((T)Convert.ChangeType(ProtobufDataSetSerializer.ProtoRead(src), typeof(T)));
            }

            if (typeof(T) == typeof(DataTable))
            {
                return((T)Convert.ChangeType(ProtobufDataTableSerializer.ProtoRead(src), typeof(T)));
            }

            T obj = ProtobufSerializer.Deserialize <T>(src);

            if (obj == null)
            {
                return(default(T));
            }

            return(obj);
        }