We have a WinRT component with business logic that internally massages a C++ unsigned char
buffer. We now want to feed that buffer from a C# byte[]
. What would the perfect boundary look like, i.e., what would the signature of the SomeWinRTFunction
function below be?
void SomeWinRTFunction(something containing bytes from managed land)
{
IVector<unsigned char> something using the bytes given from managed land;
}
This kind of issue seems too new still for search engines to find it...
In the C++ part, the method should accept a platform array of uint8 (the equivalent of C# byte).
public ref class Class1 sealed
{
public:
Class1();
//readonly array
void TestArray(const Platform::Array<uint8>^ intArray)
{
}
//writeonly array
void TestOutArray(Platform::WriteOnlyArray<uint8>^ intOutArray)
{
}
};
In the C# part pass the byte array:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Byte[] b = new Byte[2];
b[0] = 1;
var c = new Class1();
c.TestArray(b);
c.TestOutArray(b);
}
In WinRT IVector is projected as IList, i'm not sure about byte -> unsigned char but i suspect is too.
C#
byte[] array;
SomeWinRTFunction(array);
C++
void SomeWinRTFunction(IVector<unsigned char> bytes)
{
IVector<unsigned char> something using the bytes given from managed land;
}
This whitepaper might shed some more light.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With