Skip to content

Commit

Permalink
Fix env mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
mhart committed Feb 20, 2018
1 parent 6c200da commit a169689
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions dotnetcore2.0/run/MockBootstraps/MockLambdaContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ private MockLambdaContext()
public MockLambdaContext(string eventBody, IDictionary environment) : this()
{
EventBody = eventBody;
foreach (var propertyInfo in this.GetType().GetProperties().ToList())
foreach (var propertyInfo in this.GetType().GetProperties())
{
var attributes = propertyInfo.CustomAttributes.OfType<EnvMappingAttribute>();
foreach (var mappingAttribute in attributes.ToList())
var attributes = propertyInfo.GetCustomAttributes(typeof(EnvMappingAttribute), false);
foreach (var mappingAttribute in attributes.Cast<EnvMappingAttribute>())
{
string value = mappingAttribute.DefaultValue;
if (environment.Contains(mappingAttribute.Key))
{
value = environment[mappingAttribute.Key].ToString();
}
var value = environment[mappingAttribute.Key] ?? mappingAttribute.DefaultValue;
propertyInfo.SetValue(this, Convert.ChangeType(value, propertyInfo.PropertyType));
}
}
Expand Down Expand Up @@ -105,10 +101,10 @@ public string OutputText
[EnvMapping("AWS_LAMBDA_FUNCTION_VERSION")]
public string FunctionVersion { get; set; }

[EnvMapping("AWS_LAMBDA_FUNCTION_TIMEOUT")]
[EnvMapping("AWS_LAMBDA_FUNCTION_TIMEOUT", "300")]
public int Timeout { get; set; }

[EnvMapping("AWS_LAMBDA_FUNCTION_MEMORY_SIZE")]
[EnvMapping("AWS_LAMBDA_FUNCTION_MEMORY_SIZE", "1536")]
public int MemorySize { get; set; }
}
}
}

0 comments on commit a169689

Please sign in to comment.