private protected int ValidateAndGetLength <TAny>(NpgsqlRange <TAny> value, ref NpgsqlLengthCache?lengthCache, NpgsqlParameter?parameter) { var totalLen = 1; var lengthCachePos = lengthCache?.Position ?? 0; if (!value.IsEmpty) { if (!value.LowerBoundInfinite) { totalLen += 4; if (value.LowerBound is not null) { totalLen += _subtypeHandler.ValidateAndGetLength(value.LowerBound, ref lengthCache, null); } } if (!value.UpperBoundInfinite) { totalLen += 4; if (value.UpperBound is not null) { totalLen += _subtypeHandler.ValidateAndGetLength(value.UpperBound, ref lengthCache, null); } } } // If we're traversing an already-populated length cache, rewind to first element slot so that // the elements' handlers can access their length cache values if (lengthCache != null && lengthCache.IsPopulated) { lengthCache.Position = lengthCachePos; } return(totalLen); }
public override int ValidateAndGetLength(TComposite composite, ref NpgsqlLengthCache?lengthCache) { if (_get == null) { ThrowHelper.ThrowInvalidOperationException_NoPropertyGetter(typeof(TComposite), MemberInfo); } var value = _get(composite); if (value == null) { return(0); } return(NullableHandler <TMember> .Exists ? NullableHandler <TMember> .ValidateAndGetLength(_handler, value, ref lengthCache, null) : _handler.ValidateAndGetLength(value, ref lengthCache, null)); }