public DefaultContentBodyEvaluator(IContentBody contentBody) { if (contentBody is null) { throw new ArgumentNullException(nameof(contentBody)); } Infra.NotNull(contentBody.Value); _contentBody = contentBody; }
public bool ShouldPass(int channel, IContentBody contentBody, out IContentMethod method) { if (contentBody.SentOnValidChannel(channel) == false) { throw new CommandInvalidException($"{ contentBody.GetType()} cannot be sent on channel {channel}."); } if (_expectationManager.IsExpecting <ContentBodyExpectation>(channel) == false) { method = default; return(false); } var contentBodyExpectation = _expectationManager.Get <ContentBodyExpectation>(channel); var size = contentBody.Payload.Length; if (size > contentBodyExpectation.Size) { throw new FrameErrorException($"Invalid content body frame size. Expected {contentBodyExpectation.Size}, got {size}."); } if (size + 1 > _frameMax) { throw new FrameErrorException($"Invalid content body frame size. Maximum frame size is {_frameMax}. Current frame size was {size + 1}."); } _contentMethodStates[channel].AddContentBody(contentBody); if (size == contentBodyExpectation.Size) { method = _contentMethodStates[channel]; _expectationManager.Set(channel, new MethodExpectation(_expectedMethodManager.GetExpectingMethodsFor(method.GetType()))); _contentMethodStates.Remove(channel); return(true); } _expectationManager.Set(channel, new ContentBodyExpectation(contentBodyExpectation.Size - size)); method = default; return(false); }
public XPathContentBodyEvaluator(IContentBody contentBody) : base(contentBody) { }
public EcmaScriptContentBodyEvaluator(IContentBody contentBody) : base(contentBody) { }
public void SetBody(IContentBody body) => _body = body ?? throw new ArgumentNullException(nameof(body));
public IFrame Create(short channel, IContentBody body) { return(new Amqp091Frame(Constants.FrameBody, channel, body, _amqpWriterFactory)); }