Table of Contents

Class FileStorage.StructScope

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Disposable scope returned by WriteStruct(string, Types, string?). Disposing it calls EndWriteStruct() on the owning FileStorage.

public sealed class FileStorage.StructScope : IDisposable
Inheritance
FileStorage.StructScope
Implements
Inherited Members

Remarks

This is deliberately a class, not a struct: EndWriteStruct() has an ordered, one-shot unmanaged side effect (it closes the innermost open structure in the underlying cv::FileStorage), so calling it twice corrupts whatever is written afterwards. A struct can't guarantee that - copying it (e.g. var b = a;) produces an independent instance with its own disposed flag, so guarding with a field only protects the single-variable case, not a copy disposed separately. As a class, every reference shares the same disposed flag, so Dispose() is idempotent no matter how many variables point to it.

Methods

Dispose()

Ends the structure (calls EndWriteStruct()). Idempotent: calling this more than once only ends the structure once.

public void Dispose()