The IImmutable interface - BHoM/documentation GitHub Wiki
TODO: Specify when to use it
How to implement it
To implement the IImmutable
interface, you need to make two actions:
- Inherit from it: i.e.
public class YourObject : IImmutable
- The properties you want to be immutable must be
public
,get
only, and contain a default value. i.e.public string Title { get; } = ""
- All the properties that are not immutable, can follow the usual BHoM conventions,
public
,get
andset
, and have a default value - It must implement only one constructor, whose parameters are types of all the immutable properties of the object.
For an example, you can check the BH.oM.Structure.SectionProperties.SteelSection
from the Structure_oM
:
https://github.com/BHoM/BHoM/blob/master/Structure_oM/SectionProperties/SteelSection.cs