protected void SetArrayValue(NSString key, INativeObject[] values) { if (NullCheckAndRemoveKey(key, values == null)) { CFMutableDictionary.SetValue(Dictionary.Handle, key.Handle, CFArray.FromNativeObjects(values).Handle); } }
public IDictionary <IOHIDElement, IOHIDValue> GetValues(IOHIDElement[] elements) { ThrowIfDisposed(); if (elements == null) { throw new ArgumentNullException("elements"); } var elementArray = CFArray.FromNativeObjects(elements); IOHIDElement[] keys = new IOHIDElement[elements.Length]; IOHIDValue[] values = new IOHIDValue[elements.Length]; CFDictionary multiple = CFDictionary.FromObjectsAndKeys(values, keys); var multipleRef = multiple.Handle; var result = IOHIDDeviceCopyValueMultiple(Handle, elementArray.Handle, ref multipleRef); IOObject.ThrowIfError(result); var dict = new Dictionary <IOHIDElement, IOHIDValue> (multiple.Count); IntPtr[] keyRefs, valueRefs; multiple.GetKeysAndValues(out keyRefs, out valueRefs); for (int i = 0; i < multiple.Count; i++) { dict.Add(new IOHIDElement(keyRefs [i], true), new IOHIDValue(valueRefs [i], true)); } CFType.Release(multiple.Handle); return(dict); }
public static bool MatchFontDescriptors(CTFontDescriptor[] descriptors, NSSet mandatoryAttributes, Func <CTFontDescriptorMatchingState, IntPtr, bool> progressHandler) { var ma = mandatoryAttributes == null ? IntPtr.Zero : mandatoryAttributes.Handle; // FIXME: SIGSEGV probably due to mandatoryAttributes mismatch using (var ar = CFArray.FromNativeObjects(descriptors)) { return(CTFontDescriptorMatchFontDescriptorsWithProgressHandler(ar.Handle, ma, progressHandler)); } }
public SecStatusCode SetAnchorCertificates(SecCertificate[] array) { if (array == null) { return(SecTrustSetAnchorCertificates(handle, IntPtr.Zero)); } using (var certs = CFArray.FromNativeObjects(array)) { return(SecTrustSetAnchorCertificates(handle, certs.Handle)); } }
static IntPtr Create(CGColorSpace?colorspace, CGColor [] colors) { if (colors is null) { throw new ArgumentNullException(nameof(colors)); } using (var array = CFArray.FromNativeObjects(colors)) return(CGGradientCreateWithColors(colorspace.GetHandle(), array.Handle, null)); }
public CTFontCollection?WithFontDescriptors(CTFontDescriptor[]?queryDescriptors, CTFontCollectionOptions?options) { using var descriptors = queryDescriptors is null ? null : CFArray.FromNativeObjects(queryDescriptors); var h = CTFontCollectionCreateCopyWithFontDescriptors(Handle, descriptors.GetHandle(), options.GetHandle()); if (h == IntPtr.Zero) { return(null); } return(new CTFontCollection(h, true)); }
public CGGradient(CGColorSpace colorspace, CGColor [] colors) { if (colors == null) { throw new ArgumentNullException("colors"); } IntPtr csh = colorspace == null ? IntPtr.Zero : colorspace.handle; using (var array = CFArray.FromNativeObjects(colors)) handle = CGGradientCreateWithColors(csh, array.Handle, null); }
static IntPtr Create(CGColorSpace?colorspace, CGColor [] colors, nfloat []?locations) { // colors is __nullable but would return a `nil` instance back, // which is not something we can handle nicely from a .NET constructor if (colors is null) { throw new ArgumentNullException(nameof(colors)); } using (var array = CFArray.FromNativeObjects(colors)) return(CGGradientCreateWithColors(colorspace.GetHandle(), array.Handle, locations)); }
public CTFontCollection(CTFontDescriptor[] queryDescriptors, CTFontCollectionOptions options) { using (var descriptors = queryDescriptors == null ? null : CFArray.FromNativeObjects(queryDescriptors)) handle = CTFontCollectionCreateWithFontDescriptors( descriptors == null ? IntPtr.Zero : descriptors.Handle, options == null ? IntPtr.Zero : options.Dictionary.Handle); if (handle == IntPtr.Zero) { throw ConstructorError.Unknown(this); } }
public CGGradient(CGColorSpace colorspace, CGColor [] colors, nfloat [] locations) { // colors is __nullable but would return a `nil` instance back, // which is not something we can handle nicely from a .NET constructor if (colors == null) { throw new ArgumentNullException("colors"); } IntPtr csh = colorspace == null ? IntPtr.Zero : colorspace.handle; using (var array = CFArray.FromNativeObjects(colors)) handle = CGGradientCreateWithColors(csh, array.Handle, locations); }
protected void SetArrayValue(NSString key, INativeObject[] values) { if (key == null) { throw new ArgumentNullException("key"); } if (values == null) { RemoveValue(key); return; } CFMutableDictionary.SetValue(Dictionary.Handle, key.Handle, CFArray.FromNativeObjects(values).Handle); }
public CTFontCollection WithFontDescriptors(CTFontDescriptor[] queryDescriptors, CTFontCollectionOptions options) { IntPtr h; using (var descriptors = queryDescriptors == null ? null : CFArray.FromNativeObjects(queryDescriptors)) { h = CTFontCollectionCreateCopyWithFontDescriptors( handle, descriptors == null ? IntPtr.Zero : descriptors.Handle, options == null ? IntPtr.Zero : options.Dictionary.Handle); } if (h == IntPtr.Zero) { return(null); } return(new CTFontCollection(h, true)); }
void Initialize(SecCertificate[] array, SecPolicy policy) { using (var certs = CFArray.FromNativeObjects(array)) { Initialize(certs.Handle, policy); } }
static IntPtr Create(CTFontDescriptor []?queryDescriptors, CTFontCollectionOptions?options) { using var descriptors = queryDescriptors is null ? null : CFArray.FromNativeObjects(queryDescriptors); return(CTFontCollectionCreateWithFontDescriptors(descriptors.GetHandle(), options.GetHandle())); }
SecStatusCode SetAnchorCertificates(SecCertificate[] array) { using (var certs = CFArray.FromNativeObjects(array)) { return(SecTrustSetAnchorCertificates(Handle, certs.Handle)); } }