/// <summary> /// Converts from a Java object to a .NET object, using a wrapper class /// </summary> /// <typeparam name="TObject">The .NET type to convert to</typeparam> /// <param name="value">The Java object to convert, which MUST have been initially created with the complimentary ToJavaObject call</param> /// <returns>Returns the converted .NET type</returns> public static TObject ToNetObject <TObject>(this Java.Lang.Object value) { if (value == null) { return(default(TObject)); } if (!(value is JavaHolder)) { throw new InvalidOperationException("Unable to convert to .NET object. Only Java.Lang.Object created with .ToJavaObject() can be converted."); } TObject returnVal; try { returnVal = (TObject)((JavaHolder)value).Instance; } finally { value.Dispose(); } return(returnVal); }
public void Cleanup() => _model?.Dispose();