This is an add-in for Fody
Implements the Freezable pattern
Nuget package http://nuget.org/packages/Freezable.Fody
To Install from the Nuget Package Manager Console
PM> Install-Package Freezable.Fody
public interface IFreezable
{
void Freeze();
}
public class Person : IFreezable
{
bool isFrozen;
public string Name { get; set; }
public void Freeze()
{
isFrozen = true;
}
}
public class Person : IFreezable
{
volatile bool isFrozen;
public void Freeze()
{
isFrozen = true;
}
void CheckIfFrozen()
{
if (isFrozen)
{
throw new InvalidOperationException("Attempted to modify a frozen instance");
}
}
string name;
public string Name
{
get { return name; }
set
{
CheckIfFrozen();
name = value;
}
}
}
Icon courtesy of The Noun Project