Пример #1
0
        public static CFHTTPMessage CreateRequest(Uri uri, string method, Version version)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            CFUrl    urlRef    = null;
            NSString methodRef = null;

            var escaped = Uri.EscapeUriString(uri.ToString());

            try {
                urlRef = CFUrl.FromUrlString(escaped, null);
                if (urlRef == null)
                {
                    throw new ArgumentException("Invalid URL.");
                }
                methodRef = new NSString(method);

                return(CreateRequest(urlRef, methodRef, version));
            } finally {
                if (urlRef != null)
                {
                    urlRef.Dispose();
                }
                if (methodRef != null)
                {
                    methodRef.Dispose();
                }
            }
        }
Пример #2
0
        public static AudioFile Open(string url, AudioFilePermission permissions, AudioFileType fileTypeHint)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            using (CFUrl cfurl = CFUrl.FromUrlString(url, null))
                return(Open(cfurl, permissions, fileTypeHint));
        }
Пример #3
0
        public static AudioFile Create(string url, AudioFileType fileType, AudioStreamBasicDescription format, AudioFileFlags inFlags)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            using (CFUrl cfurl = CFUrl.FromUrlString(url, null))
                return(Create(cfurl, fileType, format, inFlags));
        }
Пример #4
0
 public void ToString_()
 {
     using (CFUrl url = CFUrl.FromFile("/")) {
         string value = TestRuntime.CheckSystemAndSDKVersion(7, 0) ? "file:///" : "file://localhost/";
         Assert.That(url.ToString(), Is.EqualTo(value), "FromFile");
     }
     using (CFUrl url = CFUrl.FromUrlString("/", null)) {
         Assert.That(url.ToString(), Is.EqualTo("/"), "FromUrlString");
     }
 }
Пример #5
0
 public static CGPDFDocument FromUrl(string str)
 {
     using (var url = CFUrl.FromUrlString(str, null)){
         if (url == null)
         {
             return(null);
         }
         IntPtr handle = CGPDFDocumentCreateWithURL(url.Handle);
         if (handle == IntPtr.Zero)
         {
             return(null);
         }
         return(new CGPDFDocument(handle, true));
     }
 }
Пример #6
0
        public static CFHTTPMessage CreateRequest(Uri uri, string method, Version?version)
        {
            if (uri is null)
            {
                throw new ArgumentNullException(nameof(uri));
            }

            // the method is obsolete, but EscapeDataString does not work the same way. We could get the components
            // of the Uri and then EscapeDataString, but this might introduce bugs, so for now we will ignore the warning
#pragma warning disable SYSLIB0013
            var escaped = Uri.EscapeUriString(uri.ToString());
#pragma warning restore SYSLIB0013

            using var urlRef = CFUrl.FromUrlString(escaped, null);
            if (urlRef is null)
            {
                throw new ArgumentException("Invalid URL.");
            }
            using var methodRef = new NSString(method);

            return(CreateRequest(urlRef, methodRef, version));
        }
Пример #7
0
        public void ToString_()
        {
            using (CFUrl url = CFUrl.FromFile("/")) {
                string value = "file://localhost/";
#if __IOS__
                if (TestRuntime.CheckSystemVersion(PlatformName.iOS, 7, 0))
                {
                    value = "file:///";
                }
#elif __WATCHOS__ || __TVOS__
                value = "file:///";
#elif __MACOS__
                if (TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 9))
                {
                    value = "file:///";
                }
#endif

                Assert.That(url.ToString(), Is.EqualTo(value), "FromFile");
            }
            using (CFUrl url = CFUrl.FromUrlString("/", null)) {
                Assert.That(url.ToString(), Is.EqualTo("/"), "FromUrlString");
            }
        }
Пример #8
0
 public void RetainCountFromUrl()
 {
     using (var url = CFUrl.FromUrlString("http://xamarin.com", null)) {
         Assert.That(TestRuntime.CFGetRetainCount(url.Handle), Is.EqualTo((nint)1), "RetainCount");
     }
 }
Пример #9
0
 public void FromUrlString_Null()
 {
     CFUrl.FromUrlString(null, CFUrl.FromFile("/"));
 }
Пример #10
0
 public void FromUrlString_Null()
 {
     Assert.Throws <ArgumentNullException> (() => CFUrl.FromUrlString(null, CFUrl.FromFile("/")));
 }