diff --git a/IPA.Loader/Utilities/Ref.cs b/IPA.Loader/Utilities/Ref.cs index 933bcb04..f710ad6a 100644 --- a/IPA.Loader/Utilities/Ref.cs +++ b/IPA.Loader/Utilities/Ref.cs @@ -49,12 +49,32 @@ namespace IPA.Utilities _value = reference; } + /// + /// Converts to referenced type, returning the stored reference. + /// + /// the object to be de-referenced + /// the value referenced by the object + public static implicit operator T(Ref self) + { + return self.Value; + } + + /// + /// Converts a value T to a reference to that object. Will overwrite the reference in the left hand expression if there is one. + /// + /// the value to wrap in the Ref + /// the Ref wrapping the value + public static implicit operator Ref(T toConvert) + { + return new Ref(toConvert); + } + /// /// Throws error if one was set. /// public void Verify() { - if (Error != null) throw new Exception("Found error", Error); + if (Error != null) throw Error; } }