Skip to content

Commit

Permalink
Update MyAmbientDataAccessor.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
edumserrano authored Dec 11, 2024
1 parent 8936125 commit 85f8e35
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ namespace AmbientDataDemo.AmbientData
public class MyAmbientDataAccessor : IMyAmbientDataAccessor
{
private static readonly AsyncLocal<MyAmbientDataHolder> _myAmbientDataCurrent = new AsyncLocal<MyAmbientDataHolder>();


// In many cases, this could probably be just a simple getter/setter like in https://github.com/edumserrano/dotnet-guides/blob/main/docs/guides/share-data-with-async-local.md#example-2.
// However, this implementation follows the guidance from the HttpContextAccessor implementation https://github.com/dotnet/aspnetcore/blob/3e08b597894891f05556dc0bee23da53cb1b3e11/src/Http/Http/src/HttpContextAccessor.cs.
public MyAmbientData? MyAmbientData
{
get
Expand Down Expand Up @@ -35,4 +37,4 @@ private class MyAmbientDataHolder
public MyAmbientData? Context;
}
}
}
}

0 comments on commit 85f8e35

Please sign in to comment.