39 private readonly Func<T> _getter;
40 private readonly Action<T> _setter;
47 public Ref(Func<T> getter, Action<T> setter)
58 get {
return _getter(); }
59 set { _setter(value); }
68 return new Ref<T>(_getter, value =>
70 throw new InvalidOperationException(
"This instance is read-only.");
78 public static class Ref
85 return new Ref<T>(getter, setter);
92 return new Ref<T>(getter, value =>
94 throw new InvalidOperationException(
"This instance is read-only.");
106 return new Ref<T>(() => initialValue, value => { initialValue = value; });