Exemple #1
0
        void ReportScanResult(NSString result)
        {
            QRCodeGlobalObject.TheQRCodeReaderViewController.ReturnResult(result.ToString());

            NSData        data       = NSData.FromFile(NSBundle.MainBundle.PathForResource("beep", "wav"));
            NSError       error      = new NSError();
            AVAudioPlayer beepPlayer = new AVAudioPlayer(data, "", out error);

            beepPlayer.Play();
        }
        private static bool ValidateLeafPublicKey(SecTrust securitySecTrust)
        {
            var first       = securitySecTrust[0].DerData;
            var firstString = first.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            var cert       = NSData.FromFile("xamarin.cer");
            var certString = cert.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            return(firstString == certString);
        }
Exemple #3
0
        private async Task PerformUploadToBlobAsync()
        {
            string str        = NSBundle.MainBundle.PathForResource("image1", "jpg");
            var    data       = NSData.FromFile(str);
            var    imageBytes = data.ToArray();

            var res = await _azureBlobStorageProxy.AddBytesToBlobAsync(imageBytes, "ocrcontactblob");

            Console.WriteLine(res.Item1.ToString());
        }
Exemple #4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            var path = NSBundle.MainBundle.PathForResource(HtmlFile, "html");

            using (var data = NSData.FromFile(path)) {
                var html = new NSString(data, NSStringEncoding.UTF8);
                InstructionWebView.LoadHtmlString(html.ToString(), NSBundle.MainBundle.BundleUrl);
            }
        }
Exemple #5
0
 public void FromData()
 {
     using (NSData data = NSData.FromFile("EmptyNib.nib"))
         using (UINib n = UINib.FromData(data, null)) {
             Assert.NotNull(n, "created with null options");
             // newer version (same selector)
             var result2 = n.Instantiate(null, null);
             Assert.That(result2.Length, Is.EqualTo(0), "Instantiate");
         }
 }
        private static bool ValidateIntermediatePublicKey(SecTrust securitySecTrust)
        {
            var first       = securitySecTrust[1].DerData;
            var firstString = first.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            var cert       = NSData.FromFile("microsoftit.cer");
            var certString = cert.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            return(firstString == certString);
        }
Exemple #7
0
        private void sendMail(object sender, EventArgs e)
        {
            mailCtrl.SetMessageBody("ICOM Archivo PDF", false);
            NSData nsdf = NSData.FromFile(urlDocumento);

            mailCtrl.AddAttachmentData(nsdf, "pdf", tituloDocumento);


            this.PresentViewController(mailCtrl, true, null);
        }
Exemple #8
0
        public void CreateFontDescriptor()
        {
            Assert.Throws <ArgumentNullException> (() => CTFontManager.CreateFontDescriptor(null), "null");

            using (var data = NSData.FromFile(pacifico_ttf_path))
                Assert.NotNull(CTFontManager.CreateFontDescriptor(data), "font");

            using (var data = NSData.FromFile(tamarin_pdf_path))
                Assert.Null(CTFontManager.CreateFontDescriptor(data), "not a font");
        }
Exemple #9
0
        static Task ComposeWithMailCompose(EmailMessage message)
        {
            // do this first so we can throw as early as possible
            var parentController = Platform.GetCurrentViewController();

            // create the controller
            var controller = new MFMailComposeViewController();

            if (!string.IsNullOrEmpty(message?.Body))
            {
                controller.SetMessageBody(message.Body, message.BodyFormat == EmailBodyFormat.Html);
            }
            if (!string.IsNullOrEmpty(message?.Subject))
            {
                controller.SetSubject(message.Subject);
            }
            if (message?.To?.Count > 0)
            {
                controller.SetToRecipients(message.To.ToArray());
            }
            if (message?.Cc?.Count > 0)
            {
                controller.SetCcRecipients(message.Cc.ToArray());
            }
            if (message?.Bcc?.Count > 0)
            {
                controller.SetBccRecipients(message.Bcc.ToArray());
            }

            if (message?.Attachments?.Count > 0)
            {
                foreach (var attachment in message.Attachments)
                {
                    var data = NSData.FromFile(attachment.FullPath);
                    if (data == null)
                    {
                        throw new FileNotFoundException($"Attachment {attachment.FileName} not found.", attachment.FullPath);
                    }

                    controller.AddAttachmentData(data, attachment.ContentType, attachment.FileName);
                }
            }

            // show the controller
            var tcs = new TaskCompletionSource <bool>();

            controller.Finished += (sender, e) =>
            {
                controller.DismissViewController(true, null);
                tcs.TrySetResult(e.Result == MFMailComposeResult.Sent);
            };
            parentController.PresentViewController(controller, true, null);

            return(tcs.Task);
        }
            public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action <NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
            {
                // case for the basic auth failing up front. As per apple documentation:
                // The URL Loading System is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers using
                // the addValue(_:forHTTPHeaderField:) or setValue(_:forHTTPHeaderField:) methods:
                //  Authorization
                //  Connection
                //  Host
                //  Proxy-Authenticate
                //  Proxy-Authorization
                //  WWW-Authenticate
                // but we are hiding such a situation from our users, we can nevertheless know if the header was added and deal with it. The idea is as follows,
                // check if we are in the first attempt, if we are (PreviousFailureCount == 0), we check the headers of the request and if we do have the Auth
                // header, it means that we do not have the correct credentials, in any other case just do what it is expected.

                if (challenge.PreviousFailureCount == 0)
                {
                    var authHeader = GetInflightData(task)?.Request?.Headers?.Authorization;
                    if (!(string.IsNullOrEmpty(authHeader?.Scheme) && string.IsNullOrEmpty(authHeader?.Parameter)))
                    {
                        completionHandler(NSUrlSessionAuthChallengeDisposition.RejectProtectionSpace, null);
                        return;
                    }
                }

                if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNTLM)
                {
                    if (sessionHandler.Credentials != null)
                    {
                        var credentialsToUse = sessionHandler.Credentials as NetworkCredential;
                        if (credentialsToUse == null)
                        {
                            var uri = GetInflightData(task).Request.RequestUri;
                            credentialsToUse = sessionHandler.Credentials.GetCredential(uri, "NTLM");
                        }
                        var credential = new NSUrlCredential(credentialsToUse.UserName, credentialsToUse.Password, NSUrlCredentialPersistence.ForSession);
                        completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, credential);
                    }
                    return;
                }

                //NOTE: SSL Pinning here
                var serverCertChain = challenge.ProtectionSpace.ServerSecTrust;
                var first           = serverCertChain[0].DerData;
                var cert            = NSData.FromFile("httpbin.cer");

                if (first.IsEqual(cert))
                {
                    completionHandler(NSUrlSessionAuthChallengeDisposition.PerformDefaultHandling, challenge.ProposedCredential);
                }
                else
                {
                    completionHandler(NSUrlSessionAuthChallengeDisposition.CancelAuthenticationChallenge, null);
                }
            }
        public void SendEmail(IEmailMessage email)
        {
            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }

            if (CanSendEmail)
            {
                _mailController = new MFMailComposeViewController();
                _mailController.SetSubject(email.Subject);
                _mailController.SetMessageBody(email.Message, ((EmailMessage)email).IsHtml);
                _mailController.SetToRecipients(email.Recipients.ToArray());

                if (email.RecipientsCc.Count > 0)
                {
                    _mailController.SetCcRecipients(email.RecipientsCc.ToArray());
                }

                if (email.RecipientsBcc.Count > 0)
                {
                    _mailController.SetBccRecipients(email.RecipientsBcc.ToArray());
                }

                foreach (var attachment in email.Attachments.Cast <EmailAttachment>())
                {
                    if (attachment.Content == null)
                    {
                        _mailController.AddAttachmentData(NSData.FromFile(attachment.FilePath), attachment.ContentType, attachment.FileName);
                    }
                    else
                    {
                        _mailController.AddAttachmentData(NSData.FromStream(attachment.Content), attachment.ContentType, attachment.FileName);
                    }
                }

                EventHandler <MFComposeResultEventArgs> handler = null;
                handler = (sender, e) =>
                {
                    _mailController.Finished -= handler;

                    var uiViewController = sender as UIViewController;
                    if (uiViewController == null)
                    {
                        throw new ArgumentException("sender");
                    }

                    uiViewController.DismissViewController(true, () => { });
                };

                _mailController.Finished += handler;

                _mailController.PresentUsingRootViewController();
            }
        }
Exemple #12
0
        public NSData GetCachedImage(string path)
        {
            var imageData = NSData.FromFile(path);

            if (imageData == null)
            {
                throw new InvalidOperationException($"Unable to load image stream data from '{path}'.");
            }

            return(imageData);
        }
Exemple #13
0
        private UIImage GetImage(string path)
        {
            var imageData = NSData.FromFile(path);

            if (imageData == null)
            {
                return(null);
            }

            return(new UIImage(imageData));
        }
Exemple #14
0
        public void FromFile()
        {
            Assert.Null(NSData.FromFile("does not exists"), "unexisting");
#if MONOMAC || __MACCATALYST__
            // Info.Plist isn't there to load from the same location on mac
            var plistPath = Path.Combine(NSBundle.MainBundle.BundlePath, "Contents", "Info.plist");
#else
            var plistPath = Path.Combine(NSBundle.MainBundle.BundlePath, "Info.plist");
#endif
            Assert.NotNull(NSData.FromFile(plistPath), "Info.plist");
        }
        public void FromFile()
        {
            Assert.Null(NSData.FromFile("does not exists"), "unexisting");
#if MONOMAC // Info.Plist isn't there to load from the same location on mac
#if !LINKALL
            Assert.NotNull(NSData.FromFile(NSBundle.MainBundle.PathForResource("runtime-options", "plist")), "runtime-options.plist");
#endif
#else
            Assert.NotNull(NSData.FromFile("Info.plist"), "Info.plist");
#endif
        }
        public void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream stream)
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                var mailer = new MFMailComposeViewController();

                mailer.SetMessageBody(messagebody ?? string.Empty, false);
                mailer.SetSubject(subject ?? subject);
                mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { });


                string exception = string.Empty;
                string path      = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                string filePath  = Path.Combine(path, fileName);
                try
                {
                    FileStream fileStream = File.Open(filePath, FileMode.Create);
                    stream.Position = 0;
                    stream.CopyTo(fileStream);
                    fileStream.Flush();
                    fileStream.Close();
                }
                catch (Exception e)
                {
                    exception = e.ToString();
                }
                finally
                {
                }


                mailer.AddAttachmentData(NSData.FromFile(filePath), GetMimeType(fileName), Path.GetFileName(fileName));



                UIViewController vc = UIApplication.SharedApplication.KeyWindow.RootViewController;
                while (vc.PresentedViewController != null)
                {
                    vc = vc.PresentedViewController;
                }
                vc.PresentViewController(mailer, true, null);
            }
            else
            {
                var alertController = UIAlertController.Create("Email not supported", "Please configure the email to send PDF document", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                UIViewController vc = UIApplication.SharedApplication.KeyWindow.RootViewController;
                while (vc.PresentedViewController != null)
                {
                    vc = vc.PresentedViewController;
                }
                vc.PresentViewController(alertController, true, null);
            }
        }
        private static bool IsValid(NSUrlAuthenticationChallenge challenge)
        {
            var serverCertChain = challenge.ProtectionSpace.ServerSecTrust;

            var first       = serverCertChain[0].DerData;
            var firstString = first.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            var cert       = NSData.FromFile("xamarin.cer");
            var certString = cert.GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            return(firstString == certString);
        }
        /// <summary> Creates the AudioData </summary>
        /// <param name="filename"></param>
        private AudioData(String filename)
        {
            Filename = filename;
#if __ANDROID__
            _AssetFileDescriptor = GameActivity.Instance.Assets.OpenFd(filename);
            Descriptor           = _AssetFileDescriptor.FileDescriptor;
            StartOffset          = _AssetFileDescriptor.StartOffset;
            Length = _AssetFileDescriptor.Length;
#elif __IOS__
            Data = NSData.FromFile(filename);
#endif
        }
Exemple #19
0
 public byte[] GetFileBinary(string filePath, bool resourceFile)
 {
     //TODO implement resource file
     try
     {
         NSData data = NSData.FromFile(CreatePathToFile(filePath));
         return(data.ToArray());
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var licensePath = Path.Combine(NSBundle.MainBundle.BundlePath, "License/AbbyyRtrSdk.license");

            engine = RTREngine.SharedEngineWithLicenseData(NSData.FromFile(licensePath));

            if (engine == null)
            {
                throw new InvalidOperationException("tmp");
            }

            textCaptureServiceDelegate = new TextCaptureServiceDelegate(this);
            textCaptureService         = engine.CreateTextCaptureServiceWithDelegate(textCaptureServiceDelegate);

            NSSet selectedRecognitionLanguages = new NSSet("English");

            textCaptureService.SetRecognitionLanguages(selectedRecognitionLanguages);

            //self.languagesTableView.register(UITableViewCell.self, forCellReuseIdentifier: RTRVideoScreenCellName)
            //self.languagesTableView.tableFooterView = UIView(frame: CGRect.zero)
            languagesTableView.Hidden = true;

            captureButton.Selected = false;
            captureButton.SetTitle("Stop", UIControlState.Selected);
            captureButton.SetTitle("Start", UIControlState.Normal);

            //let recognizeLanguageButtonTitle = self.languagesButtonTitle()
            //self.recognizeLanguageButton.title = recognizeLanguageButtonTitle

            var status = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);

            switch (status)
            {
            case AVAuthorizationStatus.Authorized:
                ConfigureCompletionAccess(true);
                break;

            case AVAuthorizationStatus.NotDetermined:
                var granted = await AVCaptureDevice.RequestAccessForMediaTypeAsync(AVMediaType.Video);

                ConfigureCompletionAccess(granted);
                break;

            case AVAuthorizationStatus.Restricted:
            case AVAuthorizationStatus.Denied:
                ConfigureCompletionAccess(false);
                break;
            }
        }
Exemple #21
0
        public void Data()
        {
#if MONOMAC || __MACCATALYST__
            // Info.Plist isn't there to load from the same location on mac
            var plistPath = global::System.IO.Path.Combine(NSBundle.MainBundle.BundlePath, "Contents", "Info.plist");
#else
            var plistPath = global::System.IO.Path.Combine(NSBundle.MainBundle.BundlePath, "Info.plist");
#endif
            using (var d = NSData.FromFile(plistPath))
                using (var s = new NSInputStream(d)) {
                    // initWithData: does not respond (see dontlink.app) but it works
                    Assert.That(s.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle");
                }
        }
        /// <summary>
        /// Async converter that retrieves an image from an url, stores it in local storage with an expiration date.
        /// </summary>
        /// <returns>The string to cached image.</returns>
        /// <param name="expiration">Expiration.</param>
        public static IConverter <string, Task <UIImage> > AsyncStringToCachedImage(TimeSpan expiration) => new RelayConverter <string, Task <UIImage> >(async(value) =>
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }

            var localPath = await FileCache.Default.DownloadCachedFile(value, expiration);

            // Reading image from cache
            NSError err;
            using (var data = NSData.FromFile(localPath, NSDataReadingOptions.Mapped, out err))
                return(UIImage.LoadFromData(data));
        });
Exemple #23
0
        public CitiesDataSource()
        {
            var citiesJSONURL  = NSBundle.MainBundle.PathForResource("Cities", "json");
            var citiesJSONData = NSData.FromFile(citiesJSONURL);
            var jsonObject     = NSJsonSerialization.Deserialize(citiesJSONData, default(NSJsonReadingOptions), out NSError error);

            if (jsonObject is NSArray jsonCities)
            {
                for (nuint i = 0; i < jsonCities.Count; i++)
                {
                    cities.Add(jsonCities.GetItem <NSString>(i));
                }
            }
        }
Exemple #24
0
        public void CopyImageSource()
        {
            TestRuntime.AssertXcodeVersion(5, 0);

            using (NSData data = NSData.FromFile(NSBundle.MainBundle.PathForResource("xamarin2", "png")))
                using (var source = CGImageSource.FromData(data))
                    using (NSMutableData destData = new NSMutableData())
                        using (var id = CGImageDestination.Create(destData, GoodUti, 1)) {
                            NSError err;
                            // testing that null is allowed (no crash) so the fact that is return false and an error does not matter
                            Assert.False(id.CopyImageSource(source, (NSDictionary)null, out err), "CopyImageSource");
                            Assert.NotNull(err, "NSError");
                        }
        }
Exemple #25
0
 // https://gist.github.com/steipete/7668246
 public bool?InstalledFromStore()
 {
     try
     {
         // If file doesn't exist, the installation is from AppStore
         var file = NSData.FromFile(NSBundle.MainBundle.PathForResource("embedded", "mobileprovision"));
         return(file == null);
     }
     catch (Exception ex)
     {
         Debug.WriteLine($"Unable to get iOS installation source {ex.Message}");
         return(false);
     }
 }
Exemple #26
0
        private bool createFontTexture(string file)
        {
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.Texture2D);
            GL.GenTextures(1, out texture);
            GL.BindTexture(TextureTarget.Texture2D, texture);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);

            string extension     = Path.GetExtension(file);
            string fileName      = Path.GetFileNameWithoutExtension(file);
            string directoryName = Path.GetDirectoryName(file);
            string path          = NSBundle.MainBundle.PathForResource(fileName, extension, directoryName);
            NSData texData       = NSData.FromFile(path);

            UIImage image = UIImage.LoadFromData(texData);

            if (image == null)
            {
                return(false);
            }

            textureWidth  = image.CGImage.Width;
            textureHeight = image.CGImage.Height;

            GL.Uniform2(texsizeUniform, (float)textureWidth, (float)textureHeight);

            byte [] imageData = new byte[textureWidth * textureHeight * 1];

            using (CGColorSpace colorSpace = CGColorSpace.CreateDeviceGray())
                using (CGContext context = new CGBitmapContext(imageData, textureWidth,
                                                               textureHeight, 8, 1 * textureWidth, colorSpace, CGImageAlphaInfo.None))
                {
                    context.TranslateCTM(0, textureHeight);
                    context.ScaleCTM(1, -1);
                    context.ClearRect(new CGRect(0, 0, textureWidth, textureHeight));
                    context.DrawImage(new CGRect(0, 0, textureWidth, textureHeight), image.CGImage);

                    GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
                    GL.PixelStore(PixelStoreParameter.PackAlignment, 1);
                    GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Luminance, (int)textureWidth,
                                  (int)textureHeight, 0, PixelFormat.Luminance, PixelType.UnsignedByte, imageData);
                }

            return(true);
        }
Exemple #27
0
        public GLTexture(string inFilename)
        {
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);

            filename = inFilename;

            GL.Hint(HintTarget.GenerateMipmapHint, HintMode.Nicest);
            GL.GenTextures(1, out texture);
            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Nearest);

            //TODO Remove the Substring method if you don't support iOS versions prior to iOS 6.
            string extension    = Path.GetExtension(filename).Substring(1);
            string baseFilename = Path.GetFileNameWithoutExtension(filename);

            string path    = NSBundle.MainBundle.PathForResource(baseFilename, extension);
            NSData texData = NSData.FromFile(path);

            UIImage image = UIImage.LoadFromData(texData);

            if (image == null)
            {
                return;
            }

            nint width  = image.CGImage.Width;
            nint height = image.CGImage.Height;

            CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();

            byte []   imageData = new byte[height * width * 4];
            CGContext context   = new CGBitmapContext(imageData, width, height, 8, 4 * width, colorSpace,
                                                      CGBitmapFlags.PremultipliedLast | CGBitmapFlags.ByteOrder32Big);

            context.TranslateCTM(0, height);
            context.ScaleCTM(1, -1);
            colorSpace.Dispose();
            context.ClearRect(new CGRect(0, 0, width, height));
            context.DrawImage(new CGRect(0, 0, width, height), image.CGImage);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)width, (int)height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, imageData);
            context.Dispose();
        }
 partial void SendButtonClick(MonoTouch.Foundation.NSObject sender)
 {
     if (MFMailComposeViewController.CanSendMail)
     {
         var mail = new MFMailComposeViewController();
         mail.SetSubject("Zetetic Message Database");
         mail.SetToRecipients(new string[] {});
         mail.SetMessageBody("Please find a database attached", false);
         mail.AddAttachmentData(NSData.FromFile(_messageDb.FilePath), MessageDb.MIME_TYPE, Path.GetFileName(_messageDb.FilePath));
         mail.Finished += (s, e) => {
             mail.DismissViewController(true, null);
         };
         PresentViewController(mail, true, null);
     }
 }
Exemple #29
0
        public void CreateICCProfile()
        {
            // of all the .icc profiles I have on my Mac then only one I found working is
            // for my old 15" sharp (secondary) display. Added it to the test suite
            // that should work on the iOS simulator - at least some as I'm not sure every Mac
            // has the file(s) so we're not trying (and fialing) to copy it into the bundle
            using (var icc = NSData.FromFile(Path.Combine(NSBundle.MainBundle.ResourcePath, "LL-171A-B-B797E457-16AB-C708-1E0F-32C19DBD47B5.icc")))
                using (var cs = CGColorSpace.CreateICCProfile(icc)) {
                    TestICC(cs);
                }

            using (var space = CGColorSpace.CreateICCProfile((NSData)null)) {
                Assert.IsNull(space, "null data");
            }
        }
Exemple #30
0
        public void CreateFontDescriptors()
        {
            TestRuntime.AssertXcodeVersion(11, 0);
            Assert.Throws <ArgumentNullException> (() => CTFontManager.CreateFontDescriptors(null), "null");

            using (var data = NSData.FromFile(pacifico_ttf_path)) {
                var fds = CTFontManager.CreateFontDescriptors(data);
                Assert.That(fds.Length, Is.EqualTo(1), "font");
            }

            using (var data = NSData.FromFile(tamarin_pdf_path)) {
                var fds = CTFontManager.CreateFontDescriptors(data);
                Assert.That(fds.Length, Is.EqualTo(0), "not font(s)");
            }
        }