Hello,
I have to move the project to the .NET (exactly ASP.NET) environment but
I encountered some problems. The old code was written using C++ and MFC
and was organized to separate "business logic" from interface. I'd like
to use this "business logic" code in ASP.NET pages so as far I know I
need to create managed wrappers for the classes. This code is not a dll
library only static lib.
My 1st problem is:
In old code I've got something like this:
typedef CTypedPtrArray <CPtrArray, CUser*> CUserArray;
class CUsersMgr
{
....
CUserArray& GetUsers();
bool AddUser(CUser &user);
protected:
CUserArray m_Users;
}
So managed wrapper would be:
class CUsersMgrWrp
{
CUsersMgrWrp() { pUsersMgr = new CUsersMgr() };
~CUsersMgrWrp() { delete pUsersMgr };
XXXXX GetUsers();
....
protected:
CUsersMgr *pUsersMgr;
}
And if I wanted to get users array on the ASP.NET page I should:
CUsersMgrWrp usersWrp = new CUsersMgrWrp
usersWrp.GetUse rs();
but what should return GetUsers() ?(XXXXXX) I can't use MFC on C#
codebehind pages. Should I convert all array data in wrapper to eg
ArrayList?
And the second question. Suppose I have written CUser wrapper:
class CUserWrp
{
CUserWrp() { pUser = new CUser() };
~CUserWrp() { delete pUser };
....
friend class CUsersMgr;
protected:
CUsers *pUser;
}
Will my wrapped code look like this?
CUsersMgrWrp::A ddUser(CUserWrp userWrp)
{
pUsersMgr->AddUser(userWr p.pUser)
}
What about marshaling in this case?
Please, tell me if it is OK, maybe I should design it in some other way.
Regrads,
mirek
I have to move the project to the .NET (exactly ASP.NET) environment but
I encountered some problems. The old code was written using C++ and MFC
and was organized to separate "business logic" from interface. I'd like
to use this "business logic" code in ASP.NET pages so as far I know I
need to create managed wrappers for the classes. This code is not a dll
library only static lib.
My 1st problem is:
In old code I've got something like this:
typedef CTypedPtrArray <CPtrArray, CUser*> CUserArray;
class CUsersMgr
{
....
CUserArray& GetUsers();
bool AddUser(CUser &user);
protected:
CUserArray m_Users;
}
So managed wrapper would be:
class CUsersMgrWrp
{
CUsersMgrWrp() { pUsersMgr = new CUsersMgr() };
~CUsersMgrWrp() { delete pUsersMgr };
XXXXX GetUsers();
....
protected:
CUsersMgr *pUsersMgr;
}
And if I wanted to get users array on the ASP.NET page I should:
CUsersMgrWrp usersWrp = new CUsersMgrWrp
usersWrp.GetUse rs();
but what should return GetUsers() ?(XXXXXX) I can't use MFC on C#
codebehind pages. Should I convert all array data in wrapper to eg
ArrayList?
And the second question. Suppose I have written CUser wrapper:
class CUserWrp
{
CUserWrp() { pUser = new CUser() };
~CUserWrp() { delete pUser };
....
friend class CUsersMgr;
protected:
CUsers *pUser;
}
Will my wrapped code look like this?
CUsersMgrWrp::A ddUser(CUserWrp userWrp)
{
pUsersMgr->AddUser(userWr p.pUser)
}
What about marshaling in this case?
Please, tell me if it is OK, maybe I should design it in some other way.
Regrads,
mirek