Vector<bytes> support in .NET binding.

GitOrigin-RevId: b9b168c865bb2144e902229e36776bdce92f22dc
This commit is contained in:
levlam 2018-05-11 13:53:49 +03:00
parent bd7a53c936
commit 40db52670d
2 changed files with 12 additions and 1 deletions

View File

@ -376,7 +376,8 @@ class TlWriterDotNet : public TL_writer {
} else {
ss << ", ";
}
ss << (gen_field_type(it) == "Array<byte>^" ? "Bytes" : "") << "FromUnmanaged(from." << gen_native_field_name(it.name) << ")";
bool need_bytes = gen_field_type(it) == "Array<byte>^" || gen_field_type(it) == "Array<Array<byte>^>^";
ss << (need_bytes ? "Bytes" : "") << "FromUnmanaged(from." << gen_native_field_name(it.name) << ")";
}
ss << ");\n}\n";
}

View File

@ -82,6 +82,16 @@ auto CLRCALL FromUnmanaged(std::vector<FromT> &vec) {
return res;
}
inline auto CLRCALL BytesFromUnmanaged(const std::vector<std::string> &vec) {
using ToT = decltype(BytesFromUnmanaged(vec[0]));
Array<ToT>^ res = REF_NEW Vector<ToT>(static_cast<ArrayIndexType>(vec.size()));
ArrayIndexType i = 0;
for (auto &from : vec) {
ArraySet(res, i++, BytesFromUnmanaged(from));
}
return res;
}
template <class T>
auto CLRCALL FromUnmanaged(td::td_api::object_ptr<T> &from) -> decltype(FromUnmanaged(*from.get())) {
if (!from) {