Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
How inject HttpContextbase in AutoMapper ITypeConverter with Autofac
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
  6 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
 
fernando mondo  
View profile  
 More options Jan 24, 10:19 am
From: fernando mondo <fernando.mo...@gmail.com>
Date: Tue, 24 Jan 2012 07:19:58 -0800 (PST)
Local: Tues, Jan 24 2012 10:19 am
Subject: How inject HttpContextbase in AutoMapper ITypeConverter with Autofac
I have a Asp.Net Mvc3 Site and I wish to know how to inject
HttpContextbase in the TestConverter?

the unitOfWork works, but with the httpContext the error

  public class TestConverter: ITypeConverter<ClientModel, Client>
        {
            private readonly IUnitOfWork _unitOfWork;
            private readonly HttpContextBase _httpContext;

            public TestConverter(IUnitOfWork unitOfWork/*,
HttpContextBase httpContext*/)
            {
                _unitOfWork = unitOfWork;
              //  _httpContext = httpContext;
            }

            public Client Convert(ResolutionContext context)
            {
                var clientModel = context.SourceValue as ClientModel;
                return new Client(ClientModel.Name,
httpContext.Request["Origin"]);
            }

global.asax

builder.RegisterAssemblyTypes(assemblies).AssignableTo<Profile>().As<Profil e>();
var container = builder.Build();
Mapper.Initialize(c =>
            {
                c.ConstructServicesUsing(container.Resolve);
                profiles.ToList().ForEach(c.AddProfile);
            });

Myprofile

protected override void Configure()
    {

        CreateMap<ClientModel,
Client>().ConvertUsing<TestConverter>();
    }


 
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.
Fernando Mondo  
View profile  
 More options Jan 24, 10:42 am
From: Fernando Mondo <fernando.mo...@gmail.com>
Date: Tue, 24 Jan 2012 13:42:14 -0200
Local: Tues, Jan 24 2012 10:42 am
Subject: Re: How inject HttpContextbase in AutoMapper ITypeConverter with Autofac

i forgot error:

"No scope with a Tag matching 'httpRequest' is visible from the scope in
which the instance was requested. This generally indicates that a component
registered as per-HTTP request is being reqested by a SingleInstance()
component (or a similar scenario.) Under the web integration always request
dependencies from the DependencyResolver.Current or
ILifetimeScopeProvider.RequestLifetime, never from the container itself."

2012/1/24 fernando mondo <fernando.mo...@gmail.com>


 
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.
Fabio Miceli  
View profile  
 More options Feb 8, 4:39 pm
From: Fabio Miceli <fbo.mcl...@gmail.com>
Date: Wed, 8 Feb 2012 22:39:14 +0100
Local: Wed, Feb 8 2012 4:39 pm
Subject: Re: How inject HttpContextbase in AutoMapper ITypeConverter with Autofac

grazie infinite per il tuo suggerimento......vedrņ di studiarci per capire
bene.
a risentirci

2012/1/24 fernando mondo <fernando.mo...@gmail.com>


 
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.
Fabio Miceli  
View profile  
 More options Feb 8, 4:39 pm
From: Fabio Miceli <fbo.mcl...@gmail.com>
Date: Wed, 8 Feb 2012 22:39:25 +0100
Local: Wed, Feb 8 2012 4:39 pm
Subject: Re: How inject HttpContextbase in AutoMapper ITypeConverter with Autofac

grazie infinite per il tuo suggerimento......vedrņ di studiarci per capire
bene.
a risentirci

2012/1/24 Fernando Mondo <fernando.mo...@gmail.com>


 
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 9, 4:28 am
From: Mathias Stenbom <math...@stenbom.com>
Date: Thu, 9 Feb 2012 10:28:23 +0100
Local: Thurs, Feb 9 2012 4:28 am
Subject: Re: How inject HttpContextbase in AutoMapper ITypeConverter with Autofac

I think this might be the same problem, which iv posted on SO about;

http://stackoverflow.com/questions/8243135/autofac-asp-net-mvc-3-http...

Did you find any solution? (English please )

Regards,
Mathias


 
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 16, 12:02 am
From: Jimmy Bogard <jimmy.bog...@gmail.com>
Date: Wed, 15 Feb 2012 23:02:53 -0600
Local: Thurs, Feb 16 2012 12:02 am
Subject: Re: How inject HttpContextbase in AutoMapper ITypeConverter with Autofac

The latest drop allows contextual injection with an overload to the Map
method that allows you to pass in a different service locator. Great for
contextual injection!

On Thursday, February 9, 2012, Mathias Stenbom <math...@stenbom.com> wrote:
> I think this might be the same problem, which iv posted on SO about;

http://stackoverflow.com/questions/8243135/autofac-asp-net-mvc-3-http...

which the instance was requested. This generally indicates that a component
registered as per-HTTP request is being reqested by a SingleInstance()
component (or a similar scenario.) Under the web integration always request
dependencies from the DependencyResolver.Current or
ILifetimeScopeProvider.RequestLifetime, never from the container itself."

builder.RegisterAssemblyTypes(assemblies).AssignableTo<Profile>().As<Profil e>();

"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 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 received this message because you are subscribed to the Google Groups

"AutoMapper-users" group.


 
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 »