Class PayloadSizeCalculator
Namespace: Momentum.Extensions.EventMarkdownGenerator.Services
Assembly: Momentum.Extensions.EventMarkdownGenerator.dll
Calculates estimated payload sizes for event properties based on type analysis and data annotation constraints (MaxLength, Range, StringLength). Subclass to define serialization-format-specific overhead (JSON, Binary, etc.).
public abstract class PayloadSizeCalculatorInheritance
object ← PayloadSizeCalculator
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
PayloadSizeCalculator()
protected PayloadSizeCalculator()PayloadSizeCalculator()
protected PayloadSizeCalculator()Properties
FormatName
Display name of the serialization format (e.g., "JSON", "Binary").
public abstract string FormatName { get; }Property Value
FormatName
public abstract string FormatName { get; }Property Value
Methods
CalculatePropertySize(PropertyInfo, Type)
Calculates the estimated size in bytes for a property's serialized payload.
public PayloadSizeResult CalculatePropertySize(PropertyInfo property, Type propertyType)Parameters
property PropertyInfo
The property to analyze for size constraints.
propertyType Type
The type of the property.
Returns
A result containing the estimated size, accuracy flag, and any warnings.
CalculatePropertySize(PropertyInfo, Type)
public PayloadSizeResult CalculatePropertySize(PropertyInfo property, Type propertyType)Parameters
property PropertyInfo
propertyType Type
Returns
Create(string)
Creates a PayloadSizeCalculator for the specified serialization format.
public static PayloadSizeCalculator Create(string format)Parameters
format string
Returns
Create(string)
public static PayloadSizeCalculator Create(string format)Parameters
format string
Returns
GetCollectionOverhead()
Overhead bytes for collection wrappers (e.g., JSON [ ] adds 2 bytes).
protected abstract int GetCollectionOverhead()Returns
GetCollectionOverhead()
protected abstract int GetCollectionOverhead()Returns
GetElementSeparatorOverhead()
Overhead bytes per element separator (e.g., JSON comma: 1 byte).
protected abstract int GetElementSeparatorOverhead()Returns
GetElementSeparatorOverhead()
protected abstract int GetElementSeparatorOverhead()Returns
GetObjectOverhead()
Overhead bytes for object wrappers (e.g., JSON { } adds 2 bytes).
protected abstract int GetObjectOverhead()Returns
GetObjectOverhead()
protected abstract int GetObjectOverhead()Returns
GetPropertyOverhead(string)
Overhead bytes for a property entry including key and delimiters.
protected abstract int GetPropertyOverhead(string propertyName)Parameters
propertyName string
Returns
GetPropertyOverhead(string)
protected abstract int GetPropertyOverhead(string propertyName)Parameters
propertyName string
Returns
GetStringValueOverhead()
Overhead bytes for a serialized string value (e.g., JSON quotes: 2 bytes).
protected abstract int GetStringValueOverhead()Returns
GetStringValueOverhead()
protected abstract int GetStringValueOverhead()