Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Private AutoMapping container.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dennis  
View profile  
 More options Feb 21 2012, 8:57 pm
From: Dennis <dennis.s...@gmail.com>
Date: Tue, 21 Feb 2012 17:57:53 -0800 (PST)
Local: Tues, Feb 21 2012 8:57 pm
Subject: Private AutoMapping container.
Hi!

First post here, so first things first: Thanks for AutoMapper,
absolutely nice to work with.

I have a scenario where I want to have multiple mapping containers
within the same AppDomain. A small part of the system has its own
mapping scenarios which I don't want to expose to the full
application. I have browsed through the API and I am getting the
feeling that this is not possible.

Something like: var mapper = Mapper.CreateScopedMapper();
mapper.CreateMap<>() ....
mapper.Map<>() ....

Is this possible? Or is it planned?

Thanks in advance for your answer!

Finest regards,
Dennis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mathias Stenbom  
View profile  
 More options Feb 22 2012, 2:29 am
From: Mathias Stenbom <math...@stenbom.com>
Date: Wed, 22 Feb 2012 08:29:30 +0100
Local: Wed, Feb 22 2012 2:29 am
Subject: Re: Private AutoMapping container.

Hi!

I think you can do that by creating multiple instances of the MappingEngine
class. I havnt tried it and dont know how much more complexity is involved,
but I think I read somewhere that that is the solution to these kind of
scenarios.

.Ms


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ramon Smits  
View profile  
 More options Feb 22 2012, 3:33 am
From: Ramon Smits <ramon.sm...@gmail.com>
Date: Wed, 22 Feb 2012 09:33:06 +0100
Local: Wed, Feb 22 2012 3:33 am
Subject: Re: Private AutoMapping container.

You can have multiple instances of the IMappingEngine. This enable you to
have multple mapping configurations within one app domain.

Don't know why you need seperate configurations. Do you have conflicting
mappings? If not then you might as well just pass an IMappingEngine
reference around. (AutoMapper.Mapper.Engine) which is probably a good thing
anyway when you use dependancy injection. Just google on AutoMapper
IMappingEngine and you will get several posts. This makes the design much
more explicit as you have the mapping engine (IMappingEngine) and its
configuration (IConfiguration) where the configuration should be only done
once in an app domain.

--
Ramon

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ramon Smits  
View profile  
 More options Feb 22 2012, 4:01 am
From: Ramon Smits <ramon.sm...@gmail.com>
Date: Wed, 22 Feb 2012 10:01:18 +0100
Local: Wed, Feb 22 2012 4:01 am
Subject: Re: Private AutoMapping container.

By the way.. the key is in the source :-)

https://github.com/AutoMapper/AutoMapper/blob/master/src/AutoMapper/M...

Here you see that the static Mapper class is just a wrapper then Lazy
creates the configuration and engine instances. If you want to create your
own instances then you can do so as you see in the above code reference.

In my version I can do it like

var config = new AutoMapper.Configuration((AutoMapper.ITypeMapFactory)new
AutoMapper.TypeMapFactory(),
AutoMapper.Mappers.MapperRegistry.AllMappers());
var engine = new AutoMapper.MappingEngine(config);

Hope this helps.

--
Ramon

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sunny  
View profile  
 More options Feb 22 2012, 8:22 am
From: Sunny <slon...@gmail.com>
Date: Wed, 22 Feb 2012 07:22:06 -0600
Local: Wed, Feb 22 2012 8:22 am
Subject: Re: Private AutoMapping container.

You can also look at AutoMapperAssist, very nice little wrapper around
AutoMapper, which helps isolate the creation of isolated mapper
classes: https://github.com/darrencauthon/AutoMapperAssist

There's Nuget package as well.

--
Svetoslav Milenov (Sunny)

Artificial Intelligence is no match for natural stupidity.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ramon Smits  
View profile  
 More options Feb 22 2012, 8:37 am
From: Ramon Smits <ramon.sm...@gmail.com>
Date: Wed, 22 Feb 2012 14:37:49 +0100
Local: Wed, Feb 22 2012 8:37 am
Subject: Re: Private AutoMapping container.

> You can also look at AutoMapperAssist, very nice little wrapper around
> AutoMapper, which helps isolate the creation of isolated mapper
> classes: https://github.com/darrencauthon/AutoMapperAssist

> There's Nuget package as well.

What does this do? I just browsed the code and it seems like a wrapper
around AutoMapper which to me sounds a bit unneeded. The project doesn't
explain why it does that and what problem it tries to fix.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sunny  
View profile  
 More options Feb 22 2012, 9:09 am
From: Sunny <slon...@gmail.com>
Date: Wed, 22 Feb 2012 08:09:23 -0600
Local: Wed, Feb 22 2012 9:09 am
Subject: Re: Private AutoMapping container.

On Wed, Feb 22, 2012 at 7:37 AM, Ramon Smits <ramon.sm...@gmail.com> wrote:

>> You can also look at AutoMapperAssist, very nice little wrapper around
>> AutoMapper, which helps isolate the creation of isolated mapper
>> classes: https://github.com/darrencauthon/AutoMapperAssist

>> There's Nuget package as well.

> What does this do? I just browsed the code and it seems like a wrapper
> around AutoMapper which to me sounds a bit unneeded. The project doesn't
> explain why it does that and what problem it tries to fix.

It actually uses its own IMappingEngine for each instance, which
solves the problem you described.

Look at the ctor of Mapper class, it creates new instance of
MappingEngine, and uses it. It's very simple to use, just inherit from
Mapper<TSource, TDest> and override DefineMap:

public class POSCurrencyDetailDTOToCurrencyMapper :
Mapper<POSCurrencyDetailDTO, POSCurrency>
    {
        public override void DefineMap(IConfiguration configuration)
        {
            base.DefineMap(configuration);
            configuration.CreateMap<POSCurrencyDetailDTO, POSCurrency>()
                .ForMember(d => d.Code, opt => opt.MapFrom(s =>
s.CurrencyCode));
        }
    }

That will isolate your mapping to only this class, and then you can
use it like this:

var myMapper = new POSCurrencyDetailDTOToCurrencyMapper();
var mapped = myMapper.CreateInstance(myDTO);

Added benefit is that Mapper<TSoirce, TDest> implements
IAbstractMapper<TSource, TDest>, so you can use actually the interface
to inject mappers in your code for unit testing, etc.

Cheers
--
Svetoslav Milenov (Sunny)

Artificial Intelligence is no match for natural stupidity.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ramon Smits  
View profile  
 More options Feb 22 2012, 9:21 am
From: Ramon Smits <ramon.sm...@gmail.com>
Date: Wed, 22 Feb 2012 15:21:42 +0100
Local: Wed, Feb 22 2012 9:21 am
Subject: Re: Private AutoMapping container.

> It actually uses its own IMappingEngine for each instance, which
> solves the problem you described.

Yes, but why :-) I don't understand why you would want to do that. It also
makes any automatic mappings like collections impossible and if you do that
why not just depend on the interfaces that AutoMapper provides instead of
relying on an additional set of interfaces?

Added benefit is that Mapper<TSoirce, TDest> implements

> IAbstractMapper<TSource, TDest>, so you can use actually the interface
> to inject mappers in your code for unit testing, etc.

And why would I just do that with the AutoMapper interfaces?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dennis Smit  
View profile  
 More options Feb 22 2012, 10:32 am
From: "Dennis Smit" <dennis.s...@gmail.com>
Date: Wed, 22 Feb 2012 16:32:39 +0100
Local: Wed, Feb 22 2012 10:32 am
Subject: RE: Private AutoMapping container.

Hey Ramon,

I had seen the code after sending my initial message to the list (and I
should have checked it before sending mails to the list), thanks for
confirming that this is indeed the -way-to-go- ! ;-).

Thanks,

Dennis

From: automapper-users@googlegroups.com
[mailto:automapper-users@googlegroups.com] On Behalf Of Ramon Smits
Sent: woensdag 22 februari 2012 10:01
To: automapper-users@googlegroups.com
Subject: Re: Private AutoMapping container.

By the way.. the key is in the source :-)

https://github.com/AutoMapper/AutoMapper/blob/master/src/AutoMapper/M...
s

Here you see that the static Mapper class is just a wrapper then Lazy
creates the configuration and engine instances. If you want to create your
own instances then you can do so as you see in the above code reference.

In my version I can do it like

            var config = new
AutoMapper.Configuration((AutoMapper.ITypeMapFactory)new
AutoMapper.TypeMapFactory(),
AutoMapper.Mappers.MapperRegistry.AllMappers());

            var engine = new AutoMapper.MappingEngine(config);

Hope this helps.

On Wed, Feb 22, 2012 at 2:57 AM, Dennis <dennis.s...@gmail.com> wrote:

Hi!

First post here, so first things first: Thanks for AutoMapper,
absolutely nice to work with.

I have a scenario where I want to have multiple mapping containers
within the same AppDomain. A small part of the system has its own
mapping scenarios which I don't want to expose to the full
application. I have browsed through the API and I am getting the
feeling that this is not possible.

Something like: var mapper = Mapper.CreateScopedMapper();
mapper.CreateMap<>() ....
mapper.Map<>() ....

Is this possible? Or is it planned?

Thanks in advance for your answer!

Finest regards,
Dennis

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com
<mailto:automapper-users%2Bunsubscribe@googlegroups.com> .
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.

--

Ramon

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dennis Smit  
View profile  
 More options Feb 22 2012, 10:34 am
From: "Dennis Smit" <dennis.s...@gmail.com>
Date: Wed, 22 Feb 2012 16:34:56 +0100
Local: Wed, Feb 22 2012 10:34 am
Subject: RE: Private AutoMapping container.

Hey,

Thanks! The reason why I need this configuration is because I don't want the
conversion ability to leak out of the area where I explicitly need it since
this is rather isolated from the other parts of the system, so it might not
always be clear

a conversion was setup in the first place.

Cheers,

Dennis

From: automapper-users@googlegroups.com
[mailto:automapper-users@googlegroups.com] On Behalf Of Ramon Smits
Sent: woensdag 22 februari 2012 9:33
To: automapper-users@googlegroups.com
Subject: Re: Private AutoMapping container.

You can have multiple instances of the IMappingEngine. This enable you to
have multple mapping configurations within one app domain.

Don't know why you need seperate configurations. Do you have conflicting
mappings? If not then you might as well just pass an IMappingEngine
reference around. (AutoMapper.Mapper.Engine) which is probably a good thing
anyway when you use dependancy injection. Just google on AutoMapper
IMappingEngine and you will get several posts. This makes the design much
more explicit as you have the mapping engine (IMappingEngine) and its
configuration (IConfiguration) where the configuration should be only done
once in an app domain.

On Wed, Feb 22, 2012 at 2:57 AM, Dennis <dennis.s...@gmail.com> wrote:

Hi!

First post here, so first things first: Thanks for AutoMapper,
absolutely nice to work with.

I have a scenario where I want to have multiple mapping containers
within the same AppDomain. A small part of the system has its own
mapping scenarios which I don't want to expose to the full
application. I have browsed through the API and I am getting the
feeling that this is not possible.

Something like: var mapper = Mapper.CreateScopedMapper();
mapper.CreateMap<>() ....
mapper.Map<>() ....

Is this possible? Or is it planned?

Thanks in advance for your answer!

Finest regards,
Dennis

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com
<mailto:automapper-users%2Bunsubscribe@googlegroups.com> .
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.

--

Ramon

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dennis Smit  
View profile  
 More options Feb 22 2012, 10:35 am
From: "Dennis Smit" <dennis.s...@gmail.com>
Date: Wed, 22 Feb 2012 16:35:51 +0100
Local: Wed, Feb 22 2012 10:35 am
Subject: RE: Private AutoMapping container.

Someone had an itch, and scratched it. What more reason do we need? ;-).

From: automapper-users@googlegroups.com
[mailto:automapper-users@googlegroups.com] On Behalf Of Ramon Smits
Sent: woensdag 22 februari 2012 14:38
To: automapper-users@googlegroups.com
Subject: Re: Private AutoMapping container.

You can also look at AutoMapperAssist, very nice little wrapper around
AutoMapper, which helps isolate the creation of isolated mapper
classes: https://github.com/darrencauthon/AutoMapperAssist

There's Nuget package as well.

What does this do? I just browsed the code and it seems like a wrapper
around AutoMapper which to me sounds a bit unneeded. The project doesn't
explain why it does that and what problem it tries to fix.

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sunny  
View profile  
 More options Feb 22 2012, 11:34 am
From: Sunny <slon...@gmail.com>
Date: Wed, 22 Feb 2012 10:34:20 -0600
Local: Wed, Feb 22 2012 11:34 am
Subject: Re: Private AutoMapping container.

On Wed, Feb 22, 2012 at 8:21 AM, Ramon Smits <ramon.sm...@gmail.com> wrote:
>> It actually uses its own IMappingEngine for each instance, which
>> solves the problem you described.

> Yes, but why :-) I don't understand why you would want to do that. It also
> makes any automatic mappings like collections impossible and if you do that
> why not just depend on the interfaces that AutoMapper provides instead of
> relying on an additional set of interfaces?

Its just a convenient wrapper (at least for me). It has all 3 most
used methods CreateInstance, LoadIntoInstance and CreateSet. Keeps
things separated.

>> Added benefit is that Mapper<TSoirce, TDest> implements
>> IAbstractMapper<TSource, TDest>, so you can use actually the interface
>> to inject mappers in your code for unit testing, etc.

> And why would I just do that with the AutoMapper interfaces?

You can, and you'll most probably end up doing something very similar.
Of course, your implementation will fit better your needs, and could
be better. Its up to you.

At the end, as someone else pointed out - someone had an itch, and
scratched it. I found it useful, and I use it when I need it.

Cheers

--
Svetoslav Milenov (Sunny)

Artificial Intelligence is no match for natural stupidity.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jimmy Bogard  
View profile  
 More options Feb 23 2012, 9:23 am
From: Jimmy Bogard <jimmy.bog...@gmail.com>
Date: Thu, 23 Feb 2012 08:23:29 -0600
Local: Thurs, Feb 23 2012 9:23 am
Subject: Re: Private AutoMapping container.

You can always create instances of the ConfigurationStore and MappingEngine
as needed. It's not as easy as I would like, which is why folks create
wrappers. It's my intention to build AutoMapper 3.0 as a completely
instance-based model-first, and static as just the wrapper.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sunny  
View profile  
 More options Feb 23 2012, 9:47 am
From: Sunny <slon...@gmail.com>
Date: Thu, 23 Feb 2012 08:47:10 -0600
Local: Thurs, Feb 23 2012 9:47 am
Subject: Re: Private AutoMapping container.

On Thu, Feb 23, 2012 at 8:23 AM, Jimmy Bogard <jimmy.bog...@gmail.com> wrote:
> You can always create instances of the ConfigurationStore and MappingEngine
> as needed. It's not as easy as I would like, which is why folks create
> wrappers. It's my intention to build AutoMapper 3.0 as a completely
> instance-based model-first, and static as just the wrapper.

Good news :)

Thanks

--
Svetoslav Milenov (Sunny)

Artificial Intelligence is no match for natural stupidity.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dennis Smit  
View profile  
 More options Feb 23 2012, 2:23 pm
From: "Dennis Smit" <dennis.s...@gmail.com>
Date: Thu, 23 Feb 2012 20:23:55 +0100
Local: Thurs, Feb 23 2012 2:23 pm
Subject: RE: Private AutoMapping container.

Cool! Have you branched out to a 3.0 devel tree already?

From: automapper-users@googlegroups.com
[mailto:automapper-users@googlegroups.com] On Behalf Of Jimmy Bogard
Sent: donderdag 23 februari 2012 15:23
To: automapper-users@googlegroups.com
Subject: Re: Private AutoMapping container.

You can always create instances of the ConfigurationStore and MappingEngine
as needed. It's not as easy as I would like, which is why folks create
wrappers. It's my intention to build AutoMapper 3.0 as a completely
instance-based model-first, and static as just the wrapper.

On Tue, Feb 21, 2012 at 7:57 PM, Dennis <dennis.s...@gmail.com> wrote:

Hi!

First post here, so first things first: Thanks for AutoMapper,
absolutely nice to work with.

I have a scenario where I want to have multiple mapping containers
within the same AppDomain. A small part of the system has its own
mapping scenarios which I don't want to expose to the full
application. I have browsed through the API and I am getting the
feeling that this is not possible.

Something like: var mapper = Mapper.CreateScopedMapper();
mapper.CreateMap<>() ....
mapper.Map<>() ....

Is this possible? Or is it planned?

Thanks in advance for your answer!

Finest regards,
Dennis

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com
<mailto:automapper-users%2Bunsubscribe@googlegroups.com> .
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.

--
You received this message because you are subscribed to the Google Groups
"AutoMapper-users" group.
To post to this group, send email to automapper-users@googlegroups.com.
To unsubscribe from this group, send email to
automapper-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/automapper-users?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jimmy Bogard  
View profile  
 More options Feb 28 2012, 12:24 pm
From: Jimmy Bogard <jimmy.bog...@gmail.com>
Date: Tue, 28 Feb 2012 11:24:46 -0600
Local: Tues, Feb 28 2012 12:24 pm
Subject: Re: Private AutoMapping container.

haaaaa yes, but I'm going to kill the branch and start over. It's just
changed too much.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »