Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions snippets/fsharp/System/OperatingSystem/Clone/clone.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//<Snippet1>
// 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
//</Snippet1>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/Clone/fs.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="clone.fs" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/Overview/fs.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="osinfo1.fs" />
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions snippets/fsharp/System/OperatingSystem/Overview/osinfo1.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// <Snippet1>
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'
// </Snippet1>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/Platform/fs.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="plat_ver.fs" />
</ItemGroup>
</Project>
54 changes: 54 additions & 0 deletions snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//<Snippet1>
// 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
//</Snippet1>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/ServicePack/fs.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="sp.fs" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/ServicePack/sp.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//<snippet1>
// 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"
//</snippet1>
49 changes: 49 additions & 0 deletions snippets/fsharp/System/OperatingSystem/ToString/ctor_tostr.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//<Snippet1>
// 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
//</Snippet1>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/ToString/fs.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="ctor_tostr.fs" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions snippets/fsharp/System/OperatingSystem/VersionString/fs.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="osvs.fs" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions snippets/fsharp/System/OperatingSystem/VersionString/osvs.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//<snippet1>
// 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
//</snippet1>
7 changes: 7 additions & 0 deletions xml/System/OperatingSystem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
The following code example uses the <xref:System.OperatingSystem> 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":::

]]></format>
Expand Down Expand Up @@ -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":::

]]></format>
Expand Down Expand Up @@ -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":::

]]></format>
Expand Down Expand Up @@ -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":::

]]></format>
Expand Down Expand Up @@ -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":::

]]></format>
Expand Down Expand Up @@ -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":::

]]></format>
Expand Down Expand Up @@ -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":::

]]></format>
Expand Down