コード例 #1
0
ファイル: ArrayTest.cs プロジェクト: cwensley/xamarin-macios
        public void ArrayFromHandleFuncTest_bool_false()
        {
            var handle = CFArray.Create(TestArray);
            var a      = CFArray.ArrayFromHandleFunc <string> (handle, (v) => CFString.FromHandle(v), false);

            VerifyArray(a);
            Assert.AreEqual((nint)1, CFGetRetainCount(handle), "RC");
            CFRelease(handle);
        }
コード例 #2
0
        public CTFontDescriptor [] GetMatchingFontDescriptors(CTFontCollectionOptions?options)
        {
            var cfArrayRef = CTFontCollectionCreateMatchingFontDescriptorsWithOptions(Handle, options.GetHandle());

            if (cfArrayRef == IntPtr.Zero)
            {
                return(Array.Empty <CTFontDescriptor> ());
            }
            return(CFArray.ArrayFromHandleFunc(cfArrayRef, fd => new CTFontDescriptor(fd, false), true) !);
        }
コード例 #3
0
        public CTFontDescriptor[] GetMatchingFontDescriptors(NSSet?mandatoryAttributes)
        {
            var cfArrayRef = CTFontDescriptorCreateMatchingFontDescriptors(Handle, mandatoryAttributes.GetHandle());

            if (cfArrayRef == IntPtr.Zero)
            {
                return(Array.Empty <CTFontDescriptor> ());
            }
            return(CFArray.ArrayFromHandleFunc(cfArrayRef, fd => new CTFontDescriptor(cfArrayRef, false), true) !);
        }
コード例 #4
0
ファイル: PrintCore.cs プロジェクト: cwensley/xamarin-macios
        public static PMStatusCode CreatePrinterList(out PMPrinter []?printerList)
        {
            var code = PMServerCreatePrinterList(IntPtr.Zero /* ServerLocal */, out var arr);

            if (code != PMStatusCode.Ok)
            {
                printerList = null;
                return(code);
            }
            printerList = CFArray.ArrayFromHandleFunc <PMPrinter> (arr, (handle) => new PMPrinter(handle, false), true);
            return(PMStatusCode.Ok);
        }
コード例 #5
0
ファイル: PrintCore.cs プロジェクト: cwensley/xamarin-macios
        public PMStatusCode TryGetPaperList(out PMPaper []?paperList)
        {
            var code = PMPrinterGetPaperList(Handle, out var m);

            if (code != PMStatusCode.Ok)
            {
                paperList = null;
                return(code);
            }
            paperList = (PMPaper [])CFArray.ArrayFromHandleFunc <PMPaper> (m, (handle) => new PMPaper(handle, false)) !;
            return(PMStatusCode.Ok);
        }
コード例 #6
0
        public CTFontDescriptor?[]? GetMatchingFontDescriptors(Comparison <CTFontDescriptor> comparer)
        {
            GCHandle comparison = GCHandle.Alloc(comparer);

            try {
                var cfArrayRef = CTFontCollectionCreateMatchingFontDescriptorsSortedWithCallback(
                    Handle,
                    new CTFontCollectionSortDescriptorsCallback(CompareDescriptors),
                    GCHandle.ToIntPtr(comparison));
                if (cfArrayRef == IntPtr.Zero)
                {
                    return(Array.Empty <CTFontDescriptor> ());
                }
                return(CFArray.ArrayFromHandleFunc(cfArrayRef, fd => new CTFontDescriptor(fd, false), true) !);
            }
            finally {
                comparison.Free();
            }
        }
コード例 #7
0
        public CGImageMetadataTag []? GetTags()
        {
            var result = CGImageMetadataCopyTags(Handle);

            return(CFArray.ArrayFromHandleFunc(result, (handle) => new CGImageMetadataTag(handle, false), true));
        }
コード例 #8
0
        public CGPDFStream?[]? GetStreams()
        {
            var rv = CGPDFContentStreamGetStreams(Handle);

            return(CFArray.ArrayFromHandleFunc(rv, (handle) => new CGPDFStream(handle)));
        }