有没有办法使用另一个 C++/CX WinRT 组件中的 ref 类中的本机参数调用内部方法?我知道有通过暴露为 int 的指针的解决方案,但有没有更好的方法?像包含来自其他库的头文件而不使用托管引用的东西(这样我从 C# Component3 "error CS0433: The type 'Class1' exists in both 'Component1' and 'Component2'" in the other component that uses these两个都)...
组件1/class1.h:
public ref class Class1 sealed
{
internal:
bool InternalMethodForComponent2(NativeType& param1);
public:
Class1();
virtual ~Class1();
int SomeMethodForComponent3();
private:
};
组件2/class2.cpp:
//#include "Component1/class1.h" - replaced by adding reference because of CS0433 in Component3
void Class2::SomeMethod(Class1^ obj)
{
NativeType nt;
nt.start = 1;
...
obj->InternalMethodForComponent2(nt); //does not work - error C2039: 'InternalMethodForComponent2' : is not a member of 'Component1::Class1'
}
组件3/class3.cs:
void MethodInClass3()
{
Class1 obj1 = new Class1();
Class2 obj2 = new Class2();
obj2.SomeMethod(obj1);
var res = obj1.SomeMethodForComponent3();
}