diff --git a/snippets/fsharp/System/OperatingSystem/Clone/clone.fs b/snippets/fsharp/System/OperatingSystem/Clone/clone.fs new file mode 100644 index 00000000000..aa9853227be --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/Clone/clone.fs @@ -0,0 +1,47 @@ +// +// Example for the OperatingSystem.Clone method. +open System + +// Copy, clone, and duplicate an OperatingSystem object. +let copyOperatingSystemObjects () = + // The Version object does not need to correspond to an + // actual OS version. + let verMMBVer = Version(5, 6, 7, 8) + + let opCreate1 = OperatingSystem(PlatformID.Win32NT, verMMBVer) + + // Create another OperatingSystem object with the same + // parameters as opCreate1. + let opCreate2 = OperatingSystem(PlatformID.Win32NT, verMMBVer) + + // Clone opCreate1 and copy the opCreate1 reference. + let opClone = opCreate1.Clone() :?> OperatingSystem + let opCopy = opCreate1 + + // Compare the various objects for equality. + printfn "%-50s%O" "Is the second object the same as the original?" (opCreate1.Equals opCreate2) + printfn "%-50s%O" "Is the object clone the same as the original?" (opCreate1.Equals opClone) + printfn "%-50s%O" "Is the copied object the same as the original?" (opCreate1.Equals opCopy) + +printfn + """This example of OperatingSystem.Clone( ) generates the following output. + +Create an OperatingSystem object, and then create another object with the +same parameters. Clone and copy the original object, and then compare +each object with the original using the Equals( ) method. Equals( ) +returns true only when both references refer to the same object. +""" + +copyOperatingSystemObjects () + +// This example of OperatingSystem.Clone( ) generates the following output. +// +// Create an OperatingSystem object, and then create another object with the +// same parameters. Clone and copy the original object, and then compare +// each object with the original using the Equals( ) method. Equals( ) +// returns true only when both references refer to the same object. +// +// Is the second object the same as the original? False +// Is the object clone the same as the original? False +// Is the copied object the same as the original? True +// \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/Clone/fs.fsproj b/snippets/fsharp/System/OperatingSystem/Clone/fs.fsproj new file mode 100644 index 00000000000..7ddb8988b43 --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/Clone/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/Overview/fs.fsproj b/snippets/fsharp/System/OperatingSystem/Overview/fs.fsproj new file mode 100644 index 00000000000..bdc637de8bf --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/Overview/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/Overview/osinfo1.fs b/snippets/fsharp/System/OperatingSystem/Overview/osinfo1.fs new file mode 100644 index 00000000000..c082aa83814 --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/Overview/osinfo1.fs @@ -0,0 +1,30 @@ +// +open System + +let os = Environment.OSVersion +printfn "Current OS Information:\n" +printfn $"Platform: {os.Platform:G}" +printfn $"Version String: {os.VersionString}" +printfn $"Version Information:" +printfn $" Major: {os.Version.Major}" +printfn $" Minor: {os.Version.Minor}" +printfn $"Service Pack: '{os.ServicePack}'" +// If run on a Windows 8.1 system, the example displays output like the following: +// Current OS Information: +// +// Platform: Win32NT +// Version String: Microsoft Windows NT 6.2.9200.0 +// Version Information: +// Major: 6 +// Minor: 2 +// Service Pack: '' +// If run on a Windows 7 system, the example displays output like the following: +// Current OS Information: +// +// Platform: Win32NT +// Version String: Microsoft Windows NT 6.1.7601 Service Pack 1 +// Version Information: +// Major: 6 +// Minor: 1 +// Service Pack: 'Service Pack 1' +// \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/Platform/fs.fsproj b/snippets/fsharp/System/OperatingSystem/Platform/fs.fsproj new file mode 100644 index 00000000000..d291ea61a16 --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/Platform/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs b/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs new file mode 100644 index 00000000000..974040c7acb --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs @@ -0,0 +1,54 @@ +// +// Example for the OperatingSystem.Platform and +// OperatingSystem.Version properties. +open System + +// Create an OperatingSystem object and display the Platform +// and Version properties. +let buildOSObj pID ver = + let opSys = OperatingSystem(pID, ver) + let platform = opSys.Platform + let version = opSys.Version + + printfn $" Platform: {platform,-15} Version: {version}" + +let buildOperatingSystemObjects () = + // The Version object does not need to correspond to an + // actual OS version. + let verNull = Version() + let verString = Version("3.5.8.13") + let verMajMin = Version(6, 10) + let verMMBld = Version(5, 25, 5025) + let verMMBVer = Version(5, 6, 7, 8) + + // All PlatformID members are shown here. + buildOSObj PlatformID.Win32NT verNull + buildOSObj PlatformID.Win32S verString + buildOSObj PlatformID.Win32Windows verMajMin + buildOSObj PlatformID.WinCE verMMBld + buildOSObj PlatformID.Win32NT verMMBVer + +printfn "This example of OperatingSystem.Platform and OperatingSystem.Version \ngenerates the following output.\n" +printfn "Create several OperatingSystem objects and display their properties:\n" + +buildOperatingSystemObjects () + +printfn "\nThe operating system of the host computer is:\n" + +buildOSObj Environment.OSVersion.Platform Environment.OSVersion.Version + +// This example of OperatingSystem.Platform and OperatingSystem.Version +// generates the following output. +// +// Create several OperatingSystem objects and display their properties: +// +// Platform: Win32NT Version: 0.0 +// Platform: Win32S Version: 3.5.8.13 +// Platform: Win32Windows Version: 6.10 +// Platform: WinCE Version: 5.25.5025 +// Platform: Win32NT Version: 5.6.7.8 +// +// The operating system of the host computer is: +// +// Platform: Win32NT Version: 5.1.2600.0 +// \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/ServicePack/fs.fsproj b/snippets/fsharp/System/OperatingSystem/ServicePack/fs.fsproj new file mode 100644 index 00000000000..47ff89fef0a --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/ServicePack/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/ServicePack/sp.fs b/snippets/fsharp/System/OperatingSystem/ServicePack/sp.fs new file mode 100644 index 00000000000..620c9e976be --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/ServicePack/sp.fs @@ -0,0 +1,10 @@ +// +// This example demonstrates the OperatingSystem.ServicePack property. +open System + +let os = Environment.OSVersion +let sp = os.ServicePack +printfn $"Service pack version = \"{sp}\"" +// This example produces the following results: +// Service pack version = "Service Pack 1" +// \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/ToString/ctor_tostr.fs b/snippets/fsharp/System/OperatingSystem/ToString/ctor_tostr.fs new file mode 100644 index 00000000000..efc9e7b51fa --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/ToString/ctor_tostr.fs @@ -0,0 +1,49 @@ +// +// Example for the OperatingSystem constructor and the +// OperatingSystem.ToString( ) method. +open System + +// Create and display an OperatingSystem object. +let buildOSObj pID ver = + let os = OperatingSystem(pID, ver) + // String Interpolation calls .ToString() + printfn $" {os}" + +let buildOperatingSystemObjects () = + // The Version object does not need to correspond to an + // actual OS version. + let verNull = Version() + let verMajMin = Version(3, 11) + let verMMBld = Version(5, 25, 625) + let verMMBVer = Version(5, 6, 7, 8) + let verString = Version("3.5.8.13") + + // All PlatformID members are shown here. + buildOSObj PlatformID.Win32NT verNull + buildOSObj PlatformID.Win32S verMajMin + buildOSObj PlatformID.Win32Windows verMMBld + buildOSObj PlatformID.WinCE verMMBVer + buildOSObj PlatformID.Win32NT verString + +printfn "This example of the OperatingSystem constructor and \nOperatingSystem.ToString( ) generates the following output.\n" +printfn "Create and display several different OperatingSystem objects:\n" + +buildOperatingSystemObjects () + +printfn $"\nThe OS version of the host computer is:\n\n {Environment.OSVersion}" + +// This example of the OperatingSystem constructor and +// OperatingSystem.ToString( ) generates the following output. +// +// Create and display several different OperatingSystem objects: +// +// Microsoft Windows NT 0.0 +// Microsoft Win32S 3.11 +// Microsoft Windows 98 5.25.625 +// Microsoft Windows CE 5.6.7.8 +// Microsoft Windows NT 3.5.8.13 +// +// The OS version of the host computer is: +// +// Microsoft Windows NT 5.1.2600.0 +// \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/ToString/fs.fsproj b/snippets/fsharp/System/OperatingSystem/ToString/fs.fsproj new file mode 100644 index 00000000000..a267c801a5f --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/ToString/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/VersionString/fs.fsproj b/snippets/fsharp/System/OperatingSystem/VersionString/fs.fsproj new file mode 100644 index 00000000000..b1ee3187ce4 --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/VersionString/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/OperatingSystem/VersionString/osvs.fs b/snippets/fsharp/System/OperatingSystem/VersionString/osvs.fs new file mode 100644 index 00000000000..594d076535e --- /dev/null +++ b/snippets/fsharp/System/OperatingSystem/VersionString/osvs.fs @@ -0,0 +1,11 @@ +// +// This example demonstrates the VersionString property. +open System + +let os = Environment.OSVersion +// Display the value of OperatingSystem.VersionString. By default, this is +// the same value as OperatingSystem.ToString. +printfn $"This operating system is {os.VersionString}" +// This example produces the following results: +// This operating system is Microsoft Windows NT 5.1.2600.0 Service Pack 1 +// \ No newline at end of file diff --git a/xml/System/OperatingSystem.xml b/xml/System/OperatingSystem.xml index 2115fb084dc..519310856e3 100644 --- a/xml/System/OperatingSystem.xml +++ b/xml/System/OperatingSystem.xml @@ -82,6 +82,7 @@ The following code example uses the object to display information about the runtime operating system. :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Overview/osinfo1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Overview/osinfo1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.environment.osversion/vb/osinfo1.vb" id="Snippet1"::: ]]> @@ -188,6 +189,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Clone/CPP/clone.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Clone/clone.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Clone/clone.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Clone/VB/clone.vb" id="Snippet1"::: ]]> @@ -1008,6 +1010,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Platform/plat_ver.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/VB/plat_ver.vb" id="Snippet1"::: ]]> @@ -1066,6 +1069,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/OperatingSystem.ServicePack/CPP/sp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/ServicePack/sp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/ServicePack/sp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/OperatingSystem.ServicePack/VB/sp.vb" id="Snippet1"::: ]]> @@ -1126,6 +1130,7 @@ For a list of Windows operating system versions and their corresponding version :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/CPP/ctor_tostr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/ToString/ctor_tostr.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/ToString/ctor_tostr.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/VB/ctor_tostr.vb" id="Snippet1"::: ]]> @@ -1185,6 +1190,7 @@ For a list of Windows operating system versions and their corresponding version :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Platform/plat_ver.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/VB/plat_ver.vb" id="Snippet1"::: ]]> @@ -1243,6 +1249,7 @@ For a list of Windows operating system versions and their corresponding version :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/OperatingSystem.VersionString/CPP/osvs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/VersionString/osvs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/VersionString/osvs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/OperatingSystem.VersionString/VB/osvs.vb" id="Snippet1"::: ]]>