6

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...

4

2 に答える 2

6

C ++の部分では、メソッドはuint8のプラットフォーム配列(C#バイトに相当)を受け入れる必要があります。

public ref class Class1 sealed
{
public:
    Class1();
    //readonly array
    void TestArray(const Platform::Array<uint8>^ intArray)
    {

    }
    //writeonly array
    void TestOutArray(Platform::WriteOnlyArray<uint8>^ intOutArray)
    {

    }

};

C#の部分で、バイト配列を渡します。

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        Byte[] b = new Byte[2];
        b[0] = 1;
        var c = new Class1();
        c.TestArray(b);
        c.TestOutArray(b); 

    }
于 2012-06-11T18:39:16.267 に答える
2

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.

于 2012-06-08T12:44:54.200 に答える