TPayload PipeContext.GetOrAddPayload <TPayload>(PayloadFactory <TPayload> payloadFactory) { if (_payloadCache != null) { return(_payloadCache.GetOrAddPayload(payloadFactory)); } return(_context.GetOrAddPayload(payloadFactory)); }
/// <summary> /// Get or add a payload to the context, using the provided payload factory. /// </summary> /// <param name="payloadFactory">The payload factory, which is only invoked if the payload is not present.</param> /// <typeparam name="TPayload">The payload type</typeparam> /// <returns></returns> public virtual TPayload GetOrAddPayload <TPayload>(PayloadFactory <TPayload> payloadFactory) where TPayload : class { var context = this as TPayload; if (context != null) { return(context); } return(_payloadCache.GetOrAddPayload(payloadFactory)); }
T IPayloadCache.GetOrAddPayload <T>(PayloadFactory <T> payloadFactory) { if (_payloadCache.TryGetPayload(out T payload)) { return(payload); } if (_parentCache.TryGetPayload(out payload)) { return(payload); } return(_payloadCache.GetOrAddPayload(payloadFactory)); }
public TPayload GetOrAddPayload <TPayload>(PayloadFactory <TPayload> payloadFactory) where TPayload : class { TPayload payload; if (_payloadCache.TryGetPayload(out payload)) { return(payload); } if (_parentCache.TryGetPayload(out payload)) { return(payload); } return(_payloadCache.GetOrAddPayload(payloadFactory)); }