Annotations Framework - does this have access to an IHostEnvironment ? #1517
-
👋🏻 G'Day team! With the Annotations Framework, we can register services into the DI container. e.g.
But in the code above, I was hoping to access if the HostEnvironment that I'm familiar with in a normal ASP.NET Core API project : Is this available here, in Annotation Framework or even in Lambda's in general? I understand that the value of the host environment is a number of Environment Variables (like But yeah - is this possible or not? Thank you kindly. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@PureKrome Good morning. Based on my understanding, the Lambda Annotations framework uses C# source generators to create the translation layer at compile time. It uses FieldAndConstructor TT template to emit constructor for the generated type, where it includes a statement to invoke the Startup type's (class decorated with LambdaStartupAttribute) ConfigureServices(IServiceCollection) method. My assumption is that during deployment, you could set the environment variable Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@PureKrome Good morning. Based on my understanding, the Lambda Annotations framework uses C# source generators to create the translation layer at compile time.
It uses FieldAndConstructor TT template to emit constructor for the generated type, where it includes a statement to invoke the Startup type's (class decorated with LambdaStartupAttribute) ConfigureServices(IServiceCollection) method.
My assumption is that during deployment, you could set the environment variable
ASPNETCORE_ENVIRONMENT
to appropriate value and should be able to read it in your code.CC @normj
Thanks,
Ashish