Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.21 KB

README.md

File metadata and controls

28 lines (19 loc) · 1.21 KB

Ephemera

.NET ephemerons

Attach and use properties to objects at run-time which are automatically collected after the host object is collected.

This is accomplished with weak-references, implemented in the ConditionalWeakTable class

.NET support NuGet package
>= Framework 4.0 || >= Standard 2.0 NuGet Status

Usage

var foo = new Foo();

// Attach some things to `foo`
foo.Fmrn().Set("Name", "Value");
foo.Fmrn().Set("Bar", new Bar());

// Retrieve them
var bar = foo.Fmrn().Get<Bar>("Bar");
var name = foo.Fmrn().Get<String>("Name");

// Retrieve with `TryGet`
var didGetUnsetProperty = foo.Fmrn().TryGet("Nope", out var unset);