_cachedCustomer

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anos atrás
How is _cachedCustomer field populated in WebWorkContext class?
12 anos atrás
Have a look at the GetCurrentCustomer method in WebWorkContext class
12 anos atrás
a.m. wrote:
Have a look at the GetCurrentCustomer method in WebWorkContext class


Hi,

Thanks for your response. I can see _cachedCustomer is set near the bottom of the method.

_cachedCustomer = customer;


How is it set at the top though?

  
if (_cachedCustomer != null)
                return _cachedCustomer;


Surely at this stage _cachedCustomer is always null??? I can't work out how it is populated.

Darren
12 anos atrás
It's null only for the first time this method is invoked. But it's not null once it's already been cached.
12 anos atrás
a.m. wrote:
It's null only for the first time this method is invoked. But it's not null once it's already been cached.


Sorry for asking stupid questions, but which line of code caches this variable? Or is the whole webworkcontext class cached?

Darren
12 anos atrás
wunpac wrote:
Or is the whole webworkcontext class cached?

Right. IWorkContext is instantiated per HTTP request. Have a look at the \Presentation\Nop.Web.Framework\DependencyRegistrar.cs file:
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerHttpRequest();
12 anos atrás
a.m. wrote:
Or is the whole webworkcontext class cached?
Right. IWorkContext is instantiated per HTTP request. Have a look at the \Presentation\Nop.Web.Framework\DependencyRegistrar.cs file:
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerHttpRequest();


Now I understand!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.