Table of Contents

BencodeDocumentOptions Struct

Definition

Namespace
Bodu.Text.Bencode.Document
Assembly
Bodu.Text.Bencode.dll
Package
Bodu.Text.Bencode 1.0.0
Source
BencodeDocumentOptions.cs

Defines the customizations applied when parsing a BencodeDocument.

public struct BencodeDocumentOptions
Inherited Members
Extension Methods

Remarks

Bencode has no comment syntax and no trailing-comma concept; the options relax the two dictionary-key rules that older real-world encoders are known to violate: AllowUnsortedKeys and AllowDuplicateKeys. Both default to the strict canonical behaviour.

Properties

AllowDuplicateKeys

Gets or sets a value indicating whether a dictionary may contain more than one entry for the same key.

public bool AllowDuplicateKeys { readonly get; set; }

Property Value

bool

true to accept duplicate keys; the default of false rejects them with BencodeFormatException.

Remarks

Every entry of a duplicated key is retained and visible through object enumeration; name lookups such as GetProperty(string) return the first match in document order.

AllowUnsortedKeys

Gets or sets a value indicating whether dictionary keys may appear out of ascending bytewise order.

public bool AllowUnsortedKeys { readonly get; set; }

Property Value

bool

true to accept unsorted keys; the default of false rejects them with BencodeFormatException.

Remarks

Object properties are exposed in stored order regardless of this option; lookups compare raw key bytes, so an unsorted document resolves properties identically to a canonical one.

MaxDepth

Gets or sets the maximum container nesting depth the parser will accept.

public int MaxDepth { readonly get; set; }

Property Value

int

The maximum container nesting depth; 0 selects the default of 64.

Remarks

The effective depth is clamped to the hard ceiling Bodu.Text.Bencode.BencodeLimits.AbsoluteMaxDepth; a document nested past the effective limit throws BencodeFormatException rather than risking a StackOverflowException.

Applies to

ProductVersions
.NET8, 10