コード例 #1
0
        public override T AddOrUpdatePayload <T>(PayloadFactory <T> addFactory, UpdatePayloadFactory <T> updateFactory)
        {
            if (this is T context)
            {
                return(context);
            }

            if (_context.TryGetPayload <T>(out var payload))
            {
                return(_context.AddOrUpdatePayload(addFactory, updateFactory));
            }

            if (base.TryGetPayload(out payload))
            {
                T Add()
                {
                    return(updateFactory(payload));
                }

                return(_context.AddOrUpdatePayload(Add, updateFactory));
            }

            return(_context.AddOrUpdatePayload(addFactory, updateFactory));
        }