public unsafe CGFunction(nfloat []?domain, nfloat []?range, CGFunctionEvaluate callback) { if (domain is not null) { if ((domain.Length % 2) != 0) { throw new ArgumentException("The domain array must consist of pairs of values", nameof(domain)); } } if (range is not null) { if ((range.Length % 2) != 0) { throw new ArgumentException("The range array must consist of pairs of values", nameof(range)); } } if (callback is null) { throw new ArgumentNullException(nameof(callback)); } this.evaluate = callback; var gch = GCHandle.Alloc(this); var handle = CGFunctionCreate(GCHandle.ToIntPtr(gch), domain != null ? domain.Length / 2 : 0, domain, range != null ? range.Length / 2 : 0, range, ref cbacks); InitializeHandle(handle); }
public unsafe CGFunction(float [] domain, float [] range, CGFunctionEvaluate callback) { if (domain != null) { if ((domain.Length % 2) != 0) { throw new ArgumentException("The domain array must consist of pairs of values", "domain"); } } if (range != null) { if ((range.Length % 2) != 0) { throw new ArgumentException("The range array must consist of pairs of values", "range"); } } if (callback == null) { throw new ArgumentNullException("callback"); } this.evaluate = callback; CGFunctionCallbacks cbacks; cbacks.version = 0; cbacks.evaluate = new CGFunctionEvaluateCallback(EvaluateCallback); cbacks.release = IntPtr.Zero; gch = GCHandle.Alloc(this); handle = CGFunctionCreate(GCHandle.ToIntPtr(gch), domain != null ? domain.Length / 2 : 0, domain, range != null ? range.Length / 2 : 0, range, ref cbacks); }
protected virtual void Dispose (bool disposing) { if (handle != IntPtr.Zero){ CGFunctionRelease (handle); handle = IntPtr.Zero; gch.Free (); evaluate = null; } }
protected virtual void Dispose(bool disposing) { if (handle != IntPtr.Zero) { CGFunctionRelease(handle); handle = IntPtr.Zero; gch.Free(); evaluate = null; } }
public unsafe CGFunction(float [] domain, float [] range, CGFunctionEvaluate callback) { if (domain != null){ if ((domain.Length % 2) != 0) throw new ArgumentException ("The domain array must consist of pairs of values", "domain"); } if (range != null) { if ((range.Length % 2) != 0) throw new ArgumentException ("The range array must consist of pairs of values", "range"); } if (callback == null) throw new ArgumentNullException ("callback"); this.evaluate = callback; CGFunctionCallbacks cbacks; cbacks.version = 0; cbacks.evaluate = new CGFunctionEvaluateCallback (EvaluateCallback); cbacks.release = IntPtr.Zero; gch = GCHandle.Alloc (this); handle = CGFunctionCreate (GCHandle.ToIntPtr (gch), domain != null ? domain.Length/2 : 0, domain, range != null ? range.Length/2 : 0, range, ref cbacks); }