Esempio n. 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (handle != IntPtr.Zero)
     {
         CFObject.CFRelease(handle);
         handle = IntPtr.Zero;
     }
 }
Esempio n. 2
0
 public void Dispose(bool disposing)
 {
     if (handle != IntPtr.Zero)
     {
         CFObject.CFRelease(handle);
         handle = IntPtr.Zero;
     }
 }
        public virtual void Dispose(bool disposing)
#endif
        {
            if (Handle != IntPtr.Zero)
            {
                CFObject.CFRelease(Handle);
                Handle = IntPtr.Zero;
            }
        }
Esempio n. 4
0
 protected virtual void Dispose(bool disposing)
 {
     if (handle != IntPtr.Zero)
     {
         CFObject.CFRelease(handle);
     }
     handle      = IntPtr.Zero;
     AddressBook = null;
 }
Esempio n. 5
0
 protected override bool ReleaseHandle()
 {
     if (handle != IntPtr.Zero)
     {
         CFObject.CFRelease(handle);
     }
     SetHandle(IntPtr.Zero);
     return(true);
 }
		public NSObject GetLocalizedAttribute (NSString attribute, out NSString language)
		{
			IntPtr lang;
			var o = Runtime.GetNSObject (CTFontDescriptorCopyLocalizedAttribute (handle, attribute.Handle, out lang));
			o.DangerousRelease ();
			language = (NSString) Runtime.GetNSObject (lang);
			if (lang != IntPtr.Zero)
				CFObject.CFRelease (lang);
			return o;
		}
Esempio n. 7
0
 protected override bool ReleaseHandle()
 {
     if (owner != IntPtr.Zero)
     {
         CFObject.CFRelease(owner);
         owner = IntPtr.Zero;
         SetHandle(IntPtr.Zero);
         return(true);
     }
     return(base.ReleaseHandle());
 }
		public CTFontDescriptor[] GetMatchingFontDescriptors (NSSet mandatoryAttributes)
		{
			var cfArrayRef = CTFontDescriptorCreateMatchingFontDescriptors (handle, 
						mandatoryAttributes == null ? IntPtr.Zero : mandatoryAttributes.Handle);
			if (cfArrayRef == IntPtr.Zero)
				return new CTFontDescriptor [0];
			var matches = NSArray.ArrayFromHandle (cfArrayRef,
					fd => new CTFontDescriptor (cfArrayRef, false));
			CFObject.CFRelease (cfArrayRef);
			return matches;
		}
Esempio n. 9
0
        protected virtual void Dispose(bool disposing)
        {
            if (handle != IntPtr.Zero)
            {
                lock (handles)
                    handles.Remove(handle);

                CFObject.CFRelease(handle);
                handle = IntPtr.Zero;
            }
        }
Esempio n. 10
0
        static string ReturnString(IntPtr newStringHandle)
        {
            if (newStringHandle == IntPtr.Zero)
            {
                return(null);
            }
            var ret = CFString.FetchString(newStringHandle);

            CFObject.CFRelease(newStringHandle);
            return(ret);
        }
Esempio n. 11
0
        public NSObject GetLocalizedAttribute(NSString attribute, out NSString language)
        {
            IntPtr lang;
            var    o = Runtime.GetNSObject(CTFontDescriptorCopyLocalizedAttribute(handle, attribute.Handle, out lang));

            language = Runtime.GetNSObject <NSString> (lang);
            if (lang != IntPtr.Zero)
            {
                CFObject.CFRelease(lang);
            }
            return(o);
        }
Esempio n. 12
0
 protected virtual void Dispose(bool disposing)
 {
     if (handle != IntPtr.Zero)
     {
         CFObject.CFRelease(handle);
     }
     if (sender.IsAllocated)
     {
         sender.Free();
     }
     handle = IntPtr.Zero;
 }
Esempio n. 13
0
        protected virtual void Dispose(bool disposing)
        {
            if (invalidate.IsAllocated)
            {
                invalidate.Free();
            }

            if (handle != IntPtr.Zero)
            {
                CFObject.CFRelease(handle);
                handle = IntPtr.Zero;
            }
        }
        public string[] GetSupportedLanguages()
        {
            var cfArrayRef = CTFontCopySupportedLanguages(handle);

            if (cfArrayRef == IntPtr.Zero)
            {
                return(new string [0]);
            }
            var languages = NSArray.ArrayFromHandle <string> (cfArrayRef, CFString.FetchString);

            CFObject.CFRelease(cfArrayRef);
            return(languages);
        }
Esempio n. 15
0
 protected virtual void Dispose(bool disposing)
 {
     queueObjects = null;
     if (handle != IntPtr.Zero)
     {
         CFObject.CFRelease(handle);
         handle = IntPtr.Zero;
     }
     if (gch.IsAllocated)
     {
         gch.Free();
     }
 }
Esempio n. 16
0
        // according to webkit source code (the only use I could find) this is an array of CFString
        // https://github.com/WebKit/webkit/blob/master/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
        static public string[] GetPreferredCharacteristics()
        {
            var handle = MAAudibleMediaCopyPreferredCharacteristics();

            if (handle == IntPtr.Zero)
            {
                return(null);
            }
            var result = NSArray.StringArrayFromHandle(handle);

            CFObject.CFRelease(handle);              // *Copy* API
            return(result);
        }
Esempio n. 17
0
        public CTFontDescriptor[] GetMatchingFontDescriptors()
        {
            var cfArrayRef = CTFontCollectionCreateMatchingFontDescriptors(handle);

            if (cfArrayRef == IntPtr.Zero)
            {
                return(new CTFontDescriptor [0]);
            }
            var matches = NSArray.ArrayFromHandle(cfArrayRef,
                                                  fd => new CTFontDescriptor(fd, false));

            CFObject.CFRelease(cfArrayRef);
            return(matches);
        }
        public CTFontDescriptor [] GetMatchingFontDescriptors(CTFontCollectionOptions options)
        {
            var cfArrayRef = CTFontCollectionCreateMatchingFontDescriptorsWithOptions(handle, options == null ? IntPtr.Zero : options.Dictionary.Handle);

            if (cfArrayRef == IntPtr.Zero)
            {
                return(Array.Empty <CTFontDescriptor> ());
            }
            var matches = NSArray.ArrayFromHandle(cfArrayRef,
                                                  fd => new CTFontDescriptor(fd, false));

            CFObject.CFRelease(cfArrayRef);
            return(matches);
        }
Esempio n. 19
0
        static public SecStatusCode ImportPkcs12(CFData data, CFDictionary options, out CFDictionary [] array)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            IntPtr        handle;
            SecStatusCode code = SecPKCS12Import(data.Handle, options.Handle, out handle);

            array = CFArray.ArrayFromHandle <CFDictionary> (handle, h => new CFDictionary(h, false));
            CFObject.CFRelease(handle);
            return(code);
        }
        public VTStatus CopyBlackPixelBuffer(out CVPixelBuffer pixelBuffer)
        {
            if (Handle == IntPtr.Zero)
            {
                throw new ObjectDisposedException("DecompressionSession");
            }

            IntPtr ret;
            var    result = VTDecompressionSessionCopyBlackPixelBuffer(Handle, out ret);

            pixelBuffer = Runtime.GetINativeObject <CVPixelBuffer> (ret, true);
            CFObject.CFRelease(ret);
            return(result);
        }
Esempio n. 21
0
        static public StatusCode TryGetSupportedInterfaces(out string[] supportedInterfaces)
        {
            IntPtr array = CNCopySupportedInterfaces();

            if (array == IntPtr.Zero)
            {
                supportedInterfaces = null;
                return(StatusCodeError.SCError());
            }

            supportedInterfaces = NSArray.StringArrayFromHandle(array);
            CFObject.CFRelease(array);
            return(StatusCode.OK);
        }
        public CTFontFeatureSettings[] GetFeatureSettings()
        {
            var cfArrayRef = CTFontCopyFeatureSettings(handle);

            if (cfArrayRef == IntPtr.Zero)
            {
                return(new CTFontFeatureSettings [0]);
            }
            var featureSettings = NSArray.ArrayFromHandle(cfArrayRef,
                                                          d => new CTFontFeatureSettings((NSDictionary)Runtime.GetNSObject(d)));

            CFObject.CFRelease(cfArrayRef);
            return(featureSettings);
        }
        public CTFontVariationAxes[] GetVariationAxes()
        {
            var cfArrayRef = CTFontCopyVariationAxes(handle);

            if (cfArrayRef == IntPtr.Zero)
            {
                return(new CTFontVariationAxes [0]);
            }
            var axes = NSArray.ArrayFromHandle(cfArrayRef,
                                               d => new CTFontVariationAxes((NSDictionary)Runtime.GetNSObject(d)));

            CFObject.CFRelease(cfArrayRef);
            return(axes);
        }
Esempio n. 24
0
        public CTFontTable[] GetAvailableTables(CTFontTableOptions options)
        {
            var cfArrayRef = CTFontCopyAvailableTables(handle, options);

            if (cfArrayRef == IntPtr.Zero)
            {
                return(new CTFontTable [0]);
            }
            var tables = NSArray.ArrayFromHandle(cfArrayRef, v => {
                return((CTFontTable)(uint)v);
            });

            CFObject.CFRelease(cfArrayRef);
            return(tables);
        }
Esempio n. 25
0
        public string[] GetEmailAddresses()
        {
            string[] results = null;
            IntPtr   emails;

            if (SecCertificateCopyEmailAddresses(handle, out emails) == 0)
            {
                results = NSArray.StringArrayFromHandle(emails);
                if (emails != IntPtr.Zero)
                {
                    CFObject.CFRelease(emails);
                }
            }
            return(results);
        }
        static SecStatusCode ImportPkcs12(CFData data, CFDictionary options, out CFDictionary[] array)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var code = SecPKCS12Import(data.Handle, options.Handle, out var handle);

            array = CFArray.ArrayFromHandle <CFDictionary> (handle, h => new CFDictionary(h, false));
            if (handle != IntPtr.Zero)
            {
                CFObject.CFRelease(handle);
            }
            return(code);
        }
Esempio n. 27
0
        public CFHTTPMessage GetResponseHeader()
        {
            var handle = GetProperty(_ResponseHeader);

            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            if (CFType.GetTypeID(handle) != CFHTTPMessage.GetTypeID())
            {
                CFObject.CFRelease(handle);
                throw new InvalidCastException();
            }
            return(new CFHTTPMessage(handle));
        }
Esempio n. 28
0
        static InitConstants()
        {
            // ensure we can init.
            CFObject.CFRelease(ABAddressBook.ABAddressBookCreate());

            ABGroupProperty.Init();
            ABLabel.Init();
            ABPersonAddressKey.Init();
            ABPersonDateLabel.Init();
            ABPersonInstantMessageKey.Init();
            ABPersonInstantMessageService.Init();
            ABPersonKindId.Init();
            ABPersonPhoneLabel.Init();
            ABPersonPropertyId.Init();
            ABPersonRelatedNamesLabel.Init();
            ABPersonUrlLabel.Init();
        }
Esempio n. 29
0
        public CFHTTPMessage?GetFinalRequest()
        {
            var handle = GetProperty(_FinalRequest);

            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            if (CFType.GetTypeID(handle) != CFHTTPMessage.GetTypeID())
            {
                CFObject.CFRelease(handle);
                throw new InvalidCastException();
            }

            return(new CFHTTPMessage(handle, true));
        }
Esempio n. 30
0
        public string GetLocalizedName(PMPrinter printer)
        {
            if (printer == null)
            {
                throw new ArgumentNullException(nameof(printer));
            }
            IntPtr name;
            var    code = PMPaperCreateLocalizedName(handle, printer.handle, out name);

            if (code != PMStatusCode.Ok)
            {
                return(null);
            }
            var str = CFString.FetchString(name);

            CFObject.CFRelease(name);
            return(str);
        }