Class SliceFeature
Default implementation of ISliceFeature.
public sealed class SliceFeature : ISliceFeature
- Inheritance
-
SliceFeature
- Implements
- Inherited Members
Constructors
SliceFeature(SliceEncodeOptions?, int, int, ISliceProxy?, ISliceFeature?)
Constructs a Slice feature.
public SliceFeature(SliceEncodeOptions? encodeOptions = null, int maxCollectionAllocation = -1, int maxSegmentSize = -1, ISliceProxy? baseProxy = null, ISliceFeature? defaultFeature = null)
Parameters
encodeOptionsSliceEncodeOptionsThe encode options.
maxCollectionAllocationintThe maximum collection allocation. Use
-1to get the default value: 8 timesmaxSegmentSizeif set, otherwise the value provided bydefaultFeature.maxSegmentSizeintThe maximum segment size. Use
-1to get the default value.baseProxyISliceProxyThe base proxy, used when decoding service addresses into proxies.
defaultFeatureISliceFeatureA feature that provides default values for all parameters. null is equivalent to Default.
Exceptions
- ArgumentOutOfRangeException
Thrown when
maxCollectionAllocationis a negative value other than-1, whenmaxSegmentSizeis0or a negative value other than-1, or whenmaxSegmentSizeis greater thanint.MaxValue / 8(256 MB) whilemaxCollectionAllocationis-1.
Properties
BaseProxy
Gets the base proxy used when decoding a service address into a proxy.
public ISliceProxy? BaseProxy { get; }
Property Value
- ISliceProxy
The base proxy. A decoded proxy inherits the invoker and encode options of the base proxy, and a decoded relative service address is resolved against the service address of the base proxy. When null, the proxy that sent the request serves as the base proxy for a proxy decoded from an incoming response, while a proxy decoded from an incoming request receives Instance as its invoker and keeps its relative service address as is.
Default
Gets a ISliceFeature with default values for all properties.
public static ISliceFeature Default { get; }
Property Value
EncodeOptions
Gets the options to use when encoding the payload of an outgoing response.
public SliceEncodeOptions? EncodeOptions { get; }
Property Value
MaxCollectionAllocation
Gets the maximum collection allocation when decoding a payload, in bytes.
public int MaxCollectionAllocation { get; }
Property Value
- int
The maximum collection allocation.
Remarks
This value is a cumulative budget for the decoding of one Slice payload segment, not a limit on the
size of each collection: the decoder charges the estimated memory size of each string, sequence, and
dictionary against this budget before decoding it, based on the size or element count found in the encoded
data, and throws InvalidDataException when the charge exceeds the remaining budget.
Implementations must return a value greater than or equal to 0.
MaxSegmentSize
Gets the maximum size of a Slice payload segment, in bytes. A Slice payload segment corresponds to the encoded arguments of an operation, the encoded return values of an operation, or a portion of a stream of variable-size elements.
public int MaxSegmentSize { get; }
Property Value
- int
The maximum size of a Slice payload segment, in bytes.
Remarks
This limit applies only when decoding the payload of an incoming request or response: the decoding
throws InvalidDataException when the size encoded in the size prefix of a segment exceeds this
maximum, before decoding any byte of the segment. It does not restrict the size of the segments encoded by the
application. The segment size does not include the size of its size prefix. Implementations must return a value
greater than 0.