Allow accessing null inputs

This commit is contained in:
Sipke Schoorstra 2022-03-04 12:13:55 +01:00
parent 9244ab6c21
commit 4acb8689c3
3 changed files with 3 additions and 3 deletions

View file

@ -19,7 +19,7 @@ public class ExpressionExecutionContext
public RegisterLocation GetLocation(RegisterLocationReference locationReference) => GetLocationInternal(locationReference) ?? throw new InvalidOperationException();
public object Get(RegisterLocationReference locationReference) => GetLocation(locationReference).Value!;
public T Get<T>(RegisterLocationReference locationReference) => (T)Get(locationReference);
public T? Get<T>(Input<T> input) => (T?)GetLocation(input.LocationReference).Value;
public T? Get<T>(Input<T>? input) => input != null ? (T?)GetLocation(input.LocationReference).Value : default;
public void Set(RegisterLocationReference locationReference, object? value)
{

View file

@ -15,5 +15,5 @@ public class TriggerIndexingContext
Trigger = trigger;
}
public T? Get<T>(Input<T> input) => ExpressionExecutionContext.Get<T>(input);
public T? Get<T>(Input<T>? input) => ExpressionExecutionContext.Get(input);
}

View file

@ -13,7 +13,7 @@ public class MessageReceived : TriggerActivity
protected override object GetPayload(TriggerIndexingContext context)
{
var queueOrTopic = context.Get(QueueOrTopic)!;
var subscription = context.Get(Subscription!)!;
var subscription = context.Get(Subscription);
return new MessageReceivedTriggerPayload(queueOrTopic, subscription);
}
}