On Thu, Sep 8, 2016 at 6:51 PM, Michael Powell <mwpow...@gmail.com> wrote:
> Hello,
>
> I'd like to do something like this:
>
> IMapperConfiguration mapperCfg = /* ... */
>
> IMapper mapper = mapperCfg.CreateMapper();
>
> // Possibly: cfg being the IMapperConfiguration, e being a
> TypeConverterRequiredEventArgs
> mapper.TypeConverterRequired += (cfg, e) =>
> {
> if (e.RequestedConverterType == typeof(MyTypeConverter)
> {
> // i.e. if done from a Controller where an Identity User is
> available
> e.Converter = new MyTypeConverter(this.User);
> }
> };
>
> Basically, I've got a type converter which I need to inject some details
> into, such as User Identity, in order to make decisions based on his/her
> Claims.
>
> The alternative is brutal logic in the controller, which is what I'm trying
> to avoid much of. Additionally, the conversions are not different enough to
> justify a whole other type converter, per se; just a strategic decision here
> or there whether to convert a property one way or another. This kind of
> thing. I would if I had to, but it's overkill and potentially confounding to
> the API.
Another option might be to pass the details in via view model on the
"left" (input) side. Mulling that one over a bit...
> I haven't looked at the interfaces closely, yet, but I'm headed this
> direction. Is it possible?
>
> Thanks!
>
> Regards,
>
> Michael Powell
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AutoMapper-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/automapper-users/zsv5d0kRNyE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
On Thursday, September 8, 2016 at 7:06:35 PM UTC-4, Michael Powell wrote:On Thu, Sep 8, 2016 at 6:51 PM, Michael Powell <mwpow...@gmail.com> wrote:
> Hello,
>
> I'd like to do something like this:
>
> IMapperConfiguration mapperCfg = /* ... */
>
> IMapper mapper = mapperCfg.CreateMapper();
>
> // Possibly: cfg being the IMapperConfiguration, e being a
> TypeConverterRequiredEventArgs
> mapper.TypeConverterRequired += (cfg, e) =>
> {
> if (e.RequestedConverterType == typeof(MyTypeConverter)
> {
> // i.e. if done from a Controller where an Identity User is
> available
> e.Converter = new MyTypeConverter(this.User);
> }
> };
>
> Basically, I've got a type converter which I need to inject some details
> into, such as User Identity, in order to make decisions based on his/her
> Claims.
--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.