I have a WP C++ Runtime Component that is to be consumed by a C# WP application.
In C++ Runtime Component, I have
public interface class ICallback
{
public:
virtual void sendMail(Platform::String ^to, Platform::String ^subject, Platform::String ^body);
};
In C# Application, I have CallbackImpl
, which implements ICallback
:
public class CallbackImpl : Windows8Comp.ICallback
{
public void sendMail(String to, String subject, String body)
{
//...
}
And it works perfectly.
But now I need to pass something more complex than String
: in C# I have
public class MyDesc
{
public string m_bitmapName { get; set; }
public string m_link { get; set; }
public string m_event { get; set; }
}
and I have added:
public class CallbackImpl : Windows8Comp.IMyCSCallback
{
private List<MyDesc> m_moreGamesDescs;
public List<MyDesc> getMoreGamesDescs()
{
return m_moreGamesDescs;
}
// ...
}
How do I call it from C++?
public interface class ICallback
{
public:
virtual <what ret val?> getMoreGamesDescs();
};
I tried to create a "mirror" structure in C++ like this:
struct MyDescCPP
{
Platform::String ^m_bitmapName;
Platform::String ^m_link;
Platform::String ^m_event;
}
but I don't understand what does C#'s List
map to in C++.
Is this what you need?
there is no
^
(dash) next toMyDescCPP
because unlike theList<T>
which is aref
type, theMyDescCPP
that you defined is astruct
and that means it's avalue
type.EDIT:
oh, and your
struct
must bevalue class
orvalue struct
because you want aCLR
type there and not the native type:Classes and Structs (C++ Component Extensions)