Ejemplo n.º 1
0
        TPayload PipeContext.GetOrAddPayload <TPayload>(PayloadFactory <TPayload> payloadFactory)
        {
            if (_payloadCache != null)
            {
                return(_payloadCache.GetOrAddPayload(payloadFactory));
            }

            return(_context.GetOrAddPayload(payloadFactory));
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
        }