There are two objects, instants of two different class, but they has
same schema.
Class ClientDivision
{
public string Name
{
get {}; set {};
}
public string Manager
{
get {}; set {};
}
}
Class ClientPerson
{
public string Name
{
get {}; set {};
}
public int Age
{
get {}; set {};
}
public Division div
{
get {}; set {};
}
}
Class ServerDivision
{
public string Name
{
get {}; set {};
}
public string Manager
{
get {}; set {};
}
}
Class ServerPerson
{
public string Name
{
get {}; set {};
}
public int Age
{
get {}; set {};
}
public Division div
{
get {}; set {};
}
}
I have a instant of ClientPerson and need to build a ServerPerson with
the value from ClientPerson. The following code is what I do that job
now.
ServerPerson sPerson = new ServerPerson();
sPerson.Name = cPerson.Name;
sPerson.Age = cPerson.Age;
sPerson.Div = new ServerDivision();
sPerson.Div.Name = cPerson.Div.Name;
sPerson.Div.Manager = cPerson.Div.Manager;
Like you see, all value pass statement wrote by my hand. It's ok when
the class's struct is simple. But will be a large work when it's
complex. In last few days, I even wrote about 300 lines of code just
for copy the value. As you know, nobody will like coding in this way.
So, I'm thinking to find or write a "Deep copy" like tool to do that
job for me. Is anyone has seen a tool like this?