Update an already injected service DryIoc c#

Hi I have a situation where I need to update a service that I have injected.

When I first launch the app I have something like

public class MyService:IMyService
{
  public string ValueAPopulatedBeforeLogin { get; set; }
  public string ValueBPopulatedBeforeLogin { get; set; }
  public string ValueCPopulatedAfterLogin { get; set; }
 }
container<IMyService,MyService>();
  1. Start the app
  2. ValueA and B are populated ValueC IS NOT
  3. Login now valueC is populated

Now I need to update MyService but doing

 container.ClearCache(typeOf(IMyService));
 container.UseInstance(MyService);  //with new ValueC updated value

however the new property has not been updated.

How do you update an already injected service? Is this possible?

thanks



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)