Monthly chores: Automated repo cleanup (#39136)

* Bot 🤖 generated CleanRepo tool run

* add commandbehavior to toc

---------

Co-authored-by: gewarren <gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2024-01-16 10:31:58 -05:00 коммит произвёл GitHub
Родитель 35b9cc0485
Коммит fb1346327d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
38 изменённых файлов: 21 добавлений и 1972 удалений

Просмотреть файл

@ -14,7 +14,7 @@
},
{
"source_path_from_root": "/docs/architecture/dapr-for-net-developers/secrets.md",
"redirect_url": "/dotnet/architecture/dapr-for-net-developers/secrets-management"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/dapr-for-net-developers/Dapr-for-NET-Developers.pdf"
},
{
"source_path_from_root": "/docs/architecture/microservices/architect-microservice-container-applications/communication-between-microservices.md",
@ -27,59 +27,59 @@
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/build-resilient-services-ready-for-the-cloud-embrace-transient-failures-in-the-cloud.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/build-resilient-services-ready-for-the-cloud-embrace-transient-failures-in-the-cloud"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/deploy-existing-net-apps-as-windows-containers.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/deploy-existing-net-apps-as-windows-containers"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/how-to-deploy-existing-net-apps-to-azure-app-service.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/when-to-deploy-windows-containers-to-azure-container-instances-ACI"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/index.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/index"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/microsoft-technologies-in-cloud-devops-ready-applications.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/microsoft-technologies-in-cloud-optimized-applications"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/migrate-to-hybrid-cloud-scenarios.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/migrate-to-hybrid-cloud-scenarios"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/modernize-your-apps-lifecycle-with-ci-cd-pipelines-and-devops-tools-in-the-cloud.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/life-cycle-ci-cd-pipelines-devops-tools"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/modernize-your-apps-with-monitoring-and-telemetry.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/modernize-your-apps-with-monitoring-and-telemetry"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/reasons-to-lift-and-shift-existing-net-apps-to-cloud-devops-ready-applications.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/reasons-to-modernize-existing-net-apps-to-cloud-optimized-applications"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/what-about-cloud-optimized-applications.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/what-about-cloud-native-applications"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/when-not-to-deploy-to-windows-containers.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/when-not-to-deploy-to-windows-containers"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/when-to-deploy-windows-containers-in-your-on-premises-iaas-vm-infrastructure.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/when-to-deploy-windows-containers-in-your-on-premises-iaas-vm-infrastructure"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/when-to-deploy-windows-containers-to-azure-container-service-kubernetes.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/when-to-deploy-windows-containers-to-azure-container-service-kubernetes"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/when-to-deploy-windows-containers-to-azure-vms-iaas-cloud.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/when-to-deploy-windows-containers-to-azure-vms-iaas-cloud"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/lift-and-shift-existing-apps-devops/when-to-deploy-windows-containers-to-service-fabric.md",
@ -87,7 +87,7 @@
},
{
"source_path_from_root": "/docs/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/modernize-your-apps-lifecycle-with-ci-cd-pipelines-and-devops-tools-in-the-cloud.md",
"redirect_url": "/dotnet/architecture/modernize-with-azure-containers/modernize-existing-apps-to-cloud-optimized/life-cycle-ci-cd-pipelines-devops-tools"
"redirect_url": "https://github.com/dotnet-architecture/eBooks/blob/1ed30275281b9060964fcb2a4c363fe7797fe3f3/current/modernize-with-azure-containers/Modernize-Existing-.NET-applications-with-Azure-cloud-and-Windows-Containers.pdf"
},
{
"source_path_from_root": "/docs/architecture/containerized-lifecycle/design-develop-containerized-apps/build-aspnet-core-applications-linux-containers-aks-kubernetes.md",

Просмотреть файл

@ -2436,7 +2436,7 @@
},
{
"source_path_from_root": "/docs/csharp/programming-guide/concepts/linq/linq-and-generic-types.md",
"redirect_url": "/dotnet/csharp/programming-guide/concepts/linq/type-relationships-in-linq-query-operations"
"redirect_url": "/dotnet/csharp/linq/get-started/type-relationships-in-linq-query-operations"
},
{
"source_path_from_root": "/docs/csharp/programming-guide/concepts/linq/linq-and-reflection.md",
@ -2587,7 +2587,7 @@
},
{
"source_path_from_root": "/docs/csharp/programming-guide/concepts/linq/query-syntax-and-method-syntax-in-linq.md",
"redirect_url": "/dotnet/csharp/linq/write-linq-queries",
"redirect_url": "/dotnet/csharp/linq/get-started/write-linq-queries",
"redirect_document_id": true
},
{
@ -3094,7 +3094,7 @@
},
{
"source_path_from_root": "/docs/csharp/programming-guide/linq-query-expressions/how-to-write-linq-queries.md",
"redirect_url": "/dotnet/csharp/linq/write-linq-queries"
"redirect_url": "/dotnet/csharp/linq/get-started/write-linq-queries"
},
{
"source_path_from_root": "/docs/csharp/programming-guide/linq-query-expressions/index.md",

Просмотреть файл

@ -1,31 +0,0 @@
using Xunit;
using static LinqSamples.Test.Shared;
using Linq.GetStarted;
namespace LinqSamples.Test;
public class BasicsTest
{
[Fact]
public void Basics5Test()
{
StringWriter sw = InitTest();
Basics.Basics5();
Assert.Equal(
@"93
90
82
82
", sw.ToString());
}
[Fact]
public void Basics18Test()
{
StringWriter sw = InitTest();
Basics.Basics18();
Assert.Equal("Svetlana Claire Sven Cesar ", sw.ToString());
}
}

Просмотреть файл

@ -1,18 +0,0 @@
using Xunit;
using static LinqSamples.Test.Shared;
namespace LinqSamples.Test;
public class IndexTest
{
/* This may come back once I've moved more code.
[Fact]
public void IntroTest()
{
StringWriter sw = InitTest();
Index.Intro();
Assert.Equal("97 92 81 ", sw.ToString());
}
*/
}

Просмотреть файл

@ -1,27 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SnippetApp\LinqGetStarted.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,16 +0,0 @@
using Xunit;
// Tests need to be carried out synchronously, otherwise the console output for different tests gets intermingled
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
namespace LinqSamples.Test;
public static class Shared
{
public static StringWriter InitTest()
{
// We want to capture the console output for each test separately
StringWriter sw = new();
Console.SetOut(sw);
return sw;
}
}

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 43 KiB

Просмотреть файл

@ -1,55 +0,0 @@
'<snippet01>
Imports System.Collections.Generic
Class Program
'<snippet02>
Shared Sub Main()
'<snippet03>
Dim evenNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()
Dim oddNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()
For i As Integer = 0 To 4
' Populate evenNumbers with only even numbers.
evenNumbers.Add(i * 2)
' Populate oddNumbers with only odd numbers.
oddNumbers.Add((i * 2) + 1)
Next i
'</snippet03>
Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count)
DisplaySet(evenNumbers)
Console.Write("oddNumbers contains {0} elements: ", oddNumbers.Count)
DisplaySet(oddNumbers)
' Create a new HashSet populated with even numbers.
Dim numbers As HashSet(Of Integer) = New HashSet(Of Integer)(evenNumbers)
Console.WriteLine("numbers UnionWith oddNumbers...")
numbers.UnionWith(oddNumbers)
Console.Write("numbers contains {0} elements: ", numbers.Count)
DisplaySet(numbers)
End Sub
'</snippet02>
Private Shared Sub DisplaySet(ByVal collection As HashSet(Of Integer))
Console.Write("{")
For Each i As Integer In collection
Console.Write(" {0}", i)
Next i
Console.WriteLine(" }")
End Sub
End Class
' This example produces output similar to the following:
' evenNumbers contains 5 elements: { 0 2 4 6 8 }
' oddNumbers contains 5 elements: { 1 3 5 7 9 }
' numbers UnionWith oddNumbers...
' numbers contains 10 elements: { 0 2 4 6 8 1 3 5 7 9 }
'</snippet01>

Просмотреть файл

@ -1,57 +0,0 @@
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
//<snippet01>
//<snippet02>
//<snippet03>
HashSet<int> evenNumbers = new HashSet<int>();
HashSet<int> oddNumbers = new HashSet<int>();
for (int i = 0; i < 5; i++)
{
// Populate numbers with just even numbers.
evenNumbers.Add(i * 2);
// Populate oddNumbers with just odd numbers.
oddNumbers.Add((i * 2) + 1);
}
//</snippet03>
Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count);
DisplaySet(evenNumbers);
Console.Write("oddNumbers contains {0} elements: ", oddNumbers.Count);
DisplaySet(oddNumbers);
// Create a new HashSet populated with even numbers.
HashSet<int> numbers = new HashSet<int>(evenNumbers);
Console.WriteLine("numbers UnionWith oddNumbers...");
numbers.UnionWith(oddNumbers);
Console.Write("numbers contains {0} elements: ", numbers.Count);
DisplaySet(numbers);
//</snippet02>
void DisplaySet(HashSet<int> collection)
{
Console.Write("{");
foreach (int i in collection)
{
Console.Write(" {0}", i);
}
Console.WriteLine(" }");
}
/* This example produces output similar to the following:
* evenNumbers contains 5 elements: { 0 2 4 6 8 }
* oddNumbers contains 5 elements: { 1 3 5 7 9 }
* numbers UnionWith oddNumbers...
* numbers contains 10 elements: { 0 2 4 6 8 1 3 5 7 9 }
*/
//</snippet01>
}
}

Просмотреть файл

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8</TargetFrameworks>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,699 +0,0 @@
Imports System.Security.Permissions
Imports System.Collections
Imports System.Collections.ObjectModel
Imports System.CodeDom
Imports System.Reflection
Imports System.IO
Imports System.Xml
Imports System.Runtime.Serialization.Formatters
Imports System.Runtime.Serialization
Imports System.Xml.Linq
<assembly: CLSCompliant(True)>
<assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution := True)>
Namespace Examples.NetDataContractSerializer
'<snippet0>
' You must apply a DataContractAttribute or SerializableAttribute
' to a class to have it serialized by the NetDataContractSerializer.
<DataContract(Name := "Customer", [Namespace] := "http://www.contoso.com")> _
Class Person
Implements IExtensibleDataObject
<DataMember()> _
Public FirstName As String
<DataMember()> _
Public LastName As String
<DataMember()> _
Public ID As Integer
Public Sub New(ByVal newfName As String, ByVal newLName As String, _
ByVal newID As Integer)
FirstName = newfName
LastName = newLName
ID = newID
End Sub
Private extensionData_Value As ExtensionDataObject
Public Property ExtensionData() As ExtensionDataObject _
Implements IExtensibleDataObject.ExtensionData
Get
Return extensionData_Value
End Get
Set
extensionData_Value = value
End Set
End Property
End Class
NotInheritable Public Class Test
Private Sub New()
End Sub
Public Shared Sub Main()
Try
WriteObject("NetDataContractSerializerExample.xml")
ReadObject("NetDataContractSerializerExample.xml")
Catch serExc As SerializationException
Console.WriteLine("Serialization Failed")
Console.WriteLine(serExc.Message)
Catch exc As Exception
Console.WriteLine("The serialization operation failed: {0} StackTrace: {1}", exc.Message, exc.StackTrace)
Finally
Console.WriteLine("Press <Enter> to exit....")
Console.ReadLine()
End Try
End Sub
'<snippet1>
Public Shared Sub WriteObject(ByVal fileName As String)
Console.WriteLine("Creating a Person object and serializing it.")
Dim p1 As New Person("Zighetti", "Barbara", 101)
Dim fs As New FileStream(fileName, FileMode.Create)
Dim writer As XmlDictionaryWriter = XmlDictionaryWriter.CreateTextWriter(fs)
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
ser.WriteObject(writer, p1)
writer.Close()
End Sub
'</snippet1>
'<snippet2>
Public Shared Sub ReadObject(ByVal fileName As String)
Console.WriteLine("Deserializing an instance of the object.")
Dim fs As New FileStream(fileName, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
' Deserialize the data and read it from the instance.
Dim deserializedPerson As Person = CType(ser.ReadObject(reader, True), Person)
fs.Close()
Console.WriteLine(String.Format("{0} {1}, ID: {2}", deserializedPerson.FirstName, deserializedPerson.LastName, deserializedPerson.ID))
End Sub
'</snippet2>
End Class
'</snippet0>
'<snippet3>
<DataContract()> _
Public Class GetCurrency
Implements IExtensibleDataObject
<DataMemberAttribute()> _
Private Country_value As String
Public Property Country() As String
Get
Return Country_value
End Get
Set
Country_value = value
End Set
End Property
' Note that this field is not serialized. Instead, it is
' populated after serialization.
Private Currency_value As String
Public Property Currency() As String
Get
Return Currency_value
End Get
Set
Currency_value = value
End Set
End Property
' Use this method to look up the country/region and set
' the Currency field after deserialization.
<OnDeserialized()> _
Private Sub GetLocalRate(ByVal sc As StreamingContext)
If Me.Country = "Japan" Then
Me.Currency = "Yen"
End If
End Sub
' Implement the IExensibleDataObject interface to
' retain future version information.
Private extensionData_Value As ExtensionDataObject
Public Property ExtensionData() As ExtensionDataObject _
Implements IExtensibleDataObject.ExtensionData
Get
Return extensionData_Value
End Get
Set
extensionData_Value = value
End Set
End Property
End Class
'</snippet3>
'<snippet4>
<DataContract(Name := "PurchaseOrder", [Namespace] := "urn:www.Microsoft.com")> _
Public Class PurchaseOrder
Implements IExtensibleDataObject
Private purchaseDate_value As DateTime
<DataMember()> _
Public Property PurchaseDate() As DateTime
Get
Return purchaseDate_value
End Get
Set
purchaseDate_value = Value
End Set
End Property
Private extensionData_value As ExtensionDataObject
Public Property ExtensionData() As ExtensionDataObject _
Implements IExtensibleDataObject.ExtensionData
Get
Return extensionData_value
End Get
Set
extensionData_value = value
End Set
End Property
End Class
<DataContract(Name := "PurchaseOrder", [Namespace] := "urn:www.Microsoft.com")> _
Public Class PurchaseOrderV2
Implements IExtensibleDataObject
Private purchaseDate_value As DateTime
<DataMember()> _
Public Property PurchaseDate() As DateTime
Get
Return purchaseDate_value
End Get
Set
purchaseDate_value = value
End Set
End Property
<DataMember()> _
Private purchaseOrderId_value As Integer
Public Property PurchaseOrderId() As Integer
Get
Return purchaseOrderId_value
End Get
Set
purchaseOrderId_value = value
End Set
End Property
Private extensionData_value As ExtensionDataObject
Public Property ExtensionData() As ExtensionDataObject _
Implements IExtensibleDataObject.ExtensionData
Get
Return extensionData_value
End Get
Set
extensionData_value = value
End Set
End Property
End Class
NotInheritable Public Class TestFutureCompatibleTypes
Private Sub New()
End Sub
Public Shared Sub RunTest()
SerializeNewVersion("myTestFile.xml")
DeserializeAndSerialize("myTestFile.xml")
DeserializeToNewVersion("myTestFile.xml")
Console.ReadLine()
End Sub
Shared Sub SerializeNewVersion(ByVal path As String)
Console.WriteLine("Serializing new version of a contract.")
Dim fs As New FileStream(path, FileMode.Create)
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
Dim PO_V2 As New PurchaseOrderV2()
PO_V2.PurchaseDate = DateTime.Now
PO_V2.PurchaseOrderId = 1234
ser.WriteObject(fs, PO_V2)
fs.Close()
Console.WriteLine("Order Date: {0}", PO_V2.PurchaseDate.ToLongDateString())
Console.WriteLine("Order ID:{0}", PO_V2.PurchaseOrderId)
End Sub
Shared Sub DeserializeAndSerialize(ByVal path As String)
Console.WriteLine("Deserializing new version to old version")
Dim fs As New FileStream(path, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
' Create the serializer.
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
' Deserialize version 1 of the data.
Dim PO_V1 As PurchaseOrder = CType(ser.ReadObject(reader, False), PurchaseOrder)
Console.WriteLine("Order Date:{0}", PO_V1.PurchaseDate.ToLongDateString())
fs.Close()
Console.WriteLine("Reserialize the object with extension data intact")
' First change the order date.
Dim newDate As DateTime = PO_V1.PurchaseDate.AddDays(10)
PO_V1.PurchaseDate = newDate
' Create a new FileStream to write with.
Dim writer As New FileStream(path, FileMode.Create)
' Serialize the object with changed data.
ser.WriteObject(writer, PO_V1)
writer.Close()
End Sub
Shared Sub DeserializeToNewVersion(ByVal path As String)
Console.WriteLine("Deserializing to new version, extension data intact")
Dim fs As New FileStream(path, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
Dim newOrder As PurchaseOrderV2 = CType(ser.ReadObject(reader, False), PurchaseOrderV2)
Console.WriteLine("Original OrderID: {0}", newOrder.PurchaseOrderId)
Console.WriteLine("New Order Date: {0}", newOrder.PurchaseDate.ToLongDateString())
fs.Close()
End Sub
End Class
'</snippet4>
'<snippet5>
NotInheritable Public Class ShowWriteStartObject
Public Shared Sub WriteObjectData(ByVal path As String)
' Create the object to serialize.
Dim p As New Person("Lynn", "Tsoflias", 9876)
' Create the writer.
Dim fs As New FileStream(path, FileMode.Create)
Dim writer As XmlDictionaryWriter = XmlDictionaryWriter.CreateTextWriter(fs)
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
' Use the writer to start a document.
writer.WriteStartDocument(True)
' Use the serializer to write the start of the
' object data. Use it again to write the object
' data.
ser.WriteStartObject(writer, p)
writer.WriteStartAttribute("MyAttribute")
writer.WriteString("My Text")
writer.WriteEndAttribute()
ser.WriteObjectContent(writer, p)
' Use the serializer to write the end of the
' object data. Then use the writer to write the end
' of the document.
ser.WriteEndObject(writer)
writer.WriteEndDocument()
Console.WriteLine("Done")
' Close and release the writer resources.
writer.Flush()
fs.Flush()
fs.Close()
End Sub
'</snippet5>
'<snippet6>
Public Shared Sub ReadObjectData(ByVal path As String)
' Create the reader.
Dim fs As New FileStream(path, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
' Create the NetDataContractSerializer, specifying the type,
' root, and namespace to use. The root value corresponds
' to the DataContract.Name value, and the namespace value
' corresponds to the DataContract.Namespace value.
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
' Test if the serializer is on the start of the
' object data. If so, read the data and write it
' to the console.
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
If ser.IsStartObject(reader) Then
Console.WriteLine("Found the element")
Dim p As Person = CType(ser.ReadObject(reader), Person)
Console.WriteLine("{0} {1} id:{2}", p.FirstName, _
p.LastName, p.ID)
End If
Console.WriteLine(reader.Name)
End Select
End While
fs.Flush()
fs.Close()
End Sub
'</snippet6>
'<snippet7>
Public Shared Sub WriteObjectContentInDocument(ByVal path As String)
' Create the object to serialize.
Dim p As New Person("Lynn", "Tsoflias", 9876)
' Create the writer.
Dim fs As New FileStream(path, FileMode.Create)
Dim writer As XmlDictionaryWriter = _
XmlDictionaryWriter.CreateTextWriter(fs)
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
' Use the writer to start a document.
writer.WriteStartDocument(True)
' Use the writer to write the root element.
writer.WriteStartElement("Company")
' Use the writer to write an element.
writer.WriteElementString("Name", "Microsoft")
' Use the serializer to write the start, content,
' and end data.
ser.WriteStartObject(writer, p)
ser.WriteObjectContent(writer, p)
ser.WriteEndObject(writer)
' Use the writer to write the end element
' and end of the document.
writer.WriteEndElement()
writer.WriteEndDocument()
' Close and release the writer resources.
writer.Flush()
fs.Flush()
fs.Close()
End Sub
'</snippet7>
'<snippet8>
Public Shared Sub Constructor1()
' Create an instance of the NetDataContractSerializer.
Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()
End Sub
' Other code not shown.
'</snippet8>
'<snippet9>
Public Shared Sub Constructor2()
' Create an instance of the StreamingContext to hold
' context data.
Dim sc As New StreamingContext()
' Create a DatatContractSerializer with the collection.
Dim ser2 As New System.Runtime.Serialization.NetDataContractSerializer(sc)
' Other code not shown.
End Sub
'</snippet9>
'<snippet10>
Public Shared Sub Constructor3()
' Create an instance of the NetDataContractSerializer
' specifying the name and namespace as strings.
Dim ser As New System.Runtime.Serialization. _
NetDataContractSerializer("Customer", "http://www.contoso.com")
' Other code not shown.
End Sub
'</snippet10>
'<snippet11>
Public Shared Sub Constructor4()
' Create an XmlDictionary and add values to it.
Dim d As New XmlDictionary()
Dim name_value As XmlDictionaryString =d.Add("Customer")
Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")
' Create the serializer.
Dim ser As New System.Runtime.Serialization. _
NetDataContractSerializer(name_value, ns_value)
' Other code not shown.
End Sub
'</snippet11>
'<snippet12>
Public Shared Sub Constructor5()
' Create an instance of the StreamingContext to hold
' context data.
Dim sc As New StreamingContext()
' Create an instance of a class that implements the
' ISurrogateSelector interface. The implementation code
' is not shown here.
Dim mySurrogateSelector As New MySelector()
Dim ser As New System.Runtime.Serialization. _
NetDataContractSerializer _
(sc, _
65536, _
True, _
FormatterAssemblyStyle.Simple, _
mySurrogateSelector)
' Other code not shown.
End Sub
'</snippet12>
'<snippet13>
Public Shared Sub Constructor6()
' Create an instance of the StreamingContext to hold
' context data.
Dim sc As New StreamingContext()
' Create an instance of a class that implements the
' ISurrogateSelector interface. The implementation code
' is not shown here.
Dim mySurrogateSelector As New MySelector()
Dim ser As New System.Runtime.Serialization. _
NetDataContractSerializer( _
"Customer", _
"http://www.contoso.com", _
sc, _
65536, _
True, _
FormatterAssemblyStyle.Simple, _
mySurrogateSelector)
' Other code not shown.
End Sub
'</snippet13>
'<snippet14>
Public Shared Sub Constructor7()
' Create an instance of the StreamingContext to hold
' context data.
Dim sc As New StreamingContext()
' Create an XmlDictionary and add values to it.
Dim d As New XmlDictionary()
Dim name_value As XmlDictionaryString =d.Add("Customer")
Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")
' Create an instance of a class that implements the
' ISurrogateSelector interface. The implementation code
' is not shown here.
Dim mySurrogateSelector As New MySelector()
Dim ser As New System.Runtime.Serialization. _
NetDataContractSerializer( _
name_value, _
ns_value, _
sc, _
65536, _
True, _
FormatterAssemblyStyle.Simple, _
mySurrogateSelector)
' Other code not shown.
End Sub
'</snippet14>
Public Sub CannotSerialize()
'<snippet15>
Dim fs As New FileStream("mystuff.xml", FileMode.Create, FileAccess.ReadWrite)
Dim myElement As New XElement("Parent", New XElement("child1", "form"), _
New XElement("child2", "base"), _
New XElement("child3", "formbase") _
)
Dim ser As New System.Runtime.Serialization. _
NetDataContractSerializer()
ser.WriteObject(fs, myElement)
'</snippet15>
End Sub
End Class
<DataContract()> _
Public Class Orders
Public Sub New()
Me.OrderCollection = New Hashtable()
End Sub
<DataMember()> _
Friend OrderCollection As Hashtable
End Class
<DataContract()> _
Public Class PurchaseOrderV3
<DataMember()> _
Friend PurchaseDate As DateTime
<DataMember()> _
Friend OrderId As Integer
End Class
Public Class DCSurrogate
Implements IDataContractSurrogate
Overloads Public Function GetCustomDataToExport(ByVal memberInfo As MemberInfo, ByVal dataContractType As Type) As Object _
Implements IDataContractSurrogate.GetCustomDataToExport
Return New Person("Lynne", "Tsofilas", 1)
End Function
Overloads Public Function GetCustomDataToExport(ByVal clrType As Type, ByVal dataContractType As Type) As Object _
Implements IDataContractSurrogate.GetCustomDataToExport
Return New Person("Lynne", "Tsofilas", 1)
End Function
Public Function GetDataContractType(ByVal type As Type) As Type _
Implements IDataContractSurrogate.GetDataContractType
Return GetType(Person)
End Function
Public Function GetDeserializedObject(ByVal obj As Object, ByVal targetType As Type) As Object _
Implements IDataContractSurrogate.GetDeserializedObject
Return New Person("Lynne", "Tsofilas", 1)
End Function
Public Sub GetKnownCustomDataTypes(ByVal customDataTypes As Collection(Of Type)) _
Implements IDataContractSurrogate.GetKnownCustomDataTypes
customDataTypes.Add(GetType(PurchaseOrder))
customDataTypes.Add(GetType(PurchaseOrderV3))
End Sub
Public Function GetObjectToSerialize(ByVal obj As Object, ByVal targetType As Type) As Object _
Implements IDataContractSurrogate.GetObjectToSerialize
Return New Person("Lynne", "Tsofilas", 1)
End Function
Public Function GetReferencedTypeOnImport(ByVal typeName As String, ByVal typeNamespace As String, ByVal customData As Object) As Type _
Implements IDataContractSurrogate.GetReferencedTypeOnImport
Return GetType(Person)
End Function
Public Function ProcessImportedType(ByVal typeDeclaration As CodeTypeDeclaration, ByVal compileUnit As CodeCompileUnit) As CodeTypeDeclaration _
Implements IDataContractSurrogate.ProcessImportedType
Return New CodeTypeDeclaration()
End Function
End Class
Friend Class MySelector
Implements ISurrogateSelector
Public Sub ChainSelector(ByVal selector As ISurrogateSelector) _
Implements ISurrogateSelector.ChainSelector
End Sub
Public Function GetNextSelector() As ISurrogateSelector _
Implements ISurrogateSelector.GetNextSelector
Return New PersonSurrogateSelector()
End Function
Public Function GetSurrogate(ByVal type As Type, ByVal context As StreamingContext, ByRef selector As ISurrogateSelector) As ISerializationSurrogate _
Implements ISurrogateSelector.GetSurrogate
Return New MySerializationSurrogate()
End Function
End Class
Friend Class PersonSurrogateSelector
Implements ISurrogateSelector
Public Sub ChainSelector(ByVal selector As ISurrogateSelector) _
Implements ISurrogateSelector.ChainSelector
End Sub
Public Function GetNextSelector() As ISurrogateSelector _
Implements ISurrogateSelector.GetNextSelector
Return New PersonSurrogateSelector()
End Function
Public Function GetSurrogate(ByVal type As Type, ByVal context As StreamingContext, ByRef selector As ISurrogateSelector) As ISerializationSurrogate _
Implements ISurrogateSelector.GetSurrogate
selector = New MySelector()
Return New MySerializationSurrogate()
End Function
End Class
Friend Class MySerializationSurrogate
Implements ISerializationSurrogate
Public Sub GetObjectData(ByVal obj As Object, ByVal info As SerializationInfo, ByVal context As StreamingContext) _
Implements ISerializationSurrogate.GetObjectData
End Sub
Public Function SetObjectData(ByVal obj As Object, ByVal info As SerializationInfo, ByVal context As StreamingContext, ByVal selector As ISurrogateSelector) As Object _
Implements ISerializationSurrogate.SetObjectData
Return New Object()
End Function
End Class
End Namespace

Просмотреть файл

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8</TargetFrameworks>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,50 +0,0 @@
// <snippet0>
using System;
using System.Text.RegularExpressions;
public class Test
{
public static void Main ()
{
// <snippet1>
// Define a regular expression for repeated words.
Regex rx = new Regex(@"\b(?<word>\w+)\s+(\k<word>)\b",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
// </snippet1>
// Define a test string.
string text = "The the quick brown fox fox jumps over the lazy dog dog.";
// <snippet2>
// Find matches.
MatchCollection matches = rx.Matches(text);
// </snippet2>
// <snippet3>
// Report the number of matches found.
Console.WriteLine("{0} matches found in:\n {1}",
matches.Count,
text);
// </snippet3>
// <snippet4>
// Report on each match.
foreach (Match match in matches)
{
GroupCollection groups = match.Groups;
Console.WriteLine("'{0}' repeated at positions {1} and {2}",
groups["word"].Value,
groups[0].Index,
groups[1].Index);
}
// </snippet4>
}
}
// The example produces the following output to the console:
// 3 matches found in:
// The the quick brown fox fox jumps over the lazy dog dog.
// 'The' repeated at positions 0 and 4
// 'fox' repeated at positions 20 and 25
// 'dog' repeated at positions 49 and 53
// </snippet0>

Просмотреть файл

@ -1,23 +0,0 @@
// <snippet23>
open System
let chA = 'A'
let ch1 = '1'
let str = "test string"
printfn $"{chA.CompareTo 'B'}" //----------- Output: "-1" (meaning 'A' is 1 less than 'B')
printfn $"{chA.Equals 'A'}" //----------- Output: "True"
printfn $"{Char.GetNumericValue ch1}" //----------- Output: "1"
printfn $"{Char.IsControl '\t'}" //----------- Output: "True"
printfn $"{Char.IsDigit ch1}" //----------- Output: "True"
printfn $"{Char.IsLetter ','}" //----------- Output: "False"
printfn $"{Char.IsLower 'u'}" //----------- Output: "True"
printfn $"{Char.IsNumber ch1}" //----------- Output: "True"
printfn $"{Char.IsPunctuation '.'}" //----------- Output: "True"
printfn $"{Char.IsSeparator(str, 4)}" //----------- Output: "True"
printfn $"{Char.IsSymbol '+'}" //----------- Output: "True"
printfn $"{Char.IsWhiteSpace(str, 4)}" //----------- Output: "True"
printfn $"""{Char.Parse "S"}""" //----------- Output: "S"
printfn $"{Char.ToLower 'M'}" //----------- Output: "m"
printfn $"{'x'}" //----------- Output: "x"
// </snippet23>

Просмотреть файл

@ -1,32 +0,0 @@
' <snippet23>
Module CharStructure
Public Sub Main()
Dim chA As Char
chA = "A"c
Dim ch1 As Char
ch1 = "1"c
Dim str As String
str = "test string"
Console.WriteLine(chA.CompareTo("B"c)) ' Output: "-1" (meaning 'A' is 1 less than 'B')
Console.WriteLine(chA.Equals("A"c)) ' Output: "True"
Console.WriteLine(Char.GetNumericValue(ch1)) ' Output: "1"
Console.WriteLine(Char.IsControl(Chr(9))) ' Output: "True"
Console.WriteLine(Char.IsDigit(ch1)) ' Output: "True"
Console.WriteLine(Char.IsLetter(","c)) ' Output: "False"
Console.WriteLine(Char.IsLower("u"c)) ' Output: "True"
Console.WriteLine(Char.IsNumber(ch1)) ' Output: "True"
Console.WriteLine(Char.IsPunctuation("."c)) ' Output: "True"
Console.WriteLine(Char.IsSeparator(str, 4)) ' Output: "True"
Console.WriteLine(Char.IsSymbol("+"c)) ' Output: "True"
Console.WriteLine(Char.IsWhiteSpace(str, 4)) ' Output: "True"
Console.WriteLine(Char.Parse("S")) ' Output: "S"
Console.WriteLine(Char.ToLower("M"c)) ' Output: "m"
Console.WriteLine("x"c.ToString()) ' Output: "x"
End Sub
End Module
' </snippet23>

Просмотреть файл

@ -1,22 +0,0 @@
// <Snippet4>
open System
let numbers = [| Int32.MinValue; -1; 0; 121; 340; Int32.MaxValue |]
for number in numbers do
try
let result = Convert.ToByte number
printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
with :? OverflowException ->
printfn $"The {number.GetType().Name} value {number} is outside the range of the Byte type."
// The example displays the following output:
// The Int32 value -2147483648 is outside the range of the Byte type.
// The Int32 value -1 is outside the range of the Byte type.
// Converted the Int32 value 0 to the Byte value 0.
// Converted the Int32 value 121 to the Byte value 121.
// The Int32 value 340 is outside the range of the Byte type.
// The Int32 value 2147483647 is outside the range of the Byte type.
// </Snippet4>

Просмотреть файл

@ -1,25 +0,0 @@
open System
// <Snippet4>
let values =
[| Decimal.MinValue; -1034.23M; -12m; 0M; 147M
199.55M; 9214.16M; Decimal.MaxValue |]
for value in values do
try
let result = Convert.ToInt32 value
printfn $"Converted the {value.GetType().Name} value '{value}' to the {result.GetType().Name} value {result}."
with :? OverflowException ->
printfn $"{value} is outside the range of the Int32 type."
// The example displays the following output:
// -79228162514264337593543950335 is outside the range of the Int32 type.
// Converted the Decimal value '-1034.23' to the Int32 value -1034.
// Converted the Decimal value '-12' to the Int32 value -12.
// Converted the Decimal value '0' to the Int32 value 0.
// Converted the Decimal value '147' to the Int32 value 147.
// Converted the Decimal value '199.55' to the Int32 value 200.
// Converted the Decimal value '9214.16' to the Int32 value 9214.
// 79228162514264337593543950335 is outside the range of the Int32 type.
// </Snippet4>

Просмотреть файл

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8</TargetFrameworks>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,57 +0,0 @@
//<snippet1>
using System;
namespace GCCollectIntExample
{
class MyGCCollectClass
{
private const long maxGarbage = 1000;
static void Main()
{
MyGCCollectClass myGCCol = new MyGCCollectClass();
// Determine the maximum number of generations the system
// garbage collector currently supports.
Console.WriteLine("The highest generation is {0}", GC.MaxGeneration);
myGCCol.MakeSomeGarbage();
// Determine which generation myGCCol object is stored in.
Console.WriteLine("Generation: {0}", GC.GetGeneration(myGCCol));
// Determine the best available approximation of the number
// of bytes currently allocated in managed memory.
Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(false));
// Perform a collection of generation 0 only.
GC.Collect(0);
// Determine which generation myGCCol object is stored in.
Console.WriteLine("Generation: {0}", GC.GetGeneration(myGCCol));
Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(false));
// Perform a collection of all generations up to and including 2.
GC.Collect(2);
// Determine which generation myGCCol object is stored in.
Console.WriteLine("Generation: {0}", GC.GetGeneration(myGCCol));
Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(false));
Console.Read();
}
void MakeSomeGarbage()
{
Version vt;
for(int i = 0; i < maxGarbage; i++)
{
// Create objects and release them to fill up memory
// with unused objects.
vt = new Version();
}
}
}
}
//</snippet1>

Просмотреть файл

@ -1,45 +0,0 @@
//<snippet1>
open System
let maxGarbage = 1000
type MyGCCollectClass() =
member _.MakeSomeGarbage() =
for _ = 1 to maxGarbage do
// Create objects and release them to fill up memory with unused objects.
Version() |> ignore
[<EntryPoint>]
let main _ =
let myGCCol = MyGCCollectClass()
// Determine the maximum number of generations the system
// garbage collector currently supports.
printfn $"The highest generation is {GC.MaxGeneration}"
myGCCol.MakeSomeGarbage()
// Determine which generation myGCCol object is stored in.
printfn $"Generation: {GC.GetGeneration myGCCol}"
// Determine the best available approximation of the number
// of bytes currently allocated in managed memory.
printfn $"Total Memory: {GC.GetTotalMemory false}"
// Perform a collection of generation 0 only.
GC.Collect 0
// Determine which generation myGCCol object is stored in.
printfn $"Generation: {GC.GetGeneration myGCCol}"
printfn $"Total Memory: {GC.GetTotalMemory false}"
// Perform a collection of all generations up to and including 2.
GC.Collect 2
// Determine which generation myGCCol object is stored in.
printfn $"Generation: {GC.GetGeneration myGCCol}"
printfn $"Total Memory: {GC.GetTotalMemory false}"
0
//</snippet1>

Просмотреть файл

@ -1,53 +0,0 @@
'<snippet1>
Namespace GCCollectInt_Example
Class MyGCCollectClass
Private maxGarbage As Long = 10000
Public Shared Sub Main()
Dim myGCCol As New MyGCCollectClass
'Determine the maximum number of generations the system
'garbage collector currently supports.
Console.WriteLine("The highest generation is {0}", GC.MaxGeneration)
myGCCol.MakeSomeGarbage()
'Determine which generation myGCCol object is stored in.
Console.WriteLine("Generation: {0}", GC.GetGeneration(myGCCol))
'Determine the best available approximation of the number
'of bytes currently allocated in managed memory.
Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(False))
'Perform a collection of generation 0 only.
GC.Collect(0)
'Determine which generation myGCCol object is stored in.
Console.WriteLine("Generation: {0}", GC.GetGeneration(myGCCol))
Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(False))
'Perform a collection of all generations up to and including 2.
GC.Collect(2)
'Determine which generation myGCCol object is stored in.
Console.WriteLine("Generation: {0}", GC.GetGeneration(myGCCol))
Console.WriteLine("Total Memory: {0}", GC.GetTotalMemory(False))
Console.Read()
End Sub
Sub MakeSomeGarbage()
Dim vt As Version
Dim i As Integer
For i = 0 To maxGarbage - 1
'Create objects and release them to fill up memory
'with unused objects.
vt = New Version
Next i
End Sub
End Class
End Namespace
'</snippet1>

Просмотреть файл

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8</TargetFrameworks>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,35 +0,0 @@
// <Snippet1>
using System;
using System.Collections.Generic;
public struct OrderOrderLine : IEquatable<OrderOrderLine>
{
public int OrderId { get; }
public int OrderLineId { get; }
public OrderOrderLine(int orderId, int orderLineId) => (OrderId, OrderLineId) = (orderId, orderLineId);
public override bool Equals(object obj) => obj is OrderOrderLine o && Equals(o);
public bool Equals(OrderOrderLine other) => OrderId == other.OrderId && OrderLineId == other.OrderLineId;
public override int GetHashCode() => HashCode.Combine(OrderId, OrderLineId);
}
class Program2
{
static void Main(string[] args)
{
var set = new HashSet<OrderOrderLine>
{
new OrderOrderLine(1, 1),
new OrderOrderLine(1, 1),
new OrderOrderLine(1, 2)
};
Console.WriteLine($"Item count: {set.Count}.");
}
}
// The example displays the following output:
// Item count: 2.
// </Snippet1>

Просмотреть файл

@ -1,55 +0,0 @@
// <Snippet1>
using System;
using System.Collections.Generic;
public struct Path1 : IEquatable<Path1>
{
public IReadOnlyList<string> Segments { get; }
public Path1(params string[] segments) => Segments = segments;
public override bool Equals(object obj) => obj is Path1 o && Equals(o);
public bool Equals(Path1 other)
{
if (ReferenceEquals(Segments, other.Segments)) return true;
if (Segments is null || other.Segments is null) return false;
if (Segments.Count != other.Segments.Count) return false;
for (var i = 0; i < Segments.Count; i++)
{
if (!string.Equals(Segments[i], other.Segments[i]))
return false;
}
return true;
}
public override int GetHashCode()
{
var hash = new HashCode();
for (var i = 0; i < Segments?.Count; i++)
hash.Add(Segments[i]);
return hash.ToHashCode();
}
}
class Program1
{
static void Main(string[] args)
{
var set = new HashSet<Path1>
{
new Path1("C:", "tmp", "file.txt"),
new Path1("C:", "tmp", "file.txt"),
new Path1("C:", "tmp", "file.tmp")
};
Console.WriteLine($"Item count: {set.Count}.");
}
}
// The example displays the following output:
// Item count: 2.
// </Snippet1>

Просмотреть файл

@ -1,55 +0,0 @@
// <Snippet1>
using System;
using System.Collections.Generic;
public struct Path : IEquatable<Path>
{
public IReadOnlyList<string> Segments { get; }
public Path(params string[] segments) => Segments = segments;
public override bool Equals(object obj) => obj is Path o && Equals(o);
public bool Equals(Path other)
{
if (ReferenceEquals(Segments, other.Segments)) return true;
if (Segments is null || other.Segments is null) return false;
if (Segments.Count != other.Segments.Count) return false;
for (var i = 0; i < Segments.Count; i++)
{
if (!string.Equals(Segments[i], other.Segments[i], StringComparison.OrdinalIgnoreCase))
return false;
}
return true;
}
public override int GetHashCode()
{
var hash = new HashCode();
for (var i = 0; i < Segments?.Count; i++)
hash.Add(Segments[i], StringComparer.OrdinalIgnoreCase);
return hash.ToHashCode();
}
}
class Program
{
static void Main(string[] args)
{
var set = new HashSet<Path>
{
new Path("C:", "tmp", "file.txt"),
new Path("C:", "TMP", "file.txt"),
new Path("C:", "tmp", "FILE.TXT")
};
Console.WriteLine($"Item count: {set.Count}.");
}
}
// The example displays the following output:
// Item count: 1.
// </Snippet1>

Просмотреть файл

@ -1,61 +0,0 @@
// <Snippet1>
using System;
using System.Collections.Generic;
public struct Path2 : IEquatable<Path2>
{
public IReadOnlyList<string> Segments { get; }
public Path2(params string[] segments) => Segments = segments;
public override bool Equals(object obj) => obj is Path2 o && Equals(o);
public bool Equals(Path2 other)
{
if (ReferenceEquals(Segments, other.Segments)) return true;
if (Segments is null || other.Segments is null) return false;
if (Segments.Count != other.Segments.Count) return false;
for (var i = 0; i < Segments.Count; i++)
{
if (!PlatformUtils.Path2Equals(Segments[i], other.Segments[i]))
return false;
}
return true;
}
public override int GetHashCode()
{
var hash = new HashCode();
for (var i = 0; i < Segments?.Count; i++)
PlatformUtils.AddPath2(ref hash, Segments[i]);
return hash.ToHashCode();
}
}
internal static class PlatformUtils
{
public static bool Path2Equals(string a, string b) => string.Equals(a, b, StringComparison.OrdinalIgnoreCase);
public static void AddPath2(ref HashCode hash, string Path2) => hash.Add(Path2, StringComparer.OrdinalIgnoreCase);
}
class Program4
{
static void Main(string[] args)
{
var set = new HashSet<Path2>
{
new Path2("C:", "tmp", "file.txt"),
new Path2("C:", "TMP", "file.txt"),
new Path2("C:", "tmp", "FILE.TXT")
};
Console.WriteLine($"Item count: {set.Count}.");
}
}
// The example displays the following output:
// Item count: 1.
// </Snippet1>

Просмотреть файл

@ -1,30 +0,0 @@
module example1
// <Snippet1>
open System
open System.Collections.Generic
[<Struct; CustomEquality; NoComparison>]
type OrderOrderLine(orderId: int, orderLineId: int) =
member _.OrderId = orderId
member _.OrderLineId = orderLineId
override _.GetHashCode() =
HashCode.Combine(orderId, orderLineId)
override this.Equals(obj) =
match obj with
| :? OrderOrderLine as o -> (this :> IEquatable<_>).Equals o
| _ -> false
interface IEquatable<OrderOrderLine> with
member _.Equals(other: OrderOrderLine) =
orderId = other.OrderId && orderLineId = other.OrderLineId
let set =
HashSet<OrderOrderLine> [ OrderOrderLine(1, 1); OrderOrderLine(1, 1); OrderOrderLine(1, 2) ]
printfn $"Item count: {set.Count}."
// The example displays the following output:
// Item count: 2.
// </Snippet1>

Просмотреть файл

@ -1,42 +0,0 @@
module example2
// <Snippet1>
open System
open System.Collections.Generic
[<Struct; CustomEquality; NoComparison>]
type Path([<ParamArray>]segments: string[]) =
member _.Segments =
Array.AsReadOnly segments
override this.Equals(obj) =
match obj with
| :? Path as o -> (this :> IEquatable<_>).Equals(o)
| _ -> false
interface IEquatable<Path> with
member this.Equals(other: Path) =
Object.ReferenceEquals(this.Segments, other.Segments) ||
not (isNull this.Segments) &&
not (isNull other.Segments) &&
this.Segments.Count = other.Segments.Count &&
Seq.forall2 (=) this.Segments other.Segments
override this.GetHashCode() =
let hash = HashCode()
for i = 0 to this.Segments.Count - 1 do
hash.Add this.Segments[i]
hash.ToHashCode()
let set =
HashSet<Path> [
Path("C:", "tmp", "file.txt")
Path("C:", "tmp", "file.tmp")
Path("C:", "tmp", "file.txt") ]
printfn $"Item count: {set.Count}."
// The example displays the following output:
// Item count: 2.
// </Snippet1>

Просмотреть файл

@ -1,42 +0,0 @@
module example3
// <Snippet1>
open System
open System.Collections.Generic
[<Struct; CustomEquality; NoComparison>]
type Path([<ParamArray>]segments: string[]) =
member _.Segments =
Array.AsReadOnly segments
override this.Equals(obj) =
match obj with
| :? Path as o -> (this :> IEquatable<_>).Equals(o)
| _ -> false
interface IEquatable<Path> with
member this.Equals(other: Path) =
Object.ReferenceEquals(this.Segments, other.Segments) ||
not (isNull this.Segments) &&
not (isNull other.Segments) &&
this.Segments.Count = other.Segments.Count &&
Seq.forall2 (fun x y -> String.Equals(x, y, StringComparison.OrdinalIgnoreCase)) this.Segments other.Segments
override this.GetHashCode() =
let hash = HashCode()
for i = 0 to this.Segments.Count - 1 do
hash.Add(this.Segments[i], StringComparer.OrdinalIgnoreCase)
hash.ToHashCode()
let set =
HashSet<Path> [
Path("C:", "tmp", "file.txt")
Path("C:", "tmp", "file.tmp")
Path("C:", "tmp", "file.txt") ]
printfn $"Item count: {set.Count}."
// The example displays the following output:
// Item count: 1.
// </Snippet1>

Просмотреть файл

@ -1,47 +0,0 @@
module example4
// <Snippet1>
open System
open System.Collections.Generic
module PlatformUtils =
let pathEquals a b = String.Equals(a, b, StringComparison.OrdinalIgnoreCase)
let addPath (hash: byref<HashCode>) path = hash.Add(path, StringComparer.OrdinalIgnoreCase)
[<Struct; CustomEquality; NoComparison>]
type Path([<ParamArray>]segments: string[]) =
member _.Segments =
Array.AsReadOnly segments
override this.Equals(obj) =
match obj with
| :? Path as o -> (this :> IEquatable<_>).Equals(o)
| _ -> false
interface IEquatable<Path> with
member this.Equals(other: Path) =
Object.ReferenceEquals(this.Segments, other.Segments) ||
not (isNull this.Segments) &&
not (isNull other.Segments) &&
this.Segments.Count = other.Segments.Count &&
Seq.forall2 PlatformUtils.pathEquals this.Segments other.Segments
override this.GetHashCode() =
let mutable hash = HashCode()
for i = 0 to this.Segments.Count - 1 do
PlatformUtils.addPath &hash this.Segments[i]
hash.ToHashCode()
let set =
HashSet<Path> [
Path("C:", "tmp", "file.txt")
Path("C:", "TMP", "file.txt")
Path("C:", "tmp", "FILE.TXT") ]
printfn $"Item count: {set.Count}."
// The example displays the following output:
// Item count: 1.
// </Snippet1>

Просмотреть файл

@ -1,41 +0,0 @@
' <Snippet1>
Public Structure OrderOrderLine
Implements IEquatable(Of OrderOrderLine)
Public ReadOnly Property OrderId As Integer
Public ReadOnly Property OrderLineId As Integer
Public Sub New(ByVal orderId As Integer, ByVal orderLineId As Integer)
Me.OrderId = orderId
Me.OrderLineId = orderLineId
End Sub
Public Overrides Function Equals(obj As Object) As Boolean
Return (TypeOf obj Is OrderOrderLine) AndAlso Equals(DirectCast(obj, OrderOrderLine))
End Function
Public Overloads Function Equals(other As OrderOrderLine) As Boolean Implements IEquatable(Of OrderOrderLine).Equals
Return OrderId = other.OrderId AndAlso
OrderLineId = other.OrderLineId
End Function
Public Overrides Function GetHashCode() As Integer
Return HashCode.Combine(OrderId, OrderLineId)
End Function
End Structure
Module Program
Sub Main(args As String())
Dim hashSet As HashSet(Of OrderOrderLine) = New HashSet(Of OrderOrderLine)
hashSet.Add(New OrderOrderLine(1, 1))
hashSet.Add(New OrderOrderLine(1, 1))
hashSet.Add(New OrderOrderLine(1, 2))
Console.WriteLine($"Item count: {hashSet.Count}")
End Sub
End Module
' The example displays the following output:
' Item count: 2.
' </Snippet1>

Просмотреть файл

@ -1,53 +0,0 @@
' <Snippet1>
Public Structure Path
Implements IEquatable(Of Path)
Public ReadOnly Property Segments As IReadOnlyList(Of String)
Public Sub New(ParamArray ByVal segments() As String)
Me.Segments = segments
End Sub
Public Overrides Function Equals(obj As Object) As Boolean
Return (TypeOf obj Is Path) AndAlso Equals(DirectCast(obj, Path))
End Function
Public Overloads Function Equals(other As Path) As Boolean Implements IEquatable(Of Path).Equals
If ReferenceEquals(Segments, other.Segments) Then Return True
If Segments Is Nothing OrElse other.Segments Is Nothing Then Return False
If Segments.Count <> other.Segments.Count Then Return False
For i As Integer = 0 To Segments.Count - 1
If Not String.Equals(Segments(i), other.Segments(i)) Then Return False
Next
Return True
End Function
Public Overrides Function GetHashCode() As Integer
Dim hash As HashCode = New HashCode()
For i As Integer = 0 To Segments?.Count - 1
hash.Add(Segments(i))
Next
Return hash.ToHashCode()
End Function
End Structure
Module Program
Sub Main(args As String())
Dim hashSet As HashSet(Of Path) = New HashSet(Of Path) From {
New Path("C:", "tmp", "file.txt"),
New Path("C:", "tmp", "file.txt"),
New Path("C:", "tmp", "file.tmp")
}
Console.WriteLine($"Item count: {hashSet.Count}.")
End Sub
End Module
' The example displays the following output:
' Item count: 2.
' </Snippet1>

Просмотреть файл

@ -1,53 +0,0 @@
' <Snippet1>
Public Structure Path
Implements IEquatable(Of Path)
Public ReadOnly Property Segments As IReadOnlyList(Of String)
Public Sub New(ParamArray ByVal segments() As String)
Me.Segments = segments
End Sub
Public Overrides Function Equals(obj As Object) As Boolean
Return (TypeOf obj Is Path) AndAlso Equals(DirectCast(obj, Path))
End Function
Public Overloads Function Equals(other As Path) As Boolean Implements IEquatable(Of Path).Equals
If ReferenceEquals(Segments, other.Segments) Then Return True
If Segments Is Nothing OrElse other.Segments Is Nothing Then Return False
If Segments.Count <> other.Segments.Count Then Return False
For i As Integer = 0 To Segments.Count - 1
If Not String.Equals(Segments(i), other.Segments(i), StringComparison.OrdinalIgnoreCase) Then Return False
Next
Return True
End Function
Public Overrides Function GetHashCode() As Integer
Dim hash As HashCode = New HashCode()
For i As Integer = 0 To Segments?.Count - 1
hash.Add(Segments(i), StringComparer.OrdinalIgnoreCase)
Next
Return hash.ToHashCode()
End Function
End Structure
Module Program
Sub Main(args As String())
Dim hashSet As HashSet(Of Path) = New HashSet(Of Path) From {
New Path("C:", "tmp", "file.txt"),
New Path("C:", "TMP", "file.txt"),
New Path("C:", "tmp", "FILE.TXT")
}
Console.WriteLine($"Item count: {hashSet.Count}.")
End Sub
End Module
' The example displays the following output:
' Item count: 1.
' </Snippet1>

Просмотреть файл

@ -1,65 +0,0 @@
' <Snippet1>
Public Structure Path
Implements IEquatable(Of Path)
Public ReadOnly Property Segments As IReadOnlyList(Of String)
Public Sub New(ParamArray ByVal segments() As String)
Me.Segments = segments
End Sub
Public Overrides Function Equals(obj As Object) As Boolean
Return (TypeOf obj Is Path) AndAlso Equals(DirectCast(obj, Path))
End Function
Public Overloads Function Equals(other As Path) As Boolean Implements IEquatable(Of Path).Equals
If ReferenceEquals(Segments, other.Segments) Then Return True
If Segments Is Nothing OrElse other.Segments Is Nothing Then Return False
If Segments.Count <> other.Segments.Count Then Return False
For i As Integer = 0 To Segments.Count - 1
If Not PathEquals(Segments(i), other.Segments(i)) Then Return False
Next
Return True
End Function
Public Overrides Function GetHashCode() As Integer
Dim hash As HashCode = New HashCode()
For i As Integer = 0 To Segments?.Count - 1
AddPath(hash, Segments(i))
Next
Return hash.ToHashCode()
End Function
End Structure
Friend Module PlatformUtils
Public Function PathEquals(ByVal a As String, ByVal b As String) As Boolean
Return String.Equals(a, b, StringComparison.OrdinalIgnoreCase)
End Function
Public Sub AddPath(ByRef hash As HashCode, ByVal path As String)
hash.Add(path, StringComparer.OrdinalIgnoreCase)
End Sub
End Module
Module Program
Sub Main(args As String())
Dim hashSet As HashSet(Of Path) = New HashSet(Of Path) From {
New Path("C:", "tmp", "file.txt"),
New Path("C:", "TMP", "file.txt"),
New Path("C:", "tmp", "FILE.TXT")
}
Console.WriteLine($"Item count: {hashSet.Count}.")
End Sub
End Module
' The example displays the following output:
' Item count: 1.
' </Snippet1>

Просмотреть файл

@ -1,53 +0,0 @@
open System
let callToString () =
// <Snippet1>
let numbers = [| -1403L; 0L; 169L; 1483104L |]
for number in numbers do
// Display value using default formatting.
printf $"{number.ToString(),-8} --> "
// Display value with 3 digits and leading zeros.
printf $"{number,8:D3}"
// Display value with 1 decimal digit.
printf $"{number,13:N1}"
// Display value as hexadecimal.
printf $"{number,18:X2}"
// Display value with eight hexadecimal digits.
printfn $"{number,18:X8}"
// The example displays the following output:
// -1403 --> -1403 -1,403.0 FFFFFFFFFFFFFA85 FFFFFFFFFFFFFA85
// 0 --> 000 0.0 00 00000000
// 169 --> 169 169.0 A9 000000A9
// 1483104 --> 1483104 1,483,104.0 16A160 0016A160
// </Snippet1>
let callConvert () =
// <Snippet2>
let numbers = [| -146L; 11043L; 2781913L |]
for number in numbers do
printfn $"{number} (Base 10):"
printfn $" Binary: {Convert.ToString(number, 2)}"
printfn $" Octal: {Convert.ToString(number, 8)}"
printfn $" Hex: {Convert.ToString(number, 16)}\n"
// The example displays the following output:
// -146 (Base 10):
// Binary: 1111111111111111111111111111111111111111111111111111111101101110
// Octal: 1777777777777777777556
// Hex: ffffffffffffff6e
//
// 11043 (Base 10):
// Binary: 10101100100011
// Octal: 25443
// Hex: 2b23
//
// 2781913 (Base 10):
// Binary: 1010100111001011011001
// Octal: 12471331
// Hex: 2a72d9
// </Snippet2>
callToString ()
printfn "-----"
callConvert ()

Просмотреть файл

@ -1,43 +0,0 @@
' The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
Imports Windows.UI.Core
''' <summary>
''' An empty page that can be used on its own or navigated to within a Frame.
''' </summary>
Public NotInheritable Class MainPage
Inherits Page
' <Snippet4>
Private Async Sub DoSomeWork(milliseconds As Integer)
' Simulate work.
Await Task.Delay(milliseconds)
' Report completion.
Dim uiAccess As Boolean = textBox1.Dispatcher.HasThreadAccess
Dim msg As String = String.Format("Some work completed in {0} ms. on {1}UI thread" + vbCrLf,
milliseconds, If(uiAccess, String.Empty, "non-"))
If (uiAccess) Then
textBox1.Text += msg
Else
Await textBox1.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() textBox1.Text += msg)
End If
End Sub
' </Snippet4>
Private Async Sub threadExampleBtn_Click(sender As Object, e As RoutedEventArgs) ' Handles threadExampleBtn.Click
textBox1.Text = String.Empty
textBox1.Text = "Simulating work on UI thread." + vbCrLf
DoSomeWork(20)
textBox1.Text += "Work completed..." + vbCrLf
textBox1.Text += "Simulating work on non-UI thread." + vbCrLf
Await Task.Run(Sub() DoSomeWork(1000))
textBox1.Text += "Work completed.." + vbCrLf
End Sub
End Class

Просмотреть файл

@ -1,36 +0,0 @@
' Visual Basic .NET Document
Option Strict On
' <Snippet2>
Imports System.Globalization
Imports System.IO
Module Example
Public Sub Main()
Dim sw As New StreamWriter(".\graphemes.txt")
Dim grapheme As String = ChrW(&H0061) + ChrW(&h0308)
sw.WriteLine(grapheme)
Dim singleChar As String = ChrW(&h00e4)
sw.WriteLine(singleChar)
sw.WriteLine("{0} = {1} (Culture-sensitive): {2}", grapheme, singleChar,
String.Equals(grapheme, singleChar,
StringComparison.CurrentCulture))
sw.WriteLine("{0} = {1} (Ordinal): {2}", grapheme, singleChar,
String.Equals(grapheme, singleChar,
StringComparison.Ordinal))
sw.WriteLine("{0} = {1} (Normalized Ordinal): {2}", grapheme, singleChar,
String.Equals(grapheme.Normalize(),
singleChar.Normalize(),
StringComparison.Ordinal))
sw.Close()
End Sub
End Module
' The example produces the following output:
'
' ä
' = ä (Culture-sensitive): True
' = ä (Ordinal): False
' = ä (Normalized Ordinal): True
' </Snippet2>

Просмотреть файл

@ -703,6 +703,8 @@ items:
href: ../../standard/data/sqlite/xamarin.md
- name: Supplemental API remarks
items:
- name: System.Data.CommandBehavior enum
href: ../../fundamentals/runtime-libraries/system-data-commandbehavior.md
- name: System.Data.DataSet class
href: ../../fundamentals/runtime-libraries/system-data-dataset.md
- name: System.Data.DataTable class