From c7ca76537780b1cda064e275918555981b584103 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Sun, 8 May 2022 14:21:27 -0700 Subject: [PATCH] Uri F# snippets --- snippets/fsharp/System/Uri/.ctor/fs.fsproj | 14 ++ .../System/Uri/.ctor/nclurienhancements.fs | 99 +++++++++ snippets/fsharp/System/Uri/.ctor/source.fs | 7 + snippets/fsharp/System/Uri/.ctor/source1.fs | 7 + snippets/fsharp/System/Uri/.ctor/source2.fs | 10 + snippets/fsharp/System/Uri/.ctor/source3.fs | 8 + .../fsharp/System/Uri/AbsolutePath/fs.fsproj | 10 + .../fsharp/System/Uri/AbsolutePath/source.fs | 8 + .../fsharp/System/Uri/AbsoluteUri/fs.fsproj | 10 + .../fsharp/System/Uri/AbsoluteUri/source.fs | 8 + .../fsharp/System/Uri/Authority/fs.fsproj | 10 + .../fsharp/System/Uri/Authority/source.fs | 8 + .../fsharp/System/Uri/CheckHostName/fs.fsproj | 10 + .../fsharp/System/Uri/CheckHostName/source.fs | 5 + .../System/Uri/CheckSchemeName/fs.fsproj | 10 + .../System/Uri/CheckSchemeName/uriexamples.fs | 209 ++++++++++++++++++ snippets/fsharp/System/Uri/Host/fs.fsproj | 10 + snippets/fsharp/System/Uri/Host/source.fs | 8 + snippets/fsharp/System/Uri/Overview/fs.fsproj | 10 + snippets/fsharp/System/Uri/Overview/source.fs | 57 +++++ .../fsharp/System/Uri/PathAndQuery/fs.fsproj | 10 + .../fsharp/System/Uri/PathAndQuery/source.fs | 16 ++ snippets/fsharp/System/Uri/Port/fs.fsproj | 10 + snippets/fsharp/System/Uri/Port/source.fs | 8 + snippets/fsharp/System/Uri/Scheme/fs.fsproj | 10 + snippets/fsharp/System/Uri/Scheme/source.fs | 8 + xml/System/Uri.xml | 53 +++++ 27 files changed, 633 insertions(+) create mode 100644 snippets/fsharp/System/Uri/.ctor/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs create mode 100644 snippets/fsharp/System/Uri/.ctor/source.fs create mode 100644 snippets/fsharp/System/Uri/.ctor/source1.fs create mode 100644 snippets/fsharp/System/Uri/.ctor/source2.fs create mode 100644 snippets/fsharp/System/Uri/.ctor/source3.fs create mode 100644 snippets/fsharp/System/Uri/AbsolutePath/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/AbsolutePath/source.fs create mode 100644 snippets/fsharp/System/Uri/AbsoluteUri/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/AbsoluteUri/source.fs create mode 100644 snippets/fsharp/System/Uri/Authority/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/Authority/source.fs create mode 100644 snippets/fsharp/System/Uri/CheckHostName/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/CheckHostName/source.fs create mode 100644 snippets/fsharp/System/Uri/CheckSchemeName/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs create mode 100644 snippets/fsharp/System/Uri/Host/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/Host/source.fs create mode 100644 snippets/fsharp/System/Uri/Overview/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/Overview/source.fs create mode 100644 snippets/fsharp/System/Uri/PathAndQuery/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/PathAndQuery/source.fs create mode 100644 snippets/fsharp/System/Uri/Port/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/Port/source.fs create mode 100644 snippets/fsharp/System/Uri/Scheme/fs.fsproj create mode 100644 snippets/fsharp/System/Uri/Scheme/source.fs diff --git a/snippets/fsharp/System/Uri/.ctor/fs.fsproj b/snippets/fsharp/System/Uri/.ctor/fs.fsproj new file mode 100644 index 00000000000..8577fe474ee --- /dev/null +++ b/snippets/fsharp/System/Uri/.ctor/fs.fsproj @@ -0,0 +1,14 @@ + + + Exe + net6.0 + + + + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs b/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs new file mode 100644 index 00000000000..f313f997995 --- /dev/null +++ b/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs @@ -0,0 +1,99 @@ +module nclurienhancements + +open System + +let sampleConstructor () = + // + // Create an absolute Uri from a string. + let absoluteUri = Uri "http://www.contoso.com/" + + // Create a relative Uri from a string. allowRelative = true to allow for + // creating a relative Uri. + let relativeUri = Uri("/catalog/shownew.htm?date=today", UriKind.Relative) + + // Check whether the new Uri is absolute or relative. + if not relativeUri.IsAbsoluteUri then + printfn $"{relativeUri} is a relative Uri." + + // Create a new Uri from an absolute Uri and a relative Uri. + let combinedUri = Uri(absoluteUri, relativeUri) + printfn $"{combinedUri.AbsoluteUri}" + // + +// OriginalString +let sampleOriginalString () = + // + // Create a new Uri from a string address. + let uriAddress = Uri "HTTP://www.ConToso.com:80//thick%20and%20thin.htm" + + // Write the new Uri to the console and note the difference in the two values. + // ToString() gives the canonical version. OriginalString gives the original + // string that was passed to the constructor. + + // The following outputs "http://www.contoso.com//thick and thin.htm". + printfn $"{uriAddress.ToString()}" + + // The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm". + printfn $"{uriAddress.OriginalString}" + // + +// DNSSafeHost +let sampleDNSSafeHost () = + // + // Create new Uri using a string address. + let address = Uri "http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm" + + // Make the address DNS safe. + + // The following outputs "[fe80::200:39ff:fe36:1a2d]". + printfn $"{address.Host}" + + // The following outputs "fe80::200:39ff:fe36:1a2d%254". + printfn $"{address.DnsSafeHost}" + // + +// operator = and <> +let sampleOperatorEqual () = + // + // Create some Uris. + let address1 = Uri "http://www.contoso.com/index.htm#search" + let address2 = Uri "http://www.contoso.com/index.htm" + let address3 = Uri "http://www.contoso.com/index.htm?date=today" + + // The first two are equal because the fragment is ignored. + if address1 = address2 then + printfn $"{address1} is equal to {address2}" + + // The second two are not equal. + if address2 <> address3 then + printfn $"{address2} is not equal to {address3}" + // + +// IsBaseOf +let sampleIsBaseOf () = + // + // Create a base Uri. + let baseUri = Uri "http://www.contoso.com/" + + // Create a new Uri from a string. + let uriAddress = Uri "http://www.contoso.com/index.htm?date=today" + + // Determine whether BaseUri is a base of UriAddress. + if baseUri.IsBaseOf uriAddress then + printfn $"{baseUri} is the base of {uriAddress}" + // + +// Constructor +sampleConstructor () + +// OriginalString +sampleOriginalString () + +// DNSSafeHost +sampleDNSSafeHost () + +// operator = and <> +sampleOperatorEqual () + +// IsBaseOf +sampleIsBaseOf () \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/.ctor/source.fs b/snippets/fsharp/System/Uri/.ctor/source.fs new file mode 100644 index 00000000000..8b3159f4430 --- /dev/null +++ b/snippets/fsharp/System/Uri/.ctor/source.fs @@ -0,0 +1,7 @@ +module source + +open System + +// +let myUri = Uri "http://www.contoso.com/" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/.ctor/source1.fs b/snippets/fsharp/System/Uri/.ctor/source1.fs new file mode 100644 index 00000000000..5d0e0806417 --- /dev/null +++ b/snippets/fsharp/System/Uri/.ctor/source1.fs @@ -0,0 +1,7 @@ +module source1 + +open System + +// +let myUri = Uri("http://www.contoso.com/Hello%20World.htm", true) +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/.ctor/source2.fs b/snippets/fsharp/System/Uri/.ctor/source2.fs new file mode 100644 index 00000000000..221efc71b49 --- /dev/null +++ b/snippets/fsharp/System/Uri/.ctor/source2.fs @@ -0,0 +1,10 @@ +module source2 + +open System + +// +let baseUri = Uri "http://www.contoso.com" +let myUri = Uri(baseUri, "catalog/shownew.htm") + +printfn $"{myUri}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/.ctor/source3.fs b/snippets/fsharp/System/Uri/.ctor/source3.fs new file mode 100644 index 00000000000..a0f0cf66cff --- /dev/null +++ b/snippets/fsharp/System/Uri/.ctor/source3.fs @@ -0,0 +1,8 @@ +module source3 + +open System + +// +let baseUri = Uri "http://www.contoso.com" +let myUri = Uri(baseUri, "Hello%20World.htm", false) +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/AbsolutePath/fs.fsproj b/snippets/fsharp/System/Uri/AbsolutePath/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/AbsolutePath/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/AbsolutePath/source.fs b/snippets/fsharp/System/Uri/AbsolutePath/source.fs new file mode 100644 index 00000000000..0b7c4bca782 --- /dev/null +++ b/snippets/fsharp/System/Uri/AbsolutePath/source.fs @@ -0,0 +1,8 @@ +// +open System + +let baseUri = Uri "http://www.contoso.com/" +let myUri = Uri(baseUri, "catalog/shownew.htm?date=today") + +printfn $"{myUri.AbsolutePath}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/AbsoluteUri/fs.fsproj b/snippets/fsharp/System/Uri/AbsoluteUri/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/AbsoluteUri/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/AbsoluteUri/source.fs b/snippets/fsharp/System/Uri/AbsoluteUri/source.fs new file mode 100644 index 00000000000..7e9671bfefb --- /dev/null +++ b/snippets/fsharp/System/Uri/AbsoluteUri/source.fs @@ -0,0 +1,8 @@ +// +open System + +let baseUri= Uri "http://www.contoso.com" +let myUri = Uri(baseUri,"catalog/shownew.htm?date=today") + +printfn $"{myUri.AbsoluteUri}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Authority/fs.fsproj b/snippets/fsharp/System/Uri/Authority/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/Authority/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Authority/source.fs b/snippets/fsharp/System/Uri/Authority/source.fs new file mode 100644 index 00000000000..b8e7ebed1be --- /dev/null +++ b/snippets/fsharp/System/Uri/Authority/source.fs @@ -0,0 +1,8 @@ +// +open System + +let baseUri = Uri "http://www.contoso.com:8080/" +let myUri = Uri(baseUri, "shownew.htm?date=today") + +printfn $"{myUri.Authority}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/CheckHostName/fs.fsproj b/snippets/fsharp/System/Uri/CheckHostName/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/CheckHostName/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/CheckHostName/source.fs b/snippets/fsharp/System/Uri/CheckHostName/source.fs new file mode 100644 index 00000000000..75725c9df4f --- /dev/null +++ b/snippets/fsharp/System/Uri/CheckHostName/source.fs @@ -0,0 +1,5 @@ +open System + +// +printfn $"""{Uri.CheckHostName "www.contoso.com"}""" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/CheckSchemeName/fs.fsproj b/snippets/fsharp/System/Uri/CheckSchemeName/fs.fsproj new file mode 100644 index 00000000000..1983ebb4954 --- /dev/null +++ b/snippets/fsharp/System/Uri/CheckSchemeName/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs b/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs new file mode 100644 index 00000000000..02deb28e2bc --- /dev/null +++ b/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs @@ -0,0 +1,209 @@ +open System + +let sampleToString () = + // + // Create a new Uri from a string address. + let uriAddress = Uri "HTTP://www.Contoso.com:80/thick%20and%20thin.htm" + + // Write the new Uri to the console and note the difference in the two values. + // ToString() gives the canonical version. OriginalString gives the orginal + // string that was passed to the constructor. + + // The following outputs "http://www.contoso.com/thick and thin.htm". + printfn $"{uriAddress.ToString()}" + + // The following outputs "HTTP://www.Contoso.com:80/thick%20and%20thin.htm". + printfn $"{uriAddress.OriginalString}" + // + +let sampleEquals () = + // + // Create some Uris. + let address1 = Uri "http://www.contoso.com/index.htm#search" + let address2 = Uri "http://www.contoso.com/index.htm" + if address1.Equals address2 then + printfn "The two addresses are equal" + else + printfn "The two addresses are not equal" + // Will output "The two addresses are equal" + // + +let getParts () = + // + // Create Uri + let uriAddress = Uri "http://www.contoso.com/index.htm#search" + printfn $"{uriAddress.Fragment}" + printfn $"""Uri {if uriAddress.IsDefaultPort then "uses" else "does not use"} the default port """ + + printfn $"The path of this Uri is {uriAddress.GetLeftPart UriPartial.Path}" + printfn $"Hash code {uriAddress.GetHashCode()}" + // The example displays output similar to the following: + // #search + // Uri uses the default port + // The path of this Uri is http://www.contoso.com/index.htm + // Hash code -988419291 + // + // + let uriAddress1 = Uri "http://www.contoso.com/title/index.htm" + printfn $"The parts are {uriAddress1.Segments[0]}, {uriAddress1.Segments[1]}, {uriAddress1.Segments[2]}" + // + + // + let uriAddress2 = Uri "file://server/filename.ext" + printfn $"{uriAddress2.LocalPath}" + printfn $"""Uri {if uriAddress2.IsUnc then "is" else "is not"} a UNC path""" + printfn $"""Uri {if uriAddress2.IsLoopback then "is" else "is not"} a local host""" + printfn $"""Uri {if uriAddress2.IsFile then "is" else "is not"} a file""" + // The example displays the following output: + // \\server\filename.ext + // Uri is a UNC path + // Uri is not a local host + // Uri is a file + // + +let hexConversions () = + // + let testChar = 'e' + if Uri.IsHexDigit testChar then + printfn $"'{testChar}' is the hexadecimal representation of {Uri.FromHex testChar}" + else + printfn $"'{testChar}' is not a hexadecimal character" + + let returnString = Uri.HexEscape testChar + printfn $"The hexadecimal value of '{testChar}' is {returnString}" + // + + // + let testString = "%75" + let mutable index = 0 + if Uri.IsHexEncoding(testString, index) then + printfn $"The character is {Uri.HexUnescape(testString, &index)}" + else + printfn "The character is not hexadecimal encoded" + // + +// MakeRelative +let sampleMakeRelative () = + // + // Create a base Uri. + let address1 = Uri "http://www.contoso.com/" + + // Create a new Uri from a string. + let address2 = Uri "http://www.contoso.com/index.htm?date=today" + + // Determine the relative Uri. + printfn $"The difference is {address1.MakeRelativeUri address2}" + // + +//CheckSchemeName +let sampleCheckSchemeName () = + // + let address1 = Uri "http://www.contoso.com/index.htm#search" + printfn $"""address 1 {if Uri.CheckSchemeName address1.Scheme then " has" else " does not have"} a valid scheme name""" + + if address1.Scheme = Uri.UriSchemeHttp then + printfn "Uri is HTTP type" + + printfn $"{address1.HostNameType}" + // + + // + let address2 = Uri "file://server/filename.ext" + if address2.Scheme = Uri.UriSchemeFile then + printfn "Uri is a file" + // + + printfn $"{address2.HostNameType}" + + // + let address3 = Uri "mailto:user@contoso.com?subject=uri" + if address3.Scheme = Uri.UriSchemeMailto then + printfn $"Uri is an email address" + // + + // + let address4 = Uri "news:123456@contoso.com" + if address4.Scheme = Uri.UriSchemeNews then + printfn $"Uri is an Internet news group" + // + + // + let address5 = Uri "nntp://news.contoso.com/123456@contoso.com" + if address5.Scheme = Uri.UriSchemeNntp then + printfn "Uri is nntp protocol" + // + + // + let address6 = Uri "gopher://example.contoso.com/" + if address6.Scheme = Uri.UriSchemeGopher then + printfn "Uri is Gopher protocol" + // + + // + let address7 = Uri "ftp://contoso/files/testfile.txt" + if address7.Scheme = Uri.UriSchemeFtp then + printfn "Uri is Ftp protocol" + // + + // + let address8 = Uri "https://example.contoso.com" + if address8.Scheme = Uri.UriSchemeHttps then + printfn "Uri is Https protocol." + // + + // + let address = "www.contoso.com" + let uriString = $"{Uri.UriSchemeHttp}{Uri.SchemeDelimiter}{address}/" +#if OLDMETHOD + match Uri.TryParse(uriString, false, false) with + | true, result -> + printfn $"{result} is a valid Uri" + | _ -> + printfn "Uri not created" +#endif + let result = Uri uriString + if result.IsWellFormedOriginalString() then + printfn $"{uriString} is a well formed Uri" + else + printfn $"{uriString} is not a well formed Uri" + // + +let sampleUserInfo () = + // + let uriAddress = Uri "http://user:password@www.contoso.com/index.htm " + printfn $"{uriAddress.UserInfo}" + printfn $"""Fully Escaped {if uriAddress.UserEscaped then "yes" else "no"}""" +// + +let unescapeUriWithPlusConversion () = + // + let DataString = Uri.UnescapeDataString ".NET+Framework" + printfn $"Unescaped string: {DataString}" + + let PlusString = DataString.Replace('+',' ') + printfn $"plus to space string: {PlusString}" +// + +// Snippets 1 and 2 +hexConversions () + +// snippet 7 +sampleToString () + +// snippet 8 +sampleEquals () + +// snippets 4, 5, and 6 +getParts () + +// snippet 3 +sampleMakeRelative () + +// snippets 9 - 17 +sampleCheckSchemeName () + +// snippet 18 +sampleUserInfo () + +// snippet 19 +unescapeUriWithPlusConversion () diff --git a/snippets/fsharp/System/Uri/Host/fs.fsproj b/snippets/fsharp/System/Uri/Host/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/Host/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Host/source.fs b/snippets/fsharp/System/Uri/Host/source.fs new file mode 100644 index 00000000000..bfb150262ab --- /dev/null +++ b/snippets/fsharp/System/Uri/Host/source.fs @@ -0,0 +1,8 @@ +open System + +// +let baseUri = Uri "http://www.contoso.com:8080/" +let myUri = Uri(baseUri, "shownew.htm?date=today") + +printfn $"{myUri.Host}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Overview/fs.fsproj b/snippets/fsharp/System/Uri/Overview/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/Overview/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Overview/source.fs b/snippets/fsharp/System/Uri/Overview/source.fs new file mode 100644 index 00000000000..d8a97152573 --- /dev/null +++ b/snippets/fsharp/System/Uri/Overview/source.fs @@ -0,0 +1,57 @@ +open System +open System.Net + +// +let contoso = Uri "http://www.contoso.com/" + +let wr = WebRequest.Create contoso +// + +// +let uri = Uri "https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName" + +printfn $"AbsolutePath: {uri.AbsolutePath}" +printfn $"AbsoluteUri: {uri.AbsoluteUri}" +printfn $"DnsSafeHost: {uri.DnsSafeHost}" +printfn $"Fragment: {uri.Fragment}" +printfn $"Host: {uri.Host}" +printfn $"HostNameType: {uri.HostNameType}" +printfn $"IdnHost: {uri.IdnHost}" +printfn $"IsAbsoluteUri: {uri.IsAbsoluteUri}" +printfn $"IsDefaultPort: {uri.IsDefaultPort}" +printfn $"IsFile: {uri.IsFile}" +printfn $"IsLoopback: {uri.IsLoopback}" +printfn $"IsUnc: {uri.IsUnc}" +printfn $"LocalPath: {uri.LocalPath}" +printfn $"OriginalString: {uri.OriginalString}" +printfn $"PathAndQuery: {uri.PathAndQuery}" +printfn $"Port: {uri.Port}" +printfn $"Query: {uri.Query}" +printfn $"Scheme: {uri.Scheme}" +printfn $"""Segments: {String.Join(", ", uri.Segments)}""" +printfn $"UserEscaped: {uri.UserEscaped}" +printfn $"UserInfo: {uri.UserInfo}" + +// AbsolutePath: /Home/Index.htm +// AbsoluteUri: https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName +// DnsSafeHost: www.contoso.com +// Fragment: #FragmentName +// Host: www.contoso.com +// HostNameType: Dns +// IdnHost: www.contoso.com +// IsAbsoluteUri: True +// IsDefaultPort: False +// IsFile: False +// IsLoopback: False +// IsUnc: False +// LocalPath: /Home/Index.htm +// OriginalString: https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName +// PathAndQuery: /Home/Index.htm?q1=v1&q2=v2 +// Port: 80 +// Query: ?q1=v1&q2=v2 +// Scheme: https +// Segments: /, Home/, Index.htm +// UserEscaped: False +// UserInfo: user:password + +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/PathAndQuery/fs.fsproj b/snippets/fsharp/System/Uri/PathAndQuery/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/PathAndQuery/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/PathAndQuery/source.fs b/snippets/fsharp/System/Uri/PathAndQuery/source.fs new file mode 100644 index 00000000000..b4903462f6e --- /dev/null +++ b/snippets/fsharp/System/Uri/PathAndQuery/source.fs @@ -0,0 +1,16 @@ +open System + +do + // + let baseUri = Uri "http://www.contoso.com/" + let myUri = Uri(baseUri, "catalog/shownew.htm?date=today") + + printfn $"{myUri.PathAndQuery}" + // + + // + let baseUri = Uri "http://www.contoso.com/" + let myUri = Uri (baseUri, "catalog/shownew.htm?date=today") + + printfn $"{myUri.Query}" + // \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Port/fs.fsproj b/snippets/fsharp/System/Uri/Port/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/Port/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Port/source.fs b/snippets/fsharp/System/Uri/Port/source.fs new file mode 100644 index 00000000000..aa1d3e3b483 --- /dev/null +++ b/snippets/fsharp/System/Uri/Port/source.fs @@ -0,0 +1,8 @@ +// +open System + +let baseUri = Uri "http://www.contoso.com/" +let myUri = Uri(baseUri,"catalog/shownew.htm?date=today") + +printfn $"{myUri.Port}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Scheme/fs.fsproj b/snippets/fsharp/System/Uri/Scheme/fs.fsproj new file mode 100644 index 00000000000..f0a89cd967d --- /dev/null +++ b/snippets/fsharp/System/Uri/Scheme/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/Uri/Scheme/source.fs b/snippets/fsharp/System/Uri/Scheme/source.fs new file mode 100644 index 00000000000..eedb528b485 --- /dev/null +++ b/snippets/fsharp/System/Uri/Scheme/source.fs @@ -0,0 +1,8 @@ +// +open System + +let baseUri = Uri "http://www.contoso.com/" +let myUri = Uri(baseUri, "catalog/shownew.htm?date=today") + +printfn $"{myUri.Scheme}" +// \ No newline at end of file diff --git a/xml/System/Uri.xml b/xml/System/Uri.xml index 0bb0353f3fd..5394a362bda 100644 --- a/xml/System/Uri.xml +++ b/xml/System/Uri.xml @@ -233,11 +233,13 @@ The following example creates an instance of the class and use :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri Example/VB/source.vb" id="Snippet1"::: The following code snippet shows example values of the various properties on the class. :::code language="csharp" source="~/snippets/csharp/System/Uri/Overview/source.cs" id="Snippet2"::: +:::code language="fsharp" source="~/snippets/fsharp/System/Uri/Overview/source.fs" id="Snippet2"::: ]]> @@ -321,6 +323,7 @@ The following code snippet shows example values of the various properties on the :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri.Uri Example/VB/source.vb" id="Snippet1"::: ]]> @@ -547,6 +550,7 @@ The following code snippet shows example values of the various properties on the :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/source1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri.Uri1 Example/VB/source.vb" id="Snippet1"::: ]]> @@ -814,6 +818,7 @@ The following code snippet shows example values of the various properties on the :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/source2.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/source2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri.Uri3 Example/VB/source.vb" id="Snippet1"::: ]]> @@ -932,6 +937,7 @@ The following code snippet shows example values of the various properties on the :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet2"::: ]]> @@ -1065,6 +1071,7 @@ The URI formed by combining and @@ -1179,6 +1186,7 @@ The URI formed by combining and @@ -1236,6 +1244,7 @@ The URI formed by combining and @@ -1293,6 +1302,7 @@ The URI formed by combining and @@ -1416,6 +1426,7 @@ The URI formed by combining and @@ -1487,6 +1498,7 @@ The URI formed by combining and @@ -1718,6 +1730,7 @@ If you used an escaped string to construct this instance (for example, `"http:// :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet4"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet4"::: As explained in Remarks, unescape the host name before resolving it. You can use the method to unescape the host name, and you can resolve it by calling the method. @@ -1800,6 +1813,7 @@ If you used an escaped string to construct this instance (for example, `"http:// :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet8"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet8"::: ]]> @@ -2113,6 +2127,7 @@ The length of exceeds 32766 characters. @@ -2170,6 +2185,7 @@ The length of exceeds 32766 characters. @@ -2292,6 +2308,7 @@ The length of exceeds 32766 characters. @@ -2369,6 +2386,7 @@ The length of exceeds 32766 characters. @@ -2466,6 +2484,7 @@ The length of exceeds 32766 characters. @@ -2523,6 +2542,7 @@ The length of exceeds 32766 characters. @@ -2581,6 +2601,7 @@ The length of exceeds 32766 characters. @@ -2635,6 +2656,7 @@ The length of exceeds 32766 characters. @@ -2874,6 +2896,7 @@ The length of exceeds 32766 characters. @@ -2930,6 +2953,7 @@ The length of exceeds 32766 characters. @@ -3045,6 +3069,7 @@ The length of exceeds 32766 characters. @@ -3103,6 +3128,7 @@ The length of exceeds 32766 characters. @@ -3162,6 +3188,7 @@ The length of exceeds 32766 characters. @@ -3219,6 +3246,7 @@ The length of exceeds 32766 characters. @@ -3334,6 +3362,7 @@ The length of exceeds 32766 characters. @@ -3541,6 +3570,7 @@ The length of exceeds 32766 characters. @@ -3623,6 +3653,7 @@ The length of exceeds 32766 characters. @@ -3696,6 +3727,7 @@ The length of exceeds 32766 characters. @@ -3762,6 +3794,7 @@ The length of exceeds 32766 characters. @@ -3825,6 +3858,7 @@ The length of exceeds 32766 characters. @@ -3888,6 +3922,7 @@ The length of exceeds 32766 characters. @@ -4001,6 +4036,7 @@ The length of exceeds 32766 characters. @@ -4058,6 +4094,7 @@ The length of exceeds 32766 characters. @@ -4119,6 +4156,7 @@ The length of exceeds 32766 characters. @@ -4194,6 +4232,7 @@ The length of exceeds 32766 characters. @@ -4243,6 +4282,7 @@ The length of exceeds 32766 characters. @@ -4329,6 +4369,7 @@ The length of exceeds 32766 characters. @@ -4442,6 +4483,7 @@ The length of exceeds 32766 characters. @@ -4835,6 +4877,7 @@ The length of exceeds 32766 characters. @@ -4889,6 +4932,7 @@ The length of exceeds 32766 characters. @@ -4937,6 +4981,7 @@ The length of exceeds 32766 characters. @@ -5012,6 +5057,7 @@ The length of exceeds 32766 characters. @@ -5060,6 +5106,7 @@ The length of exceeds 32766 characters. @@ -5108,6 +5155,7 @@ The length of exceeds 32766 characters. @@ -5156,6 +5204,7 @@ The length of exceeds 32766 characters. @@ -5276,6 +5325,7 @@ The length of exceeds 32766 characters. @@ -5327,6 +5377,7 @@ The length of exceeds 32766 characters. @@ -5519,6 +5570,7 @@ The length of exceeds 32766 characters. @@ -5575,6 +5627,7 @@ The length of exceeds 32766 characters.