Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:11:47+00:00 2026-05-25T11:11:47+00:00

I am writing a simple mapper class to clone and copy properties between different

  • 0

I am writing a simple mapper class to clone and copy properties between different objects of different/same types.

Mapping is performed via reflection and works just fine for value types, lists and reference types.

Everything works for types like this one:

class SimpleValueTypes 
{
    public string Name { get; set; }
    public int Number { get; set; }
    public long LongNumber { get; set; }
    public float FloatNumber { get; set; }
    public bool BooleanValue { get; set; }
    public AnotherType AnotherProperty{ get; set; }

}

where AnotherType is a class type. Mapping of reference types is performed by inspecting the properties recursively until all the properties are mapped to the destination pretty much this way:

object value = mapFrom.GetValue(input, null);                
mapTo.SetValue(output, value, null);

where mapForm and mapTo are PropertyInfo objects.

Problems began when a new type with a “Bitmap” property arrived and I realised a whole class of objects cannot be treated the same way.

Class NewType
{
    public Bitmap Bitmap{get;set;}
    public string Name{get;set;}
}

What would you reccomend to do for cases like these? Obviously copying the properties would not lead to a new copy of the original Bitmap object.

PS

I can’t use automapper/emit mapper or any other external packages.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:11:47+00:00Added an answer on May 25, 2026 at 11:11 am

    If you are implementing a mapper and not use some existing ones :

    I think that this always worked on your side, it’s only a case of your project (which is a good news). The thing is that, by me, you arrived on point where you need to implement custom mapper. So define some base class like BaseMapper with mapping basic functionality, and derive from it BitmapMapper:BaseMapper class which takes care of mapping of Bitmap type objects.

    After a while could be you will get some other type, you will create MyTypeMapper : BaseMapper with concrete implementation of mapping.

    This just a basic idea, you should think of this to find out the most suitable way of concrete implementation of it for your project.

    If using your own mapper is not mandatory for you, you can use some already existing solutions available on market, like for example Automapper

    Regards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing simple program to communicate between smart devices and I receive 11001 when
I have the following code with a simple class and a method for writing
I'm learning Rails by writing simple TODO tasks aplication. Two models are: class List
I am writing simple game on flex. In the game there are 2 objects
Hello I'm writing simple j2me calculator. using GameCanvas class as a basis of my
I'm looking into writing simple graphics code in Android and I've noticed some synchronized()
I am writing simple site that requires users and profiles to be handled. The
How long does it take for an experienced Windows programmer to learn writing simple
I'm writing a simple OpenGL application that uses GLUT . I don't want to
I'm writing a simple app that's going to have a tiny form sitting in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.