public static T Get <T>(Buffer buffer) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (typeof(T) == typeof(bool)) { return((T)(object)buffer.GetBoolean()); } if (typeof(T) == typeof(byte)) { return((T)(object)buffer.GetByte()); } if (typeof(T) == typeof(sbyte)) { return((T)(object)buffer.GetSByte()); } if (typeof(T) == typeof(char)) { return((T)(object)buffer.GetChar()); } if (typeof(T) == typeof(double)) { return((T)(object)buffer.GetDouble()); } if (typeof(T) == typeof(float)) { return((T)(object)buffer.GetFloat()); } if (typeof(T) == typeof(int)) { return((T)(object)buffer.GetInt()); } if (typeof(T) == typeof(uint)) { return((T)(object)buffer.GetUInt()); } if (typeof(T) == typeof(long)) { return((T)(object)buffer.GetLong()); } if (typeof(T) == typeof(ulong)) { return((T)(object)buffer.GetULong()); } if (typeof(T) == typeof(short)) { return((T)(object)buffer.GetShort()); } if (typeof(T) == typeof(ushort)) { return((T)(object)buffer.GetUShort()); } if (typeof(T) == typeof(string)) { return((T)(object)buffer.GetString()); } throw new DataException(string.Format("Provided type ({0}) cannot be deserialized from buffer. You must provide a (except struct and enum) or a string", typeof(T))); }