my C# code interface:
namespace IShared;
{
public interface IChannelEntity
{
void SendMsg(string p_msg);
void Exit();
}
public interface IChannelEntityCallBack
{
[OneWay]
void RcvMsg(string p_msg);
}
}
I am trying to figure out how to implement my Interfaces into a c++ managed class. Here is what I got in my cpp file:
namespace EMRBridge
{
//gc managed c++ class
EMRBridge::EMRBridge( )
{
}
void EMRBridge::SendMsg(IChannelEntity *EMR_IChannelEntity, String *p_msg)
{
try {
EMR_IChannelEntity->SendMsg(p_msg);
}
catch (Exception* ex) {
Console::WriteLine( ex->ToString( ) );
}
}
void EMRBridge::ReceiveMsg(IChannelEntityCallBack *rcv, String *p_msg)
{
try {
rcv->RcvMsg(p_msg);
}
catch(Exception* ex){
Console::WriteLine( ex->ToString( ) );
}
}
}
I will have another question after this. Basically this interface I have is for a message router. The IChannelEntity and IChannelCallBack are Interfaces. Did I code the functions right to accept an object and a string correctly? I have never written a managed c++ file that implements c# code interfaces.
my header:
// EMRBridge.h
#pragma once
#using <mscorlib.dll>
#using <System.dll>
#using <System.Runtime.Remoting.dll>
using namespace System;
using namespace System;
using namespace System::Data;
using namespace System::Xml;
using namespace System::Threading;
using namespace System::Runtime::Remoting::Services;
using namespace MB;
using namespace IShared;
namespace EMRBridge
{
__gc class EMRBridge
{
public:
EMRBridge();
IShared::IChannelEntity *EMR_IChannelEntity;
//Send Messages
public:
void SendMsg(IChannelEntity *EMR_IChannelEntity, String *p_msg);
//Receive Messages
public:
void ReceiveMsg(IChannelEntityCallBack *rcv, String *p_msg);
};
}
_____________________
Message posted via http://www.dotnetmonster.com