IFPSTools.NET/LibIFPSCC/Driver/SetOnce.cs
zc e16c00799d ifpscc: initial commit
libifpscc: initial commit
readme: document ifpscc/libifpscc
license: add credits for ifpscc/libifpscc (derived from code also MIT licensed)
libifps: make additional fields/types public for libifpscc
libifps: fix field documentation for some opcodes
libifps: fix loading functions that are not exported
libifps: allow saving a nonexistant primitive type if the same primitive type was added already
libifps: fix parsing Extended constants
libifps: fix ushort/short being mapped to the wrong types in one table
csproj: set Prefer32Bit=false for release builds
2023-03-28 17:24:19 +01:00

30 lines
632 B
C#

using System;
public class SetOnce<T> {
public SetOnce() {
this.IsSet = false;
this._value = default(T);
}
public Boolean IsSet { get; private set; }
private T _value;
public T Value {
get {
if (!this.IsSet) {
throw new InvalidOperationException("Value hasn't been set.");
}
return this._value;
}
set {
if (this.IsSet) {
throw new InvalidOperationException("Value cannot be set twice.");
}
this._value = value;
this.IsSet = true;
}
}
}