From 3645e28060c5d39450acb00a8d213db9c9768840 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:05:11 +0200 Subject: [PATCH 1/8] delete code example text from obsolete types --- .../CaseInsensitiveHashCodeProvider.xml | 32 - .../LocalizationExtenderProvider.xml | 24 - .../OdbcParameterCollection.xml | 146 ++- .../OleDbParameterCollection.xml | 124 +- .../OracleClientFactory.xml | 143 +-- .../OracleCommand.xml | 490 +++----- .../OracleCommandBuilder.xml | 46 - .../OracleConnection.xml | 99 +- .../OracleConnectionStringBuilder.xml | 82 -- .../OracleDataAdapter.xml | 1005 +++-------------- .../OracleParameterCollection.xml | 8 +- .../RegistrationHelperTx.xml | 96 +- xml/System.Net.Mail/SmtpPermission.xml | 222 ++-- .../NetworkInformationPermission.xml | 228 ++-- xml/System.Net/DnsPermission.xml | 68 +- xml/System.Net/DnsPermissionAttribute.xml | 62 +- xml/System.Net/GlobalProxySelection.xml | 20 - xml/System.Net/SocketPermission.xml | 138 +-- xml/System.Net/WebPermission.xml | 126 --- xml/System.Net/WebPermissionAttribute.xml | 134 +-- .../UnmanagedMarshal.xml | 141 ++- .../WorkflowServiceHostFactory.xml | 47 +- .../SqlPersistenceProviderFactory.xml | 64 +- xml/System.Xml.Schema/XmlSchemaCollection.xml | 78 -- xml/System.Xml.Xsl/XslTransform.xml | 634 +---------- xml/System.Xml/XmlDataDocument.xml | 112 +- xml/System.Xml/XmlValidatingReader.xml | 413 +------ xml/System/TimeZone.xml | 37 +- 28 files changed, 856 insertions(+), 3963 deletions(-) diff --git a/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml b/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml index 1c75c58768e..7d426c822de 100644 --- a/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml +++ b/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml @@ -82,14 +82,6 @@ The objects used as keys by a are required to override the method (or the interface) and the method (or the interface). The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the might behave incorrectly. For example, when creating a , you must use this class with the class or any case-insensitive implementation. - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - ]]> @@ -150,14 +142,6 @@ ## Remarks When the instance is created using this constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the casing rules; therefore, hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - ]]> @@ -210,14 +194,6 @@ ## Remarks Comparison procedures use the specified to determine the casing rules. Hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - ]]> @@ -320,14 +296,6 @@ ## Remarks Comparison procedures use the to determine the casing rules. Hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - ]]> diff --git a/xml/System.ComponentModel.Design/LocalizationExtenderProvider.xml b/xml/System.ComponentModel.Design/LocalizationExtenderProvider.xml index 4260d58b172..d967b92745b 100644 --- a/xml/System.ComponentModel.Design/LocalizationExtenderProvider.xml +++ b/xml/System.ComponentModel.Design/LocalizationExtenderProvider.xml @@ -52,21 +52,6 @@ The default serializers that ship with Visual Studio are already capable of localizing components and controls, but they only do so if they locate support for the .NET Framework localization architecture. To detect the presence of localization support, the serialization system must locate a public property named "Localizable" on the root designer component. If a serializer finds this property, it searches for a property of type named "Language" to determine the current resource configuration. Default serializers use these properties to determine if it should localize any localizable resources of the component, and if so, what format the resource information should be saved in. - - -## Examples - The following code example adds a to a component. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/LocalizationExtenderProviderExample/CPP/class1.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.ComponentModel.Design/LocalizationExtenderProvider/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/LocalizationExtenderProviderExample/VB/class1.vb" id="Snippet2"::: - - The following code example includes an example component and designer. The designer uses a to add localization support properties for the component. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/LocalizationExtenderProviderExample/CPP/class1.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.ComponentModel.Design/LocalizationExtenderProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/LocalizationExtenderProviderExample/VB/class1.vb" id="Snippet1"::: - ]]> @@ -99,15 +84,6 @@ ## Remarks By default, a new sets the current language to , which is the generic and default language resource setting. This setting causes a designer to generate code that references the generic language resource. You can create other objects to represent and identify other localized resource data that a program can use at run time. - - -## Examples - The following code example creates a new object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/LocalizationExtenderProviderExample/CPP/class1.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.ComponentModel.Design/LocalizationExtenderProvider/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/LocalizationExtenderProviderExample/VB/class1.vb" id="Snippet2"::: - ]]> diff --git a/xml/System.Data.Odbc/OdbcParameterCollection.xml b/xml/System.Data.Odbc/OdbcParameterCollection.xml index ec557bfcd2d..bb60befadad 100644 --- a/xml/System.Data.Odbc/OdbcParameterCollection.xml +++ b/xml/System.Data.Odbc/OdbcParameterCollection.xml @@ -70,30 +70,30 @@ Represents a collection of parameters relevant to an and their respective mappings to columns in a . This class cannot be inherited. - Working with Commands @@ -234,14 +234,14 @@ INSERT INTO MyTable VALUES (@p1, @p2, @p3); Adds an to the , given the parameter name and data type. The index of the new object. - to the collection. - + to the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add2/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add2/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add2/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -301,17 +301,11 @@ INSERT INTO MyTable VALUES (@p1, @p2, @p3); Adds an to the given the parameter name and value. The index of the new object. - method to specify integer parameter values. Because this overload takes a `value` of type , you must convert the integer value to an type when the value is zero, as the following C# example demonstrates. - -``` -parameters.Add("@pname", Convert.ToInt32(0)); -``` - - If you do not perform this conversion, the compiler will assume you are attempting to call the overload. - + method to specify integer parameter values. Because this overload takes a `value` of type , you must convert the integer value to an type when the value is zero. If you don't perform this conversion, the compiler will assume you are attempting to call the overload. + ]]> The parameter is not an . @@ -361,14 +355,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Adds an to the , given the parameter name, data type, and column length. The index of the new object. - to the `OdbcCommand.Parameters` collection. - + to the `OdbcCommand.Parameters` collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add3/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add3/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add3/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -418,14 +412,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Adds an to the given the parameter name, data type, column length, and source column name. The index of the new object. - to the collection. - + to the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add4/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add4/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Add4/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -707,14 +701,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); if the collection contains the parameter; otherwise, . - with a given within an . If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an has already been created. - + with a given within an . If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an has already been created. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.this1/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.this1/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.this1/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -1298,14 +1292,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Gets or sets the at the specified index. The at the specified index. - , adds instances of to the collection, displays the names of its objects, and then clears the collection. - + , adds instances of to the collection, displays the names of its objects, and then clears the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Count/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Count/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.Count/VB/source.vb" id="Snippet1"::: + ]]> The index specified does not exist. @@ -1352,14 +1346,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Gets or sets the with the specified name. The with the specified name. - with a given within an . If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an has already been created. - + with a given within an . If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an has already been created. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.this1/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.this1/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameterCollection.this1/VB/source.vb" id="Snippet1"::: + ]]> The name specified does not exist. diff --git a/xml/System.Data.OleDb/OleDbParameterCollection.xml b/xml/System.Data.OleDb/OleDbParameterCollection.xml index 1afa91c80fd..f033bfe9fbc 100644 --- a/xml/System.Data.OleDb/OleDbParameterCollection.xml +++ b/xml/System.Data.OleDb/OleDbParameterCollection.xml @@ -73,19 +73,19 @@ Represents a collection of parameters relevant to an as well as their respective mappings to columns in a . - through the collection within the . These parameters are used to select data within the data source and place the data in the . This example assumes that a and an have already been created with the appropriate schema, commands, and connection. - + through the collection within the . These parameters are used to select data within the data source and place the data in the . This example assumes that a and an have already been created with the appropriate schema, commands, and connection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -133,14 +133,14 @@ Adds the specified to the . The index of the new object. - and adds an . - + and adds an . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add5 Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add5 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add5 Example/VB/source.vb" id="Snippet1"::: + ]]> The specified in the parameter is already added to this or another . @@ -236,14 +236,14 @@ Adds an to the , given the parameter name and data type. The index of the new object. - and adds an . - + and adds an . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add6 Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add6 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add6 Example/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -303,17 +303,11 @@ Adds an to the given the parameter name and value. The index of the new object. - method to specify integer parameter values. Because this overload takes a `value` of type , you must convert the value to an type when the value is zero, as the following C# example demonstrates. - -``` -parameters.Add("@pname", Convert.ToInt32(0)); -``` - - If you do not perform this conversion, the compiler will assume you are attempting to call the overload. - + method to specify integer parameter values. Because this overload takes a `value` of type , you must convert the value to an type when the value is zero.If you don't perform this conversion, the compiler will assume you are attempting to call the overload. + ]]> The parameter is not an . @@ -363,14 +357,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Adds an to the given the parameter name, data type, and column length. The index of the new object. - , adds an instance of to the collection, and returns a reference to the new . - + , adds an instance of to the collection, and returns a reference to the new . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add3 Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add3 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add3 Example/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -420,14 +414,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Adds an to the given the parameter name, data type, column length, and source column name. The index of the new object. - , adds an instance of to the collection, and returns a reference to the new . - + , adds an instance of to the collection, and returns a reference to the new . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add4 Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add4 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Add4 Example/VB/source.vb" id="Snippet1"::: + ]]> Working with Commands @@ -1290,14 +1284,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Gets or sets the at the specified index. The at the specified index. - , adds instances of to the collection, displays the names of its objects, and then clears the collection. - + , adds instances of to the collection, displays the names of its objects, and then clears the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Count Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Count Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.Count Example/VB/source.vb" id="Snippet1"::: + ]]> The index specified does not exist. @@ -1344,14 +1338,14 @@ parameters.Add("@pname", Convert.ToInt32(0)); Gets or sets the with the specified name. The with the specified name. - with a given within an . If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an has already been created. - + with a given within an . If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an has already been created. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.this1 Example/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.this1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameterCollection.this1 Example/VB/source.vb" id="Snippet1"::: + ]]> The name specified does not exist. diff --git a/xml/System.Data.OracleClient/OracleClientFactory.xml b/xml/System.Data.OracleClient/OracleClientFactory.xml index 1f1ea2a58cb..07f1d6b3b2f 100644 --- a/xml/System.Data.OracleClient/OracleClientFactory.xml +++ b/xml/System.Data.OracleClient/OracleClientFactory.xml @@ -23,11 +23,11 @@ Represents a set of methods for creating instances of the Oracle provider's implementation of the data source classes. - @@ -52,24 +52,7 @@ Returns a strongly typed instance. A new strongly typed instance of . - - instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim command As DbCommand = newFactory.CreateCommand() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbCommand command = newFactory.CreateCommand(); -``` - - ]]> - + To be added. @@ -92,24 +75,7 @@ DbCommand command = newFactory.CreateCommand(); Returns a strongly typed instance. A new strongly typed instance of . - - instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim commandBuilder As DbCommandBuilder = newFactory.CreateCommandBuilder() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbCommandBuilder commandBuilder = newFactory.CreateCommandBuilder(); -``` - - ]]> - + To be added. @@ -132,24 +98,7 @@ DbCommandBuilder commandBuilder = newFactory.CreateCommandBuilder(); Returns a strongly typed instance. A new strongly typed instance of . - - instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim connection As DbConnection = newFactory.CreateConnection() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbConnection connection = newFactory.CreateConnection(); -``` - - ]]> - + To be added. @@ -172,24 +121,7 @@ DbConnection connection = newFactory.CreateConnection(); Returns a strongly typed instance. A new strongly typed instance of . - - instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim connectionBuilder As DbConnectionStringBuilder = newFactory.CreateConnectionStringBuilder() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbConnectionStringBuilder connectionBuilder = newFactory.CreateConnectionStringBuilder(); -``` - - ]]> - + To be added. @@ -212,24 +144,7 @@ DbConnectionStringBuilder connectionBuilder = newFactory.CreateConnectionStringB Returns a strongly typed instance. A new strongly typed instance of . - - instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim dataAdapter As DbDataAdapter = newFactory.CreateDataAdapter() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbDataAdapter dataAdapter = newFactory.CreateDataAdapter(); -``` - - ]]> - + To be added. @@ -252,24 +167,7 @@ DbDataAdapter dataAdapter = newFactory.CreateDataAdapter(); Returns a strongly typed instance. A new strongly typed instance of . - - instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim parameter As DbParameter = newFactory.CreateParameter() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbParameter parameter = newFactory.CreateParameter(); -``` - - ]]> - + To be added. @@ -316,24 +214,7 @@ DbParameter parameter = newFactory.CreateParameter(); Gets an instance of the , which can be used to retrieve strongly typed data objects. - - field to retrieve an instance and then return a strongly typed instance. - -```vb -Dim newFactory As OracleClientFactory = OracleClientFactory.Instance -Dim command As DbCommand = newFactory.CreateCommand() -``` - -```csharp -OracleClientFactory newFactory = OracleClientFactory.Instance; -DbCommand command = newFactory.CreateCommand(); -``` - - ]]> - + To be added. diff --git a/xml/System.Data.OracleClient/OracleCommand.xml b/xml/System.Data.OracleClient/OracleCommand.xml index 35f513e26a1..dea650f883a 100644 --- a/xml/System.Data.OracleClient/OracleCommand.xml +++ b/xml/System.Data.OracleClient/OracleCommand.xml @@ -60,36 +60,28 @@ Represents an SQL statement or stored procedure to execute against a database. This class cannot be inherited. - class provides the following methods for executing commands against a data source: - -|Item|Description| -|----------|-----------------| -||Executes commands that return rows.| -||Executes an SQL statement against the and returns the number of rows affected.| -||Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.| -||Retrieves a single value (for example, an aggregate value) from a database as a .NET Framework data type.| -||Retrieves a single value (for example, an aggregate value) from a database as an Oracle-specific data type.| - - You can reset the property and reuse the object. - - If execution of the command results in a fatal , the may close. However, the user can reopen the connection and continue. - + class provides the following methods for executing commands against a data source: + +|Item|Description| +|----------|-----------------| +||Executes commands that return rows.| +||Executes an SQL statement against the and returns the number of rows affected.| +||Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.| +||Retrieves a single value (for example, an aggregate value) from a database as a .NET Framework data type.| +||Retrieves a single value (for example, an aggregate value) from a database as an Oracle-specific data type.| + + You can reset the property and reuse the object. + + If execution of the command results in a fatal , the may close. However, the user can reopen the connection and continue. + > [!NOTE] -> Unlike the **Command** object in the other .NET Framework data providers (SQL Server, OLE DB, and ODBC), the object does not support a property. Setting a command timeout has no effect and the value returned is always zero. - - - -## Examples - The following example uses the method of , along with and , to select rows from a table. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb" id="Snippet1"::: - +> Unlike the **Command** object in the other .NET Framework data providers (SQL Server, OLE DB, and ODBC), the object does not support a property. Setting a command timeout has no effect and the value returned is always zero. + ]]> Working with Commands @@ -122,25 +114,17 @@ Initializes a new instance of the . - . - -|Properties|Initial Value| -|----------------|-------------------| -||empty string ("")| -||`Text`| -||null| - - - -## Examples - The following example creates an and sets some of its properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb" id="Snippet1"::: - + . + +| Properties | Initial Value | +|--------------------------------------------------------------|-------------------| +| | empty string ("") | +| | `Text` | +| | null | + ]]> Working with Commands @@ -192,17 +176,7 @@ The text of the query. An object that represents the connection to a database. Initializes a new instance of the class with the text of the query and an object. - - . - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb" id="Snippet1"::: - - ]]> - + To be added. Working with Commands @@ -231,27 +205,19 @@ The in which the executes. Initializes a new instance of the class with the text of the query, an object, and an . - . - -|Properties|Initial Value| -|----------------|-------------------| -||`cmdText`| -||`Text`| -||A new that is the value for the `connection` parameter.| - - You can change the value for any of these parameters by setting the related property. - - - -## Examples - The following example creates an and sets some of its properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/CS/mysample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb" id="Snippet1"::: - + . + +| Properties | Initial Value | +|--------------------------------------------------------------|---------------| +| | `cmdText` | +| | `Text` | +| | A new that is the value for the `connection` parameter. | + + You can change the value for any of these parameters by setting the related property. + ]]> Working with Commands @@ -286,19 +252,11 @@ Attempts to cancel the execution of an . - , executes it, then cancels the execution. To accomplish this, the method is passed a string that is an SQL SELECT statement and a string to use to connect to the database. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb" id="Snippet1"::: - + Working with Commands @@ -381,27 +339,15 @@ Gets or sets the SQL statement or stored procedure to execute against the database. The SQL statement or stored procedure to execute. The default value is an empty string (""). - property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the Execute methods. - - The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an of `CommandType.Text`. In this case, named parameters must be used. For example: - -``` -SELECT * FROM Customers WHERE CustomerID = :pCustomerID -``` - - When using named parameters in an SQL statement called by an of `CommandType.Text`, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding objects to the property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically. - - - -## Examples - The following example creates an and sets some of its properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb" id="Snippet1"::: - + property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the Execute methods. + + The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an of `CommandType.Text`. In this case, named parameters must be used. + + When using named parameters in an SQL statement called by an of `CommandType.Text`, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding objects to the property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically. + ]]> Working with Commands @@ -441,11 +387,11 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Gets or sets the wait time (in seconds) before terminating the attempt to execute a command and generating an error. The time (in seconds) to wait for the command to execute. The default value is 30 seconds. - is generated if the assigned property value is less than 0. - + is generated if the assigned property value is less than 0. + ]]> Working with Commands @@ -488,29 +434,17 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Gets or sets a value indicating how the property is interpreted. One of the values. The default is . - property is set to `StoredProcedure`, you should set the property to the full Oracle call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, or ). - - The , and properties cannot be set if the current connection is performing an execute or fetch operation. - - The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an of `CommandType.Text`. In this case, named parameters must be used. For example: - -``` -SELECT * FROM Customers WHERE CustomerID = :pCustomerID -``` - - When using named parameters in an SQL statement called by an of `CommandType.Text`, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding objects to the property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically. - - - -## Examples - The following example creates an instance of a derived class and sets some of its properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb" id="Snippet1"::: - + property is set to `StoredProcedure`, you should set the property to the full Oracle call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, or ). + + The , and properties cannot be set if the current connection is performing an execute or fetch operation. + + The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an of `CommandType.Text`. In this case, named parameters must be used. + + When using named parameters in an SQL statement called by an of `CommandType.Text`, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding objects to the property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically. + ]]> The value was not a valid . @@ -556,21 +490,13 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Gets or sets the used by this instance of the . The connection to a data source. The default is a null value. - , , and properties if the current connection is performing an execute or fetch operation. - - If you set while a transaction is in progress and the property is not null, an is generated. If you set after the transaction has been committed or rolled back, and the property is not null, the property is then set to a null value. - - - -## Examples - The following example creates an and sets some of its properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb" id="Snippet1"::: - + , , and properties if the current connection is performing an execute or fetch operation. + + If you set while a transaction is in progress and the property is not null, an is generated. If you set after the transaction has been committed or rolled back, and the property is not null, the property is then set to a null value. + ]]> The property was changed while a transaction was in progress. @@ -623,11 +549,11 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Creates a new instance of an object. An object. - method is a strongly-typed version of . - + method is a strongly-typed version of . + ]]> Working with Commands @@ -801,29 +727,21 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Executes an SQL statement against the and returns the number of rows affected. For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For CREATE TABLE and DROP TABLE statements, the return value is 0. For all other types of statements, the return value is -1. - to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables); or to change the data in a database, without using a , by executing UPDATE, INSERT, or DELETE statements. - - Although does not return any rows, any output parameters or return values mapped to parameters are populated with data. - - For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For CREATE TABLE and DROP TABLE statements, the return value is 0. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1. - - - -## Examples - The following example creates an and then executes it by using . The example is passed a string that is an SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to connect to the database. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb" id="Snippet1"::: - + to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables); or to change the data in a database, without using a , by executing UPDATE, INSERT, or DELETE statements. + + Although does not return any rows, any output parameters or return values mapped to parameters are populated with data. + + For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For CREATE TABLE and DROP TABLE statements, the return value is 0. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1. + ]]> - The connection does not exist. - - -or- - + The connection does not exist. + + -or- + The connection is not open. Working with Commands @@ -853,21 +771,21 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Executes an SQL statement against the and returns the number of rows affected. For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For CREATE TABLE and DROP TABLE statements, the return value is 0. For all other types of statements, the return value is -1. - to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables); or to change the data in a database, without using a , by executing UPDATE, INSERT, or DELETE statements. - - differs from in that it returns `rowid` as an output parameter if you are executing an INSERT, DELETE, or UPDATE statement that affects exactly one row. This allows you to uniquely identify a row in the Oracle database, which can allow you to increase performance in subsequent, related queries. - - Although does not return any rows, any output parameters or return values mapped to parameters are populated with data. - + to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables); or to change the data in a database, without using a , by executing UPDATE, INSERT, or DELETE statements. + + differs from in that it returns `rowid` as an output parameter if you are executing an INSERT, DELETE, or UPDATE statement that affects exactly one row. This allows you to uniquely identify a row in the Oracle database, which can allow you to increase performance in subsequent, related queries. + + Although does not return any rows, any output parameters or return values mapped to parameters are populated with data. + ]]> - The connection does not exist. - - -or- - + The connection does not exist. + + -or- + The connection is not open. Working with Commands @@ -894,18 +812,11 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Executes the query, and returns the first column of the first row in the result set returned by the query as an Oracle-specific data type. Extra columns or rows are ignored. The first column of the first row in the result set as an Oracle-specific data type, or a null reference if the result is a . - method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the method, and then performing the operations necessary to generate the single value from the data returned by an . - - A typical query can be formatted as in the following C# example: - -``` -command.CommandText = "SELECT COUNT(*) AS NumberOfRegions FROM Region"; -count = command.ExecuteOracleScalar(); -``` - + method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the method, and then performing the operations necessary to generate the single value from the data returned by an . + ]]> Working with Commands @@ -944,21 +855,13 @@ count = command.ExecuteOracleScalar(); Sends the to the and builds an . An object. - property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The command then executes this stored procedure when you call . - - More than one can be open at any given time. - - - -## Examples - The following example creates an , and then executes it by passing a string that is an SQL SELECT statement, and a string to use to connect to the data source. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb" id="Snippet1"::: - + property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The command then executes this stored procedure when you call . + + More than one can be open at any given time. + ]]> Working with Commands @@ -990,25 +893,17 @@ count = command.ExecuteOracleScalar(); Sends the to the , and builds an using one of the values. An object. - value may improve application performance. - - When the property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The command then executes this stored procedure when you call . - - The supports a special mode that enables large binary values to be read efficiently. For more information, see the `SequentialAccess` setting for . - - More than one can be open at any given time. - - - -## Examples - The following example creates an , and then executes it by passing a string that is an SQL SELECT statement, and a string to use to connect to the database. is then set to . - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/CS/mysample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb" id="Snippet1"::: - + value may improve application performance. + + When the property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The command then executes this stored procedure when you call . + + The supports a special mode that enables large binary values to be read efficiently. For more information, see the `SequentialAccess` setting for . + + More than one can be open at any given time. + ]]> Working with Commands @@ -1044,26 +939,11 @@ count = command.ExecuteOracleScalar(); Executes the query, and returns the first column of the first row in the result set returned by the query as a .NET data type. Extra columns or rows are ignored. The first column of the first row in the result set as a .NET data type, or a null reference if the result set is empty or the result is a . - method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the method, and then performing the operations necessary to generate the single value from the data returned by an . - - A typical query can be formatted as in the following C# example: - -``` -CommandText = "SELECT COUNT(*) FROM Region"; -Int32 count = (int32) ExecuteScalar(); -``` - - - -## Examples - The following example creates an and then executes it using . The example is passed a string that is an SQL statement that returns an aggregate result, and a string to use to connect to the database. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/CS/mysample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb" id="Snippet1"::: - + method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the method, and then performing the operations necessary to generate the single value from the data returned by an . + ]]> Working with Commands @@ -1096,27 +976,15 @@ Int32 count = (int32) ExecuteScalar(); Gets the . The parameters of the SQL statement or stored procedure. The default is an empty collection. - property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the Execute methods. - - The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an of `CommandType.Text`. In this case, named parameters must be used. For example: - -``` -SELECT * FROM Customers WHERE CustomerID = :pCustomerID -``` - - When using named parameters in an SQL statement called by an of `CommandType.Text`, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding objects to the property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically. - - - -## Examples - The following example creates an and displays its parameters. To accomplish this, the method is passed an , a query string that is an SQL SELECT statement, and an array of objects. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb" id="Snippet1"::: - + property is set to `StoredProcedure`, the property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the Execute methods. + + The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an of `CommandType.Text`. In this case, named parameters must be used. + + When using named parameters in an SQL statement called by an of `CommandType.Text`, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding objects to the property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically. + ]]> Working with Commands @@ -1151,17 +1019,17 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Creates a prepared (or compiled) version of the command at the data source. - , specify the data type of each parameter in the statement to be prepared. - + , specify the data type of each parameter in the statement to be prepared. + ]]> - The is not set. - - -or- - + The is not set. + + -or- + The is not . Working with Commands @@ -1186,11 +1054,11 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID Resets the property to the default value. - is 30 seconds. - + is 30 seconds. + ]]> Working with Commands @@ -1221,7 +1089,7 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID . ]]> @@ -1281,7 +1149,7 @@ For more information, see . . ]]> @@ -1319,11 +1187,11 @@ For more information, see . Gets or sets the within which the executes. An . The default is a null value. - property if it is already set to a specific value, and the command is in the process of executing. If you set the transaction property to an object that is not connected to the same as the object, an exception will be thrown the next time you attempt to execute a statement. - + property if it is already set to a specific value, and the command is in the process of executing. If you set the transaction property to an object that is not connected to the same as the object, an exception will be thrown the next time you attempt to execute a statement. + ]]> Working with Commands @@ -1362,13 +1230,13 @@ For more information, see . Gets or sets a value that specifies how the method should apply command results to the . One of the values. - value is `Both` unless the command is automatically generated (as in the case of the ), in which case the default is `None`. - - For more information about using the property, see [DataAdapter Parameters](/dotnet/framework/data/adonet/dataadapter-parameters). - + value is `Both` unless the command is automatically generated (as in the case of the ), in which case the default is `None`. + + For more information about using the property, see [DataAdapter Parameters](/dotnet/framework/data/adonet/dataadapter-parameters). + ]]> The value entered was not one of the values. diff --git a/xml/System.Data.OracleClient/OracleCommandBuilder.xml b/xml/System.Data.OracleClient/OracleCommandBuilder.xml index ca1cdb4b05e..aff355ca8c4 100644 --- a/xml/System.Data.OracleClient/OracleCommandBuilder.xml +++ b/xml/System.Data.OracleClient/OracleCommandBuilder.xml @@ -45,52 +45,6 @@ If you call , the is disassociated from the , and the generated commands are no longer used. - - -## Examples - The following example uses , along with and , to select rows from a database. The example is passed an initialized , a connection string, a query string that is an SQL SELECT statement, and a string that is the name of the database table. The example then creates an . - -```vb -Private Function SelectOracleRows(connection As String, queryString As String, tableName As String) As DataSet - - Dim connection As New OracleConnection(connection) - Dim dataAdapter As New OracleDataAdapter() - Dim dataSet As DataSet = New DataSet - - dataAdapter.SelectCommand = New OracleCommand(queryString, connection) - - Dim cmdBuilder As OracleCommandBuilder = New OracleCommandBuilder(dataAdapter) - - connection.Open() - dataAdapter.Fill(dataSet, tableName) - ' Code to modify data in DataSet here - ' Without the OracleCommandBuilder this line would fail. - dataAdapter.Update(dataSet, tableName) - connection.Close() -End Function -``` - -```csharp -public static DataSet SelectOracleSrvRows(string myConnection, string mySelectQuery, string myTableName) -{ - OracleConnection myConn = new OracleConnection(myConnection); - OracleDataAdapter myDataAdapter = new OracleDataAdapter(); - myDataAdapter.SelectCommand = new OracleCommand(mySelectQuery, myConn); - OracleCommandBuilder cb = new OracleCommandBuilder(myDataAdapter); - - myConn.Open(); - DataSet ds = new DataSet(); - myDataAdapter.Fill(ds, myTableName); - - //Code to modify data in DataSet goes here... - - //Without the OracleCommandBuilder this line would fail. - myDataAdapter.Update(ds, myTableName); - myConn.Close(); - return ds; -} -``` - ]]> Generating Commands with CommandBuilders diff --git a/xml/System.Data.OracleClient/OracleConnection.xml b/xml/System.Data.OracleClient/OracleConnection.xml index fc055b52324..ee19ca67827 100644 --- a/xml/System.Data.OracleClient/OracleConnection.xml +++ b/xml/System.Data.OracleClient/OracleConnection.xml @@ -47,27 +47,19 @@ object represents a unique connection to an Oracle database. In the case of a client/server database system, it is equivalent to a network connection to the server. An application that creates an instance of the object can set declarative or imperative security demands that require all direct and indirect callers to have adequate permission to the code. creates security demands by using the object. Users can verify that their code has adequate permissions by using the object. Users and administrators can also use the Code Access Security Policy Tool (Caspol.exe) to modify security policy at the machine, user, and enterprise levels. For more information, see [Security](/dotnet/standard/security/). > [!NOTE] -> Unlike the **Connection** object in the other .NET Framework data providers (SQL Server, OLE DB, and ODBC), does not support a property. Setting a connection time-out either as a property or in the connection string has no effect, and the value returned is always zero. also does not support a property or a method. +> Unlike the **Connection** object in the other .NET Framework data providers (SQL Server, OLE DB, and ODBC), does not support a property. Setting a connection time-out either as a property or in the connection string has no effect, and the value returned is always zero. also does not support a property or a method. If the object goes out of scope, it remains open. Therefore, you should always close objects by calling or **Dispose**, or by using the object within a `Using` statement. Otherwise, the garbage collection might not free them immediately. Such delays can cause errors if the maximum number of connections is reached while a number of connections are waiting to be deleted by the garbage collector. By contrast, closing the connections by calling uses native resources more efficiently, enhancing scalability and improving overall application performance. To ensure that connections are always closed, open the connection inside of a `Using` block. > [!NOTE] -> To deploy high-performance applications, you often need to use connection pooling. However, when you use the .NET Framework Data Provider for Oracle, you do not need to enable connection pooling because the provider manages this automatically. - - - -## Examples - The following example creates an and an . The is opened and set as the property. The example then calls , and closes the connection. To accomplish this, the is passed a connection string and a query string that is an SQL INSERT statement. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb" id="Snippet1"::: +> To deploy high-performance applications, you often need to use connection pooling. However, when you use the .NET Framework Data Provider for Oracle, you do not need to enable connection pooling because the provider manages this automatically. ]]> @@ -100,17 +92,7 @@ Initializes a new instance of the . - - . - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb" id="Snippet1"::: - - ]]> - + To be added. @@ -133,17 +115,7 @@ The connection used to open the database. Initializes a new instance of the class with the specified connection string. - - . - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb" id="Snippet1"::: - - ]]> - + To be added. @@ -212,15 +184,7 @@ To ensure that the .NET Framework Data Provider for Oracle transaction management model performs correctly, avoid using other transaction management models, such as those provided by the database. > [!NOTE] -> If you do not specify an isolation level, the default isolation level is used. To specify an isolation level with the method, use the overload. - - - -## Examples - The following example creates an and an . It also demonstrates how to use the , , and methods. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.BeginTransaction/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.BeginTransaction/VB/source.vb" id="Snippet1"::: +> If you do not specify an isolation level, the default isolation level is used. To specify an isolation level with the method, use the overload. ]]> @@ -262,14 +226,6 @@ To ensure that the .NET Framework Data Provider for Oracle transaction management model performs correctly, avoid using other transaction management models, such as those provided by the database. - - -## Examples - The following example creates an and an . It also demonstrates how to use the , , and methods. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.BeginTransaction/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.BeginTransaction/VB/source.vb" id="Snippet1"::: - ]]> Parallel transactions are not supported. @@ -484,11 +440,7 @@ ## Remarks The can be set only when the connection is closed. - You can use the property to connect to a database. The following example illustrates a typical connection string. - -``` -"Data Source=Oracle8i;Integrated Security=yes" -``` + You can use the property to connect to a database. Many of the settings specified in the string have corresponding read-only properties (for example, `Data Source=MyServer`, which corresponds to the property). When the connection string is set, all of these properties are updated, unless an error is detected, in which case none of the properties are updated. properties return only default settings or those settings specified in the . @@ -535,14 +487,6 @@ When setting keyword or connection pooling values that require a Boolean value, you can use 'yes' instead of 'true', and 'no' instead of 'false'. Integer values are represented as strings. - - -## Examples - The following example creates an and sets some of its properties in the connection string. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb" id="Snippet1"::: - ]]> @@ -714,17 +658,7 @@ Gets the name of the Oracle server to which to connect. The name of the Oracle server to which to connect. The default value is an empty string (""). - - and displays some of its read-only properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb" id="Snippet1"::: - - ]]> - + To be added. @@ -1072,14 +1006,6 @@ ## Remarks The property is in Oracle version format. For example, the format for an Oracle8 release is a string in the form "8.1.7.0.0 Oracle8 Release 8.1.7.0.0 - Production." - - -## Examples - The following example creates an and displays some of its read-only properties. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb" id="Snippet1"::: - ]]> The connection is closed. @@ -1128,17 +1054,8 @@ The allowed state changes are: - From `Closed` to `Open`, using the `Open` method of the object. - - From `Open` to `Closed`, using the method of the object. - - -## Examples - The following example creates an instance of a derived class, , sets its , and displays its . - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb" id="Snippet1"::: - ]]> diff --git a/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml b/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml index 5bfd95a282e..8459c11139e 100644 --- a/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml +++ b/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml @@ -42,32 +42,6 @@ The performs checks for valid key/value pairs. Therefore, this class cannot be used to create invalid connection strings. Trying to add invalid pairs will throw an exception. The class maintains a fixed collection of synonyms, and when required, can perform the required translation to convert from a synonym to the corresponding well-known key name. For example, when you use the property to retrieve a value, you can specify a string that contains any synonym for the key you need. See the property for a full list of acceptable synonyms. - The handles attempts to insert malicious entries. For example, the following code, using the default property (the indexer, in C#), correctly escapes the nested key/value pair. - -```vb -Dim builder As New System.Data. _ - OracleClient.OracleConnectionStringBuilder -builder("Data Source") = "OracleDemo;NewValue=Bad" -builder("Integrated Security") = True -builder("User ID") = "Mary;NewValue=Bad" -System.Diagnostics.Debug.WriteLine(builder.ConnectionString) -``` - -```csharp -System.Data.OracleClient.OracleConnectionStringBuilder builder = - new System.Data.OracleClient.OracleConnectionStringBuilder(); -builder["Data Source"] = "OracleDemo"; -builder["integrated Security"] = true; -builder["User ID"] = "Mary;NewValue=Bad"; -System.Diagnostics.Debug.WriteLine(builder.ConnectionString); -``` - - The result is the following connection string that handles the invalid value in a safe manner by enclosing the User ID value in quotes: - -```txt -Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" -``` - [!INCLUDE[ROPC warning](~/includes/ropc-warning.md)] ]]> @@ -159,14 +133,6 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" ## Remarks The method removes all key/value pairs from the , and resets all corresponding properties. This includes resetting the connection string to an empty string. - - -## Examples - The following example demonstrates the effect of calling the method. This example populates the with some key/value pairs, and then calls the method and shows the results. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb" id="Snippet1"::: - ]]> Building Connection Strings @@ -202,14 +168,6 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" ## Remarks Because the contains a fixed-size collection of key/value pairs, the method determines only if a particular key name is valid. - - -## Examples - The following example creates an instance, sets some of its properties, and then tries to determine whether various keys exist within the object by calling the method. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb" id="Snippet1"::: - ]]> @@ -252,14 +210,6 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" ## Remarks This property corresponds to the "Data Source" and "Server" keys within the connection string. Regardless of which of these values has been supplied within the supplied connection string, the connection string created by the will use the well-known "Data Source" key. If the value passed in is null when you try to set the property, the property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . - - -## Examples - The following example demonstrates that the class converts synonyms for the "Data Source" connection string key into the well-known key. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb" id="Snippet1"::: - ]]> Building Connection Strings @@ -435,14 +385,6 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" |Unicode||False| |Load Balance Timeout (or connection lifetime)||0| - - -## Examples - The following code, in a console application, creates a new and adds key/value pairs to its connection string, using the property. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb" id="Snippet1"::: - ]]> @@ -477,14 +419,6 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" ## Remarks The order of the values in the is unspecified, but it is the same order as the associated values in the returned by the property. - - -## Examples - The following console application example creates a new . The code loops through the returned by the property displaying the key/value pairs. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb" id="Snippet1"::: - ]]> @@ -904,14 +838,6 @@ The collection of keys supported by the method lets developers safely retrieve a value from an without needing to verify that the supplied key name is a valid key name. Because gracefully handles searching for a non-existent key, there is no need to look for the existence of a key before retrieving its value. Calling with a nonexistent key will place the value null (`Nothing` in Visual Basic) in the `value` parameter. - - -## Examples - The following example demonstrates the behavior of the method. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb" id="Snippet1"::: - ]]> Building Connection Strings @@ -1024,14 +950,6 @@ The collection of keys supported by the is unspecified, but it is the same order as the associated keys in the returned by the property. Because each instance of the always contains the same fixed set of keys, the property always returns the values corresponding to the fixed set of keys, in the same order as the keys. - - -## Examples - The following example first creates a new , and then iterates through all the values within the object. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb" id="Snippet1"::: - ]]> Building Connection Strings diff --git a/xml/System.Data.OracleClient/OracleDataAdapter.xml b/xml/System.Data.OracleClient/OracleDataAdapter.xml index 6dd084a6c53..117d201619a 100644 --- a/xml/System.Data.OracleClient/OracleDataAdapter.xml +++ b/xml/System.Data.OracleClient/OracleDataAdapter.xml @@ -67,183 +67,24 @@ Represents a set of data commands and a connection to a database that are used to fill the and update the database. This class cannot be inherited. - serves as a bridge between a **DataSet** and database for retrieving and saving data. The provides this bridge by using to load data from the database into the , and using to send changes made in the back to the data source. - - When the fills a , it creates the necessary tables and columns for the returned data if they do not already exist. However, primary key information is not included in the implicitly created schema unless the property is set to . You may also have the create the schema of the , including primary key information, before filling it with data using . For more information, see [Adding Existing Constraints to a DataSet](/dotnet/framework/data/adonet/adding-existing-constraints-to-a-dataset). - + serves as a bridge between a **DataSet** and database for retrieving and saving data. The provides this bridge by using to load data from the database into the , and using to send changes made in the back to the data source. + + When the fills a , it creates the necessary tables and columns for the returned data if they do not already exist. However, primary key information is not included in the implicitly created schema unless the property is set to . You may also have the create the schema of the , including primary key information, before filling it with data using . For more information, see [Adding Existing Constraints to a DataSet](/dotnet/framework/data/adonet/adding-existing-constraints-to-a-dataset). + > [!NOTE] -> By default, numeric fields imported to a with are mapped to objects. It is possible to overflow the , and throw an Oracle exception, by importing a non-integral numeric value that is either too large or too high precision for the 's precision limitations. Refer to the description of for more information. - - The also includes the , , , , and `TableMappings` properties to facilitate loading and updating of data. - - The .NET Framework Data Provider for Oracle does not support batched SQL statements. However, it does allow you to use multiple `REF CURSOR` output parameters to fill a **DataSet**, each in its own . You must define the parameters, mark them as output parameters, and indicate that they are `REF CURSOR` data types. Note that you cannot use the method when the is filled using `REF CURSOR` parameters returned by a stored procedure, because Oracle does not provide the information necessary to determine what the table name and column names are when the SQL statement is executed. The following C# example assumes that you have created this stored procedure. - - Create the following Oracle package on the Oracle server. - -``` -CREATE OR REPLACE PACKAGE CURSPKG AS - TYPE T_CURSOR IS REF CURSOR; - PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, - IO_CURSOR OUT T_CURSOR); - PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, - DEPTCURSOR OUT T_CURSOR); -END CURSPKG; -/ -``` - - Create the following Oracle package body on the Oracle server. - -``` -CREATE OR REPLACE PACKAGE BODY CURSPKG AS - PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, - IO_CURSOR OUT T_CURSOR) - IS - V_CURSOR T_CURSOR; - BEGIN - IF N_EMPNO <> 0 THEN - OPEN V_CURSOR FOR - SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME - FROM EMP, DEPT - WHERE EMP.DEPTNO = DEPT.DEPTNO - AND EMP.EMPNO = N_EMPNO; - ELSE - OPEN V_CURSOR FOR - SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME - FROM EMP, DEPT - WHERE EMP.DEPTNO = DEPT.DEPTNO; - END IF; - IO_CURSOR := V_CURSOR; - END OPEN_ONE_CURSOR; - PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, - DEPTCURSOR OUT T_CURSOR) - IS - V_CURSOR1 T_CURSOR; - V_CURSOR2 T_CURSOR; - BEGIN - OPEN V_CURSOR1 FOR SELECT * FROM EMP; - OPEN V_CURSOR2 FOR SELECT * FROM DEPT; - EMPCURSOR := V_CURSOR1; - DEPTCURSOR := V_CURSOR2; - END OPEN_TWO_CURSORS; -END CURSPKG; - / -``` - - The following C# example demonstrates how you might obtain table and column information using the stored procedure. - -```csharp -// GetConnectionString() returns a connection string for -// the data source. - -string connString = GetConnectionString(); -DataSet ds = new DataSet(); -OracleConnection conn = new OracleConnection(connString); -OracleCommand cmd = conn.CreateCommand(); - -cmd.CommandText = "CURSPKG.OPEN_TWO_CURSORS"; -cmd.CommandType = CommandType.StoredProcedure; -cmd.Parameters.Add("EMPCURSOR", OracleType.Cursor).Direction = - ParameterDirection.Output; -cmd.Parameters.Add("DEPTCURSOR", OracleType.Cursor).Direction = - ParameterDirection.Output; - -OracleDataAdapter da = new OracleDataAdapter(cmd); -da.TableMappings.Add("Table", "Emp"); -da.TableMappings.Add("Table1", "Dept"); -da.Fill(ds); - -ds.Relations.Add("EmpDept", ds.Tables["Dept"].Columns["Deptno"], - ds.Tables["Emp"].Columns["Deptno"], false); -``` - - The following Visual Basic example demonstrates how to use an to fill a using an Oracle `REF CURSOR`. These examples use tables that are defined in the Oracle Scott/Tiger schema, and require the following PL/SQL package and package body. You must create these on your server to use the examples. - - Create the following Oracle package on the Oracle server. - -``` -CREATE OR REPLACE PACKAGE CURSPKG AS - TYPE T_CURSOR IS REF CURSOR; - PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, - IO_CURSOR OUT T_CURSOR); - PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, - DEPTCURSOR OUT T_CURSOR); -END CURSPKG; -/ -``` - - Create the following Oracle package body on the Oracle server. - -``` -CREATE OR REPLACE PACKAGE BODY CURSPKG AS - PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, - IO_CURSOR OUT T_CURSOR) - IS - V_CURSOR T_CURSOR; - BEGIN - IF N_EMPNO <> 0 THEN - OPEN V_CURSOR FOR - SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME - FROM EMP, DEPT - WHERE EMP.DEPTNO = DEPT.DEPTNO - AND EMP.EMPNO = N_EMPNO; - ELSE - OPEN V_CURSOR FOR - SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME - FROM EMP, DEPT - WHERE EMP.DEPTNO = DEPT.DEPTNO; - END IF; - IO_CURSOR := V_CURSOR; - END OPEN_ONE_CURSOR; - PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, - DEPTCURSOR OUT T_CURSOR) - IS - V_CURSOR1 T_CURSOR; - V_CURSOR2 T_CURSOR; - BEGIN - OPEN V_CURSOR1 FOR SELECT * FROM EMP; - OPEN V_CURSOR2 FOR SELECT * FROM DEPT; - EMPCURSOR := V_CURSOR1; - DEPTCURSOR := V_CURSOR2; - END OPEN_TWO_CURSORS; -END CURSPKG; - / -``` - - This Visual Basic example executes a PL/SQL stored procedure that returns two `REF CURSOR` parameters, and fills a with the rows that are returned. - -```vb - -' GetConnectionString() returns a connection string for -' the data source. - - Dim connString As New String(GetConnectionString()) - Dim ds As New DataSet() - Dim conn As New OracleConnection(connString) - Dim cmd As OracleCommand = conn.CreateCommand() - - cmd.CommandText = "CURSPKG.OPEN_TWO_CURSORS" - cmd.CommandType = CommandType.StoredProcedure - cmd.Parameters.Add("EMPCURSOR", OracleType.Cursor).Direction = _ - ParameterDirection.Output - cmd.Parameters.Add("DEPTCURSOR", OracleType.Cursor).Direction = _ - ParameterDirection.Output - - Dim da As New OracleDataAdapter(cmd) - da.TableMappings.Add("Table", "Emp") - da.TableMappings.Add("Table1", "Dept") - da.Fill(ds) - - ds.Relations.Add("EmpDept", ds.Tables("Dept").Columns("Deptno"), _ - ds.Tables("Emp").Columns("Deptno"), False) -``` - - After using the to perform a `Fill` or `FillSchema` operation, the `DataColumn.ReadOnly` property always returns false, regardless of whether a column can be updated or not, because the Oracle server does not return this information. - +> By default, numeric fields imported to a with are mapped to objects. It is possible to overflow the , and throw an Oracle exception, by importing a non-integral numeric value that is either too large or too high precision for the 's precision limitations. Refer to the description of for more information. + + The also includes the , , , , and `TableMappings` properties to facilitate loading and updating of data. + + The .NET Framework Data Provider for Oracle does not support batched SQL statements. However, it does allow you to use multiple `REF CURSOR` output parameters to fill a **DataSet**, each in its own . You must define the parameters, mark them as output parameters, and indicate that they are `REF CURSOR` data types. Note that you cannot use the method when the is filled using `REF CURSOR` parameters returned by a stored procedure, because Oracle does not provide the information necessary to determine what the table name and column names are when the SQL statement is executed. + + After using the to perform a `Fill` or `FillSchema` operation, the `DataColumn.ReadOnly` property always returns false, regardless of whether a column can be updated or not, because the Oracle server does not return this information. + ]]> Retrieving and Modifying Data in ADO.NET @@ -275,72 +116,18 @@ END CURSPKG; Initializes a new instance of the class. - , the following read/write properties are set to their default values, as shown in the table. - -|Properties|Default value| -|----------------|-------------------| -||`MissingMappingAction.Passthrough`| -||`MissingSchemaAction.Add`| - - You can change the value of any of these properties through a separate call to the property. - - - -## Examples - The following example creates an and sets some of its properties. - -```vb -Public Sub CreateOracleDataAdapter() - Dim myOracleConnection As OracleConnection = New OracleConnection("Data Source=Oracle8i;Integrated Security=yes") - Dim custDA As OracleDataAdapter = New OracleDataAdapter - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey - - custDA.SelectCommand = New OracleCommand("SELECT DeptNo, DName FROM Dept", myOracleConnection) - custDA.InsertCommand = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _ - "VALUES (:pDeptNo, :pDName)", myOracleConnection) - custDA.UpdateCommand = New OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " & _ - "WHERE DeptNo = :pDeptNo", myOracleConnection) - custDA.DeleteCommand = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection) - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original -End Sub -``` - -```csharp -public static void CreateOracleDataAdapter() -{ - OracleConnection myOracleConnection = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes"); - OracleDataAdapter custDA = new OracleDataAdapter(); - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - custDA.SelectCommand = new OracleCommand("SELECT DeptNo, CompanyName FROM Dept", myOracleConnection); - custDA.InsertCommand = new OracleCommand("INSERT INTO Dept (DeptNo, CompanyName) " + - "VALUES (:pDeptNo, :pCompanyName)", myOracleConnection); - custDA.UpdateCommand = new OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, CompanyName = :pCompanyName " + - "WHERE DeptNo = :pDeptNo", myOracleConnection); - custDA.DeleteCommand = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection); - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.InsertCommand.Parameters.Add("pCompanyName", OracleType.VarChar, 14, "CompanyName"); - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.UpdateCommand.Parameters.Add("pCompanyName", OracleType.VarChar, 14, "CompanyName"); - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; -} -``` - + , the following read/write properties are set to their default values, as shown in the table. + +| Properties | Default value | +|---------------------------------------------------------------|------------------------------------| +| | `MissingMappingAction.Passthrough` | +| | `MissingSchemaAction.Add` | + + You can change the value of any of these properties through a separate call to the property. + ]]> Retrieving and Modifying Data in ADO.NET @@ -367,74 +154,20 @@ public static void CreateOracleDataAdapter() An that is an SQL SELECT statement or stored procedure, and is set as the property of the . Initializes a new instance of the class with the specified SQL SELECT statement. - constructor sets the property to the value specified in the `selectCommand` parameter. - - When you create an instance of , the following read/write properties are set to their default values, as shown in the table. - -|Properties|Initial value| -|----------------|-------------------| -||`MissingMappingAction.Passthrough`| -||`MissingSchemaAction.Add`| - - You can change the value of any of these properties through a separate call to the property. - - - -## Examples - The following example creates an and sets some of its properties. - -```vb -Public Sub CreateOracleDataAdapter() - Dim myOracleConnection As OracleConnection = New OracleConnection("Data Source=Oracle8i;Integrated Security=yes") - Dim myOracleCommand As OracleCommand = New OracleCommand("SELECT DeptNo, DName FROM Dept", myOracleConnection) - Dim custDA As OracleDataAdapter = New OracleDataAdapter(myOracleCommand) - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey - - custDA.InsertCommand = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _ - "VALUES (:pDeptNo, :pDName)", myOracleConnection) - custDA.UpdateCommand = New OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " & _ - "WHERE DeptNo = :pDeptNo", myOracleConnection) - custDA.DeleteCommand = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection) - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original -End Sub -``` - -```csharp -public static void CreateOracleDataAdapter() -{ - OracleConnection myOracleConnection = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes"); - OracleCommand myOracleCommand = new OracleCommand("SELECT DeptNo, DName FROM Dept", myOracleConnection); - OracleDataAdapter custDA = new OracleDataAdapter(myOracleCommand); - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - custDA.InsertCommand = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " + - "VALUES (:pDeptNo, :pDName)", myOracleConnection); - custDA.UpdateCommand = new OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " + - "WHERE DeptNo = :pDeptNo", myOracleConnection); - custDA.DeleteCommand = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection); - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName"); - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName"); - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; -} -``` - + constructor sets the property to the value specified in the `selectCommand` parameter. + + When you create an instance of , the following read/write properties are set to their default values, as shown in the table. + +|Properties|Initial value| +|----------------|-------------------| +||`MissingMappingAction.Passthrough`| +||`MissingSchemaAction.Add`| + + You can change the value of any of these properties through a separate call to the property. + ]]> Retrieving and Modifying Data in ADO.NET @@ -463,67 +196,11 @@ public static void CreateOracleDataAdapter() An that represents the connection. Initializes a new instance of the class with an SQL SELECT statement and an . - can be useful in an application that must call the `Fill` method for two or more objects. - - - -## Examples - The following example creates an and sets some of its properties. - -```vb -Public Sub CreateOracleDataAdapter() - Dim myOracleConnection As OracleConnection = New OracleConnection("Data Source=Oracle8i;Integrated Security=yes") - Dim mySelectText As String = "SELECT DeptNo, DName FROM Dept" - Dim custDA As OracleDataAdapter = New OracleDataAdapter(mySelectText, myOracleConnection) - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey - - custDA.InsertCommand = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _ - "VALUES (:pDeptNo, :pDName)", myOracleConnection) - custDA.UpdateCommand = New OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " & _ - "WHERE DeptNo = :pDeptNo", myOracleConnection) - custDA.DeleteCommand = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection) - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original -End Sub -``` - -```csharp -public static void CreateOracleDataAdapter() -{ - OracleConnection myOracleConnection = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes"); - - string mySelectText = "SELECT DeptNo, DName FROM Dept"; - - OracleDataAdapter custDA = new OracleDataAdapter(mySelectText, myOracleConnection ); - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - custDA.InsertCommand = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " + - "VALUES (:pDeptNo, :pDName)", myOracleConnection); - custDA.UpdateCommand = new OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " + - "WHERE DeptNo = :pDeptNo", myOracleConnection); - custDA.DeleteCommand = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection); - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName"); - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName"); - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; -} -``` - + can be useful in an application that must call the `Fill` method for two or more objects. + ]]> Retrieving and Modifying Data in ADO.NET @@ -551,69 +228,7 @@ public static void CreateOracleDataAdapter() A string that is an SQL SELECT statement or stored procedure to be used by the property of the . The connection string. Initializes a new instance of the class with an SQL SELECT statement and a connection string. - - and sets some of its properties. - -```vb -Public Sub CreateOracleDataAdapter() - Dim myConnectionText As String = "Data Source=Oracle8i;Integrated Security=yes" - Dim mySelectText As String = "SELECT DeptNo, DName FROM Dept" - Dim custDA As OracleDataAdapter = New OracleDataAdapter(mySelectText, myConnectionText ) - Dim myOracleConnection As OracleConnection = custDA.SelectCommand.Connection - - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey - - custDA.InsertCommand = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _ - "VALUES (:pDeptNo, :pDName)", myOracleConnection) - custDA.UpdateCommand = New OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " & _ - "WHERE DeptNo = :pDeptNo", myOracleConnection) - custDA.DeleteCommand = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection) - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName") - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original -End Sub -``` - -```csharp -public static void CreateOracleDataAdapter() -{ - string myConnectionText = "Data Source=Oracle8i;Integrated Security=yes"; - - string mySelectText = "SELECT DeptNo, DName FROM Dept"; - - OracleDataAdapter custDA = new OracleDataAdapter(mySelectText, myConnectionText ); - OracleConnection myOracleConnection = custDA.SelectCommand.Connection; - - custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - custDA.InsertCommand = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " + - "VALUES (:pDeptNo, :pDName)", myOracleConnection); - custDA.UpdateCommand = new OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " + - "WHERE DeptNo = :pDeptNo", myOracleConnection); - custDA.DeleteCommand = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection); - - custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName"); - - custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName"); - custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; - - custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original; -} -``` - - ]]> - + To be added. Retrieving and Modifying Data in ADO.NET @@ -770,78 +385,13 @@ public static void CreateOracleDataAdapter() Gets or sets an SQL statement or stored procedure used to delete records in the database. An used during an update operation to delete records in the database that correspond to deleted rows in the . - property is assigned to a previously created , the is not cloned. Instead, the maintains a reference to the previously created . - - During an update operation, if is not set and primary key information is present in the , you can use the class to automatically generate the , and additional commands needed to reconcile the to the database. To do this, set the property of the . The generation logic also requires key column information to be present in the . For more information see [Generating Commands with CommandBuilders](/dotnet/framework/data/adonet/generating-commands-with-commandbuilders). - - - -## Examples - The following example creates an and sets the and properties. It assumes you have already created an object. - -```vb -Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter - - Dim da As OracleDataAdapter = New OracleDataAdapter() - Dim cmd As OracleCommand - Dim parm As OracleParameter - - ' Create the SelectCommand. - - cmd = New OracleCommand("SELECT * FROM Dept " & _ - "WHERE DName = :pDName AND Loc = :pLoc", conn) - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14) - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13) - - da.SelectCommand = cmd - - ' Create the DeleteCommand. - - cmd = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", conn) - - parm = cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - parm.SourceVersion = DataRowVersion.Original - - da.DeleteCommand = cmd - - Return da -End Function -``` - -```csharp -public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) -{ - OracleDataAdapter da = new OracleDataAdapter(); - OracleCommand cmd; - OracleParameter parm; - - // Create the SelectCommand. - - cmd = new OracleCommand("SELECT * FROM Dept " + - "WHERE DName = :pDName AND Loc = :pLoc", conn); - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14); - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13); - - da.SelectCommand = cmd; - - // Create the DeleteCommand. - - cmd = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", conn); - - parm = cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - parm.SourceVersion = DataRowVersion.Original; - - da.DeleteCommand = cmd; - - return da; -} -``` - + property is assigned to a previously created , the is not cloned. Instead, the maintains a reference to the previously created . + + During an update operation, if is not set and primary key information is present in the , you can use the class to automatically generate the , and additional commands needed to reconcile the to the database. To do this, set the property of the . The generation logic also requires key column information to be present in the . For more information see [Generating Commands with CommandBuilders](/dotnet/framework/data/adonet/generating-commands-with-commandbuilders). + ]]> Retrieving and Modifying Data in ADO.NET @@ -989,83 +539,18 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) Gets or sets an SQL statement or stored procedure used to insert new records into the database. An used during an update operation to insert records in the database that correspond to new rows in the . - property is assigned to a previously created object, the is not cloned. Instead, maintains a reference to the previously created . - - During an update operation, if is not set and primary key information is present in the , you can use the class to automatically generate , and additional commands needed to reconcile the to the database. To do this, set the property of the . The generation logic also requires key column information to be present in the . For more information see [Generating Commands with CommandBuilders](/dotnet/framework/data/adonet/generating-commands-with-commandbuilders). - + property is assigned to a previously created object, the is not cloned. Instead, maintains a reference to the previously created . + + During an update operation, if is not set and primary key information is present in the , you can use the class to automatically generate , and additional commands needed to reconcile the to the database. To do this, set the property of the . The generation logic also requires key column information to be present in the . For more information see [Generating Commands with CommandBuilders](/dotnet/framework/data/adonet/generating-commands-with-commandbuilders). + > [!NOTE] -> If execution of this command returns rows, these rows may be added to the depending upon how you set the property of the object. - - When you update a column with the `LONG RAW` data type, an exception is thrown when you enter a value of `NULL` in the column. The Oracle `LONG RAW` data type is a deprecated type in Oracle version 8.0. To avoid this error, use the `BLOB` data type instead of `LONG RAW`. - - - -## Examples - The following example creates an and sets the and properties. It assumes you have already created an object. - -```vb -Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter - - Dim da As OracleDataAdapter = New OracleDataAdapter() - Dim cmd As OracleCommand - - ' Create the SelectCommand. - - cmd = New OracleCommand("SELECT * FROM Dept " & _ - "WHERE DName = :pDName AND Loc = :pLoc", conn) - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14) - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13) - - da.SelectCommand = cmd - - ' Create the InsertCommand. - - cmd = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _ - "VALUES (:pDeptNo, :pDName)", conn) - - cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName") - - da.InsertCommand = cmd - - Return da -End Function -``` - -```csharp -public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) -{ - OracleDataAdapter da = new OracleDataAdapter(); - OracleCommand cmd; - - // Create the SelectCommand. - - cmd = new OracleCommand("SELECT * FROM Dept " + - "WHERE DName = :pDName AND Loc = :pLoc", conn); - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14); - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13); - - da.SelectCommand = cmd; - - // Create the InsertCommand. - - cmd = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " + - "VALUES (:pDeptNo, :pDName)", conn); - - cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName"); - - da.InsertCommand = cmd; - - return da; -} -``` - +> If execution of this command returns rows, these rows may be added to the depending upon how you set the property of the object. + + When you update a column with the `LONG RAW` data type, an exception is thrown when you enter a value of `NULL` in the column. The Oracle `LONG RAW` data type is a deprecated type in Oracle version 8.0. To avoid this error, use the `BLOB` data type instead of `LONG RAW`. + ]]> Retrieving and Modifying Data in ADO.NET @@ -1143,25 +628,25 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) Occurs during an update operation after a command is executed against the database. - are moved to the parameter values. - -2. The `OnRowUpdating` event is raised. - -3. The command executes. - -4. If the `UpdateRowSource` enumeration is set to `FirstReturnedRecord`, the first returned result is placed in the **DataRow**. - -5. If there are output parameters, they are placed in the **DataRow**. - -6. The `OnRowUpdated` event is raised. - -7. `AcceptChanges` is called. - + are moved to the parameter values. + +2. The `OnRowUpdating` event is raised. + +3. The command executes. + +4. If the `UpdateRowSource` enumeration is set to `FirstReturnedRecord`, the first returned result is placed in the **DataRow**. + +5. If there are output parameters, they are placed in the **DataRow**. + +6. The `OnRowUpdated` event is raised. + +7. `AcceptChanges` is called. + ]]> @@ -1186,25 +671,25 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) Occurs during before a command is executed against the data source. - are moved to the parameter values. - -2. The `OnRowUpdating` event is raised. - -3. The command executes. - -4. If the `UpdateRowSource` enumeration is set to `FirstReturnedRecord`, the first returned result is placed in the **DataRow**. - -5. If there are output parameters, they are placed in the **DataRow**. - -6. The `OnRowUpdated` event is raised. - -7. `AcceptChanges` is called. - + are moved to the parameter values. + +2. The `OnRowUpdating` event is raised. + +3. The command executes. + +4. If the `UpdateRowSource` enumeration is set to `FirstReturnedRecord`, the first returned result is placed in the **DataRow**. + +5. If there are output parameters, they are placed in the **DataRow**. + +6. The `OnRowUpdated` event is raised. + +7. `AcceptChanges` is called. + ]]> @@ -1248,78 +733,13 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) Gets or sets an SQL statement or stored procedure used to select records in the database. An that is used during a fill operation to select records from database for placement in the . - is assigned to a previously created , the is not cloned. Instead, the maintains a reference to the previously created object. - - If does not return any rows, no tables are added to the **DataSet**, and no exception is raised. - - - -## Examples - The following example creates an and sets the and properties. It assumes you have already created an object. - -```vb -Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter - - Dim da As OracleDataAdapter = New OracleDataAdapter() - Dim cmd As OracleCommand - - ' Create the SelectCommand. - - cmd = New OracleCommand("SELECT * FROM Dept " & _ - "WHERE DName = :pDName AND Loc = :pLoc", conn) - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14) - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13) - - da.SelectCommand = cmd - - ' Create the InsertCommand. - - cmd = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _ - "VALUES (pDeptNo, pDName)", conn) - - cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName") - - da.InsertCommand = cmd - - Return da -End Function -``` - -```csharp -public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) -{ - OracleDataAdapter da = new OracleDataAdapter(); - OracleCommand cmd; - - // Create the SelectCommand. - - cmd = new OracleCommand("SELECT * FROM Dept " + - "WHERE DName = :pDName AND Loc = :pLoc", conn); - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14); - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13); - - da.SelectCommand = cmd; - - // Create the InsertCommand. - - cmd = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " + - "VALUES (:pDeptNo, :pDName)", conn); - - cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName"); - - da.InsertCommand = cmd; - - return da; -} -``` - + is assigned to a previously created , the is not cloned. Instead, the maintains a reference to the previously created object. + + If does not return any rows, no tables are added to the **DataSet**, and no exception is raised. + ]]> Retrieving and Modifying Data in ADO.NET @@ -1348,11 +768,11 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) For a description of this member, see . A string representing the command. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1380,11 +800,11 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) For a description of this member, see . A string representing the command. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1412,11 +832,11 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) For a description of this member, see . A string representing the command. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1444,11 +864,11 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) For a description of this member, see . A string representing the command. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1477,11 +897,11 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) For a description of this member, see . A new object that is a copy of this instance. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1526,37 +946,37 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) Gets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch. - The number of rows to process per batch. - - Value: - - Effect: - - 0 - - There is no limit on the batch size. - - 1 - - Disables batch updating. - - > 1 - - Changes are sent using batches of operations at a time. - - + The number of rows to process per batch. + + Value: + + Effect: + + 0 + + There is no limit on the batch size. + + 1 + + Disables batch updating. + + > 1 + + Changes are sent using batches of operations at a time. + + When setting this to a value other than 1 all the commands associated with the have to have their property set to or . An exception is thrown otherwise. - property to update a data source with changes from a . This can increase application performance by reducing the number of round-trips to the server. - - Executing an extremely large batch could decrease performance. Therefore, you should test for the optimum batch size setting before you implement your application. - - An is thrown if the value is set to a number less than zero. - + property to update a data source with changes from a . This can increase application performance by reducing the number of round-trips to the server. + + Executing an extremely large batch could decrease performance. Therefore, you should test for the optimum batch size setting before you implement your application. + + An is thrown if the value is set to a number less than zero. + ]]> Retrieving and Modifying Data in ADO.NET @@ -1601,91 +1021,18 @@ public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) Gets or sets an SQL statement or stored procedure used to update records in the database. An used during an update operation to update records in the database that correspond to modified rows in the . - is assigned to a previously created , the is not cloned. Instead, the maintains a reference to the previously created object. - - During an update operation, if is not set and primary key information is present in the **DataSet**, you can use the class to automatically generate , and additional commands needed to reconcile the to the database. To do this, set the property of the . The generation logic also requires key column information to be present in the . For more information see [Generating Commands with CommandBuilders](/dotnet/framework/data/adonet/generating-commands-with-commandbuilders). - + is assigned to a previously created , the is not cloned. Instead, the maintains a reference to the previously created object. + + During an update operation, if is not set and primary key information is present in the **DataSet**, you can use the class to automatically generate , and additional commands needed to reconcile the to the database. To do this, set the property of the . The generation logic also requires key column information to be present in the . For more information see [Generating Commands with CommandBuilders](/dotnet/framework/data/adonet/generating-commands-with-commandbuilders). + > [!NOTE] -> If execution of this command returns rows, these rows may be merged with the depending upon how you set the property of the object. - - When you update a column with the `LONG RAW` data type, an exception is thrown when you enter a value of `NULL` in the column. The Oracle `LONG RAW` data type is a deprecated type in Oracle version 8.0. To avoid this error, use the `BLOB` data type instead of `LONG RAW`. - - - -## Examples - The following example creates an and sets the and properties. It assumes you have already created an object. - -```vb -Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter - - Dim da As OracleDataAdapter = New OracleDataAdapter() - Dim cmd As OracleCommand - Dim parm As OracleParameter - - ' Create the SelectCommand. - - cmd = New OracleCommand("SELECT * FROM Dept " & _ - "WHERE DName = pDName AND Loc = pLoc", conn) - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14) - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13) - - da.SelectCommand = cmd - - ' Create the UpdateCommand. - - cmd = New OracleCommand("UPDATE Dept SET DeptNo = pDeptNo, DName = pDName " & _ - "WHERE DeptNo = poldDeptNo", conn) - - cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo") - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName") - - parm = cmd.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo") - parm.SourceVersion = DataRowVersion.Original - - da.UpdateCommand = cmd - - Return da -End Function -``` - -```csharp -public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn) -{ - OracleDataAdapter da = new OracleDataAdapter(); - OracleCommand cmd; - OracleParameter parm; - - // Create the SelectCommand. - - cmd = new OracleCommand("SELECT * FROM Dept " + - "WHERE DName = pDName AND Loc = pLoc", conn); - - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14); - cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13); - - da.SelectCommand = cmd; - - // Create the UpdateCommand. - - cmd = new OracleCommand("UPDATE Dept SET DeptNo = pDeptNo, DName = pDName " + - "WHERE DeptNo = poldDeptNo", conn); - - cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo"); - cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName"); - - parm = cmd.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo"); - parm.SourceVersion = DataRowVersion.Original; - - da.UpdateCommand = cmd; - - return da; -} -``` - +> If execution of this command returns rows, these rows may be merged with the depending upon how you set the property of the object. + + When you update a column with the `LONG RAW` data type, an exception is thrown when you enter a value of `NULL` in the column. The Oracle `LONG RAW` data type is a deprecated type in Oracle version 8.0. To avoid this error, use the `BLOB` data type instead of `LONG RAW`. + ]]> Retrieving and Modifying Data in ADO.NET diff --git a/xml/System.Data.OracleClient/OracleParameterCollection.xml b/xml/System.Data.OracleClient/OracleParameterCollection.xml index ad1f47ce8d5..e2b46cbcb40 100644 --- a/xml/System.Data.OracleClient/OracleParameterCollection.xml +++ b/xml/System.Data.OracleClient/OracleParameterCollection.xml @@ -270,13 +270,7 @@ SELECT * FROM Customers WHERE CustomerID = :pCustomerID method to specify integer parameter values. Because this overload takes a `value` of type , you must convert the integral value to an type when the value is zero, as the following C# example demonstrates. - -```csharp -parameters.Add("pname", Convert.ToInt32(0)); -``` - - If you do not perform this conversion, the compiler will assume you are attempting to call the `OracleParameterCollection.Add` (`string`, `OracleType`) overload. + Use caution when using this overload of the method to specify integer parameter values. Because this overload takes a `value` of type , you must convert the integral value to an type when the value is zero. If you don't perform this conversion, the compiler will assume you are attempting to call the `OracleParameterCollection.Add` (`string`, `OracleType`) overload. ]]> diff --git a/xml/System.EnterpriseServices/RegistrationHelperTx.xml b/xml/System.EnterpriseServices/RegistrationHelperTx.xml index 22a6371ad8c..bba5fb04377 100644 --- a/xml/System.EnterpriseServices/RegistrationHelperTx.xml +++ b/xml/System.EnterpriseServices/RegistrationHelperTx.xml @@ -37,13 +37,13 @@ Used by the .NET Framework infrastructure to install and configure assemblies in the COM+ catalog while maintaining a newly established transaction. - class attribute is applied to the class, with a parameter of the field. - - This type does not need to be used directly from your code. Instead, use the class. - + class attribute is applied to the class, with a parameter of the field. + + This type does not need to be used directly from your code. Instead, use the class. + ]]> @@ -159,13 +159,13 @@ A synchronization object generated by the infrastructure that can wait until the specified assembly has been configured in the COM+ catalog. Installs the named assembly in the COM+ catalog using transactional semantics. - method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. - - This method requires the caller to have administrative privileges on the local computer. - + method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. + + This method requires the caller to have administrative privileges on the local computer. + ]]> @@ -205,13 +205,13 @@ A synchronization object generated by the infrastructure that can wait until the specified assembly has been configured in the COM+ catalog. Installs the named assembly in the COM+ catalog using transactional semantics. - method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. - - This method requires the caller to have administrative privileges on the local computer. - + method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. + + This method requires the caller to have administrative privileges on the local computer. + ]]> @@ -243,13 +243,13 @@ A synchronization object generated by the infrastructure that waits until the specified assembly has been configured in the COM+ catalog. Installs a specified assembly in the COM+ catalog using transactional semantics. - method is called from within the .NET Framework infrastructure. It does not need to be called directly from your code. Instead, call the method. - - This method requires the caller to have administrative privileges on the local computer. - + method is called from within the .NET Framework infrastructure. It does not need to be called directly from your code. Instead, call the method. + + This method requires the caller to have administrative privileges on the local computer. + ]]> @@ -278,11 +278,11 @@ if the current context for the class instance is transactional; otherwise, . - method is called from within the .NET Framework infrastructure. It does not need to be called directly from your code. - + method is called from within the .NET Framework infrastructure. It does not need to be called directly from your code. + ]]> @@ -326,11 +326,11 @@ A synchronization object generated by the infrastructure that can wait until the specified assembly has been uninstalled. Uninstalls an assembly from a COM+ application using transactional semantics. - method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. - + method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. + ]]> @@ -366,11 +366,11 @@ A synchronization object generated by the infrastructure that can wait until the specified assembly has been uninstalled. Uninstalls an assembly from a COM+ application using transactional semantics. - method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. - + method does not need to be called directly from your code. Instead, call the method with the same parameters except object sync. + ]]> @@ -402,11 +402,11 @@ A synchronization object generated by the infrastructure that waits until the specified assembly has been uninstalled. Uninstalls a specified assembly from a COM+ application using transactional semantics. - method is called from within the .NET Framework infrastructure. It does not need to be called directly from your code. Instead, call the method. - + method is called from within the .NET Framework infrastructure. It does not need to be called directly from your code. Instead, call the method. + ]]> diff --git a/xml/System.Net.Mail/SmtpPermission.xml b/xml/System.Net.Mail/SmtpPermission.xml index 6f077f539de..45e8ba6ae7b 100644 --- a/xml/System.Net.Mail/SmtpPermission.xml +++ b/xml/System.Net.Mail/SmtpPermission.xml @@ -47,24 +47,16 @@ Controls access to Simple Mail Transport Protocol (SMTP) servers. - and classes control access to SMTP host computers. The class demands an when sending electronic mail to the SMTP host for delivery. - - The enumeration specifies the level of access controlled by an instance of this permission. - - - -## Examples - The following code example creates an instance of an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/SmtpAccess/Overview/mailpermissions.cs" id="Snippet1"::: - + The and classes control access to SMTP host computers. The class demands an when sending electronic mail to the SMTP host for delivery. + + The enumeration specifies the level of access controlled by an instance of this permission. + ]]> @@ -110,19 +102,11 @@ if the new permission is unrestricted; otherwise, . Initializes a new instance of the class with the specified state. - access to SMTP servers. If unrestricted is `false`, the permission controls access. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/SmtpAccess/Overview/mailpermissions.cs" id="Snippet4"::: - + access to SMTP servers. If unrestricted is `false`, the permission controls access. + ]]> @@ -164,19 +148,11 @@ One of the values. Initializes a new instance of the class using the specified access level. - @@ -212,19 +188,11 @@ One of the values. Initializes a new instance of the class using the specified permission state value. - @@ -265,17 +233,7 @@ Gets the level of access to SMTP servers controlled by the permission. One of the values. - - - + To be added. @@ -312,19 +270,11 @@ One of the values. Adds the specified access level value to the permission. - access to a permission object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/SmtpAccess/Overview/mailpermissions.cs" id="Snippet5"::: - + @@ -361,19 +311,11 @@ Creates and returns an identical copy of the current permission. An that is identical to the current permission. - @@ -412,18 +354,18 @@ The XML encoding to use to set the state of the current permission. Sets the state of the permission using the specified XML encoding. - - does not describe an object. - - -or- - + does not describe an object. + + -or- + does not contain the required state information to reconstruct the permission. is . @@ -464,19 +406,11 @@ Creates and returns a permission that is the intersection of the current permission and the specified permission. An that represents the intersection of the current permission and the specified permission. Returns if the intersection is empty or is . - @@ -519,19 +453,11 @@ if the current permission is a subset of the specified permission; otherwise, . - @@ -574,19 +500,11 @@ if the current permission is unrestricted; otherwise, . - @@ -623,11 +541,11 @@ Creates an XML encoding of the state of the permission. A that contains an XML encoding of the current permission. - @@ -667,19 +585,11 @@ Creates a permission that is the union of the current permission and the specified permission. A new permission that represents the union of the current permission and the specified permission. - method returns a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union. - - - -## Examples - The following example creates a permission object that is the union of two permission objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp" id="Snippet8"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/SmtpAccess/Overview/mailpermissions.cs" id="Snippet8"::: - + method returns a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union. + ]]> diff --git a/xml/System.Net.NetworkInformation/NetworkInformationPermission.xml b/xml/System.Net.NetworkInformation/NetworkInformationPermission.xml index 94ffea10dd1..31d24f7d7de 100644 --- a/xml/System.Net.NetworkInformation/NetworkInformationPermission.xml +++ b/xml/System.Net.NetworkInformation/NetworkInformationPermission.xml @@ -48,25 +48,16 @@ Controls access to network information and traffic statistics for the local computer. This class cannot be inherited. - namespace. - - For declarative security, use the class. - - - -## Examples - The following example creates an unrestricted permission object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkInformationAccess/Overview/permissionexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetworkInfoPerms/VB/permissionexample.vb" id="Snippet1"::: - + This permission is used to secure data returned by the classes in the namespace. + + For declarative security, use the class. + ]]> @@ -119,20 +110,11 @@ One of the values. Initializes a new instance of the class using the specified value. - @@ -169,20 +151,11 @@ One of the values. Initializes a new instance of the class with the specified . - @@ -225,20 +198,11 @@ Gets the level of access to network information controlled by this permission. One of the values. - created with is given | access. A created with is given access. - - - -## Examples - The following code example creates a , adds a value to it, and displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkInformationAccess/Overview/permissionexample.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetworkInfoPerms/VB/permissionexample.vb" id="Snippet7"::: - + created with is given | access. A created with is given access. + ]]> @@ -278,20 +242,11 @@ One of the values. Adds the specified value to this permission. - @@ -329,20 +284,11 @@ Creates and returns an identical copy of this permission. A that is identical to the current permission. - @@ -382,24 +328,24 @@ A that contains the XML encoding to use to set the state of the current permission. Sets the state of this permission using the specified XML encoding. - is . - is not a permission encoding. - - -or- - - is not an encoding of a . - - -or- - + is not a permission encoding. + + -or- + + is not an encoding of a . + + -or- + has invalid values. @@ -439,20 +385,11 @@ Creates and returns a permission that is the intersection of the current permission and the specified permission. A that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty or is . - @@ -496,20 +433,11 @@ if the current permission is a subset of the specified permission; otherwise, . - @@ -551,20 +479,11 @@ if the current permission is unrestricted; otherwise, . - constructor. - - - -## Examples - The following example creates a permission object and displays its state. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkInformationAccess/Overview/permissionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetworkInfoPerms/VB/permissionexample.vb" id="Snippet2"::: - + constructor. + ]]> @@ -602,11 +521,11 @@ Creates an XML encoding of the state of this permission. A that contains the XML encoding of the current permission. - @@ -647,20 +566,11 @@ Creates a permission that is the union of this permission and the specified permission. A new permission that represents the union of the current permission and the specified permission. - method returns a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union. - - - -## Examples - The following example creates a permission object that is the union of existing permission objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkInformationAccess/Overview/permissionexample.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetworkInfoPerms/VB/permissionexample.vb" id="Snippet5"::: - + method returns a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union. + ]]> diff --git a/xml/System.Net/DnsPermission.xml b/xml/System.Net/DnsPermission.xml index ee8d1019c87..efa92107af0 100644 --- a/xml/System.Net/DnsPermission.xml +++ b/xml/System.Net/DnsPermission.xml @@ -98,14 +98,6 @@ ## Remarks If `state` is , the instance passes all demands. If `state` contains any other value, the instance fails all demands. - - -## Examples - The following example creates an instance of the class. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb" id="Snippet1"::: - ]]> @@ -150,14 +142,6 @@ ## Remarks A copy of a instance provides the same access to DNS servers as the original permission instance. - - -## Examples - The following example creates an identical copy of an existing instance. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb" id="Snippet1"::: - ]]> @@ -204,14 +188,6 @@ Use the method to XML-encode the instance, including state information. - - -## Examples - The following example reconstructs a instance from an XML encoding. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb" id="Snippet1"::: - ]]> @@ -262,14 +238,6 @@ ## Remarks The method returns a instance that allows the access defined by both the current instance and the specified instance. Any demand must pass both permissions to pass their intersection. - - -## Examples - The following example creates a permission instance that is the intersection of the current permission instance and the specified permission instance. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb" id="Snippet2"::: - ]]> @@ -320,14 +288,6 @@ If the method returns `true`, the current instance allows no more access to DNS servers than does the specified instance. - - -## Examples - The following example uses the method to determine whether the current permission instance is a subset of the specified permission instance. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb" id="Snippet1"::: - ]]> @@ -370,17 +330,7 @@ Checks the overall permission state of the object. if the instance was created with ; otherwise, . - - method to check the overall permission state of the object. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb" id="Snippet1"::: - - ]]> - + To be added. @@ -423,14 +373,6 @@ Use the method to restore the state information from a instance. - - -## Examples - The following example creates an XML encoding of a instance. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb" id="Snippet1"::: - ]]> @@ -476,14 +418,6 @@ ## Remarks The method returns a instance that allows the access defined by either the current instance or the specified instance. Any demand that passes either permission passes their union. - - -## Examples - The following example creates a permission instance that is the union of the current permission instance and the specified permission instance. - - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb" id="Snippet1"::: - ]]> diff --git a/xml/System.Net/DnsPermissionAttribute.xml b/xml/System.Net/DnsPermissionAttribute.xml index 3b50c7b99a9..45066b2c30d 100644 --- a/xml/System.Net/DnsPermissionAttribute.xml +++ b/xml/System.Net/DnsPermissionAttribute.xml @@ -48,29 +48,20 @@ Specifies permission to request information from Domain Name Servers. - is stored in the metadata of the attribute target, which is the class to which the is applied. The system then accesses this information at run time. The that is passed to the constructor determines the allowable DNS targets. - - These security attributes are used only for [Declarative Security](/previous-versions/dotnet/netframework-4.0/kaacwy28(v=vs.100)). For [Imperative Security](/previous-versions/dotnet/netframework-4.0/0xkh23z7(v=vs.100)), use the corresponding class. - - Security access is either fully restricted or fully unrestricted. Set the property to `true` to grant access, or `false` for no access. Set this property as a named parameter. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example uses to apply declarative security to a custom class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermissionAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/VB/source.vb" id="Snippet1"::: - + The security information declared by is stored in the metadata of the attribute target, which is the class to which the is applied. The system then accesses this information at run time. The that is passed to the constructor determines the allowable DNS targets. + + These security attributes are used only for [Declarative Security](/previous-versions/dotnet/netframework-4.0/kaacwy28(v=vs.100)). For [Imperative Security](/previous-versions/dotnet/netframework-4.0/0xkh23z7(v=vs.100)), use the corresponding class. + + Security access is either fully restricted or fully unrestricted. Set the property to `true` to grant access, or `false` for no access. Set this property as a named parameter. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + ]]> @@ -114,20 +105,11 @@ One of the values. Initializes a new instance of the class with the specified value. - value that is passed to this constructor specifies the allowable targets. - - - -## Examples - The following example uses to apply declarative security to a custom class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermissionAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/VB/source.vb" id="Snippet1"::: - + value that is passed to this constructor specifies the allowable targets. + ]]> The parameter is not a valid . @@ -167,13 +149,13 @@ Creates and returns a new instance of the class. A that corresponds to the security declaration. - is stored in the metadata of the attribute target, which is the class to which is applied. The system then accesses the information at run time and calls . The system uses the returned to enforce the specified security requirements. - + is stored in the metadata of the attribute target, which is the class to which is applied. The system then accesses the information at run time and calls . The system uses the returned to enforce the specified security requirements. + ]]> diff --git a/xml/System.Net/GlobalProxySelection.xml b/xml/System.Net/GlobalProxySelection.xml index 9686a326319..78caa83823e 100644 --- a/xml/System.Net/GlobalProxySelection.xml +++ b/xml/System.Net/GlobalProxySelection.xml @@ -71,14 +71,6 @@ **Note** Changes to the after a request is made are not reflected in a . - - -## Examples - The following code example sets the for an HTTP proxy named "webproxy" on port 80. - - :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb" id="Snippet1"::: - ]]> DefaultProxy Element (Network Settings) @@ -175,11 +167,6 @@ The method returns a Instead of calling the `GetEmptyWebProxy` method, you can assign `null` to members such as the property, which specifies the proxy that communicates with remote servers on behalf of the object. -## Examples - The following code example creates a instance that does not use a proxy. - - :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/GetEmptyWebProxy/test.cs" id="Snippet1"::: - ]]> @@ -228,13 +215,6 @@ Instead of calling the `GetEmptyWebProxy` method, you can assign `null` to membe ## Remarks The property sets the proxy that all instances use if the request supports proxies and no proxy is set explicitly using the property. Proxies are currently supported by and . - - -## Examples - The following code example sets the property to the empty proxy. - - :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/GetEmptyWebProxy/test.cs" id="Snippet1"::: - ]]> The value specified for a set operation was . diff --git a/xml/System.Net/SocketPermission.xml b/xml/System.Net/SocketPermission.xml index c386ff4e0d8..a6581e2e3b8 100644 --- a/xml/System.Net/SocketPermission.xml +++ b/xml/System.Net/SocketPermission.xml @@ -60,15 +60,6 @@ > [!NOTE] > Avoid creating socket permissions using host names, as these names have to be resolved to IP addresses, and this might block the stack. - - -## Examples - The following example demonstrates how to use the class to set, change, and enforce various socket access restrictions. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb" id="Snippet1"::: - ]]> @@ -121,15 +112,6 @@ ## Remarks If the instance is created with the `Unrestricted` value from then the instance passes all demands. Any other value for `state` results in a instance that fails all demands unless a transport address permission is added with . - - -## Examples - The following example creates a using a enumerated value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb" id="Snippet1"::: - ]]> @@ -182,15 +164,6 @@ The `portNumber` can be any valid port number defined by the transport, or . - - -## Examples - The following example creates a using a enumerated value, a enumerated value, the hostname, and the port number. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb" id="Snippet1"::: - ]]> @@ -229,18 +202,7 @@ Gets a list of instances that identifies the endpoints that can be accepted under this permission instance. An instance that implements the interface that contains instances. - - property to return a list of endpoints to which accept privileges are granted. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb" id="Snippet2"::: - - ]]> - + To be added. @@ -290,15 +252,6 @@ ## Remarks The `hostName` can be a DNS name, an IP address, or a specified IP subnet, such as 192.168.1.*. - - -## Examples - The following example uses the method to add connection permissions to the specified host. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb" id="Snippet1"::: - ]]> @@ -343,15 +296,6 @@ ## Remarks This field is read-only. The value of this field is -1. - - -## Examples - The following example uses the property to provide connection permissions to all of the resources ports. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb" id="Snippet1"::: - ]]> @@ -388,18 +332,7 @@ Gets a list of instances that identifies the endpoints that can be connected to under this permission instance. An instance that implements the interface that contains instances. - - property to return a list of endpoints to which connection privileges are granted. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb" id="Snippet1"::: - - ]]> - + To be added. @@ -441,15 +374,6 @@ ## Remarks The object returned by this method represents the same level of access as the current instance. This method overrides and is implemented to support the interface. - - -## Examples - The following example creates a by taking a copy of an existing . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/Overview/source.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb" id="Snippet4"::: - ]]> @@ -497,15 +421,6 @@ Use the method to encode the instance, including state information, in XML. - - -## Examples - The following example uses the method to convert XML encoded data to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb" id="Snippet1"::: - ]]> The is . @@ -554,15 +469,6 @@ ## Remarks The intersection of two permissions is a permission that helps to protect the resources and operations protected by both permissions. Specifically, it represents the minimum permission such that any demand that passes both permissions also passes their intersection. This method overrides and is implemented to support the interface. - - -## Examples - The following example uses the method to obtain a logical intersection between two instances. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb" id="Snippet1"::: - ]]> The parameter is not a . @@ -614,15 +520,6 @@ For example, a permission that represents access to 192.168.1.1:80 is a subset of a permission that represents access to 192.168.1.1:Any. If this method returns `true`, the current permission represents no more access to the protected resource than does the specified permission. - - -## Examples - The following example uses the method to determine if one is the subset of another. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb" id="Snippet2"::: - ]]> @@ -668,18 +565,7 @@ Checks the overall permission state of the object. if the instance is created with the value from ; otherwise, . - - property to determine if the specified has any restrictions. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb" id="Snippet1"::: - - ]]> - + To be added. @@ -723,15 +609,6 @@ Use the method to restore the state information from a instance. - - -## Examples - The following example uses the method to convert a to XML. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb" id="Snippet1"::: - ]]> @@ -778,15 +655,6 @@ ## Remarks The result of a call to is a permission that represents all of the access to connections represented by the current instance as well as the access represented by `target`. Any demand that passes either the current instance or `target` passes their union. This method overrides and is implemented to support the interface. - - -## Examples - The following example uses the method to return the logical union of two existing instances. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/SocketPermission/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb" id="Snippet2"::: - ]]> diff --git a/xml/System.Net/WebPermission.xml b/xml/System.Net/WebPermission.xml index 3869ed933fa..edbe52c4ab2 100644 --- a/xml/System.Net/WebPermission.xml +++ b/xml/System.Net/WebPermission.xml @@ -78,15 +78,6 @@ > [!NOTE] > User name and default port information is stripped from the before the comparison with the regular expression argument that is supplied to the constructor. If the regular expression contains user information or the default port number, then all incoming s will fail to match the regular expression. - - -## Examples - The following example demonstrates how to create a new instance of using a . Additional hosts are added to the connect and accept list of . Finally, the connect and accept list are displayed to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/Overview/regex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Regex/VB/regex.vb" id="Snippet1"::: - ]]> @@ -181,15 +172,6 @@ ## Remarks The value of the `state` parameter is either or , respectively yielding fully restricted or fully unrestricted access to all security variables. If you specify , then you can give access to individual URIs using . - - -## Examples - The following example creates an instance of and gives access rights to specific URLs. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Copy/VB/webpermission_copy.vb" id="Snippet1"::: - ]]> @@ -235,15 +217,6 @@ ## Remarks This constructor initializes a and grants its target permission to either make a remote host connection or accept a remote host connection using the URI described by the `uriString` parameter. - - -## Examples - The following example creates a new instance of with connect rights for the specified URI. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Union/VB/webpermission_union.vb" id="Snippet1"::: - ]]> @@ -297,15 +270,6 @@ > [!NOTE] > A candidate URI string is checked against the list of relevant regular expressions ( or ) in two ways. First, the candidate URI string is checked against the appropriate list; then, if there is no match, the candidate URI string is converted into a and checked against the appropriate list. - - -## Examples - The following example creates a new instance of with connect rights for the specified . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Constructor4/VB/webpermission_constructor4.vb" id="Snippet1"::: - ]]> @@ -355,15 +319,6 @@ > [!NOTE] > A candidate URI string is checked against the list of relevant regular expressions ( or ) in two ways. First, the candidate URI string is checked against the appropriate list; then, if there is no match, the candidate URI string is converted into a and checked against the appropriate list. - - -## Examples - The following example prints the URLs in the to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_AcceptConnectList/VB/webpermission_acceptconnectlist.vb" id="Snippet2"::: - ]]> @@ -428,15 +383,6 @@ > [!NOTE] > A candidate URI string is checked against the list of relevant regular expressions ( or ) in two ways. First, the candidate URI string is checked against the appropriate list; then, if there is no match, the candidate URI string is converted into a and checked against the appropriate list. - - -## Examples - The following example demonstrates how to add access rights to particular URL strings. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Intersect/VB/webpermission_intersect.vb" id="Snippet2"::: - ]]> @@ -496,15 +442,6 @@ > [!NOTE] > A candidate URI string is checked against the list of relevant regular expressions ( or ) in two ways. First, the candidate URI string is checked against the appropriate list; then, if there is no match, the candidate URI string is converted into a and checked against the appropriate list. - - -## Examples - The following example uses to give access rights for the specified URI. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset/VB/webpermission_issubset.vb" id="Snippet1"::: - ]]> The parameter is . @@ -555,15 +492,6 @@ > [!NOTE] > A candidate URI string is checked against the list of relevant regular expressions ( or ) in two ways. First, the candidate URI string is checked against the appropriate list; then, if there is no match, the candidate URI string is converted into a and checked against the appropriate list. - - -## Examples - The following example prints the URLs in the to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_AcceptConnectList/VB/webpermission_acceptconnectlist.vb" id="Snippet1"::: - ]]> @@ -608,15 +536,6 @@ ## Remarks The returned by this method represents the same access to resources as the original . This method overrides and is implemented to support the interface. - - -## Examples - The following example demonstrates how to create a second instance of using . This second instance is identical to the first. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Copy/VB/webpermission_copy.vb" id="Snippet2"::: - ]]> @@ -664,15 +583,6 @@ Use the method to XML-encode the , including state information. - - -## Examples - The following example creates a , populates its attributes, and uses to transfer this information to an instance of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_FromToXml/VB/webpermission_fromtoxml.vb" id="Snippet1"::: - ]]> The parameter is . @@ -725,15 +635,6 @@ This method overrides and is implemented to support the interface. - - -## Examples - The following example shows how to create an instance of using the logical intersection of two existing instances. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Intersect/VB/webpermission_intersect.vb" id="Snippet3"::: - ]]> @@ -783,15 +684,6 @@ ## Remarks If the current specifies a set of associated resources that is wholly contained by the `target` parameter, then the current is a subset of `target`. This method overrides and is implemented to support the interface. - - -## Examples - The following example uses to determine whether the access rights found in one instance of are found in another instance of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset2/VB/source.vb" id="Snippet1"::: - ]]> The target parameter is not an instance of . @@ -888,15 +780,6 @@ ## Remarks Use the method to restore the state information from a . - - -## Examples - The following example demonstrates how to use to create a and print its attributes to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_FromToXml/VB/webpermission_fromtoxml.vb" id="Snippet1"::: - ]]> @@ -944,15 +827,6 @@ ## Remarks returns a that contains all the permissions in both `target` and the current instance. - - -## Examples - The following example takes the logical union of two instances to create a third instance of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Union/VB/webpermission_union.vb" id="Snippet2"::: - ]]> target is not or of type . diff --git a/xml/System.Net/WebPermissionAttribute.xml b/xml/System.Net/WebPermissionAttribute.xml index 94f6f27f03f..b9323bedf0c 100644 --- a/xml/System.Net/WebPermissionAttribute.xml +++ b/xml/System.Net/WebPermissionAttribute.xml @@ -49,28 +49,19 @@ Specifies permission to access Internet resources. This class cannot be inherited. - allows you to declaratively specify which URI strings and regular expression strings your class can use. - - The security information specified in the is stored in the metadata of the attribute target, which is the class to which is applied. The system accesses this information at run time. The passed to the constructor determines the allowable targets. The system uses the returned by the method to convert the security information of the attribute target to a serializable form stored in metadata. - + allows you to declaratively specify which URI strings and regular expression strings your class can use. + + The security information specified in the is stored in the metadata of the attribute target, which is the class to which is applied. The system accesses this information at run time. The passed to the constructor determines the allowable targets. The system uses the returned by the method to convert the security information of the attribute target to a serializable form stored in metadata. + > [!NOTE] -> is used only for [Declarative Security](https://msdn.microsoft.com/library/97e21efd-6e89-4115-90d5-ad239513dad8). For [Imperative Security](https://msdn.microsoft.com/library/15aab1e1-6b7d-41ad-b102-c1ed7bedea27), use the corresponding . - - - -## Examples - The following example demonstrates how to apply to a method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/VB/webpermissionattribute_acceptconnect.vb" id="Snippet1"::: - +> is used only for [Declarative Security](https://msdn.microsoft.com/library/97e21efd-6e89-4115-90d5-ad239513dad8). For [Imperative Security](https://msdn.microsoft.com/library/15aab1e1-6b7d-41ad-b102-c1ed7bedea27), use the corresponding . + ]]> @@ -114,20 +105,11 @@ One of the values. Initializes a new instance of the class with a value that specifies the security actions that can be performed on this class. - value passed to this constructor specifies the allowable security actions that can be performed on this class. - - - -## Examples - The following example demonstrates how to apply to a method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermissionAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/VB/source.vb" id="Snippet1"::: - + value passed to this constructor specifies the allowable security actions that can be performed on this class. + ]]> @@ -167,20 +149,11 @@ Gets or sets the URI string accepted by the current . A string containing the URI accepted by the current . - to your class, this property specifies what URI string will be accepted for use within your class. This permission is applied when the security system calls . This property is write-once. - - - -## Examples - The following example demonstrates how to use to specify an allowable string. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Accept/VB/source.vb" id="Snippet1"::: - + to your class, this property specifies what URI string will be accepted for use within your class. This permission is applied when the security system calls . This property is write-once. + ]]> @@ -221,20 +194,11 @@ Gets or sets a regular expression pattern that describes the URI accepted by the current . A string containing a regular expression pattern that describes the URI accepted by the current . This string must be escaped according to the rules for encoding a constructor string. - to your class, this property specifies what regular expression string will be accepted for use within your class. This property is write-once. - - - -## Examples - The following example demonstrates how to use to specify an allowable . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/VB/source.vb" id="Snippet1"::: - + to your class, this property specifies what regular expression string will be accepted for use within your class. This property is write-once. + ]]> @@ -275,20 +239,11 @@ Gets or sets the URI connection string controlled by the current . A string containing the URI connection controlled by the current . - to your class, this property specifies what URI connection is accepted for use within your class. This property is write-once. - - - -## Examples - The following example demonstrates how to use WebPermissionAttribute to specify an allowable string. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Connect/VB/source.vb" id="Snippet1"::: - + to your class, this property specifies what URI connection is accepted for use within your class. This property is write-once. + ]]> @@ -329,20 +284,11 @@ Gets or sets a regular expression pattern that describes the URI connection controlled by the current . A string containing a regular expression pattern that describes the URI connection controlled by this . - to your class, this property specifies what regular expression connect string is accepted for use within your class. This property is write-once. - - - -## Examples - The following example demonstrates how to use to specify an allowable . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/VB/source.vb" id="Snippet1"::: - + to your class, this property specifies what regular expression connect string is accepted for use within your class. This property is write-once. + ]]> @@ -384,13 +330,13 @@ Creates and returns a new instance of the class. A corresponding to the security declaration. - method is called by the security system, not by application code. - - The security information described by is stored in the metadata of the attribute target, which is the class to which is applied. The system accesses the information at run time. The system uses the returned by to convert the security information of the attribute target to a serializable form stored in metadata. - + method is called by the security system, not by application code. + + The security information described by is stored in the metadata of the attribute target, which is the class to which is applied. The system accesses the information at run time. The system uses the returned by to convert the security information of the attribute target to a serializable form stored in metadata. + ]]> diff --git a/xml/System.Reflection.Emit/UnmanagedMarshal.xml b/xml/System.Reflection.Emit/UnmanagedMarshal.xml index 1d035a8234d..b5245195d2b 100644 --- a/xml/System.Reflection.Emit/UnmanagedMarshal.xml +++ b/xml/System.Reflection.Emit/UnmanagedMarshal.xml @@ -33,24 +33,13 @@ Represents the class that describes how to marshal a field from managed to unmanaged code. This class cannot be inherited. - type. The example emits a single-module assembly named `EmitMarshalAs.dll`, containing a type named `Sample`. The type has a method named `Test`, with one parameter of type . The code example applies the with to the parameter. - - You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the emitted assembly and observe that the parameter is marked `marshal(bstr)`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/UnmanagedMarshal/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb" id="Snippet1"::: - + @@ -108,15 +97,15 @@ Specifies a fixed-length array (ByValArray) to marshal to unmanaged code. An object. - The argument is not a simple native type. @@ -148,15 +137,15 @@ Specifies a string in a fixed array buffer (ByValTStr) to marshal to unmanaged code. An object. - The argument is not a simple native type. @@ -191,15 +180,15 @@ Specifies an to marshal to unmanaged code. The length of an is determined at runtime by the size of the actual marshaled array. An object. - The argument is not a simple native type. @@ -231,15 +220,15 @@ Specifies a to marshal to unmanaged code. An object. - The argument is not a simple native type. @@ -271,13 +260,13 @@ Specifies a given type that is to be marshaled to unmanaged code. An object. - passed to this method must be a simple native type. None of the following values may be used: , , , , or . - - Only unmanaged marshal constructs can be made using this method. - + passed to this method must be a simple native type. None of the following values may be used: , , , , or . + + Only unmanaged marshal constructs can be made using this method. + ]]> The argument is not a simple native type. @@ -305,11 +294,11 @@ Gets a number element. This property is read-only. An integer indicating the element count. - The argument is not an unmanaged element count. @@ -336,11 +325,11 @@ Indicates an unmanaged type. This property is read-only. An object. - @@ -367,11 +356,11 @@ Gets a GUID. This property is read-only. A object. - The argument is not a custom marshaler. diff --git a/xml/System.ServiceModel.Activation/WorkflowServiceHostFactory.xml b/xml/System.ServiceModel.Activation/WorkflowServiceHostFactory.xml index cee51309772..0f2359fcdd6 100644 --- a/xml/System.ServiceModel.Activation/WorkflowServiceHostFactory.xml +++ b/xml/System.ServiceModel.Activation/WorkflowServiceHostFactory.xml @@ -23,15 +23,15 @@ Factory that provides instances of in managed hosting environments where the host instance is created dynamically in response to incoming messages. - , consider also implementing a factory that derives from the class. - - If you have implemented a custom derivative of instead, then consider also implementing a factory that derives your factory from directly. - + , consider also implementing a factory that derives from the class. + + If you have implemented a custom derivative of instead, then consider also implementing a factory that derives your factory from directly. + ]]> @@ -80,29 +80,14 @@ Creates a from a string that contains either the file name of the workflow markup file or the type name of the workflow service type and the base address of the service specified. A object associated with the workflow service. The default implementation returns a object with the specified base addresses. - directives are placed. - + directives are placed. + > [!NOTE] -> To associate a rule definition with a workflow definition, name the rule definition file the same name as the workflow definition file with a .rules extension and place it in same directory as the workflow definition file. For example, the rules definition file CalculatorServiceWorkflow.rules must be in the same directory as CalculatorServiceWorkflow.xoml. - - - -## Examples - The following is an example of a type-based reference to the workflow service CalculatorServiceWorkflow. - -``` -<%@ServiceHost language=c# Debug="true" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" Service="CalculatorServiceWorkflow" %> -``` - - The following is an example of a workflow definition file reference to the workflow service CalculatorServiceWorkflow. - -``` -<%@ServiceHost language=c# Debug="true" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" Service="CalculatorServiceWorkflow.xoml" %> -``` - +> To associate a rule definition with a workflow definition, name the rule definition file the same name as the workflow definition file with a .rules extension and place it in same directory as the workflow definition file. For example, the rules definition file CalculatorServiceWorkflow.rules must be in the same directory as CalculatorServiceWorkflow.xoml. + ]]> diff --git a/xml/System.ServiceModel.Persistence/SqlPersistenceProviderFactory.xml b/xml/System.ServiceModel.Persistence/SqlPersistenceProviderFactory.xml index 1e9f16095a9..f4b137b4c49 100644 --- a/xml/System.ServiceModel.Persistence/SqlPersistenceProviderFactory.xml +++ b/xml/System.ServiceModel.Persistence/SqlPersistenceProviderFactory.xml @@ -88,13 +88,6 @@ ## Remarks This constructor can be used to arbitrarily specify `lockTimeout`, `connectionString`, and `serializeAsText` without specifying the other parameters as required by the other constructors (for example, to specify the `connectionString` and `lockTimeout` parameters without specifying the `serializeAsText` parameter.) - - -## Examples - The following code example shows how to create a new instance of the class using a parameters collection. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet3"::: - ]]> @@ -118,16 +111,7 @@ The connection parameters for the new persistence provider instance. Initializes a new instance of the class, configured with the specified connection string. - - class using a connection string. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet2"::: - - ]]> - + To be added. @@ -157,13 +141,6 @@ ## Remarks The default value for `serializeAsText` is `false`, which indicates that persistence information is serialized as binary data. - - -## Examples - The following code example shows how to create a new instance of the class. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet1"::: - ]]> @@ -199,13 +176,6 @@ The default value for `lockTimeout` is `TimeSpan.Zero`, which indicates that locking is not used. If `TimeSpan.MaxValue` is used, then locks are maintained indefinitely. - - -## Examples - The following code example shows how to create a new instance of the class. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet0"::: - ]]> @@ -229,16 +199,7 @@ Gets the connection parameters for persistence provider instances created with this factory. The connection parameters for persistence provider instances created with this factory. - - - + To be added. @@ -270,13 +231,6 @@ ## Remarks The initialized persistence provider uses the current parameters of the creating factory (, , and ), even if the factory's parameters are changed after the persistence provider is created. - - -## Examples - The following code example shows how to execute the `CreateProvider` method. Note that the resulting provider is accessed as a instance. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet7"::: - ]]> @@ -364,13 +318,6 @@ ## Remarks A time-out of `TimeSpan.Zero` specifies that no locking is used. - - -## Examples - The following code example shows how to access the `LockTimeout` property. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet5"::: - ]]> @@ -632,13 +579,6 @@ ## Remarks The default value for `serializeAsText` is `false`, which indicates that persistence information is serialized as binary data. - - -## Examples - The following code example shows how to access the `SerializeAsText` property. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/sqlpersistenceproviderfactory/cs/sqlpersistenceproviderfactory.cs" id="Snippet6"::: - ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaCollection.xml b/xml/System.Xml.Schema/XmlSchemaCollection.xml index db57bc15f62..ac8a1001ad1 100644 --- a/xml/System.Xml.Schema/XmlSchemaCollection.xml +++ b/xml/System.Xml.Schema/XmlSchemaCollection.xml @@ -87,14 +87,6 @@ > [!IMPORTANT] > The class is obsolete in the Microsoft .NET Framework version 2.0 and has been replaced by the class. - - -## Examples - The following example validates an XML document using the `XmlSchemaCollection`. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Overview/aa.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb" id="Snippet1"::: - ]]> @@ -438,34 +430,6 @@ schemaColl.Add("urn:author", "names.xsd"); > [!IMPORTANT] > The class is obsolete in .NET Framework version 2.0 and has been replaced by the class. -## Examples - The following example validates three XML files using schemas stored in the `XmlSchemaCollection`. - - :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlValidatingReader/Schemas/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/VB/source.vb" id="Snippet1"::: - - The sample uses the following five input files: - - `booksSchema.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml" id="Snippet2"::: - - `booksSchemaFail.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml" id="Snippet3"::: - - `newbooks.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml" id="Snippet4"::: - - `books.xsd` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml" id="Snippet5"::: - - `schema1.xdr` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml" id="Snippet6"::: - ]]> The schema is not a valid schema. @@ -612,12 +576,6 @@ schemaColl.Add("urn:author", "names.xsd"); > [!IMPORTANT] > The class is obsolete and has been replaced by the class. -## Examples - The following example adds a schema to the collection. An is passed to the `Add` method that sets the necessary credentials required to access any external resources referenced in the schema. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Add/schemacolladd.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb" id="Snippet1"::: - ]]> The schema is not a valid schema. @@ -774,14 +732,6 @@ schemaColl.Add("urn:author", "names.xsd"); > [!IMPORTANT] > The class is obsolete in .NET Framework version 2.0 and has been replaced by the class. - - -## Examples - The following example checks to see if a schema is in the collection. If it is, it displays the schema. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Contains/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb" id="Snippet1"::: - ]]> @@ -996,14 +946,6 @@ schemaColl.Add("urn:author", "names.xsd"); > [!IMPORTANT] > The class is obsolete in .NET Framework version 2.0 and has been replaced by the class. - - -## Examples - The following example displays each of the XML Schemas in the schema collection. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/GetEnumerator/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/VB/source.vb" id="Snippet1"::: - ]]> @@ -1066,14 +1008,6 @@ schemaColl.Add("urn:author", "names.xsd"); > [!IMPORTANT] > The class is obsolete in .NET Framework version 2.0 and has been replaced by the class. - - -## Examples - The following example checks to see if a schema is in the collection. If it is, it displays the schema. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Contains/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb" id="Snippet1"::: - ]]> @@ -1439,18 +1373,6 @@ schemaColl.Add("urn:author", "names.xsd"); > [!IMPORTANT] > The class is obsolete in .NET Framework version 2.0 and has been replaced by the class. - - -## Examples - The following example shows how to set an event handler to handle invalid XML Schemas. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/ValidationEventHandler/schemaevent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb" id="Snippet1"::: - - The preceding example uses the file `invalid.xsd` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchema.ValidationEventHandler/XML/invalid.xsd" id="Snippet2"::: - ]]> diff --git a/xml/System.Xml.Xsl/XslTransform.xml b/xml/System.Xml.Xsl/XslTransform.xml index e52ff692c8b..1a4bfa28be1 100644 --- a/xml/System.Xml.Xsl/XslTransform.xml +++ b/xml/System.Xml.Xsl/XslTransform.xml @@ -142,14 +142,6 @@ For more information see [XSLT Transformations with the XslTransform Class](/dotnet/standard/data/xml/xslt-transformations-with-the-xsltransform-class). - - -## Examples - The following example transforms the specified XML document and outputs the result to the console. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform Example/VB/source.vb" id="Snippet1"::: - ]]> @@ -278,24 +270,6 @@ > [!NOTE] > If the caller does not have `UnmanagedCode` permission, the embedded script is not compiled and a is thrown. See and for more information. - - -## Examples - The following example transforms an XML document into an HTML document. It displays the ISBN, title, and price for each book in a table. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb" id="Snippet1"::: - - The sample uses the following two input files. - - `books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/XML/books.xml" id="Snippet2"::: - - `output.xsl` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/XML/output.xsl" id="Snippet3"::: - ]]> The loaded resource is not a valid style sheet. @@ -370,24 +344,6 @@ > [!NOTE] > If the caller does not have `UnmanagedCode` permission, the embedded script is not compiled and a is thrown. See and for more information. - - -## Examples - The following example transforms an XML file sorting all the books by title. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans3.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb" id="Snippet1"::: - - The example uses the following data files as input. - - `books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XslTransform.Load3/XML/books.xml" id="Snippet2"::: - - `titles.xsl` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XslTransform.Load3/XML/titles.xsl" id="Snippet3"::: - ]]> The current node does not conform to a valid style sheet. @@ -613,26 +569,6 @@ > [!NOTE] > If the caller does not have `UnmanagedCode` permission, the embedded script is not compiled and a is thrown. See and for more information. -## Examples - The following example transforms an XML document into an HTML document. The example loads an XSLT style sheet that contains an `xsl:include` element referencing another style sheet. An is passed to the method, which sets the credentials necessary to access the network resource for the included style sheet. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load2/VB/trans2.vb" id="Snippet1"::: - - The example uses the following data files as input. - - `books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XslTransform.Load2/XML/books.xml" id="Snippet2"::: - - `sort.xsl` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XslTransform.Load2/XML/sort.xsl" id="Snippet3"::: - - `includefile.xsl` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XslTransform.Load2/XML/includefile.xsl" id="Snippet4"::: - ]]> The loaded resource is not a valid style sheet. @@ -964,12 +900,6 @@ |The XSLT style sheet comes from an outside source. The origin of the source is not known.|Set evidence to `null`. Script blocks are not processed, the XSLT `document()` function is not supported, and privileged extension objects are disallowed.

Additionally, you can also set the `resolver` parameter to `null`. This ensures that `xsl:import` and `xsl:include` elements are not processed.| |The XSLT style sheet comes from an outside source. The origin of the source is not known, but you require script support.|Request evidence from the caller. The API of the caller must provide a way to provide evidence, typically the class.| -## Examples - The following example performs an XSLT transformation where `xsltReader` is an containing a style sheet and `secureURL` is a trusted URL that can be used to create . The method is used to create , which is applied to the style sheet. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans_ev.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb" id="Snippet1"::: - ]]> The current node does not conform to a valid style sheet. @@ -1118,14 +1048,6 @@ |The XSLT style sheet comes from an outside source. The origin of the source is not known.|Set evidence to `null`. Script blocks are not processed, the XSLT `document()` function is not supported, and privileged extension objects are disallowed.

Additionally, you can also set the `resolver` parameter to `null`. This ensures that `xsl:import` and `xsl:include` elements are not processed.| |The XSLT style sheet comes from an outside source. The origin of the source is not known, but you require script support.|Request evidence from the caller. The API of the caller must provide a way to provide evidence, typically the `Evidence` class.| - - -## Examples - The following example performs an XSLT transformation using a style sheet from an outside source. Because the style sheet comes from an untrusted source, the `resolver` and `evidence` parameters are set to `null`. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans_noev.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load5/VB/trans_noev.vb" id="Snippet1"::: - ]]> The current node does not conform to a valid style sheet. @@ -1222,26 +1144,8 @@ > [!NOTE] > This method is obsolete in version 1.1 of the .NET Framework. The setting of the property determines how the XSLT `document()` function is resolved. The recommended practice is to use the method that takes an object as one of its arguments. -## Examples - The following example transforms the `books.xml` file using the `output.xsl` style sheet and outputs the results to the `books.html` file. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb" id="Snippet1"::: - - The sample uses the following two input files: - - `books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/XML/books.xml" id="Snippet2"::: - - `output.xsl` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/XML/output.xsl" id="Snippet3"::: - ]]> - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform
@@ -1321,58 +1225,8 @@ Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - ]]> - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform @@ -1454,10 +1308,7 @@ Root node is book. ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. - Implementation of Discretionary Behaviors in the XslTransform Class + There was an error processing the XSLT transformation.. @@ -1525,14 +1376,6 @@ Root node is book. supports the XSLT 1.0 syntax. The XSLT style sheet must include the namespace declaration `xmlns:xsl= http://www.w3.org/1999/XSL/Transform`. - - -## Examples - The following example performs an XSLT transformation and outputs to a file. An with default credentials is used resolve an external resources. See for details. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb" id="Snippet1"::: - ]]> @@ -1616,61 +1459,9 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform + There was an error processing the XSLT transformation.. @@ -1751,61 +1542,9 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment, and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform + There was an error processing the XSLT transformation. @@ -1887,67 +1626,9 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment, and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out, null); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - - - -## Examples - The following example transforms an XML document and outputs the results to an `XmlReader`. An with the necessary credentials is used to process any XSLT `document()` functions. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip3.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb" id="Snippet1"::: - ]]> - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform @@ -2026,61 +1707,9 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform + There was an error processing the XSLT transformation. @@ -2161,11 +1790,8 @@ Root node is book. ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation.. - Implementation of Discretionary Behaviors in the XslTransform Class @@ -2246,11 +1872,8 @@ Root node is book. ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation.. - Implementation of Discretionary Behaviors in the XslTransform Class @@ -2334,11 +1957,8 @@ Root node is book. ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation.. - Implementation of Discretionary Behaviors in the XslTransform Class @@ -2419,11 +2039,8 @@ Root node is book. ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation.. - Implementation of Discretionary Behaviors in the XslTransform Class @@ -2504,71 +2121,11 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out, null); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - - - -## Examples - The following example performs a transformation within an ASP.NET page. - - :::code language="aspx-csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/transcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform5/VB/transvb.aspx" id="Snippet1"::: - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation. - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform @@ -2651,75 +2208,11 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out, null); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - - - -## Examples - The following example transforms an XML file and outputs an HTML string. The and classes are used to read and write the strings. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/transstring.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform6/VB/transstring.vb" id="Snippet1"::: - - The example uses the `books.xml` file as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XslTransform.Transform6/XML/books.xml" id="Snippet2"::: - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation. - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform @@ -2800,81 +2293,11 @@ Root node is book. Transformations apply to the document as a whole. In other words, if you pass in a node other than the document root node, this does not prevent the transformation process from accessing all nodes in the loaded document. To transform a node fragment, you must create an containing just the node fragment and pass that to the method. - The following example performs a transformation on a node fragment. - -```csharp -XslTransform xslt = new XslTransform(); -xslt.Load("print_root.xsl"); -XmlDocument doc = new XmlDocument(); -doc.Load("library.xml"); -// Create a new document containing just the node fragment. -XmlNode testNode = doc.DocumentElement.FirstChild; -XmlDocument tmpDoc = new XmlDocument(); -tmpDoc.LoadXml(testNode.OuterXml); -// Pass the document containing the node fragment -// to the Transform method. -Console.WriteLine("Passing " + tmpDoc.OuterXml + " to print_root.xsl"); -xslt.Transform(tmpDoc, null, Console.Out, null); -``` - - The example uses the `library.xml` and `print_root.xsl` files as input, and outputs the following to the console. - -```txt -Passing Pride And Prejudice to print_root.xsl -Root node is book. -``` - - `library.xml` - -```xml - - - Pride And Prejudice - - - Hook - - -``` - - `print_root.xsl` - -```xml - - - - -``` - - - -## Examples - The following example transforms an XML document into an HTML document. It displays the ISBN, title, and price for each book in a table. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb" id="Snippet1"::: - - The sample uses the following two input files. - - `books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/XML/books.xml" id="Snippet2"::: - - `output.xsl` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/XML/output.xsl" id="Snippet3"::: - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation. - Implementation of Discretionary Behaviors in the XslTransform Class - Outputs from an XslTransform @@ -2955,27 +2378,12 @@ Root node is book. See [Outputs from an XslTransform](/dotnet/standard/data/xml/outputs-from-an-xsltransform) for specifics on which `xsl:output` attributes are supported. - - -## Examples - The following example loads a customer table into an and performs an XSLT transformation to pull the customer data into an HTML table. The example uses the Microsoft SQL Server 2000 Northwind database. - - :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/dataset_trans.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.CreateNavigator/VB/dataset_trans.vb" id="Snippet1"::: - - The example uses the `customers.xsl` file as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.CreateNavigator/XML/customers.xsl" id="Snippet2"::: - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation. - Implementation of Discretionary Behaviors in the XslTransform Class @@ -3058,13 +2466,10 @@ Root node is book. ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation.. - Implementation of Discretionary Behaviors in the XslTransform Class @@ -3145,23 +2550,12 @@ Root node is book. The `xsl:output` element is not supported when outputting to an (`xsl:output` is ignored). See [Outputs from an XslTransform](/dotnet/standard/data/xml/outputs-from-an-xsltransform) for more information. - - -## Examples - The following example loads and edits an XML document before performing an XSLT transform. - - :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CreateNavigator/trans_snip.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform2/VB/trans_snip.vb" id="Snippet1"::: - ]]> - There was an error processing the XSLT transformation. - - Note: This is a change in behavior from earlier versions. An is thrown if you are using Microsoft .NET Framework version 1.1 or earlier. + There was an error processing the XSLT transformation.. - Implementation of Discretionary Behaviors in the XslTransform Class diff --git a/xml/System.Xml/XmlDataDocument.xml b/xml/System.Xml/XmlDataDocument.xml index 11222da3e8f..203078a01c5 100644 --- a/xml/System.Xml/XmlDataDocument.xml +++ b/xml/System.Xml/XmlDataDocument.xml @@ -165,16 +165,6 @@ ## Remarks The `XmlDataDocument` is synchronized with the specified `DataSet`. Any data in the `DataSet` is immediately available through the `XmlDataDocument`. Any changes in the `DataSet` are propagated in the `XmlDataDocument`. Any changes made in the `XmlDataDocument`, provided they match the `DataSet` schema, are propagated in the `DataSet`. - - -## Examples - The following example loads a customer table into an `XmlDataDocument`. - - The example uses the SQL Server 2000 Northwind database. - - :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/VB/source.vb" id="Snippet1"::: - ]]> @@ -230,16 +220,6 @@ See in the `XmlNode` class to see a table describing how this method behaves with each of the different node types. - - -## Examples - The following example loads a `DataSet` into an `XmlDataDocument` and then creates a shallow clone of the `XmlDataDocument`. - - The example uses the SQL Server 2000 Northwind database. - - :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb" id="Snippet1"::: - ]]> @@ -299,25 +279,7 @@ The namespace Uniform Resource Identifier (URI) of the new element. If String.Empty or , there is no namespaceURI. Creates an element with the specified , , and . A new . - - - + To be added. @@ -464,24 +426,6 @@ class MyXmlDataDocument : XmlDataDocument { ## Remarks The `DataSet` enables you to access the data in the `XmlDataDocument` using a relational model. This means that you can handle the data as tables and views, rows and columns, relations, and so on. Changes made in the `DataSet` are immediately visible in the `XmlDataDocument`. - - -## Examples - The following example modifies the price of a book using the `DataSet` methods. - - :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/DataSet/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/VB/source.vb" id="Snippet1"::: - - The example uses the following two files as input. - - `2books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/XML/source.xml" id="Snippet2"::: - - `store.xsd` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/XML/source.xml" id="Snippet3"::: - ]]> @@ -578,19 +522,7 @@ class MyXmlDataDocument : XmlDataDocument { The whose associated you want to retrieve. Retrieves the associated with the specified . The containing a representation of the specified . - - - + To be added. @@ -679,27 +611,7 @@ class MyXmlDataDocument : XmlDataDocument { The whose associated you want to retrieve. Retrieves the associated with the specified . The containing a representation of the ; if there is no associated with the . - - - + To be added. @@ -932,24 +844,6 @@ class MyXmlDataDocument : XmlDataDocument { If the reader is positioned on a leaf node that is invalid for the root level of a document (for example, a white space or attribute node), the reader continues to read until it is positioned on a node that can be used for the root. The document begins loading at this point. - - -## Examples - The following example modifies the price of a book using the `DataSet` methods. - - :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/Load/loadrdr.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb" id="Snippet1"::: - - The example uses the following two input files. - - `2books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/2books.xml" id="Snippet2"::: - - `store.xsd` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/test.xsd" id="Snippet3"::: - ]]> The XML being loaded contains entity references, and the reader cannot resolve entities. diff --git a/xml/System.Xml/XmlValidatingReader.xml b/xml/System.Xml/XmlValidatingReader.xml index a6a25b8352c..5052fe412a8 100644 --- a/xml/System.Xml/XmlValidatingReader.xml +++ b/xml/System.Xml/XmlValidatingReader.xml @@ -154,27 +154,6 @@ When external document type definitions (DTDs) or schemas are needed for validation, the property sets the object to use for resolving external resources. -## Examples - -The following example validates two documents. - -[!code-csharp[XmlValidatingReader.Cctor#1](~/snippets/csharp/System.Xml/XmlValidatingReader/.ctor/valid_xsd2.cs#1)] -[!code-vb[XmlValidatingReader.Cctor#1](~/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.Cctor/VB/valid_xsd2.vb#1)] - -The sample uses the following input files: - -`notValidXSD.xml` - -[!code-xml[XmlValidatingReader.Cctor#2](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.Cctor/XML/notvalidxsd.xml#2)] - -`books.xsd` - -[!code-xml[XmlValidatingReader.Cctor#3](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.Cctor/XML/books.xsd#3)] - -`inlineXSD.xml` - -[!code-xml[XmlValidatingReader.Cctor#4](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.Cctor/XML/inlinexsd.xml#4)] - ]]> The reader specified is not an . @@ -338,13 +317,6 @@ The sample uses the following input files: If this reader will be validating by using XML-Data Reduced (XDR) or XML Schema definition language (XSD) schemas, use the property to specify the that contains the schemas (the `XmlParserContext` does not need to supply the DocumentType information). -## Examples - -The following example reads an XML fragment. It uses an `XmlParserContext` and its to handle namespace matching. - - [!code-csharp[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/csharp/System.Xml/XmlParserContext/.ctor/source.cs#1)] - [!code-vb[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlParserContext.XmlParserContext Example/VB/source.vb#1)] - ]]> @@ -400,13 +372,6 @@ The following example reads an XML fragment. It uses an `XmlParserContext` and i This property is relevant to `Element`, `DocumentType`, and `XmlDeclaration` nodes only. (Other node types do not have attributes.) -## Examples - -The following example reads all the elements on the root node. - -[!code-csharp[Classic WebData XmlValidatingReader.AttributeCount Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/AttributeCount/source.cs#1)] -[!code-vb[Classic WebData XmlValidatingReader.AttributeCount Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb#1)] - ]]> @@ -461,19 +426,6 @@ The following example reads all the elements on the root node. A networked XML document is comprised of chunks of data aggregated by using various World Wide Web Consortium (W3C) standard inclusion mechanisms and therefore contains nodes that come from different places. document type definition (DTD) entities are an example of this, but this is not limited to DTDs. The base URI tells you where these nodes came from. If there is no base URI for the nodes being returned (for example, they were parsed from an in-memory string), String.Empty is returned. -## Examples - -The following example parses a file and displays the base URI of each node. - -[!code-csharp[Classic WebData XmlValidatingReader.BaseURI Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/BaseURI/source.cs#1)] -[!code-vb[Classic WebData XmlValidatingReader.BaseURI Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.BaseURI Example/VB/source.vb#1)] - -The example uses the file, `uri.xml`, as input. - -[!code-xml[Classic WebData XmlValidatingReader.BaseURI Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.BaseURI Example/XML/source.xml#2)] - -The `style.xml` file contains the XML text ``. - ]]> @@ -685,13 +637,6 @@ The `style.xml` file contains the XML text ``. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. -## Examples - -The following example displays each node including its depth, line number, and line position. - -[!code-csharp[IXmlLineInfo#1](~/snippets/csharp/System.Xml/IXmlLineInfo/Overview/lineinfo.cs#1)] -[!code-vb[IXmlLineInfo#1](~/snippets/visualbasic/VS_Snippets_Data/IXmlLineInfo/VB/lineinfo.vb#1)] - ]]> @@ -831,17 +776,6 @@ The following example displays each node including its depth, line number, and l | 1 | EntityReference | num | | | 1 | SignificantWhitespace | | | -## Examples - -The following example uses the `ResolveEntity` method to expand a general entity. - -[!code-csharp[Classic WebData XmlValidatingReader.ResolveEntity Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/EntityHandling/source.cs#1)] -[!code-vb[Classic WebData XmlValidatingReader.ResolveEntity Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/VB/source.vb#1)] - - The example uses the file, `book1.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.ResolveEntity Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/XML/source.xml#2)] - ]]> Invalid value was specified. @@ -1028,17 +962,6 @@ The following example uses the `ResolveEntity` method to expand a general entity If the reader is positioned on a `DocumentType` node, this method can be used to get the PUBLIC and SYSTEM literals, for example, `reader.GetAttribute("PUBLIC")` -## Examples - -The following example gets the value of the ISBN attribute. - -[!code-csharp[Classic WebData XmlValidatingReader.GetAttribute Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/GetAttribute/source.cs#1)] -[!code-vb[Classic WebData XmlValidatingReader.GetAttribute Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.GetAttribute Example/VB/source.vb#1)] - - The example uses the file, `attrs.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.GetAttribute Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.GetAttribute Example/XML/attrs.xml#2)] - ]]> @@ -1247,13 +1170,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); |`Whitespace`|The white space between markup.| |`XmlDeclaration`|The content of the declaration.| -## Examples - -The following example reads in XML with various data types and displays each of the nodes. - -[!code-csharp[Classic WebData XmlValidatingReader.HasValue Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/HasValue/source.cs#1)] -[!code-vb[Classic WebData XmlValidatingReader.HasValue Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.HasValue Example/VB/source.vb#1)] - ]]> @@ -1307,23 +1223,6 @@ The following example reads in XML with various data types and displays each of > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. -## Examples - -The following example displays all attributes nodes on the root element. - - [!code-csharp[XmlValidatingReader.IsDefault#1](~/snippets/csharp/System.Xml/XmlValidatingReader/IsDefault/readdefattr.cs#1)] - [!code-vb[XmlValidatingReader.IsDefault#1](~/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.IsDefault/VB/readdefattr.vb#1)] - - The example uses the following files as input. - - `book4.xml` - - [!code-xml[XmlValidatingReader.IsDefault#2](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.IsDefault/XML/book4.xml#2)] - - `book.dtd` - - [!code-xml[XmlValidatingReader.IsDefault#3](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.IsDefault/XML/book.dtd#3)] - ]]> @@ -1386,17 +1285,6 @@ The following example displays all attributes nodes on the root element. If default content has been added to an element due to schema validation, `IsEmptyElement` still returns `true`. It has no bearing on whether or not the element has a default value. In other words, `IsEmptyElement` simply reports whether or not the element in the source document had an end element tag. -## Examples - -The following example displays the text content of each element. - - [!code-csharp[Classic WebData XmlValidatingReader.IsEmptyElement Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/IsEmptyElement/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.IsEmptyElement Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/VB/source.vb#1)] - - The example uses the file, `elems.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.IsEmptyElement Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/XML/source.xml#2)] - ]]> @@ -1677,15 +1565,6 @@ If the reader is positioned on a `DocumentType` node, this method can be used to > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. - - -## Examples - -The following example reads an XML fragment. - - [!code-csharp[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/csharp/System.Xml/XmlParserContext/.ctor/source.cs#1)] - [!code-vb[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlParserContext.XmlParserContext Example/VB/source.vb#1)] - ]]> @@ -1822,13 +1701,6 @@ The following example reads an XML fragment. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. -## Examples - -The following example reads all the elements on the root node. - - [!code-csharp[Classic WebData XmlValidatingReader.AttributeCount Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/AttributeCount/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.AttributeCount Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb#1)] - ]]> The parameter is less than 0 or greater than or equal to . @@ -1888,13 +1760,6 @@ The following example reads all the elements on the root node. After calling this method, the , , and properties reflect the properties of that attribute. -## Examples - -The following example reads an attribute with text and entity reference nodes. - - [!code-csharp[Classic WebData XmlValidatingReader.MoveToAttribute Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/MoveToAttribute/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.MoveToAttribute Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToAttribute Example/VB/source.vb#1)] - ]]> @@ -2018,13 +1883,6 @@ The following example reads an attribute with text and entity reference nodes. Use this method to return to an element after navigating through its attributes. This method moves the reader to one of the following node types: `Element`, `DocumentType`, or `XmlDeclaration`. -## Examples - -The following example reads all the elements on the root node. - - [!code-csharp[Classic WebData XmlValidatingReader.AttributeCount Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/AttributeCount/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.AttributeCount Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb#1)] - ]]> @@ -2078,13 +1936,6 @@ The following example reads all the elements on the root node. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. -## Examples - -The following example reads an XML fragment. - - [!code-csharp[Classic WebData XmlValidatingReader.MoveToFirstAttribute Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/MoveToFirstAttribute/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.MoveToFirstAttribute Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToFirstAttribute Example/VB/source.vb#1)] - ]]> @@ -2140,13 +1991,6 @@ The following example reads an XML fragment. If the current node is an element node, this method is equivalent to . If `MoveToNextAttribute` returns `true`, the reader moves to the next attribute; otherwise, the position of the reader does not change. -## Examples - -The following example reads an XML fragment. - - [!code-csharp[Classic WebData XmlValidatingReader.MoveToFirstAttribute Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/MoveToFirstAttribute/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.MoveToFirstAttribute Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToFirstAttribute Example/VB/source.vb#1)] - ]]> @@ -2218,17 +2062,6 @@ The following example reads an XML fragment. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. -## Examples - -The following example reads an XML file and displays each of the nodes. - - [!code-csharp[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/Name/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb#1)] - - The example uses the file, `items.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.Name Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/XML/source.xml#2)] - ]]> @@ -2333,15 +2166,6 @@ The following example reads an XML file and displays each of the nodes. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. - - -## Examples - -The following example reads an XML fragment. - - [!code-csharp[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/csharp/System.Xml/XmlParserContext/.ctor/source.cs#1)] - [!code-vb[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlParserContext.XmlParserContext Example/VB/source.vb#1)] - ]]> @@ -2450,17 +2274,6 @@ The following example reads an XML fragment. This property never returns the following `XmlNodeType` types: `Document`, `DocumentFragment`, `Entity`, or `Notation`. -## Examples - -The following example reads an XML file and displays each of the nodes. - - [!code-csharp[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/Name/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb#1)] - - The example uses the file, `items.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.Name Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/XML/source.xml#2)] - ]]> @@ -2512,15 +2325,6 @@ The following example reads an XML file and displays each of the nodes. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. - - -## Examples - -The following example reads an XML fragment. - - [!code-csharp[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/csharp/System.Xml/XmlParserContext/.ctor/source.cs#1)] - [!code-vb[Classic WebData XmlParserContext.XmlParserContext Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlParserContext.XmlParserContext Example/VB/source.vb#1)] - ]]> @@ -2628,17 +2432,6 @@ The following example reads an XML fragment. When a reader is first created and initialized, there is no information available. You must call `Read` to read the first node. -## Examples - -The following example reads an XML file and displays each node. - - [!code-csharp[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/Name/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb#1)] - - The example uses the file, `items.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.Name Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/XML/source.xml#2)] - ]]> @@ -2698,40 +2491,6 @@ The following example reads an XML file and displays each node. Use this method after calling to read through the text or entity reference nodes that make up the attribute value. The of the attribute value nodes is one plus the depth of the attribute node. The `Depth` increments and decrements by one when you step into and out of general entity references. - For example, suppose you have the following XML: `` - - where the entity `b` is defined in the document type definition (DTD) as follows: `` - - If is set to `ExpandCharEntities`, the following C# code returns the attribute value as two text nodes and one entity reference node: - -```csharp -reader.MoveToAttribute("name"); - while (reader.ReadAttributeValue()) - { - if (reader.NodeType == XmlNodeType.Text) - { - // at this point reader.Value == "a " or " c" - } - else if (reader.NodeType == XmlNodeType.EntityReference) - { - // at this point reader.Name == "b" - reader.ResolveEntity(); - while (reader.ReadAttributeValue() && - reader.NodeType != XmlNodeType.EndEntity) - { - // reader.Value == "123" - } - } - } -``` - -## Examples - -The following example reads an attribute with text and entity reference nodes. - - [!code-csharp[Classic WebData XmlValidatingReader.MoveToAttribute Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/MoveToAttribute/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.MoveToAttribute Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToAttribute Example/VB/source.vb#1)] - ]]> @@ -3208,17 +2967,6 @@ The text node can be either an element or an attribute text node. |ExpandEntities|Returns expanded character and general entities. This is the default.| |ExpandCharEntities|Returns the text content up to but not including a general entity reference. This means a general entity causes ReadString to stop. You must call `Read` to step over the entity reference.| -## Examples - -The following example displays the text content of each of the elements. - - [!code-csharp[Classic WebData XmlValidatingReader.IsEmptyElement Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/IsEmptyElement/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.IsEmptyElement Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/VB/source.vb#1)] - - The example uses the file, `elems.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.IsEmptyElement Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/XML/source.xml#2)] - ]]> @@ -3282,23 +3030,6 @@ The following example displays the text content of each of the elements. > [!CAUTION] > After calling , `ReadTypedValue` will return `null`. -## Examples - -The following example displays the type information for each of the elements in the XML document. - - [!code-csharp[XmlValidatingReader.SchemaType#1](~/snippets/csharp/System.Xml/XmlValidatingReader/ReadTypedValue/schematype.cs#1)] - [!code-vb[XmlValidatingReader.SchemaType#1](~/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.SchemaType/VB/schematype.vb#1)] - - The example uses the following input files. - - `booksSchema.xml` - - [!code-xml[XmlValidatingReader.SchemaType#2](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.SchemaType/XML/booksschema.xml#2)] - - `books.xsd` - - [!code-xml[XmlValidatingReader.SchemaType#3](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.SchemaType/XML/books.xsd#3)] - ]]> @@ -3355,17 +3086,6 @@ The following example displays the type information for each of the elements in > [!NOTE] > After calling this method, if the entity is part of an attribute value, you must call to step into the entity. -## Examples - -The following example uses `ResolveEntity` to expand a general entity. - - [!code-csharp[Classic WebData XmlValidatingReader.ResolveEntity Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/EntityHandling/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.ResolveEntity Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/VB/source.vb#1)] - - The example uses the file, `book1.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.ResolveEntity Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/XML/source.xml#2)] - ]]> The reader is not positioned on an node. @@ -3428,35 +3148,6 @@ The following example uses `ResolveEntity` to expand a general entity. > [!NOTE] > The schemas must be added to the `XmlSchemaCollection` before the first `Read` call. -## Examples - -The following example validates three XML files using schemas stored in the XmlSchemaCollection. - - [!code-csharp[Classic WebData XmlValidatingReader.Schemas Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/Schemas/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.Schemas Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/VB/source.vb#1)] - - The sample uses the following five input files: - - `booksSchema.xml` - - [!code-xml[Classic WebData XmlValidatingReader.Schemas Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml#2)] - - `booksSchemaFail.xml` - - [!code-xml[Classic WebData XmlValidatingReader.Schemas Example#3](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml#3)] - - `newbooks.xml` - - [!code-xml[Classic WebData XmlValidatingReader.Schemas Example#4](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml#4)] - - `books.xsd` - - [!code-xml[Classic WebData XmlValidatingReader.Schemas Example#5](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml#5)] - - `schema1.xdr` - - [!code-xml[Classic WebData XmlValidatingReader.Schemas Example#6](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/XML/source.xml#6)] - ]]> @@ -3516,22 +3207,7 @@ The following example validates three XML files using schemas stored in the XmlS > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. - The user needs to test for the returned type. For example, - -```csharp -object obj = vreader.SchemaType; - if (obj is XmlSchemaType) - { - XmlSchemaType st = (XmlSchemaType)obj; - // use XmlSchemaType object - } - if (obj is XmlSchemaDatatype) - { - XmlSchemaDatatype sd = (XmlSchemaDatatype)obj; - Type vt = sd.ValueType; - // use XmlSchemaDatatype object - } -``` + The user needs to test for the returned type. If XML Schema validation is being performed, the `XmlSchemaType` or `XmlSchemaDatatype` corresponds to the current element being read. If document type definition (DTD validation) is being performed, this property returns `null`. @@ -3547,23 +3223,6 @@ object obj = vreader.SchemaType; > [!CAUTION] > After calling , SchemaType will return Null. -## Examples - -The following example displays the type information for each of the elements in the XML document. - - [!code-csharp[XmlValidatingReader.SchemaType#1](~/snippets/csharp/System.Xml/XmlValidatingReader/ReadTypedValue/schematype.cs#1)] - [!code-vb[XmlValidatingReader.SchemaType#1](~/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.SchemaType/VB/schematype.vb#1)] - - The example uses the following input files. - - `booksSchema.xml` - - [!code-xml[XmlValidatingReader.SchemaType#2](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.SchemaType/XML/booksschema.xml#2)] - - `books.xsd` - - [!code-xml[XmlValidatingReader.SchemaType#3](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.SchemaType/XML/books.xsd#3)] - ]]> @@ -3856,23 +3515,6 @@ The following example displays the type information for each of the elements in The callback handler can use the property to guarantee that an XML instance document is validated against a schema. The `Severity` property allows you to distinguish between validation errors (Severity is equal to XmlSeverityType.Error) that indicate a fatal error, and validation warnings (Severity is equal to XmlSeverityType.Warning) that indicate that no schema information is available. -## Examples - -The following example validates a file against an XML Schema. - - [!code-csharp[Classic WebData XmlValidatingReader.ValidationEventHandler Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/ValidationEventHandler/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.ValidationEventHandler Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/VB/source.vb#1)] - - The sample uses the following two input files: - - `notValidXSD.xml` (The `xsi:schemaLocation` attribute identifies the XML Schema for the reader.) - - [!code-xml[Classic WebData XmlValidatingReader.ValidationEventHandler Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/XML/source.xml#2)] - - `books.xsd` - - [!code-xml[Classic WebData XmlValidatingReader.ValidationEventHandler Example#3](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/XML/source.xml#3)] - ]]> @@ -3929,31 +3571,6 @@ The following example validates a file against an XML Schema. If external document type definitions (DTDs) or schemas are needed for validation, the is used. -## Examples - -The following example validates two files. - - [!code-csharp[Classic WebData XmlValidatingReader.ValidationType Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/ValidationType/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.ValidationType Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/VB/source.vb#1)] - - The sample uses the following four input files: - - `notValid.xml` (The "x-schema:" prefix identifies the XML-Data Reduced (XDR) schema for the reader.) - - [!code-xml[Classic WebData XmlValidatingReader.ValidationType Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/XML/source.xml#2)] - - `schema1.xdr` - - [!code-xml[Classic WebData XmlValidatingReader.ValidationType Example#3](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/XML/source.xml#3)] - - `cdDTD.xml` - - [!code-xml[Classic WebData XmlValidatingReader.ValidationType Example#4](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/XML/source.xml#4)] - - `book1.xml` - - [!code-xml[Classic WebData XmlValidatingReader.ValidationType Example#5](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/XML/source.xml#5)] - ]]> Setting the property after a Read has been called. @@ -4030,17 +3647,6 @@ The following example validates two files. > [!NOTE] > The class is obsolete in .NET Framework 2.0. You can create a validating instance by using the class and the method. For more information, see the Remarks section of the reference page. -## Examples - -The following example reads an XML file and displays each node. - - [!code-csharp[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/csharp/System.Xml/XmlValidatingReader/Name/source.cs#1)] - [!code-vb[Classic WebData XmlValidatingReader.Name Example#1](~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb#1)] - - The example uses the file, `items.xml`, as input. - - [!code-xml[Classic WebData XmlValidatingReader.Name Example#2](~/snippets/xml/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/XML/source.xml#2)] - ]]> @@ -4167,23 +3773,6 @@ The following example reads an XML file and displays each node. When validating using schemas, you can avoid the expensive load process by providing an using the property. -## Examples - -The following example uses the `XmlResolver` property to specify the credentials necessary to access the networked DTD file. - - [!code-csharp[XmlValidatingReader.XmlResolver#1](~/snippets/csharp/System.Xml/XmlValidatingReader/XmlResolver/vrdr_resolver.cs#1)] - [!code-vb[XmlValidatingReader.XmlResolver#1](~/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.XmlResolver/VB/vrdr_resolver.vb#1)] - - The example uses the following files as input. - - `book5.xml` - - [!code-xml[XmlValidatingReader.XmlResolver#2](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.XmlResolver/XML/book5.xml#2)] - - `books.dtd` - - [!code-xml[XmlValidatingReader.XmlResolver#3](~/snippets/xml/VS_Snippets_Data/XmlValidatingReader.XmlResolver/XML/books.dtd#3)] - ]]> diff --git a/xml/System/TimeZone.xml b/xml/System/TimeZone.xml index 43589ec2355..55e1d8cbf57 100644 --- a/xml/System/TimeZone.xml +++ b/xml/System/TimeZone.xml @@ -73,18 +73,12 @@ A time zone is a geographical region in which the same standard time is used. > [!IMPORTANT] -> Whenever possible, use the class instead of the class. +> Whenever possible, use the class instead of the class. You can use the class to retrieve information about the current time zone, and to convert times from local time to Coordinated Universal Time (UTC) or vice versa. However, you cannot use the class to represent time zones other than the local zone or to handle date and time conversions from one time zone to another. For this purpose, use the class. You can use this class to retrieve information on any time zone defined on the local system, to create custom time zones, and to convert times from one time zone to another. The class supports only a single daylight saving time adjustment rule for the local time zone. As a result, the class can accurately report daylight saving time information or convert between UTC and local time only for the period in which the latest adjustment rule is in effect. In contrast, the class supports multiple adjustment rules, which makes it possible to work with historic time zone data. -## Examples - The following example references and displays selected `TimeZone` class elements. - - :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - ]]> @@ -176,14 +170,6 @@ ## Remarks The property corresponds to the property. Whenever possible, use the property. - - -## Examples - The following example references the `CurrentTimeZone` property and displays the names for standard time and daylight saving time for the local time zone. - - :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - ]]> @@ -238,14 +224,6 @@ The property corresponds to the property. Whenever possible, use the property. - - -## Examples - The following example references and displays the `DaylightName` property of the current time zone. - - :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - ]]> @@ -545,14 +523,6 @@ ## Remarks The property corresponds to the property. Whenever possible, use the property. - - -## Examples - The following example references and displays the `StandardName` property of the current time zone. - - :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - ]]> An attempt was made to set this property to . @@ -624,11 +594,6 @@ Although it is not required, in most cases derived classes running under .NET Framework version 2.0 or later should override the default implementation of this method. The behavior of the default implementation depends on the property of the parameter. If its value is , this method returns unchanged. If its value is either or , this method assumes is UTC and converts it to the local system time without calling the method. - - The following code provides a simple override of the default implementation of the method. In this code, the variable represents a private instance of the class: - - :::code language="csharp" source="~/snippets/csharp/System/TimeZone/ToLocalTime/TimeZone_ToLocalTime.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.ToLocalTime/VB/TimeZone_ToLocalTime.vb" id="Snippet1"::: From 4d973cb3e7ee0017619673f862725728e0898a8c Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 23 Jun 2025 09:51:28 +0200 Subject: [PATCH 2/8] delete orphaned C# snippets --- .../cpp/sample.cpp | 86 ---- .../CPP/modulebuilder_definedocument.cpp | 49 --- .../UnmanagedMarshalObsolete/cpp/source.cpp | 63 --- .../CPP/source.cpp | 23 -- .../classic ArrayList Example/CPP/source.cpp | 44 --- .../CPP/source.cpp | 60 --- .../CPP/source.cpp | 58 --- .../CPP/source2.cpp | 67 ---- .../CPP/source.cpp | 86 ---- .../CPP/source.cpp | 68 ---- .../CPP/source.cpp | 70 ---- .../CPP/source.cpp | 76 ---- .../CPP/source.cpp | 91 ----- .../CPP/source.cpp | 127 ------ .../CPP/source.cpp | 31 -- .../CPP/source2.cpp | 35 -- .../CPP/source.cpp | 76 ---- .../CPP/source.cpp | 91 ----- .../CPP/source.cpp | 71 ---- .../CPP/source.cpp | 55 --- .../CPP/source.cpp | 70 ---- .../CPP/source.cpp | 71 ---- .../CPP/source.cpp | 61 --- .../CPP/source.cpp | 70 ---- .../classic BitArray Example/CPP/source.cpp | 119 ------ .../classic BitArray Example/CPP/source2.cpp | 37 -- .../CPP/source.cpp | 98 ----- .../CPP/source.cpp | 104 ----- .../CPP/source.cpp | 78 ---- .../CPP/source.cpp | 70 ---- .../CPP/source.cpp | 98 ----- .../CPP/source.cpp | 99 ----- .../CPP/remarks.cpp | 30 -- .../CPP/source.cpp | 36 -- .../CPP/source.cpp | 36 -- .../CPP/source.cpp | 109 ----- .../classic Debug Example/CPP/source.cpp | 24 -- .../CPP/source.cpp | 22 -- .../CPP/source.cpp | 20 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 29 -- .../classic Debug.Fail Example/CPP/source.cpp | 57 --- .../CPP/source.cpp | 59 --- .../CPP/source.cpp | 17 - .../CPP/source.cpp | 17 - .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 27 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 33 -- .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 25 -- .../CPP/source.cpp | 12 - .../CPP/source.cpp | 25 -- .../CPP/source.cpp | 25 -- .../CPP/source.cpp | 18 - .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 33 -- .../CPP/source.cpp | 33 -- .../CPP/source.cpp | 35 -- .../CPP/source.cpp | 20 - .../CPP/source.cpp | 39 -- .../CPP/source.cpp | 37 -- .../CPP/source.cpp | 36 -- .../CPP/source.cpp | 31 -- .../CPP/source.cpp | 22 -- .../CPP/source.cpp | 20 - .../CPP/source.cpp | 21 - .../CPP/source.cpp | 29 -- .../CPP/source.cpp | 29 -- .../CPP/source.cpp | 24 -- .../CPP/source.cpp | 18 - .../CPP/source.cpp | 16 - .../CPP/source.cpp | 22 -- .../classic FileAccess Example/CPP/source.cpp | 13 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 13 - .../CPP/source.cpp | 33 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 25 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 27 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 26 -- .../CPP/source.cpp | 22 -- .../classic Hashtable Example/CPP/source2.cpp | 76 ---- .../CPP/source.cpp | 44 --- .../CPP/source.cpp | 65 --- .../CPP/source.cpp | 65 --- .../CPP/source.cpp | 63 --- .../CPP/remarks.cpp | 40 -- .../CPP/source.cpp | 33 -- .../CPP/source.cpp | 70 ---- .../CPP/source.cpp | 91 ----- .../CPP/source.cpp | 44 --- .../CPP/source.cpp | 34 -- .../classic Queue Example/CPP/source.cpp | 41 -- .../CPP/source.cpp | 56 --- .../CPP/source.cpp | 69 ---- .../CPP/source.cpp | 66 ---- .../CPP/source.cpp | 32 -- .../CPP/source2.cpp | 35 -- .../CPP/source.cpp | 23 -- .../CPP/source.cpp | 22 -- .../CPP/source.cpp | 20 - .../classic SHA256 Example/CPP/source.cpp | 76 ---- .../classic SHA384 Example/CPP/source.cpp | 23 -- .../CPP/source.cpp | 24 -- .../classic SHA512 Example/CPP/source.cpp | 23 -- .../CPP/source.cpp | 24 -- .../CPP/remarks.cpp | 27 -- .../classic SortedList Example/CPP/source.cpp | 53 --- .../CPP/source.cpp | 44 --- .../CPP/source.cpp | 106 ----- .../CPP/source.cpp | 63 --- .../CPP/source.cpp | 59 --- .../CPP/source.cpp | 54 --- .../CPP/source.cpp | 57 --- .../CPP/source.cpp | 33 -- .../CPP/source2.cpp | 35 -- .../CPP/source.cpp | 89 ----- .../CPP/source.cpp | 62 --- .../classic Stack Example/CPP/source.cpp | 41 -- .../CPP/source.cpp | 55 --- .../CPP/source.cpp | 68 ---- .../CPP/source.cpp | 32 -- .../CPP/source2.cpp | 35 -- .../classic Stack.Peek Example/CPP/source.cpp | 65 --- .../CPP/source.cpp | 22 -- .../CPP/source.cpp | 44 --- .../CPP/source.cpp | 13 - .../classic Switch Example/CPP/remarks.cpp | 30 -- .../classic Switch Example/CPP/source.cpp | 127 ------ .../CPP/source.cpp | 27 -- .../CPP/source.cpp | 35 -- .../CPP/source.cpp | 24 -- .../CPP/source.cpp | 24 -- .../CPP/source.cpp | 18 - .../classic Trace Example/CPP/source.cpp | 23 -- .../CPP/source.cpp | 27 -- .../CPP/source.cpp | 24 -- .../CPP/source.cpp | 24 -- .../classic Trace.Fail Example/CPP/source.cpp | 56 --- .../CPP/source.cpp | 68 ---- .../CPP/source.cpp | 30 -- .../CPP/source.cpp | 25 -- .../CPP/source.cpp | 18 - .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 34 -- .../CPP/source.cpp | 34 -- .../CPP/source.cpp | 33 -- .../CPP/source.cpp | 29 -- .../CPP/source.cpp | 29 -- .../CPP/source.cpp | 30 -- .../CPP/source.cpp | 28 -- .../CPP/source.cpp | 34 -- .../CPP/source.cpp | 34 -- .../CPP/source.cpp | 34 -- .../CPP/source.cpp | 28 -- .../CPP/source.cpp | 29 -- .../CPP/source.cpp | 30 -- .../CPP/source.cpp | 24 -- .../CPP/source.cpp | 42 -- .../CPP/remarks.cpp | 33 -- .../CPP/source.cpp | 42 -- .../CPP/source.cpp | 42 -- .../CPP/source.cpp | 42 -- .../FxCop.Reliability.ReliabilityContract.cpp | 11 - .../CPP/source.cpp | 42 -- .../CPP/source.cpp | 41 -- ...ateclient_socketpermission_constructor.cpp | 168 -------- .../CPP/dateclient_socketpermission_toxml.cpp | 193 --------- .../NclMailPerms/CPP/mailpermissions.cpp | 98 ----- .../CPP/NclNetworkInfoPerms.cpp | 48 --- .../SocketPermissionExample/CPP/source.cpp | 122 ------ .../CPP/source.cpp | 52 --- .../webpermissionattribute_acceptconnect.cpp | 46 --- .../CPP/source.cpp | 54 --- .../CPP/source.cpp | 50 --- .../CPP/source.cpp | 51 --- .../CPP/source.cpp | 47 --- .../CPP/webpermission_acceptconnectlist.cpp | 99 ----- .../CPP/webpermission_constructor4.cpp | 80 ---- .../CPP/webpermission_copy.cpp | 91 ----- .../CPP/webpermission_fromtoxml.cpp | 76 ---- .../CPP/webpermission_intersect.cpp | 104 ----- .../CPP/webpermission_issubset.cpp | 109 ----- .../WebPermission_IsSubset2/CPP/source.cpp | 41 -- .../WebPermission_Regex/CPP/regex.cpp | 50 --- .../CPP/webpermission_union.cpp | 92 ----- .../BookInfoContractToViewHostAdapter.cs | 51 --- .../ToIListContractT/BookInfoHostAdapter.cs | 33 -- .../BookInfoViewToContractHostAdapter.cs | 48 --- .../ToIListT/BookInfoAddInAdapter.cs | 35 -- .../BookInfoContractToViewAddInAdapter.cs | 51 --- .../BookInfoViewToContractAddInAdapter.cs | 47 --- .../ToIListT/LibraryManagerAddInAdapter.cs | 47 --- .../CodeCompileUnit/Overview/source2.cs | 50 --- .../CodeCompileUnit/Overview/source3.cs | 111 ------ .../.ctor/MyAssembly_Install.cs | 20 - .../.ctor/MyAssembly_Uninstall.cs | 20 - .../AddRange/MyAssembly1.cs | 48 --- .../AddRange/MyAssembly11.cs | 48 --- .../AddRange/MyAssembly2.cs | 48 --- .../AddRange/MyAssembly21.cs | 48 --- .../Contains/MyAssembly1.cs | 48 --- .../Contains/MyAssembly2.cs | 48 --- .../InstallerCollection/CopyTo/MyAssembly1.cs | 48 --- .../InstallerCollection/CopyTo/MyAssembly2.cs | 48 --- .../InstallerCollection/Item/MyAssembly1.cs | 48 --- .../InstallerCollection/Item/MyAssembly2.cs | 48 --- .../Overview/MyAssembly1.cs | 48 --- .../Overview/MyAssembly2.cs | 48 --- .../AssociationAttribute/Overview/Program.cs | 20 - .../ColumnAttribute/AutoSync/Program.cs | 14 - .../countercreationdatacollection_ctor1.cs | 62 --- ...datacollection_ctor_countercreationdata.cs | 62 --- .../Overview/averagetimer32.cs | 373 ------------------ .../Overview/numberofitems32.cs | 137 ------- .../Overview/numberofitems64.cs | 136 ------- .../Overview/program.cs | 155 -------- .../Overview/rateofcountspersecond32.cs | 159 -------- .../Overview/rateofcountspersecond64.cs | 158 -------- .../Overview/rawfraction.cs | 171 -------- .../CompareInfo/IndexOf/ignorable10.cs | 63 --- .../CompareInfo/IndexOf/ignorable12.cs | 127 ------ .../CompareInfo/IndexOf/ignorable6.cs | 63 --- .../CompareInfo/IndexOf/ignorable9.cs | 116 ------ .../LastIndexOf/lastignorable10.cs | 63 --- .../LastIndexOf/lastignorable12.cs | 127 ------ .../CompareInfo/LastIndexOf/lastignorable9.cs | 116 ------ .../IdnMapping/GetHashCode/conversion1a.cs | 72 ---- .../ZipFile/CreateFromDirectory/program3.cs | 19 - .../System.IO/FileStream/Overview/example2.cs | 40 -- .../StreamReader/Overview/source2.cs | 32 -- .../StreamReader/Overview/source3.cs | 32 -- .../.ctor/dnspermission_constructor.cs | 58 --- .../DnsPermission/Copy/dnspermission_copy.cs | 58 --- .../FromXml/dnspermission_fromxml.cs | 85 ---- .../dnspermission_union_intersect.cs | 83 ---- .../IsSubsetOf/dnspermission_issubsetof.cs | 69 ---- .../dnspermission_isunrestricted.cs | 59 --- .../GlobalProxySelection/Overview/source.cs | 15 - ...dateclient_socketpermission_constructor.cs | 157 -------- .../dateclient_socketpermission_toxml.cs | 186 --------- .../SocketPermission/Overview/source.cs | 117 ------ .../.ctor/webpermission_constructor4.cs | 73 ---- .../WebPermission/.ctor/webpermission_copy.cs | 84 ---- .../.ctor/webpermission_union.cs | 88 ----- .../webpermission_acceptconnectlist.cs | 93 ----- .../AddPermission/webpermission_intersect.cs | 97 ----- .../AddPermission/webpermission_issubset.cs | 103 ----- .../FromXml/webpermission_fromtoxml.cs | 71 ---- .../WebPermission/IsSubsetOf/source.cs | 42 -- .../WebPermission/Overview/regex.cs | 50 --- .../WebPermissionAttribute/Accept/source.cs | 49 --- .../AcceptPattern/source.cs | 47 --- .../WebPermissionAttribute/Connect/source.cs | 45 --- .../ConnectPattern/source.cs | 48 --- .../webpermissionattribute_acceptconnect.cs | 47 --- .../Overview/BigInteger_Examples.cs | 88 ----- .../Overview/ByteAndHex_Examples.cs | 154 -------- .../Overview/ByteAndHex_Examples2.cs | 45 --- .../Overview/Mutability_Examples.cs | 75 ---- .../Complex/Overview/create1.cs | 41 -- .../Complex/Overview/customfmt1.cs | 74 ---- .../System.Numerics/Complex/Overview/nan1.cs | 28 -- .../Complex/Overview/precision1.cs | 36 -- .../DefineUnmanagedResource/EmittedTest2.cs | 27 -- .../DefineUnmanagedResource/EmittedTest3.cs | 28 -- .../System.Reflection/Assembly/Load/load2.cs | 21 - .../Overview/source2.cs | 27 -- .../AssemblyName/Flags/keyfileattrib.cs | 18 - .../CustomAttributeData/Overview/source2.cs | 32 -- .../MemberInfo/DeclaringType/source.cs | 65 --- .../Overview/showtime.cs | 17 - .../Overview/example.cs | 31 -- .../Overview/example1.cs | 6 - .../Overview/example2.cs | 6 - .../ResXResourceWriter/Overview/enumerate1.cs | 82 ---- .../ResXResourceWriter/Overview/retrieve1.cs | 98 ----- .../ResourceManager/Overview/ctor1.cs | 31 -- .../ResourceManager/Overview/example.cs | 38 -- .../ResourceManager/Overview/example3.cs | 44 --- .../ResourceManager/Overview/getstring.cs | 45 --- .../ResourceManager/Overview/rmc.cs | 69 ---- .../Overview/multiple1.cs | 23 -- .../Overview/multiple2.cs | 26 -- .../ICustomMarshaler/Overview/source.cs | 65 --- .../IpcClientChannel/.ctor/Common.cs | 14 - .../IpcClientChannel/.ctor/Server.cs | 27 -- ...vatedServiceTypeEntry_ObjectType_Client.cs | 30 -- ...ivatedServiceTypeEntry_ObjectType_Share.cs | 14 - ...n_IsRemotelyActivatedClientType1_Server.cs | 15 - ...n_IsRemotelyActivatedClientType1_Shared.cs | 14 - ...n_IsRemotelyActivatedClientType2_Server.cs | 15 - ...n_IsRemotelyActivatedClientType2_Shared.cs | 17 - ...iguration_IsWellKnownClientType1_Server.cs | 16 - ...iguration_IsWellKnownClientType1_Shared.cs | 14 - ...iguration_IsWellKnownClientType2_Server.cs | 16 - ...iguration_IsWellKnownClientType2_Shared.cs | 16 - .../Overview/nameidpermission.cs | 216 ---------- .../Overview/CreationEndpointElement.cs | 55 --- .../Overview/Program.cs | 67 ---- .../Description/simpleservice.cs | 274 ------------- ...tem.Text.RegularExpressions.Regex.Split.cs | 37 -- .../Regex/Split/split10.cs | 31 -- .../Regex/Split/split3.cs | 31 -- .../Regex/Split/split7.cs | 36 -- .../Encoding/GetString/getstring.cs | 88 ----- .../Encoding/Overview/getencoding1.cs | 91 ----- .../StringBuilder/Append/Append1.cs | 25 -- .../StringBuilder/Overview/call1.cs | 19 - .../StringBuilder/Overview/call2.cs | 17 - .../StringBuilder/Overview/chars1.cs | 44 --- .../StringBuilder/Overview/default1.cs | 43 -- .../StringBuilder/Overview/delete1.cs | 42 -- .../StringBuilder/Overview/expand1.cs | 48 --- .../StringBuilder/Overview/immutability2.cs | 21 - .../StringBuilder/Overview/instantiate1.cs | 47 --- .../StringBuilder/Overview/pattern1.cs | 63 --- .../StringBuilder/Overview/pattern2.cs | 43 -- .../StringBuilder/Overview/pattern3.cs | 44 --- .../StringBuilder/Overview/pattern4.cs | 40 -- .../StringBuilder/Overview/perf1.cs | 83 ---- .../StringBuilder/Overview/replace1.cs | 16 - .../csharp/System/Action/Overview/Delegate.cs | 36 -- .../System/AppContext/Overview/Example4.cs | 38 -- .../System/AppContext/Overview/Example6.cs | 38 -- .../System/AppContext/Overview/Example8.cs | 42 -- .../AppContext/Overview/ForConsumers1.cs | 21 - .../AppContext/Overview/GetSwitches3.cs | 55 --- .../Overview/AsyncDelegateWithStateObject.cs | 160 -------- .../AsyncCallback/Overview/Async_EndBlock.cs | 61 --- .../Overview/Async_EndBlockWait.cs | 63 --- .../AsyncCallback/Overview/Async_Poll.cs | 74 ---- .../AsyncCallback/Overview/Factorizer.cs | 140 ------- .../Attribute/GetCustomAttributes/ca3.cs | 46 --- .../csharp/System/Boolean/Overview/binary1.cs | 35 -- .../System/Boolean/Overview/conversion1.cs | 32 -- .../System/Boolean/Overview/conversion3.cs | 32 -- .../csharp/System/Boolean/Overview/format3.cs | 73 ---- .../System/Boolean/Overview/operations1.cs | 92 ----- .../System/Boolean/Overview/operations2.cs | 24 -- .../csharp/System/Boolean/Overview/parse2.cs | 66 ---- .../csharp/System/Boolean/Overview/parse3.cs | 29 -- .../csharp/System/Boolean/Overview/size1.cs | 38 -- .../System/Boolean/Overview/tostring1.cs | 18 - .../System/Boolean/Overview/tostring2.cs | 20 - .../csharp/System/Byte/Overview/bitwise1.cs | 25 -- .../csharp/System/Byte/Overview/bitwise2.cs | 52 --- .../Byte/Overview/byteinstantiation1.cs | 79 ---- .../System/Byte/Overview/formatting1.cs | 54 --- .../Char/Overview/GetUnicodeCategory3.cs | 72 ---- .../csharp/System/Char/Overview/grapheme1.cs | 18 - .../csharp/System/Char/Overview/normalized.cs | 29 -- .../csharp/System/Char/Overview/surrogate1.cs | 28 -- .../System/Char/Overview/textelements2.cs | 17 - .../System/Char/Overview/textelements2a.cs | 20 - .../System/Console/ReadLine/readline1.cs | 34 -- .../Convert/ChangeType/changetype_enum3.cs | 36 -- .../System/Convert/ToDouble/todecimal.cs | 103 ----- .../System/Convert/ToDouble/todouble2.cs | 56 --- .../System/Convert/ToDouble/tosingle.cs | 103 ----- .../System/Convert/ToString/datetime.cs | 84 ---- .../csharp/System/Convert/ToString/numeric.cs | 109 ----- .../System/Convert/ToString/tostring4.cs | 54 --- .../System/Double/Overview/comparison1.cs | 15 - .../System/Double/Overview/comparison2.cs | 21 - .../System/Double/Overview/comparison3.cs | 18 - .../System/Double/Overview/comparison4.cs | 42 -- .../csharp/System/Double/Overview/convert1.cs | 48 --- .../csharp/System/Double/Overview/convert2.cs | 147 ------- .../System/Double/Overview/exceptional1.cs | 18 - .../System/Double/Overview/exceptional2.cs | 31 -- .../System/Double/Overview/precision1.cs | 28 -- .../System/Double/Overview/precisionlist1.cs | 17 - .../System/Double/Overview/precisionlist3.cs | 27 -- .../System/Double/Overview/precisionlist4.cs | 35 -- .../System/Double/Overview/precisionlist5.cs | 33 -- .../System/Double/Overview/representation1.cs | 21 - .../System/Double/Overview/representation2.cs | 16 - .../csharp/System/Enum/Overview/EnumMain.cs | 32 -- .../csharp/System/Enum/Overview/Extensions.cs | 41 -- .../csharp/System/Enum/Overview/class1.cs | 18 - .../csharp/System/Enum/Overview/class2.cs | 35 -- .../System/Enum/Overview/classbitwise1.cs | 59 --- .../System/Enum/Overview/classconversion1.cs | 29 -- .../System/Enum/Overview/classconversion2.cs | 17 - .../System/Enum/Overview/classformat1.cs | 22 -- .../System/Enum/Overview/classiterate.cs | 49 --- .../System/Enum/Overview/classparse1.cs | 39 -- .../setenvironmentvariable1.cs | 40 -- .../Overview/FormatExample1.cs | 108 ----- .../Overview/formatexample3.cs | 100 ----- .../FormattableString/Format/Escaping1.cs | 16 - .../FormattableString/Format/alignment1.cs | 28 -- .../System/FormattableString/Format/index1.cs | 26 -- snippets/csharp/System/Guid/Parse/program.cs | 28 -- .../System/IAsyncResult/Overview/EndInvoke.cs | 44 --- .../Overview/empty1.cs | 24 -- .../System/Int32/Overview/Formatting1.cs | 55 --- .../System/Int32/Overview/Instantiate1.cs | 105 ----- snippets/csharp/System/Int32/Parse/parse4.cs | 47 --- .../System/Int64/Overview/formatting1.cs | 63 --- .../System/Int64/Overview/instantiate1.cs | 107 ----- .../Overview/Interface1.cs | 20 - .../Overview/ToString1.cs | 13 - .../Overview/ToString2.cs | 15 - .../Overview/basetoderived1.cs | 66 ---- .../Overview/iconvertible1.cs | 30 -- .../Overview/Enumerable1.cs | 19 - .../Overview/Enumerable2.cs | 22 -- .../Overview/Enumerable3.cs | 22 -- .../Overview/Enumerable4.cs | 22 -- .../Overview/Enumerable5.cs | 22 -- .../Overview/Enumerable6.cs | 26 -- .../Overview/Iterating1.cs | 28 -- .../Overview/Iterating2.cs | 42 -- .../Overview/Iterating3.cs | 30 -- .../Overview/List_Sort1.cs | 42 -- .../Overview/List_Sort2.cs | 39 -- .../Overview/List_Sort3.cs | 42 -- .../Overview/List_Sort4.cs | 39 -- .../Overview/Nullable1.cs | 25 -- .../Overview/Nullable2.cs | 27 -- .../Overview/Consumer1.cs | 19 - .../Overview/LibraryV1.cs | 14 - .../Overview/LibraryV2.cs | 14 - .../Overview/BadState1.cs | 38 -- .../Overview/BadState2.cs | 24 -- .../Overview/TestProp1.cs | 58 --- .../Overview/TestProp2.cs | 52 --- .../System/PredicateT/Overview/source.cs | 48 --- snippets/csharp/System/SByte/Parse/parse.cs | 149 ------- .../csharp/System/SByte/Parse/parseex4.cs | 70 ---- .../csharp/System/SByte/ToString/tostring.cs | 77 ---- .../System/Single/Overview/PrecisionList5a.cs | 33 -- .../System/Single/Overview/comparison1.cs | 15 - .../System/Single/Overview/comparison2.cs | 21 - .../System/Single/Overview/comparison3.cs | 18 - .../System/Single/Overview/comparison4.cs | 42 -- .../csharp/System/Single/Overview/convert1.cs | 49 --- .../csharp/System/Single/Overview/convert2.cs | 143 ------- .../System/Single/Overview/exceptional1.cs | 18 - .../System/Single/Overview/exceptional2.cs | 31 -- .../System/Single/Overview/precisionlist1.cs | 17 - .../System/Single/Overview/precisionlist3.cs | 27 -- .../System/Single/Overview/precisionlist4.cs | 35 -- .../System/Single/Overview/precisionlist4a.cs | 35 -- .../System/Single/Overview/precisionlist5.cs | 33 -- .../System/Single/Overview/representation1.cs | 21 - .../System/Single/Overview/representation2.cs | 15 - snippets/csharp/System/Single/Parse/parse.cs | 156 -------- .../System/String/IndexOf/ignorable1.cs | 32 -- .../System/String/IndexOf/ignorable10.cs | 60 --- .../System/String/IndexOf/ignorable12.cs | 124 ------ .../System/String/IndexOf/ignorable5.cs | 53 --- .../System/String/IndexOf/ignorable6.cs | 60 --- .../System/String/IndexOf/ignorable9.cs | 113 ------ .../String/LastIndexOf/lastignorable1.cs | 31 -- .../String/LastIndexOf/lastignorable10.cs | 60 --- .../String/LastIndexOf/lastignorable12.cs | 124 ------ .../String/LastIndexOf/lastignorable5.cs | 52 --- .../String/LastIndexOf/lastignorable6.cs | 60 --- .../String/LastIndexOf/lastignorable9.cs | 113 ------ .../System/TimeSpan/Overview/instantiate1.cs | 74 ---- .../System/TimeSpan/Overview/legacycode1.cs | 49 --- .../System/TimeSpan/Overview/perappdomain1.cs | 15 - .../System/TimeSpan/Overview/showtimespan.cs | 16 - .../csharp/System/TimeSpan/Overview/zero1.cs | 31 -- .../System/TimeSpan/ToString/ToString2.cs | 55 --- .../csharp/System/Type/FullName/remarks.cs | 11 - .../System/Type/GetType/yourassembly.cs | 7 - .../csharp/System/Type/Overview/Equals1.cs | 30 -- .../csharp/System/Type/Overview/GetType1.cs | 21 - .../Overview/Missing1.cs | 48 --- .../Overview/Missing1a.cs | 24 -- .../Overview/Regex1.cs | 30 -- .../Overview/ctorException1.cs | 33 -- .../csharp/System/UInt16/Parse/parseex1.cs | 79 ---- .../System/UInt16/TryParse/tryparse1.cs | 35 -- .../Version/Overview/GettingVersions1.cs | 71 ---- .../System/Version/Overview/clickonce.cs | 13 - .../System/Version/Overview/comparisons1.cs | 33 -- .../System/Version/Overview/comparisons2.cs | 27 -- .../System/Version/Overview/currentapp.cs | 16 - .../System/Version/Overview/currentassem.cs | 16 - .../System/Version/Overview/specificassem.cs | 17 - 515 files changed, 25369 deletions(-) delete mode 100644 snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs delete mode 100644 snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs delete mode 100644 snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs delete mode 100644 snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs delete mode 100644 snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs delete mode 100644 snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs delete mode 100644 snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs delete mode 100644 snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs delete mode 100644 snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs delete mode 100644 snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs delete mode 100644 snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs delete mode 100644 snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs delete mode 100644 snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs delete mode 100644 snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs delete mode 100644 snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs delete mode 100644 snippets/csharp/System.IO/FileStream/Overview/example2.cs delete mode 100644 snippets/csharp/System.IO/StreamReader/Overview/source2.cs delete mode 100644 snippets/csharp/System.IO/StreamReader/Overview/source3.cs delete mode 100644 snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs delete mode 100644 snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs delete mode 100644 snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs delete mode 100644 snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs delete mode 100644 snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs delete mode 100644 snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs delete mode 100644 snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs delete mode 100644 snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs delete mode 100644 snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs delete mode 100644 snippets/csharp/System.Net/SocketPermission/Overview/source.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs delete mode 100644 snippets/csharp/System.Net/WebPermission/Overview/regex.cs delete mode 100644 snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs delete mode 100644 snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs delete mode 100644 snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs delete mode 100644 snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs delete mode 100644 snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs delete mode 100644 snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs delete mode 100644 snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs delete mode 100644 snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs delete mode 100644 snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs delete mode 100644 snippets/csharp/System.Numerics/Complex/Overview/create1.cs delete mode 100644 snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs delete mode 100644 snippets/csharp/System.Numerics/Complex/Overview/nan1.cs delete mode 100644 snippets/csharp/System.Numerics/Complex/Overview/precision1.cs delete mode 100644 snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs delete mode 100644 snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs delete mode 100644 snippets/csharp/System.Reflection/Assembly/Load/load2.cs delete mode 100644 snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs delete mode 100644 snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs delete mode 100644 snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs delete mode 100644 snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs delete mode 100644 snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs delete mode 100644 snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs delete mode 100644 snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs delete mode 100644 snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs delete mode 100644 snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs delete mode 100644 snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs delete mode 100644 snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs delete mode 100644 snippets/csharp/System.Resources/ResourceManager/Overview/example.cs delete mode 100644 snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs delete mode 100644 snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs delete mode 100644 snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs delete mode 100644 snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs delete mode 100644 snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs delete mode 100644 snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs delete mode 100644 snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs delete mode 100644 snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs delete mode 100644 snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs delete mode 100644 snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs delete mode 100644 snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs delete mode 100644 snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs delete mode 100644 snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs delete mode 100644 snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs delete mode 100644 snippets/csharp/System.Text/Encoding/GetString/getstring.cs delete mode 100644 snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Append/Append1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/call1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/call2.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/default1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs delete mode 100644 snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs delete mode 100644 snippets/csharp/System/Action/Overview/Delegate.cs delete mode 100644 snippets/csharp/System/AppContext/Overview/Example4.cs delete mode 100644 snippets/csharp/System/AppContext/Overview/Example6.cs delete mode 100644 snippets/csharp/System/AppContext/Overview/Example8.cs delete mode 100644 snippets/csharp/System/AppContext/Overview/ForConsumers1.cs delete mode 100644 snippets/csharp/System/AppContext/Overview/GetSwitches3.cs delete mode 100644 snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs delete mode 100644 snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs delete mode 100644 snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs delete mode 100644 snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs delete mode 100644 snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs delete mode 100644 snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/binary1.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/conversion1.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/conversion3.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/format3.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/operations1.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/operations2.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/parse2.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/parse3.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/size1.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/tostring1.cs delete mode 100644 snippets/csharp/System/Boolean/Overview/tostring2.cs delete mode 100644 snippets/csharp/System/Byte/Overview/bitwise1.cs delete mode 100644 snippets/csharp/System/Byte/Overview/bitwise2.cs delete mode 100644 snippets/csharp/System/Byte/Overview/byteinstantiation1.cs delete mode 100644 snippets/csharp/System/Byte/Overview/formatting1.cs delete mode 100644 snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs delete mode 100644 snippets/csharp/System/Char/Overview/grapheme1.cs delete mode 100644 snippets/csharp/System/Char/Overview/normalized.cs delete mode 100644 snippets/csharp/System/Char/Overview/surrogate1.cs delete mode 100644 snippets/csharp/System/Char/Overview/textelements2.cs delete mode 100644 snippets/csharp/System/Char/Overview/textelements2a.cs delete mode 100644 snippets/csharp/System/Console/ReadLine/readline1.cs delete mode 100644 snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs delete mode 100644 snippets/csharp/System/Convert/ToDouble/todecimal.cs delete mode 100644 snippets/csharp/System/Convert/ToDouble/todouble2.cs delete mode 100644 snippets/csharp/System/Convert/ToDouble/tosingle.cs delete mode 100644 snippets/csharp/System/Convert/ToString/datetime.cs delete mode 100644 snippets/csharp/System/Convert/ToString/numeric.cs delete mode 100644 snippets/csharp/System/Convert/ToString/tostring4.cs delete mode 100644 snippets/csharp/System/Double/Overview/comparison1.cs delete mode 100644 snippets/csharp/System/Double/Overview/comparison2.cs delete mode 100644 snippets/csharp/System/Double/Overview/comparison3.cs delete mode 100644 snippets/csharp/System/Double/Overview/comparison4.cs delete mode 100644 snippets/csharp/System/Double/Overview/convert1.cs delete mode 100644 snippets/csharp/System/Double/Overview/convert2.cs delete mode 100644 snippets/csharp/System/Double/Overview/exceptional1.cs delete mode 100644 snippets/csharp/System/Double/Overview/exceptional2.cs delete mode 100644 snippets/csharp/System/Double/Overview/precision1.cs delete mode 100644 snippets/csharp/System/Double/Overview/precisionlist1.cs delete mode 100644 snippets/csharp/System/Double/Overview/precisionlist3.cs delete mode 100644 snippets/csharp/System/Double/Overview/precisionlist4.cs delete mode 100644 snippets/csharp/System/Double/Overview/precisionlist5.cs delete mode 100644 snippets/csharp/System/Double/Overview/representation1.cs delete mode 100644 snippets/csharp/System/Double/Overview/representation2.cs delete mode 100644 snippets/csharp/System/Enum/Overview/EnumMain.cs delete mode 100644 snippets/csharp/System/Enum/Overview/Extensions.cs delete mode 100644 snippets/csharp/System/Enum/Overview/class1.cs delete mode 100644 snippets/csharp/System/Enum/Overview/class2.cs delete mode 100644 snippets/csharp/System/Enum/Overview/classbitwise1.cs delete mode 100644 snippets/csharp/System/Enum/Overview/classconversion1.cs delete mode 100644 snippets/csharp/System/Enum/Overview/classconversion2.cs delete mode 100644 snippets/csharp/System/Enum/Overview/classformat1.cs delete mode 100644 snippets/csharp/System/Enum/Overview/classiterate.cs delete mode 100644 snippets/csharp/System/Enum/Overview/classparse1.cs delete mode 100644 snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs delete mode 100644 snippets/csharp/System/FormatException/Overview/FormatExample1.cs delete mode 100644 snippets/csharp/System/FormatException/Overview/formatexample3.cs delete mode 100644 snippets/csharp/System/FormattableString/Format/Escaping1.cs delete mode 100644 snippets/csharp/System/FormattableString/Format/alignment1.cs delete mode 100644 snippets/csharp/System/FormattableString/Format/index1.cs delete mode 100644 snippets/csharp/System/Guid/Parse/program.cs delete mode 100644 snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs delete mode 100644 snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs delete mode 100644 snippets/csharp/System/Int32/Overview/Formatting1.cs delete mode 100644 snippets/csharp/System/Int32/Overview/Instantiate1.cs delete mode 100644 snippets/csharp/System/Int32/Parse/parse4.cs delete mode 100644 snippets/csharp/System/Int64/Overview/formatting1.cs delete mode 100644 snippets/csharp/System/Int64/Overview/instantiate1.cs delete mode 100644 snippets/csharp/System/InvalidCastException/Overview/Interface1.cs delete mode 100644 snippets/csharp/System/InvalidCastException/Overview/ToString1.cs delete mode 100644 snippets/csharp/System/InvalidCastException/Overview/ToString2.cs delete mode 100644 snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs delete mode 100644 snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs delete mode 100644 snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs delete mode 100644 snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs delete mode 100644 snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs delete mode 100644 snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs delete mode 100644 snippets/csharp/System/NotSupportedException/Overview/BadState1.cs delete mode 100644 snippets/csharp/System/NotSupportedException/Overview/BadState2.cs delete mode 100644 snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs delete mode 100644 snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs delete mode 100644 snippets/csharp/System/PredicateT/Overview/source.cs delete mode 100644 snippets/csharp/System/SByte/Parse/parse.cs delete mode 100644 snippets/csharp/System/SByte/Parse/parseex4.cs delete mode 100644 snippets/csharp/System/SByte/ToString/tostring.cs delete mode 100644 snippets/csharp/System/Single/Overview/PrecisionList5a.cs delete mode 100644 snippets/csharp/System/Single/Overview/comparison1.cs delete mode 100644 snippets/csharp/System/Single/Overview/comparison2.cs delete mode 100644 snippets/csharp/System/Single/Overview/comparison3.cs delete mode 100644 snippets/csharp/System/Single/Overview/comparison4.cs delete mode 100644 snippets/csharp/System/Single/Overview/convert1.cs delete mode 100644 snippets/csharp/System/Single/Overview/convert2.cs delete mode 100644 snippets/csharp/System/Single/Overview/exceptional1.cs delete mode 100644 snippets/csharp/System/Single/Overview/exceptional2.cs delete mode 100644 snippets/csharp/System/Single/Overview/precisionlist1.cs delete mode 100644 snippets/csharp/System/Single/Overview/precisionlist3.cs delete mode 100644 snippets/csharp/System/Single/Overview/precisionlist4.cs delete mode 100644 snippets/csharp/System/Single/Overview/precisionlist4a.cs delete mode 100644 snippets/csharp/System/Single/Overview/precisionlist5.cs delete mode 100644 snippets/csharp/System/Single/Overview/representation1.cs delete mode 100644 snippets/csharp/System/Single/Overview/representation2.cs delete mode 100644 snippets/csharp/System/Single/Parse/parse.cs delete mode 100644 snippets/csharp/System/String/IndexOf/ignorable1.cs delete mode 100644 snippets/csharp/System/String/IndexOf/ignorable10.cs delete mode 100644 snippets/csharp/System/String/IndexOf/ignorable12.cs delete mode 100644 snippets/csharp/System/String/IndexOf/ignorable5.cs delete mode 100644 snippets/csharp/System/String/IndexOf/ignorable6.cs delete mode 100644 snippets/csharp/System/String/IndexOf/ignorable9.cs delete mode 100644 snippets/csharp/System/String/LastIndexOf/lastignorable1.cs delete mode 100644 snippets/csharp/System/String/LastIndexOf/lastignorable10.cs delete mode 100644 snippets/csharp/System/String/LastIndexOf/lastignorable12.cs delete mode 100644 snippets/csharp/System/String/LastIndexOf/lastignorable5.cs delete mode 100644 snippets/csharp/System/String/LastIndexOf/lastignorable6.cs delete mode 100644 snippets/csharp/System/String/LastIndexOf/lastignorable9.cs delete mode 100644 snippets/csharp/System/TimeSpan/Overview/instantiate1.cs delete mode 100644 snippets/csharp/System/TimeSpan/Overview/legacycode1.cs delete mode 100644 snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs delete mode 100644 snippets/csharp/System/TimeSpan/Overview/showtimespan.cs delete mode 100644 snippets/csharp/System/TimeSpan/Overview/zero1.cs delete mode 100644 snippets/csharp/System/TimeSpan/ToString/ToString2.cs delete mode 100644 snippets/csharp/System/Type/FullName/remarks.cs delete mode 100644 snippets/csharp/System/Type/GetType/yourassembly.cs delete mode 100644 snippets/csharp/System/Type/Overview/Equals1.cs delete mode 100644 snippets/csharp/System/Type/Overview/GetType1.cs delete mode 100644 snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs delete mode 100644 snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs delete mode 100644 snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs delete mode 100644 snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs delete mode 100644 snippets/csharp/System/UInt16/Parse/parseex1.cs delete mode 100644 snippets/csharp/System/UInt16/TryParse/tryparse1.cs delete mode 100644 snippets/csharp/System/Version/Overview/GettingVersions1.cs delete mode 100644 snippets/csharp/System/Version/Overview/clickonce.cs delete mode 100644 snippets/csharp/System/Version/Overview/comparisons1.cs delete mode 100644 snippets/csharp/System/Version/Overview/comparisons2.cs delete mode 100644 snippets/csharp/System/Version/Overview/currentapp.cs delete mode 100644 snippets/csharp/System/Version/Overview/currentassem.cs delete mode 100644 snippets/csharp/System/Version/Overview/specificassem.cs diff --git a/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp deleted file mode 100644 index aa305292301..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::AccessControl; - -// Adds an ACL entry on the specified directory for the -// specified account. -void AddDirectorySecurity(String^ directoryName, String^ account, - FileSystemRights rights, AccessControlType controlType) -{ - // Create a new DirectoryInfo object. - DirectoryInfo^ dInfo = gcnew DirectoryInfo(directoryName); - - // Get a DirectorySecurity object that represents the - // current security settings. - DirectorySecurity^ dSecurity = dInfo->GetAccessControl(); - - // Add the FileSystemAccessRule to the security settings. - dSecurity->AddAccessRule( gcnew FileSystemAccessRule(account, - rights, controlType)); - - // Set the new access settings. - dInfo->SetAccessControl(dSecurity); -} - -// Removes an ACL entry on the specified directory for the -// specified account. -void RemoveDirectorySecurity(String^ directoryName, String^ account, - FileSystemRights rights, AccessControlType controlType) -{ - // Create a new DirectoryInfo object. - DirectoryInfo^ dInfo = gcnew DirectoryInfo(directoryName); - - // Get a DirectorySecurity object that represents the - // current security settings. - DirectorySecurity^ dSecurity = dInfo->GetAccessControl(); - - // Add the FileSystemAccessRule to the security settings. - dSecurity->RemoveAccessRule(gcnew FileSystemAccessRule(account, - rights, controlType)); - - // Set the new access settings. - dInfo->SetAccessControl(dSecurity); -} - -int main() -{ - String^ directoryName = "TestDirectory"; - String^ accountName = "MYDOMAIN\\MyAccount"; - if (!Directory::Exists(directoryName)) - { - Console::WriteLine("The directory {0} could not be found.", - directoryName); - return 0; - } - try - { - Console::WriteLine("Adding access control entry for {0}", - directoryName); - - // Add the access control entry to the directory. - AddDirectorySecurity(directoryName, accountName, - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Removing access control entry from {0}", - directoryName); - - // Remove the access control entry from the directory. - RemoveDirectorySecurity(directoryName, accountName, - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Done."); - } - catch (UnauthorizedAccessException^) - { - Console::WriteLine("You are not authorised to carry" + - " out this procedure."); - } - catch (System::Security::Principal:: - IdentityNotMappedException^) - { - Console::WriteLine("The account {0} could not be found.", accountName); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp deleted file mode 100644 index d74a7ca473d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// System::Reflection::Emit::ModuleBuilder.DefineDocument -/* -The following example demonstrates the 'DefineDocument' method -of 'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. -It gets the Object* representing the defined document using the method -'DefineDocument'. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; -using namespace System::Diagnostics::SymbolStore; -public ref class CodeGenerator -{ -private: - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - CodeGenerator() - { - - // Get the current application domain for the current thread. - AppDomain^ currentDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define a dynamic assembly in the current domain. - myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Define a dynamic module in S"TempAssembly" assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule", "Resource.mod", true ); - - // Define a document for source.on 'TempModule' module. - ISymbolDocumentWriter^ myDocument = myModuleBuilder->DefineDocument( "RTAsm.il", SymDocumentType::Text, SymLanguageType::ILAssembly, SymLanguageVendor::Microsoft ); - Console::WriteLine( "The object representing the defined document is: {0}", myDocument ); - } - -}; - -int main() -{ - CodeGenerator^ myGenerator = gcnew CodeGenerator; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp deleted file mode 100644 index bf3e8e72213..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::InteropServices; - -void main() -{ - AppDomain^ myDomain = AppDomain::CurrentDomain; - AssemblyName^ myAsmName = gcnew AssemblyName("EmitMarshalAs"); - - AssemblyBuilder^ myAssembly = - myDomain->DefineDynamicAssembly(myAsmName, - AssemblyBuilderAccess::RunAndSave); - - ModuleBuilder^ myModule = - myAssembly->DefineDynamicModule(myAsmName->Name, - myAsmName->Name + ".dll"); - - TypeBuilder^ myType = - myModule->DefineType("Sample", TypeAttributes::Public); - - MethodBuilder^ myMethod = - myType->DefineMethod("Test", MethodAttributes::Public, - nullptr, gcnew array { String::typeid }); - - - // Get a parameter builder for the parameter that needs the - // attribute, using the HasFieldMarshal attribute. In this - // example, the parameter is at position 0 and has the name - // "arg". - ParameterBuilder^ pb = - myMethod->DefineParameter(0, - ParameterAttributes::HasFieldMarshal, "arg"); - - // Get the MarshalAsAttribute constructor that takes an - // argument of type UnmanagedType. - // - //Type^ maattrType = MarshalAsAttribute::typeid; - ConstructorInfo^ ci = - (MarshalAsAttribute::typeid)->GetConstructor( - gcnew array { UnmanagedType::typeid }); - - // Create a CustomAttributeBuilder representing the attribute, - // specifying the necessary unmanaged type. In this case, - // UnmanagedType.BStr is specified. - // - CustomAttributeBuilder^ cabuilder = - gcnew CustomAttributeBuilder( - ci, gcnew array { UnmanagedType::BStr }); - - // Apply the attribute to the parameter. - // - pb->SetCustomAttribute(cabuilder); - - - ILGenerator^ il = myMethod->GetILGenerator(); - il->Emit(OpCodes::Ret); - - Type^ finished = myType->CreateType(); - myAssembly->Save(myAsmName->Name + ".dll"); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp deleted file mode 100644 index 79226085d31..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: Form -{ -protected: - TextBox^ textBox1; - // - void GetComments() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - // Print the comments in a text box. - textBox1->Text = "Comments: " + myFileVersionInfo->Comments; - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp deleted file mode 100644 index 49678c8cdc2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "Hello" ); - myAL->Add( "World" ); - myAL->Add( "!" ); - - // Displays the properties and values of the ArrayList. - Console::WriteLine( "myAL" ); - Console::WriteLine( " Count: {0}", myAL->Count ); - Console::WriteLine( " Capacity: {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* -This code produces output similar to the following: - -myAL - Count: 3 - Capacity: 4 - Values: Hello World ! - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp deleted file mode 100644 index 2755de2cbe1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, char mySeparator ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - - // Creates and initializes a new Queue. - Queue^ myQueue = gcnew Queue; - myQueue->Enqueue( "jumps" ); - myQueue->Enqueue( "over" ); - myQueue->Enqueue( "the" ); - myQueue->Enqueue( "lazy" ); - myQueue->Enqueue( "dog" ); - - // Displays the ArrayList and the Queue. - Console::WriteLine( "The ArrayList initially contains the following:" ); - PrintValues( myAL, '\t' ); - Console::WriteLine( "The Queue initially contains the following:" ); - PrintValues( myQueue, '\t' ); - - // Copies the Queue elements to the end of the ArrayList. - myAL->AddRange( myQueue ); - - // Displays the ArrayList. - Console::WriteLine( "The ArrayList now contains the following:" ); - PrintValues( myAL, '\t' ); -} - -void PrintValues( IEnumerable^ myList, char mySeparator ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -The ArrayList initially contains the following: - The quick brown fox -The Queue initially contains the following: - jumps over the lazy dog -The ArrayList now contains the following: - The quick brown fox jumps over the lazy dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp deleted file mode 100644 index f7052b8c414..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void FindMyObject( ArrayList^ myList, Object^ myObject ); -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. BinarySearch requires - // a sorted ArrayList. - ArrayList^ myAL = gcnew ArrayList; - for ( int i = 0; i <= 4; i++ ) - myAL->Add( i * 2 ); - - // Displays the ArrayList. - Console::WriteLine( "The Int32 ArrayList contains the following:" ); - PrintValues( myAL ); - - // Locates a specific object that does not exist in the ArrayList. - Object^ myObjectOdd = 3; - FindMyObject( myAL, myObjectOdd ); - - // Locates an object that exists in the ArrayList. - Object^ myObjectEven = 6; - FindMyObject( myAL, myObjectEven ); -} - -void FindMyObject( ArrayList^ myList, Object^ myObject ) -{ - int myIndex = myList->BinarySearch( myObject ); - if ( myIndex < 0 ) - Console::WriteLine( "The object to search for ({0}) is not found. The next larger object is at index {1}.", myObject, ~myIndex ); - else - Console::WriteLine( "The object to search for ({0}) is at index {1}.", myObject, myIndex ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Int32 ArrayList contains the following: - 0 2 4 6 8 - The object to search for (3) is not found. The next larger object is at index 2. - The object to search for (6) is at index 3. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp deleted file mode 100644 index cd02a23fd6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public ref class SimpleStringComparer : public IComparer -{ - virtual int Compare(Object^ x, Object^ y) sealed = IComparer::Compare - { - String^ cmpstr = (String^)x; - return cmpstr->CompareTo((String^)y); - } -}; - -public ref class MyArrayList : public ArrayList -{ -public: - static void Main() - { - // Creates and initializes a new ArrayList. - MyArrayList^ coloredAnimals = gcnew MyArrayList(); - - coloredAnimals->Add("White Tiger"); - coloredAnimals->Add("Pink Bunny"); - coloredAnimals->Add("Red Dragon"); - coloredAnimals->Add("Green Frog"); - coloredAnimals->Add("Blue Whale"); - coloredAnimals->Add("Black Cat"); - coloredAnimals->Add("Yellow Lion"); - - // BinarySearch requires a sorted ArrayList. - coloredAnimals->Sort(); - - // Compare results of an iterative search with a binary search - int index = coloredAnimals->IterativeSearch("White Tiger"); - Console::WriteLine("Iterative search, item found at index: {0}", index); - - index = coloredAnimals->BinarySearch("White Tiger", gcnew SimpleStringComparer()); - Console::WriteLine("Binary search, item found at index: {0}", index); - } - - int IterativeSearch(Object^ finditem) - { - int index = -1; - - for (int i = 0; i < this->Count; i++) - { - if (finditem->Equals(this[i])) - { - index = i; - break; - } - } - return index; - } -}; - -int main() -{ - MyArrayList::Main(); -} -// -// This code produces the following output. -// -// Iterative search, item found at index: 5 -// Binary search, item found at index: 5 -// -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp deleted file mode 100644 index ecce0f77c76..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Trim the ArrayList. - myAL->TrimToSize(); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "After TrimToSize," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Clear the ArrayList. - myAL->Clear(); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Trim the ArrayList again. - myAL->TrimToSize(); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "After the second TrimToSize," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Capacity : 16 - Values: The quick brown fox jumps - After TrimToSize, - Count : 5 - Capacity : 5 - Values: The quick brown fox jumps - After Clear, - Count : 0 - Capacity : 5 - Values: - After the second TrimToSize, - Count : 0 - Capacity : 16 - Values: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 350784fe0ae..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^myArr, char mySeparator ); -int main() -{ - - // Creates and initializes the source ArrayList. - ArrayList^ mySourceList = gcnew ArrayList; - mySourceList->Add( "three" ); - mySourceList->Add( "napping" ); - mySourceList->Add( "cats" ); - mySourceList->Add( "in" ); - mySourceList->Add( "the" ); - mySourceList->Add( "barn" ); - - // Creates and initializes the one-dimensional target Array. - array^myTargetArray = gcnew array(15); - myTargetArray[ 0 ] = "The"; - myTargetArray[ 1 ] = "quick"; - myTargetArray[ 2 ] = "brown"; - myTargetArray[ 3 ] = "fox"; - myTargetArray[ 4 ] = "jumps"; - myTargetArray[ 5 ] = "over"; - myTargetArray[ 6 ] = "the"; - myTargetArray[ 7 ] = "lazy"; - myTargetArray[ 8 ] = "dog"; - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the second element from the source ArrayList to the target ArrayList starting at index 7. - mySourceList->CopyTo( 1, myTargetArray, 7, 1 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target ArrayList starting at index 6. - mySourceList->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target ArrayList starting at index 0. - mySourceList->CopyTo( myTargetArray ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^myArr, char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ] ); - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over the napping dog - The quick brown fox jumps over three napping cats in the barn - three napping cats in the barn three napping cats in the barn - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp deleted file mode 100644 index de10c82aaf7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^myArr, char mySeparator ); -int main() -{ - - // Creates and initializes the source ArrayList. - ArrayList^ mySourceList = gcnew ArrayList; - mySourceList->Add( "three" ); - mySourceList->Add( "napping" ); - mySourceList->Add( "cats" ); - mySourceList->Add( "in" ); - mySourceList->Add( "the" ); - mySourceList->Add( "barn" ); - - // Creates and initializes the one-dimensional target Array. - array^myTargetArray = gcnew array(15); - myTargetArray[ 0 ] = "The"; - myTargetArray[ 1 ] = "quick"; - myTargetArray[ 2 ] = "brown"; - myTargetArray[ 3 ] = "fox"; - myTargetArray[ 4 ] = "jumps"; - myTargetArray[ 5 ] = "over"; - myTargetArray[ 6 ] = "the"; - myTargetArray[ 7 ] = "lazy"; - myTargetArray[ 8 ] = "dog"; - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the second element from the source ArrayList to the target Array, starting at index 7. - mySourceList->CopyTo( 1, myTargetArray, 7, 1 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target Array, starting at index 6. - mySourceList->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target Array, starting at index 0. - mySourceList->CopyTo( myTargetArray ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^myArr, char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ] ); - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over the napping dog - The quick brown fox jumps over three napping cats in the barn - three napping cats in the barn three napping cats in the barn - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp deleted file mode 100644 index 2d45857cac0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList with three elements of the same value. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "the" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - myAL->Add( "in" ); - myAL->Add( "the" ); - myAL->Add( "barn" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Search for the first occurrence of the duplicated value. - String^ myString = "the"; - int myIndex = myAL->IndexOf( myString ); - Console::WriteLine( "The first occurrence of \"{0}\" is at index {1}.", myString, myIndex ); - - // Search for the first occurrence of the duplicated value in the last section of the ArrayList. - myIndex = myAL->IndexOf( myString, 4 ); - Console::WriteLine( "The first occurrence of \"{0}\" between index 4 and the end is at index {1}.", myString, myIndex ); - - // Search for the first occurrence of the duplicated value in a section of the ArrayList. - myIndex = myAL->IndexOf( myString, 6, 6 ); - Console::WriteLine( "The first occurrence of \"{0}\" between index 6 and index 11 is at index {1}.", myString, myIndex ); -} - -void PrintIndexAndValues( IEnumerable^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " [{0}]: {1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList contains the following values: - [0]: the - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - [9]: in - [10]: the - [11]: barn - - The first occurrence of "the" is at index 0. - The first occurrence of "the" between index 4 and the end is at index 6. - The first occurrence of "the" between index 6 and index 11 is at index 6. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp deleted file mode 100644 index f29a6c01426..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList using Insert instead of Add. - ArrayList^ myAL = gcnew ArrayList; - myAL->Insert( 0, "The" ); - myAL->Insert( 1, "fox" ); - myAL->Insert( 2, "jumps" ); - myAL->Insert( 3, "over" ); - myAL->Insert( 4, "the" ); - myAL->Insert( 5, "dog" ); - - // Creates and initializes a new Queue. - Queue^ myQueue = gcnew Queue; - myQueue->Enqueue( "quick" ); - myQueue->Enqueue( "brown" ); - - // Displays the ArrayList and the Queue. - Console::WriteLine( "The ArrayList initially contains the following:" ); - PrintValues( myAL ); - Console::WriteLine( "The Queue initially contains the following:" ); - PrintValues( myQueue ); - - // Copies the Queue elements to the ArrayList at index 1. - myAL->InsertRange( 1, myQueue ); - - // Displays the ArrayList. - Console::WriteLine( "After adding the Queue, the ArrayList now contains:" ); - PrintValues( myAL ); - - // Search for "dog" and add "lazy" before it. - myAL->Insert( myAL->IndexOf( "dog" ), "lazy" ); - - // Displays the ArrayList. - Console::WriteLine( "After adding \"lazy\", the ArrayList now contains:" ); - PrintValues( myAL ); - - // Add "!!!" at the end. - myAL->Insert( myAL->Count, "!!!" ); - - // Displays the ArrayList. - Console::WriteLine( "After adding \"!!!\", the ArrayList now contains:" ); - PrintValues( myAL ); - - // Inserting an element beyond Count throws an exception. - try - { - myAL->Insert( myAL->Count + 1, "anystring" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following: - The fox jumps over the dog - The Queue initially contains the following: - quick brown - After adding the Queue, the ArrayList now contains: - The quick brown fox jumps over the dog - After adding "lazy", the ArrayList now contains: - The quick brown fox jumps over the lazy dog - After adding "!!!", the ArrayList now contains: - The quick brown fox jumps over the lazy dog !!! - Exception: System.ArgumentOutOfRangeException: Insertion index was out of range. Must be non-negative and less than or equal to size. - Parameter name: index - at System.Collections.ArrayList.Insert(Int32 index, Object value) - at SamplesArrayList.Main() - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp deleted file mode 100644 index e5271eb3ea7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp +++ /dev/null @@ -1,127 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, char mySeparator ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Create a fixed-size wrapper around the ArrayList. - ArrayList^ myFixedSizeAL = ArrayList::FixedSize( myAL ); - - // Display whether the ArrayLists have a fixed size or not. - Console::WriteLine( "myAL {0}.", myAL->IsFixedSize ? (String^)"has a fixed size" : "does not have a fixed size" ); - Console::WriteLine( "myFixedSizeAL {0}.", myFixedSizeAL->IsFixedSize ? (String^)"has a fixed size" : "does not have a fixed size" ); - Console::WriteLine(); - - // Display both ArrayLists. - Console::WriteLine( "Initially," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - - // Sort is allowed in the fixed-size ArrayList. - myFixedSizeAL->Sort(); - - // Display both ArrayLists. - Console::WriteLine( "After Sort," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - - // Reverse is allowed in the fixed-size ArrayList. - myFixedSizeAL->Reverse(); - - // Display both ArrayLists. - Console::WriteLine( "After Reverse," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - - // Add an element to the standard ArrayList. - myAL->Add( "AddMe" ); - - // Display both ArrayLists. - Console::WriteLine( "After adding to the standard ArrayList," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - Console::WriteLine(); - - // Adding or inserting elements to the fixed-size ArrayList throws an exception. - try - { - myFixedSizeAL->Add( "AddMe2" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - - try - { - myFixedSizeAL->Insert( 3, "InsertMe" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, char mySeparator ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myAL does not have a fixed size. - myFixedSizeAL has a fixed size. - - Initially, - Standard : The quick brown fox jumps over the lazy dog - Fixed size: The quick brown fox jumps over the lazy dog - After Sort, - Standard : brown dog fox jumps lazy over quick the The - Fixed size: brown dog fox jumps lazy over quick the The - After Reverse, - Standard : The the quick over lazy jumps fox dog brown - Fixed size: The the quick over lazy jumps fox dog brown - After adding to the standard ArrayList, - Standard : The the quick over lazy jumps fox dog brown AddMe - Fixed size: The the quick over lazy jumps fox dog brown AddMe - - Exception: System.NotSupportedException: Collection was of a fixed size. - at System.Collections.FixedSizeArrayList.Add(Object obj) - at SamplesArrayList.Main() - Exception: System.NotSupportedException: Collection was of a fixed size. - at System.Collections.FixedSizeArrayList.Insert(Int32 index, Object obj) - at SamplesArrayList.Main() - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 83e78208a4d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new ArrayList instance. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - - // Creates a synchronized wrapper around the ArrayList. - ArrayList^ mySyncdAL = ArrayList::Synchronized( myAL ); - - // Displays the sychronization status of both ArrayLists. - String^ szRes = myAL->IsSynchronized ? (String^)"synchronized" : "not synchronized"; - Console::WriteLine( "myAL is {0}.", szRes ); - String^ szSyncRes = mySyncdAL->IsSynchronized ? (String^)"synchronized" : "not synchronized"; - Console::WriteLine( "mySyncdAL is {0}.", szSyncRes ); -} - -/* - This code produces the following output. - - myAL is not synchronized. - mySyncdAL is synchronized. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index 7180bf8a5e0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesArrayList -{ -public: - static void Main() - { - // - ArrayList^ myCollection = gcnew ArrayList(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesArrayList::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp deleted file mode 100644 index 29c9798e23c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList with three elements of the same value. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "the" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - myAL->Add( "in" ); - myAL->Add( "the" ); - myAL->Add( "barn" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Searches for the last occurrence of the duplicated value. - String^ myString = "the"; - int myIndex = myAL->LastIndexOf( myString ); - Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in the first section of the ArrayList. - myIndex = myAL->LastIndexOf( myString, 8 ); - Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward. - myIndex = myAL->LastIndexOf( myString, 10, 6 ); - Console::WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex ); -} - -void PrintIndexAndValues( IEnumerable^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " [{0}]: {1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList contains the following values: - [0]: the - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - [9]: in - [10]: the - [11]: barn - - The last occurrence of "the" is at index 10. - The last occurrence of "the" between the start and index 8 is at index 6. - The last occurrence of "the" between index 10 and index 5 is at index 10. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp deleted file mode 100644 index 874f42b2001..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "red" ); - myAL->Add( "orange" ); - myAL->Add( "yellow" ); - - // Creates a read-only copy of the ArrayList. - ArrayList^ myReadOnlyAL = ArrayList::ReadOnly( myAL ); - - // Displays whether the ArrayList is read-only or writable. - Console::WriteLine( "myAL is {0}.", myAL->IsReadOnly ? (String^)"read-only" : "writable" ); - Console::WriteLine( "myReadOnlyAL is {0}.", myReadOnlyAL->IsReadOnly ? (String^)"read-only" : "writable" ); - - // Displays the contents of both collections. - Console::WriteLine( "\nInitially," ); - Console::WriteLine( "The original ArrayList myAL contains:" ); - for ( int i(0); i < myAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myAL[ i ]) ); - Console::WriteLine( "The read-only ArrayList myReadOnlyAL contains:" ); - for ( int i(0); i < myReadOnlyAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myReadOnlyAL[ i ]) ); - - // Adding an element to a read-only ArrayList throws an exception. - Console::WriteLine( "\nTrying to add a new element to the read-only ArrayList:" ); - try - { - myReadOnlyAL->Add( "green" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( String::Concat( "Exception: ", myException->ToString() ) ); - } - - - // Adding an element to the original ArrayList affects the read-only ArrayList. - myAL->Add( "blue" ); - - // Displays the contents of both collections again. - Console::WriteLine( "\nAfter adding a new element to the original ArrayList," ); - Console::WriteLine( "The original ArrayList myAL contains:" ); - for ( int i(0); i < myAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myAL[ i ]) ); - Console::WriteLine( "The read-only ArrayList myReadOnlyAL contains:" ); - for ( int i(0); i < myReadOnlyAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myReadOnlyAL[ i ]) ); -} - -/* -This code produces the following output. - -myAL is writable. -myReadOnlyAL is read-only. - -Initially, -The original ArrayList myAL contains: - red - orange - yellow -The read-only ArrayList myReadOnlyAL contains: - red - orange - yellow - -Trying to add a new element to the read-only ArrayList: -Exception: System.NotSupportedException: Collection is read-only. - at System.Collections.ReadOnlyArrayList.Add(Object obj) - at SamplesArrayList.Main() - -After adding a new element to the original ArrayList, -The original ArrayList myAL contains: - red - orange - yellow - blue -The read-only ArrayList myReadOnlyAL contains: - red - orange - yellow - blue - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp deleted file mode 100644 index 4b53513ceb4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following:" ); - PrintValues( myAL ); - - // Removes the element containing "lazy". - myAL->Remove( "lazy" ); - - // Displays the current state of the ArrayList. - Console::WriteLine( "After removing \"lazy\":" ); - PrintValues( myAL ); - - // Removes the element at index 5. - myAL->RemoveAt( 5 ); - - // Displays the current state of the ArrayList. - Console::WriteLine( "After removing the element at index 5:" ); - PrintValues( myAL ); - - // Removes three elements starting at index 4. - myAL->RemoveRange( 4, 3 ); - - // Displays the current state of the ArrayList. - Console::WriteLine( "After removing three elements starting at index 4:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following: - The quick brown fox jumps over the lazy dog - After removing "lazy": - The quick brown fox jumps over the dog - After removing the element at index 5: - The quick brown fox jumps the dog - After removing three elements starting at index 4: - The quick brown fox - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp deleted file mode 100644 index 0de76e16267..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates a new ArrayList with five elements and initialize each element with a null value. - ArrayList^ myAL = ArrayList::Repeat( 0, 5 ); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "ArrayList with five elements with a null value" ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Creates a new ArrayList with seven elements and initialize each element with the string "abc". - myAL = ArrayList::Repeat( "abc", 7 ); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "ArrayList with seven elements with a string value" ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - ArrayList with five elements with a null value - Count : 5 - Capacity : 16 - Values: - ArrayList with seven elements with a string value - Count : 7 - Capacity : 16 - Values: abc abc abc abc abc abc abc - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp deleted file mode 100644 index 0fed55d8877..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintValues( myAL ); - - // Reverses the sort order of the values of the ArrayList. - myAL->Reverse(); - - // Displays the values of the ArrayList. - Console::WriteLine( "After reversing:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following values: - The - quick - brown - fox - jumps - over - the - lazy - dog - - After reversing: - dog - lazy - the - over - jumps - fox - brown - quick - The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp deleted file mode 100644 index 94b787234f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "QUICK" ); - myAL->Add( "BROWN" ); - myAL->Add( "FOX" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintValues( myAL ); - - // Reverses the sort order of the values of the ArrayList. - myAL->Reverse( 1, 3 ); - - // Displays the values of the ArrayList. - Console::WriteLine( "After reversing:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following values: - The - QUICK - BROWN - FOX - jumps - over - the - lazy - dog - - After reversing: - The - FOX - BROWN - QUICK - jumps - over - the - lazy - dog - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp deleted file mode 100644 index 87913eb48c0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, char mySeparator ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Creates and initializes the source ICollection. - Queue^ mySourceList = gcnew Queue; - mySourceList->Enqueue( "big" ); - mySourceList->Enqueue( "gray" ); - mySourceList->Enqueue( "wolf" ); - - // Displays the values of five elements starting at index 0. - ArrayList^ mySubAL = myAL->GetRange( 0, 5 ); - Console::WriteLine( "Index 0 through 4 contains:" ); - PrintValues( mySubAL, '\t' ); - - // Replaces the values of five elements starting at index 1 with the values in the ICollection. - myAL->SetRange( 1, mySourceList ); - - // Displays the values of five elements starting at index 0. - mySubAL = myAL->GetRange( 0, 5 ); - Console::WriteLine( "Index 0 through 4 now contains:" ); - PrintValues( mySubAL, '\t' ); -} - -void PrintValues( IEnumerable^ myList, char mySeparator ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Index 0 through 4 contains: - The quick brown fox jumps - Index 0 through 4 now contains: - The big gray wolf jumps - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp deleted file mode 100644 index 0b0876c0b0f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintValues( myAL ); - - // Sorts the values of the ArrayList. - myAL->Sort(); - - // Displays the values of the ArrayList. - Console::WriteLine( "After sorting:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following values: - The - quick - brown - fox - jumps - over - the - lazy - dog - - After sorting: - brown - dog - fox - jumps - lazy - over - quick - the - The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp deleted file mode 100644 index d0f81ed9be8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp +++ /dev/null @@ -1,119 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes several BitArrays. - BitArray^ myBA1 = gcnew BitArray( 5 ); - BitArray^ myBA2 = gcnew BitArray( 5,false ); - array^myBytes = {1,2,3,4,5}; - BitArray^ myBA3 = gcnew BitArray( myBytes ); - array^myBools = {true,false,true,true,false}; - BitArray^ myBA4 = gcnew BitArray( myBools ); - array^myInts = {6,7,8,9,10}; - BitArray^ myBA5 = gcnew BitArray( myInts ); - - // Displays the properties and values of the BitArrays. - Console::WriteLine( "myBA1" ); - Console::WriteLine( " Count: {0}", myBA1->Count ); - Console::WriteLine( " Length: {0}", myBA1->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA1, 8 ); - Console::WriteLine( "myBA2" ); - Console::WriteLine( " Count: {0}", myBA2->Count ); - Console::WriteLine( " Length: {0}", myBA2->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine( "myBA3" ); - Console::WriteLine( " Count: {0}", myBA3->Count ); - Console::WriteLine( " Length: {0}", myBA3->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA3, 8 ); - Console::WriteLine( "myBA4" ); - Console::WriteLine( " Count: {0}", myBA4->Count ); - Console::WriteLine( " Length: {0}", myBA4->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA4, 8 ); - Console::WriteLine( "myBA5" ); - Console::WriteLine( " Count: {0}", myBA5->Count ); - Console::WriteLine( " Length: {0}", myBA5->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA5, 8 ); -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myBA1 - Count: 5 - Length: 5 - Values: - False False False False False - myBA2 - Count: 5 - Length: 5 - Values: - False False False False False - myBA3 - Count: 40 - Length: 40 - Values: - True False False False False False False False - False True False False False False False False - True True False False False False False False - False False True False False False False False - True False True False False False False False - myBA4 - Count: 5 - Length: 5 - Values: - True False True True False - myBA5 - Count: 160 - Length: 160 - Values: - False True True False False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - True True True False False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - False False False True False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - True False False True False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - False True False True False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp deleted file mode 100644 index fec3d1d5c3e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesLocker -{ -public: - static void Main() - { - // - BitArray^ myCollection = gcnew BitArray(64, true); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesLocker::Main(); -} - - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp deleted file mode 100644 index cfd52ecb27a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 2 ] = false; - myBA2[ 1 ] = true; - myBA2[ 3 ] = true; - - // Performs a bitwise AND operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - Console::WriteLine( "Result" ); - Console::Write( "AND:" ); - PrintValues( myBA1->And( myBA2 ), 8 ); - Console::WriteLine(); - Console::WriteLine( "After AND" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - - // Performing AND between BitArray instances of different sizes returns an exception. - try - { - BitArray^ myBA3 = gcnew BitArray( 8 ); - myBA3[ 0 ] = false; - myBA3[ 1 ] = false; - myBA3[ 2 ] = false; - myBA3[ 3 ] = false; - myBA3[ 4 ] = true; - myBA3[ 5 ] = true; - myBA3[ 6 ] = true; - myBA3[ 7 ] = true; - myBA1->And( myBA3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - Result - AND: False False False True - - After AND - myBA1: False False False True - myBA2: False True False True - - Exception: System.ArgumentException: Array lengths must be the same. - at System.Collections.BitArray.And(BitArray value) - at SamplesBitArray.Main() - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp deleted file mode 100644 index c1f547de31b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,104 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myArr ); -int main() -{ - // Creates and initializes the source BitArray. - BitArray^ myBA = gcnew BitArray( 4 ); - myBA[ 0 ] = true; - myBA[ 1 ] = true; - myBA[ 2 ] = true; - myBA[ 3 ] = true; - - // Creates and initializes the one-dimensional target Array of type Boolean. - array^myBoolArray = gcnew array(8); - myBoolArray[ 0 ] = false; - myBoolArray[ 1 ] = false; - - // Displays the values of the target Array. - Console::WriteLine( "The target Boolean Array contains the following (before and after copying):" ); - PrintValues( dynamic_cast(myBoolArray) ); - - // Copies the entire source BitArray to the target BitArray, starting at index 3. - myBA->CopyTo( myBoolArray, 3 ); - - // Displays the values of the target Array. - PrintValues( dynamic_cast(myBoolArray) ); - - // Creates and initializes the one-dimensional target Array of type integer. - array^myIntArray = gcnew array(8); - myIntArray[ 0 ] = 42; - myIntArray[ 1 ] = 43; - - // Displays the values of the target Array. - Console::WriteLine( "The target integer Array contains the following (before and after copying):" ); - PrintValues( dynamic_cast(myIntArray) ); - - // Copies the entire source BitArray to the target BitArray, starting at index 3. - myBA->CopyTo( myIntArray, 3 ); - - // Displays the values of the target Array. - PrintValues( dynamic_cast(myIntArray) ); - - // Creates and initializes the one-dimensional target Array of type byte. - Array^ myByteArray = Array::CreateInstance( Byte::typeid, 8 ); - myByteArray->SetValue( (Byte)10, 0 ); - myByteArray->SetValue( (Byte)11, 1 ); - - // Displays the values of the target Array. - Console::WriteLine( "The target byte Array contains the following (before and after copying):" ); - PrintValues( myByteArray ); - - // Copies the entire source BitArray to the target BitArray, starting at index 3. - myBA->CopyTo( myByteArray, 3 ); - - // Displays the values of the target Array. - PrintValues( myByteArray ); - - // Returns an exception if the array is not of type Boolean, integer or byte. - try - { - Array^ myStringArray = Array::CreateInstance( String::typeid, 8 ); - myStringArray->SetValue( "Hello", 0 ); - myStringArray->SetValue( "World", 1 ); - myBA->CopyTo( myStringArray, 3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myArr ) -{ - IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Boolean Array contains the following (before and after copying): - False False False False False False False False - False False False True True True True False - The target integer Array contains the following (before and after copying): - 42 43 0 0 0 0 0 0 - 42 43 0 15 0 0 0 0 - The target byte Array contains the following (before and after copying): - 10 11 0 0 0 0 0 0 - 10 11 0 15 0 0 0 0 - Exception: System.ArgumentException: Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[]. - at System.Collections.BitArray.CopyTo(Array array, Int32 index) - at SamplesBitArray.Main() - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp deleted file mode 100644 index 6417fdd49ba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myCol ); -int main() -{ - - // Creates and initializes a BitArray. - BitArray^ myBA = gcnew BitArray( 5 ); - - // Displays the properties and values of the BitArray. - Console::WriteLine( "myBA values:" ); - PrintIndexAndValues( myBA ); - - // Sets all the elements to true. - myBA->SetAll( true ); - - // Displays the properties and values of the BitArray. - Console::WriteLine( "After setting all elements to true," ); - PrintIndexAndValues( myBA ); - - // Sets the last index to false. - myBA->Set( myBA->Count - 1, false ); - - // Displays the properties and values of the BitArray. - Console::WriteLine( "After setting the last element to false," ); - PrintIndexAndValues( myBA ); - - // Gets the value of the last two elements. - Console::WriteLine( "The last two elements are: " ); - Console::WriteLine( " at index {0} : {1}", myBA->Count - 2, myBA->Get( myBA->Count - 2 ) ); - Console::WriteLine( " at index {0} : {1}", myBA->Count - 1, myBA->Get( myBA->Count - 1 ) ); -} - -void PrintIndexAndValues( IEnumerable^ myCol ) -{ - int i = 0; - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " [{0}]: {1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myBA values: - [0]: False - [1]: False - [2]: False - [3]: False - [4]: False - - After setting all elements to true, - [0]: True - [1]: True - [2]: True - [3]: True - [4]: True - - After setting the last element to false, - [0]: True - [1]: True - [2]: True - [3]: True - [4]: False - - The last two elements are: - at index 3 : True - at index 4 : False - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp deleted file mode 100644 index ca1de36ae1e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 1 ] = true; - myBA2[ 2 ] = false; - myBA2[ 3 ] = true; - - // Performs a bitwise NOT operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - myBA1->Not(); - myBA2->Not(); - Console::WriteLine( "After NOT" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - After NOT - myBA1: True True False False - myBA2: True False True False - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp deleted file mode 100644 index 0a5de2543d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 1 ] = true; - myBA2[ 2 ] = false; - myBA2[ 3 ] = true; - - // Performs a bitwise OR operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - Console::WriteLine( "Result" ); - Console::Write( "OR:" ); - PrintValues( myBA1->Or( myBA2 ), 8 ); - Console::WriteLine(); - Console::WriteLine( "After OR" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - - // Performing OR between BitArray instances of different sizes returns an exception. - try - { - BitArray^ myBA3 = gcnew BitArray( 8 ); - myBA3[ 0 ] = false; - myBA3[ 1 ] = false; - myBA3[ 2 ] = false; - myBA3[ 3 ] = false; - myBA3[ 4 ] = true; - myBA3[ 5 ] = true; - myBA3[ 6 ] = true; - myBA3[ 7 ] = true; - myBA1->Or( myBA3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - Result - OR: False True True True - - After OR - myBA1: False True True True - myBA2: False True False True - - Exception: System.ArgumentException: Array lengths must be the same. - at System.Collections.BitArray.Or(BitArray value) - at SamplesBitArray.Main() - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp deleted file mode 100644 index cd12c4f4ea2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp +++ /dev/null @@ -1,99 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 1 ] = true; - myBA2[ 2 ] = false; - myBA2[ 3 ] = true; - - // Performs a bitwise XOR operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - Console::WriteLine( "Result" ); - Console::Write( "XOR:" ); - PrintValues( myBA1->Xor( myBA2 ), 8 ); - Console::WriteLine(); - Console::WriteLine( "After XOR" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - - // Performing XOR between BitArray instances of different sizes returns an exception. - try - { - BitArray^ myBA3 = gcnew BitArray( 8 ); - myBA3[ 0 ] = false; - myBA3[ 1 ] = false; - myBA3[ 2 ] = false; - myBA3[ 3 ] = false; - myBA3[ 4 ] = true; - myBA3[ 5 ] = true; - myBA3[ 6 ] = true; - myBA3[ 7 ] = true; - myBA1->Xor( myBA3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - Result - XOR: False True True False - - After XOR - myBA1: False True True False - myBA2: False True False True - - Exception: System.ArgumentException: Array lengths must be the same. - at System.Collections.BitArray.Xor(BitArray value) - at SamplesBitArray.Main() - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp deleted file mode 100644 index cd78af80b5c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -public ref class SomeClass -{ -// -private: - static BooleanSwitch^ boolSwitch = gcnew BooleanSwitch("mySwitch", - "Switch in config file"); - -public: - static void Main( ) - { - //... - Console::WriteLine("Boolean switch {0} configured as {1}", - boolSwitch->DisplayName, ((Boolean^)boolSwitch->Enabled)->ToString()); - if (boolSwitch->Enabled) - { - //... - } - } -// -}; - -int main() -{ - SomeClass::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp deleted file mode 100644 index 824f579d9be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -// -public ref class BooleanSwitchTest -{ -private: - - /* Create a BooleanSwitch for data.*/ - static BooleanSwitch^ dataSwitch = gcnew BooleanSwitch( "Data","DataAccess module" ); - -public: - static void MyMethod( String^ location ) - { - - //Insert code here to handle processing. - if ( dataSwitch->Enabled ) - Console::WriteLine( "Error happened at {0}", location ); - } - -}; - -int main() -{ - - //Run the method which writes an error message specifying the location of the error. - BooleanSwitchTest::MyMethod( "in main" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp deleted file mode 100644 index fb8731a2646..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -// -public ref class BooleanSwitchTest -{ -private: - - /* Create a BooleanSwitch for data.*/ - static BooleanSwitch^ dataSwitch = gcnew BooleanSwitch( "Data","DataAccess module" ); - -public: - static void MyMethod( String^ location ) - { - - //Insert code here to handle processing. - if ( dataSwitch->Enabled ) - Console::WriteLine( "Error happened at {0}", location ); - } - -}; - -int main() -{ - - //Run the method that writes an error message specifying the location of the error. - BooleanSwitchTest::MyMethod( "in main" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp deleted file mode 100644 index ca1ec41a454..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp +++ /dev/null @@ -1,109 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Globalization; -public ref class SamplesDateTimeFormatInfo -{ -public: - static void Main() - { - - // Creates a new DateTimeFormatinfo. - DateTimeFormatInfo^ myDtfi = gcnew DateTimeFormatInfo; - - // Gets and prints all the patterns - array^myPatternsArray = myDtfi->GetAllDateTimePatterns(); - Console::WriteLine( "ALL the patterns:" ); - PrintIndexAndValues( myPatternsArray ); - - // Gets and prints the pattern(s) associated with some of the format characters. - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'd' ); - Console::WriteLine( "The patterns for 'd':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'D' ); - Console::WriteLine( "The patterns for 'D':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'f' ); - Console::WriteLine( "The patterns for 'f':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'F' ); - Console::WriteLine( "The patterns for 'F':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'r' ); - Console::WriteLine( "The patterns for 'r':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'R' ); - Console::WriteLine( "The patterns for 'R':" ); - PrintIndexAndValues( myPatternsArray ); - } - - public: - static void PrintIndexAndValues( array^myArray ) { - int i = 0; - for each ( String^ s in myArray ) - Console::WriteLine( "\t[{0}]:\t{1}", i++, s ); - Console::WriteLine(); - } -}; - -int main() -{ - SamplesDateTimeFormatInfo::Main(); -} - -/* -This code produces the following output. - -ALL the patterns: - [0]: MM/dd/yyyy - [1]: dddd, dd MMMM yyyy - [2]: dddd, dd MMMM yyyy HH:mm - [3]: dddd, dd MMMM yyyy hh:mm tt - [4]: dddd, dd MMMM yyyy H:mm - [5]: dddd, dd MMMM yyyy h:mm tt - [6]: dddd, dd MMMM yyyy HH:mm:ss - [7]: MM/dd/yyyy HH:mm - [8]: MM/dd/yyyy hh:mm tt - [9]: MM/dd/yyyy H:mm - [10]: MM/dd/yyyy h:mm tt - [11]: MM/dd/yyyy HH:mm:ss - [12]: MMMM dd - [13]: MMMM dd - [14]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - [15]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - [16]: yyyy'-'MM'-'dd'T'HH':'mm':'ss - [17]: HH:mm - [18]: hh:mm tt - [19]: H:mm - [20]: h:mm tt - [21]: HH:mm:ss - [22]: yyyy'-'MM'-'dd HH':'mm':'ss'Z' - [23]: dddd, dd MMMM yyyy HH:mm:ss - [24]: yyyy MMMM - [25]: yyyy MMMM - -The patterns for 'd': - [0]: MM/dd/yyyy - -The patterns for 'D': - [0]: dddd, dd MMMM yyyy - -The patterns for 'f': - [0]: dddd, dd MMMM yyyy HH:mm - [1]: dddd, dd MMMM yyyy hh:mm tt - [2]: dddd, dd MMMM yyyy H:mm - [3]: dddd, dd MMMM yyyy h:mm tt - -The patterns for 'F': - [0]: dddd, dd MMMM yyyy HH:mm:ss - -The patterns for 'r': - [0]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - -The patterns for 'R': - [0]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp deleted file mode 100644 index 3aab3172dfa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// Specify /DDEBUG when compiling. - -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - #if defined(DEBUG) - Debug::Listeners->Add( gcnew TextWriterTraceListener( Console::Out ) ); - Debug::AutoFlush = true; - Debug::Indent(); - Debug::WriteLine( "Entering Main" ); - #endif - Console::WriteLine( "Hello World." ); - #if defined(DEBUG) - Debug::WriteLine( "Exiting Main" ); - Debug::Unindent(); - #endif - return 0; -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp deleted file mode 100644 index 4cd8faa26fc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - - // - // Create a local value. - int index; - - // Perform some action that sets the local value. - index = -40; - - // Test that the local value is valid. - #if defined(DEBUG) - Debug::Assert( index > -1 ); - #endif - // - - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp deleted file mode 100644 index db8c6bd2ccb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -void MyMethod( Object^ obj, Type^ type ); - -int main( void ) -{ - MyMethod( nullptr, nullptr ); - return 0; -} - -// -void MyMethod( Object^ obj, Type^ type ) -{ - #if defined(DEBUG) - Debug::Assert( type != nullptr, "Type paramater is null" ); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp deleted file mode 100644 index 06b428a1024..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -void MyMethod( Object^ obj, Type^ type ); - -int main( void ) -{ - MyMethod( nullptr, nullptr ); - return 0; -} - -// -void MyMethod( Object^ obj, Type^ type ) -{ - #if defined(DEBUG) - Debug::Assert( type != nullptr, "Type paramater is null", "Can't get object for null type" ); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp deleted file mode 100644 index a9769743b9c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// Specify /DDEBUG when compiling. - -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -void main() -{ - #if defined(DEBUG) - // Create a new stream object for an output file named TestFile.txt. - FileStream^ myFileStream = - gcnew FileStream( "TestFile.txt", FileMode::Append ); - - // Add the stream object to the trace listeners. - TextWriterTraceListener^ myTextListener = - gcnew TextWriterTraceListener( myFileStream ); - Debug::Listeners->Add( myTextListener ); - - // Write output to the file. - Debug::WriteLine( "Test output" ); - - // Flush and close the output stream. - Debug::Flush(); - Debug::Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp deleted file mode 100644 index 52656e679ec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -enum class Option -{ - First, Second, Last -}; - -ref class Test -{ -public: - void SomeMethod() - { - int option = (int)Option::Last + 1; - double result; - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(DEBUG) - Debug::Fail( "Unknown Option" + option ); - #endif - result = 1.0; - break; - } - // - } -}; - -int main( void ) -{ - try - { - Object^ b; - b->ToString(); - } - // - catch ( Exception^ e ) - { - #if defined(DEBUG) - Debug::Fail( "Unknown Option " + option + ", using the default." ); - #endif - } - // - - Test^ test = gcnew Test(); - test->SomeMethod(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp deleted file mode 100644 index 3333cf56f0b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -enum class Option -{ - First, Second, Last -}; - -ref class Test -{ -public: - void SomeMethod() - { - int option = (int)Option::Last + 1; - double result; - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(DEBUG) - Debug::Fail( "Unknown Option" + option, "Result set to 1.0" ); - #endif - result = 1.0; - break; - } - // - } -}; - -int main( void ) -{ - try - { - Object^ b; - b->ToString(); - } - // - catch ( Exception^ e ) - { - #if defined(DEBUG) - Debug::Fail( "Cannot find SpecialController, proceeding with StandardController", "Setting Controller to default value" ); - #endif - } - // - - Test^ test = gcnew Test(); - test->SomeMethod(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp deleted file mode 100644 index daaf7687108..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - // - #if defined(DEBUG) - Debug::WriteLine( "List of errors:" ); - Debug::Indent(); - Debug::WriteLine( "Error 1: File not found" ); - Debug::WriteLine( "Error 2: Directory not found" ); - Debug::Unindent(); - Debug::WriteLine( "End of list of errors" ); - #endif - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp deleted file mode 100644 index 267bc674630..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - - // - // Create a listener that outputs to the console screen - // and add it to the debug listeners. - #if defined(DEBUG) - TextWriterTraceListener^ myWriter = - gcnew TextWriterTraceListener( System::Console::Out ); - Debug::Listeners->Add( myWriter ); - #endif - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp deleted file mode 100644 index 6b4827ca3c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( myObject, category ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::Write( " Object is not valid for this category." ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp deleted file mode 100644 index db1cf0381a5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteIf( generalSwitch->TraceVerbose, - "My second error message." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp deleted file mode 100644 index 21e33495423..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, myObject ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, - " is not a valid value for this method." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp deleted file mode 100644 index 9fa1f596191..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceVerbose, String::Concat( myObject, - " is not a valid object for category: " ), category ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceError, - " Please use a different category." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp deleted file mode 100644 index aa9a5022701..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceVerbose, myObject, category ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceError, - " Object is not valid for this category." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp deleted file mode 100644 index ef9961a738d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "My error message. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( "My second error message." ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp deleted file mode 100644 index c3a53e7adcd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "Invalid object. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( myObject ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp deleted file mode 100644 index 05f395a2ce6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "My error message. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( "My second error message.", category ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp deleted file mode 100644 index 8c64d37cc22..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "Invalid object for category. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( myObject, category ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp deleted file mode 100644 index 8ded25d813b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp deleted file mode 100644 index fefafc88fcc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "Invalid object. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, myObject ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp deleted file mode 100644 index ee7c49907b7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message.", category ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp deleted file mode 100644 index d7fb6a3dfaa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf(generalSwitch->TraceError, "Invalid object for category. "); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, myObject, category ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp deleted file mode 100644 index 296584f4b92..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - DirectoryInfo^ dir = gcnew DirectoryInfo( "." ); - String^ dirName = dir->Name; - Console::WriteLine( "DirectoryInfo name is {0}.", dirName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp deleted file mode 100644 index 1d5d2c3bae2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Windows::Forms; - -// -int main() -{ - - // Creates an exception with an error message. - Exception^ myException = gcnew Exception( "This is an exception test" ); - - // Creates an ErrorEventArgs with the exception. - ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException ); - - // Extracts the exception from the ErrorEventArgs and display it. - Exception^ myReturnedException = myErrorEventArgs->GetException(); - MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp deleted file mode 100644 index dafe3cd798d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Windows::Forms; - -// -int main() -{ - - //Creates an exception with an error message. - Exception^ myException = gcnew Exception( "This is an exception test" ); - - //Creates an ErrorEventArgs with the exception. - ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException ); - - //Extracts the exception from the ErrorEventArgs and display it. - Exception^ myReturnedException = myErrorEventArgs->GetException(); - MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp deleted file mode 100644 index 220658df802..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create an EventLog instance and assign its log name. - EventLog^ myLog = gcnew EventLog; - myLog->Log = "myNewLog"; - myLog->Clear(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp deleted file mode 100644 index 837b9e669dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "MySource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp deleted file mode 100644 index d34be2b024f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - String^ logName; - if ( EventLog::SourceExists( "MySource", "MyMachine") ) - { - - // Find the log associated with this source. - logName = EventLog::LogNameFromSourceName( "MySource", "MyMachine" ); - // Make sure the source is in the log we believe it to be in - if (logName != "MyLog") - return -1; - // Delete the source and the log. - EventLog::DeleteEventSource( "MySource", "MyMachine" ); - EventLog::Delete( logName, "MyMachine" ); - Console::WriteLine( "{0} deleted.", logName ); - } - else - { - // Create the event source to make next try successful. - EventSourceCreationData^ mySourceData = gcnew EventSourceCreationData("MySource", "MyLog"); - mySourceData->MachineName = "MyMachine"; - EventLog::CreateEventSource(mySourceData); - } -} - -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp deleted file mode 100644 index 7fbbf42dd7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - String^ logName; - if ( EventLog::SourceExists( "MySource" ) ) - { - - // Find the log associated with this source. - logName = EventLog::LogNameFromSourceName( "MySource", "." ); - // Make sure the source is in the log we believe it to be in - if (logName != "MyLog") - return -1; - // Delete the source and the log. - EventLog::DeleteEventSource( "MySource" ); - EventLog::Delete( logName ); - Console::WriteLine( "{0} deleted.", logName ); - } - else - { - // Create the event source to make next try successful. - EventLog::CreateEventSource("MySource", "MyLog"); - } -} - -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp deleted file mode 100644 index 8d2633a605a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -ref class MySample -{ -public: - static void MyOnEntryWritten( Object^ /*source*/, EntryWrittenEventArgs^ e ) - { - Console::WriteLine( "Written: {0}", e->Entry->Message ); - } - -}; - -int main() -{ - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "MyCustomLog"; - myNewLog->EntryWritten += gcnew EntryWrittenEventHandler( MySample::MyOnEntryWritten ); - myNewLog->EnableRaisingEvents = true; - Console::WriteLine( "Press \'q\' to quit." ); - - // Wait for the EntryWrittenEvent or a quit command. - while ( Console::Read() != 'q' ) - { - - // Wait. - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp deleted file mode 100644 index b53690fb654..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - EventLog^ myLog = gcnew EventLog; - myLog->Log = "MyNewLog"; - System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp deleted file mode 100644 index 6a70ed0eae5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -ref class MySample -{ -private: - - // This member is used to wait for events. - static AutoResetEvent^ signal; - -public: - static void main() - { - signal = gcnew AutoResetEvent( false ); - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Source = "testEventLogEvent"; - myNewLog->EntryWritten += gcnew EntryWrittenEventHandler( MyOnEntryWritten ); - myNewLog->EnableRaisingEvents = true; - myNewLog->WriteEntry("Test message", EventLogEntryType::Information); - signal->WaitOne(); - } - - static void MyOnEntryWritten( Object^ /*source*/, EntryWrittenEventArgs^ /*e*/ ) - { - Console::WriteLine("In event handler"); - signal->Set(); - } - -}; - -int main() -{ - MySample::main(); -} - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp deleted file mode 100644 index 784d135be2e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - - // Create an EventLog instance and assign its log name. - EventLog^ myLog = gcnew EventLog( "myNewLog" ); - - // Read the event log entries. - System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp deleted file mode 100644 index d4a6b83d0d1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog", "myServer" ); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - // Create an EventLog instance and assign its log name. - EventLog^ myLog = gcnew EventLog( "myNewLog","myServer" ); - - // Read the event log entries. - System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp deleted file mode 100644 index 1406cddf5c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog"); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog( "myNewLog",".","MySource" ); - - // Write an entry to the log. - myLog->WriteEntry( String::Format( "Writing to event log on {0}", myLog->MachineName ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp deleted file mode 100644 index 0bb3db04e83..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - array^remoteEventLogs; - remoteEventLogs = EventLog::GetEventLogs( "myServer" ); - Console::WriteLine( "Number of logs on computer: {0}", remoteEventLogs->Length ); - System::Collections::IEnumerator^ myEnum = remoteEventLogs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLog^ log = safe_cast(myEnum->Current); - Console::WriteLine( "Log: {0}", log->Log ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp deleted file mode 100644 index e9a75f0cb41..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "NewEventLog"; - System::Collections::IEnumerator^ myEnum = myNewLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp deleted file mode 100644 index fe550a181e0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "NewEventLog"; - myNewLog->MachineName = "MyServer"; - System::Collections::IEnumerator^ myEnum = myNewLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp deleted file mode 100644 index 44c4682c561..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - } - - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "MySource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing to event log." ); - Console::WriteLine( "Message written to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp deleted file mode 100644 index c66d775c270..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource", "MyServer" ) ) - { - EventLog::CreateEventSource( "MySource", "MyNewLog", "MyServer" ); - Console::WriteLine( "CreatingEventSource" ); - } - - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "MySource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing to event log." ); - Console::WriteLine( "Message written to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp deleted file mode 100644 index 8980996197a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "myNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - } - - - // Write an informational entry to the event log. - EventLog::WriteEntry( "MySource", "Writing to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp deleted file mode 100644 index 52610a420c6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog("MyNewLog"); - myLog->Source = "MyNewLogSource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing warning to event log.", EventLogEntryType::Warning ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp deleted file mode 100644 index 126dd6381a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp +++ /dev/null @@ -1,16 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Write an informational entry to the event log. - EventLog::WriteEntry( "MySource", "Writing warning to event log.", EventLogEntryType::Warning ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp deleted file mode 100644 index bae18050fe1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -// -int main() -{ - #if defined(TRACE) - - // Create a trace listener for the event log. - EventLogTraceListener^ myTraceListener = - gcnew EventLogTraceListener( "myEventLogSource" ); - - // Add the event log trace listener to the collection. - Trace::Listeners->Add( myTraceListener ); - - // Write output to the event log. - Trace::WriteLine( "Test output" ); - - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp deleted file mode 100644 index d0051f61250..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -using namespace System; -using namespace System::IO; - -public ref class Form1 -{ -protected: - void Method( String^ name ) - { -// -FileStream^ s2 = gcnew FileStream( name, FileMode::Open, FileAccess::Read, FileShare::Read ); -// - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp deleted file mode 100644 index 73b079909b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main( void ) -{ - FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Read ); - if ( fs->CanRead && fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt can be both written to and read from." ); - } - else - { - Console::WriteLine( "MyFile.txt is not writable" ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp deleted file mode 100644 index 1c4c9b8a84c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main( void ) -{ - FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Write ); - if ( fs->CanRead && fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt can be both written to and read from." ); - } - else - { - Console::WriteLine( "MyFile.txt is writable." ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp deleted file mode 100644 index 6d129222b6a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::IO::IsolatedStorage; - -void Method( FileStream^ s ) -{ - // - if ( s->Length == s->Position ) - { - Console::WriteLine( "End of file has been reached." ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp deleted file mode 100644 index 9239a2c8f3e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - - -public ref class Class1 -{ - -public: - static void Main() - { - // Get the file version for the notepad. - // Use either of the two following methods. - FileVersionInfo::GetVersionInfo(Path::Combine(Environment::SystemDirectory, "Notepad.exe")); - FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - - - // Print the file name and version number. - Console::WriteLine("File: " + myFileVersionInfo->FileDescription + "\n" + - "Version number: " + myFileVersionInfo->FileVersion); - } -}; - -int main() -{ - Class1::Main(); -} -// - - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp deleted file mode 100644 index 2a2d18167f1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - - // -private: - void GetCompanyName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - - // Print the company name. - textBox1->Text = "The company name: " + myFileVersionInfo->CompanyName; - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp deleted file mode 100644 index 0766d0bcf94..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileBuildPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - - // Print the file build number. - textBox1->Text = String::Format( "File build number: {0}", myFileVersionInfo->FileBuildPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp deleted file mode 100644 index 944efb43eff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Windows::Forms; -using namespace System::Diagnostics; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileDescription() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file description. - textBox1->Text = String::Concat( "File description: ", myFileVersionInfo->FileDescription ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp deleted file mode 100644 index fe1fceca8b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - - // -private: - void GetFileMajorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo( "%systemroot%\\Notepad.exe" ); - - // Print the file major part number. - textBox1->Text = String::Concat( "File major part number: ", myFileVersionInfo->FileMajorPart ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp deleted file mode 100644 index 1c1a34b3c9a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileMinorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file minor part number. - textBox1->Text = String::Concat( "File minor part number: ", myFileVersionInfo->FileMinorPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp deleted file mode 100644 index c9afaf47525..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file name. - textBox1->Text = String::Concat( "File name: ", myFileVersionInfo->FileName ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp deleted file mode 100644 index ff28177ca51..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFilePrivatePart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file private part number. - textBox1->Text = String::Concat( "File private part number: ", myFileVersionInfo->FilePrivatePart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp deleted file mode 100644 index d957207f64e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetInternalName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the internal name. - textBox1->Text = String::Concat( "Internal name: ", myFileVersionInfo->InternalName ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp deleted file mode 100644 index 03806600176..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsDebug() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file contains debugging information. - textBox1->Text = String::Concat( "File contains debugging information: ", - myFileVersionInfo->IsDebug ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp deleted file mode 100644 index 679f5f4c274..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsPatched() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file has a patch installed. - textBox1->Text = String::Concat( "File has patch installed: ", myFileVersionInfo->IsPatched ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp deleted file mode 100644 index fc4df817667..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsPreRelease() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file is a prerelease version. - textBox1->Text = String::Concat( "File is prerelease version ", myFileVersionInfo->IsPreRelease ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp deleted file mode 100644 index 83dd4978d95..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsPrivateBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the version is a private build. - textBox1->Text = String::Concat( "Version is a private build: ", myFileVersionInfo->IsPrivateBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp deleted file mode 100644 index 252a113a733..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsSpecialBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file is a special build. - textBox1->Text = String::Concat( "File is a special build: ", myFileVersionInfo->IsSpecialBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp deleted file mode 100644 index c4f8e392537..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetCopyright() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the copyright notice. - textBox1->Text = String::Concat( "Copyright notice: ", myFileVersionInfo->LegalCopyright ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp deleted file mode 100644 index 0ed892c3443..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetTrademarks() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the trademarks. - textBox1->Text = String::Concat( "Trademarks: ", myFileVersionInfo->LegalTrademarks ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp deleted file mode 100644 index 06de83f723a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetOriginalName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the original file name. - textBox1->Text = String::Concat( "Original file name: ", myFileVersionInfo->OriginalFilename ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp deleted file mode 100644 index 9087c661b55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetPrivateBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the private build number. - textBox1->Text = String::Concat( "Private build number: ", myFileVersionInfo->PrivateBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp deleted file mode 100644 index 81913117b81..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductBuildPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product build part number. - textBox1->Text = String::Concat( "Product build part number: ", myFileVersionInfo->ProductBuildPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp deleted file mode 100644 index c08b8bbc59b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductMajorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product major part number. - textBox1->Text = String::Concat( "Product major part number: ", myFileVersionInfo->ProductMajorPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp deleted file mode 100644 index a419d991f9a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductMinorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product minor part number. - textBox1->Text = String::Concat( "Product minor part number: ", myFileVersionInfo->ProductMinorPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp deleted file mode 100644 index 4b5b6d28591..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product name. - textBox1->Text = String::Concat( "Product name: ", myFileVersionInfo->ProductName ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp deleted file mode 100644 index 9ef151fdcab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductPrivatePart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product private part number. - textBox1->Text = String::Concat( "Product private part number: ", myFileVersionInfo->ProductPrivatePart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp deleted file mode 100644 index 37638630d5a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductVersion() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product version number. - textBox1->Text = String::Concat( "Product version number: ", myFileVersionInfo->ProductVersion ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp deleted file mode 100644 index a3f209f9682..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetSpecialBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the special build information. - textBox1->Text = String::Concat( "Special build information: ", myFileVersionInfo->SpecialBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp deleted file mode 100644 index fbecc3c9e0c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileVersion2() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print all the version information. - textBox1->Text = myFileVersionInfo->ToString(); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp deleted file mode 100644 index 69ae75d0f48..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Policy; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - array^dataArray; - - void Method() - { - // - HashAlgorithm^ sha = SHA256::Create(); - array^ result = sha->ComputeHash( dataArray ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp deleted file mode 100644 index 473f4a7a126..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public class HashtableExample -{ -public: - static void Main() - { - // Creates and initializes a new Hashtable. - Hashtable^ clouds = gcnew Hashtable(); - clouds->Add("Cirrus", "Castellanus"); - clouds->Add("Cirrocumulus", "Stratiformis"); - clouds->Add("Altostratus", "Radiatus"); - clouds->Add("Stratocumulus", "Perlucidus"); - clouds->Add("Stratus", "Fractus"); - clouds->Add("Nimbostratus", "Pannus"); - clouds->Add("Cumulus", "Humilis"); - clouds->Add("Cumulonimbus", "Incus"); - - // Displays the keys and values of the Hashtable using GetEnumerator() - - IDictionaryEnumerator^ denum = clouds->GetEnumerator(); - DictionaryEntry dentry; - - Console::WriteLine(); - Console::WriteLine(" Cloud Type Variation"); - Console::WriteLine(" -----------------------------"); - while (denum->MoveNext()) - { - dentry = (DictionaryEntry) denum->Current; - Console::WriteLine(" {0,-17}{1}", dentry.Key, dentry.Value); - } - Console::WriteLine(); - - // Displays the keys and values of the Hashtable using foreach statement - - Console::WriteLine(" Cloud Type Variation"); - Console::WriteLine(" -----------------------------"); - for each (DictionaryEntry de in clouds) - { - Console::WriteLine(" {0,-17}{1}", de.Key, de.Value); - } - Console::WriteLine(); - } -}; - -int main() -{ - HashtableExample::Main(); -} - -// The program displays the following output to the console: -// -// Cloud Type Variation -// ----------------------------- -// Cirrocumulus Stratiformis -// Stratocumulus Perlucidus -// Cirrus Castellanus -// Cumulus Humilis -// Nimbostratus Pannus -// Stratus Fractus -// Altostratus Radiatus -// Cumulonimbus Incus -// -// Cloud Type Variation -// ----------------------------- -// Cirrocumulus Stratiformis -// Stratocumulus Perlucidus -// Cirrus Castellanus -// Cumulus Humilis -// Nimbostratus Pannus -// Stratus Fractus -// Altostratus Radiatus -// Cumulonimbus Incus*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp deleted file mode 100644 index 21cce15687b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "one", "The" ); - myHT->Add( "two", "quick" ); - myHT->Add( "three", "brown" ); - myHT->Add( "four", "fox" ); - - // Displays the Hashtable. - Console::WriteLine( "The Hashtable contains the following:" ); - PrintKeysAndValues( myHT ); -} - -void PrintKeysAndValues( Hashtable^ myHT ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}:\t{1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Hashtable contains the following: - -KEY- -VALUE- - two: quick - three: brown - four: fox - one: The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp deleted file mode 100644 index 87875e40e37..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "one", "The" ); - myHT->Add( "two", "quick" ); - myHT->Add( "three", "brown" ); - myHT->Add( "four", "fox" ); - myHT->Add( "five", "jumps" ); - - // Displays the count and values of the Hashtable. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myHT->Count ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( myHT ); - - // Clears the Hashtable. - myHT->Clear(); - - // Displays the count and values of the Hashtable. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myHT->Count ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( myHT ); -} - -void PrintKeysAndValues( Hashtable^ myHT ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}:\t{1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Values: - -KEY- -VALUE- - two: quick - three: brown - four: fox - five: jumps - one: The - - After Clear, - Count : 0 - Values: - -KEY- -VALUE- - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp deleted file mode 100644 index b6d25cecb55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( (int^)0, "zero" ); - myHT->Add( 1, "one" ); - myHT->Add( 2, "two" ); - myHT->Add( 3, "three" ); - myHT->Add( 4, "four" ); - - // Displays the values of the Hashtable. - Console::WriteLine( "The Hashtable contains the following values:" ); - PrintIndexAndKeysAndValues( myHT ); - - // Searches for a specific key. - int myKey = 2; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, myHT->ContainsKey( myKey ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); - myKey = 6; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, myHT->ContainsKey( myKey ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); - - // Searches for a specific value. - String^ myValue = "three"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, myHT->ContainsValue( myValue ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); - myValue = "nine"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, myHT->ContainsValue( myValue ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); -} - -void PrintIndexAndKeysAndValues( Hashtable^ myHT ) -{ - int i = 0; - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i++, de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Hashtable contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 4 four - [1]: 3 three - [2]: 2 two - [3]: 1 one - [4]: 0 zero - - The key "2" is in the Hashtable. - The key "6" is NOT in the Hashtable. - The value "three" is in the Hashtable. - The value "nine" is NOT in the Hashtable. - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 70190cc955d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^myArr, char mySeparator ); -int main() -{ - - // Creates and initializes the source Hashtable. - Hashtable^ mySourceHT = gcnew Hashtable; - mySourceHT->Add( "A", "valueA" ); - mySourceHT->Add( "B", "valueB" ); - - // Creates and initializes the one-dimensional target Array. - array^myTargetArray = gcnew array(15); - myTargetArray[ 0 ] = "The"; - myTargetArray[ 1 ] = "quick"; - myTargetArray[ 2 ] = "brown"; - myTargetArray[ 3 ] = "fox"; - myTargetArray[ 4 ] = "jumps"; - myTargetArray[ 5 ] = "over"; - myTargetArray[ 6 ] = "the"; - myTargetArray[ 7 ] = "lazy"; - myTargetArray[ 8 ] = "dog"; - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following before:" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the keys in the source Hashtable to the target Hashtable, starting at index 6. - Console::WriteLine( "After copying the keys, starting at index 6:" ); - mySourceHT->Keys->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the values in the source Hashtable to the target Hashtable, starting at index 6. - Console::WriteLine( "After copying the values, starting at index 6:" ); - mySourceHT->Values->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^myArr, char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ] ); - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following before: - The quick brown fox jumps over the lazy dog - After copying the keys, starting at index 6: - The quick brown fox jumps over B A dog - After copying the values, starting at index 6: - The quick brown fox jumps over valueB valueA dog - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp deleted file mode 100644 index 5e205ba0c28..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesHashtable -{ -public: - static void Main() - { - // - Hashtable^ myCollection = gcnew Hashtable(); - bool lockTaken = false; - - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -void main() -{ - SamplesHashtable::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 4696c2337e9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( (int^)0, "zero" ); - myHT->Add( 1, "one" ); - myHT->Add( 2, "two" ); - myHT->Add( 3, "three" ); - myHT->Add( 4, "four" ); - - // Creates a synchronized wrapper around the Hashtable. - Hashtable^ mySyncdHT = Hashtable::Synchronized( myHT ); - - // Displays the sychronization status of both Hashtables. - Console::WriteLine( "myHT is {0}.", myHT->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdHT is {0}.", mySyncdHT->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* - This code produces the following output. - - myHT is not synchronized. - mySyncdHT is synchronized. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp deleted file mode 100644 index 23ce290b57a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "1a", "The" ); - myHT->Add( "1b", "quick" ); - myHT->Add( "1c", "brown" ); - myHT->Add( "2a", "fox" ); - myHT->Add( "2b", "jumps" ); - myHT->Add( "2c", "over" ); - myHT->Add( "3a", "the" ); - myHT->Add( "3b", "lazy" ); - myHT->Add( "3c", "dog" ); - - // Displays the Hashtable. - Console::WriteLine( "The Hashtable initially contains the following:" ); - PrintKeysAndValues( myHT ); - - // Removes the element with the key "3b". - myHT->Remove( "3b" ); - - // Displays the current state of the Hashtable. - Console::WriteLine( "After removing \"lazy\":" ); - PrintKeysAndValues( myHT ); -} - -void PrintKeysAndValues( Hashtable^ myHT ) -{ - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( " {0}: {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Hashtable initially contains the following: - 2c: over - 3a: the - 2b: jumps - 3b: lazy - 1b: quick - 3c: dog - 2a: fox - 1c: brown - 1a: The - - After removing "lazy": - 2c: over - 3a: the - 2b: jumps - 1b: quick - 3c: dog - 2a: fox - 1c: brown - 1a: The - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp deleted file mode 100644 index c9eb24638ad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -#include "pch.h" - -using namespace System; -using namespace System::IO; - -class MyClassCPP -{ -public: - - int static Run() - { - FileSystemWatcher^ watcher = gcnew FileSystemWatcher("C:\\path\\to\\folder"); - - watcher->NotifyFilter = static_cast(NotifyFilters::Attributes - | NotifyFilters::CreationTime - | NotifyFilters::DirectoryName - | NotifyFilters::FileName - | NotifyFilters::LastAccess - | NotifyFilters::LastWrite - | NotifyFilters::Security - | NotifyFilters::Size); - - watcher->Changed += gcnew FileSystemEventHandler(MyClassCPP::OnChanged); - watcher->Created += gcnew FileSystemEventHandler(MyClassCPP::OnCreated); - watcher->Deleted += gcnew FileSystemEventHandler(MyClassCPP::OnDeleted); - watcher->Renamed += gcnew RenamedEventHandler(MyClassCPP::OnRenamed); - watcher->Error += gcnew ErrorEventHandler(MyClassCPP::OnError); - - watcher->Filter = "*.txt"; - watcher->IncludeSubdirectories = true; - watcher->EnableRaisingEvents = true; - - Console::WriteLine("Press enter to exit."); - Console::ReadLine(); - - return 0; - } - -private: - - static void OnChanged(Object^ sender, FileSystemEventArgs^ e) - { - if (e->ChangeType != WatcherChangeTypes::Changed) - { - return; - } - Console::WriteLine("Changed: {0}", e->FullPath); - } - - static void OnCreated(Object^ sender, FileSystemEventArgs^ e) - { - Console::WriteLine("Created: {0}", e->FullPath); - } - - static void OnDeleted(Object^ sender, FileSystemEventArgs^ e) - { - Console::WriteLine("Deleted: {0}", e->FullPath); - } - - static void OnRenamed(Object^ sender, RenamedEventArgs^ e) - { - Console::WriteLine("Renamed:"); - Console::WriteLine(" Old: {0}", e->OldFullPath); - Console::WriteLine(" New: {0}", e->FullPath); - } - - static void OnError(Object^ sender, ErrorEventArgs^ e) - { - PrintException(e->GetException()); - } - - static void PrintException(Exception^ ex) - { - if (ex != nullptr) - { - Console::WriteLine("Message: {0}", ex->Message); - Console::WriteLine("Stacktrace:"); - Console::WriteLine(ex->StackTrace); - Console::WriteLine(); - PrintException(ex->InnerException); - } - } -}; - - -int main() -{ - MyClassCPP::Run(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp deleted file mode 100644 index 0c7dbce3903..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -String^ PrintArraySet( array^myArr ) -{ - String^ myStr = nullptr; - myStr = myArr[ 0 ].ToString(); - for ( int i = 1; i < myArr->Length; i++ ) - myStr = String::Concat( myStr, ", ", myArr[ i ].ToString() ); - return myStr; -} - -int main() -{ - - // Creates a new NumberFormatinfo. - NumberFormatInfo^ myNfi = gcnew NumberFormatInfo; - - // Takes a long value. - Int64 myInt = 123456789012345; - - // Displays the value with default formatting. - Console::WriteLine( "Default \t\t:\t{0}", myInt.ToString( "N", myNfi ) ); - - // Displays the value with three elements in the GroupSize array. - array^newInts1 = {2,3,4}; - myNfi->NumberGroupSizes = newInts1; - Console::WriteLine( "Grouping ( {0} )\t:\t{1}", PrintArraySet( myNfi->NumberGroupSizes ), myInt.ToString( "N", myNfi ) ); - - // Displays the value with zero as the last element in the GroupSize array. - array^newInts2 = {2,4,0}; - myNfi->NumberGroupSizes = newInts2; - Console::WriteLine( "Grouping ( {0} )\t:\t{1}", PrintArraySet( myNfi->NumberGroupSizes ), myInt.ToString( "N", myNfi ) ); -} - -/* -This code produces the following output. - -Default : 123, 456, 789, 012, 345.00 -Grouping (2, 3, 4) : 12, 3456, 7890, 123, 45.00 -Grouping (2, 4, 0) : 123456789, 0123, 45.00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp deleted file mode 100644 index 25d277574d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create a new NumberFormatinfo. - NumberFormatInfo^ nfi = gcnew NumberFormatInfo; - - // Takes a negative value. - Int64 value = -1234; - - // Displays the value with default formatting. - Console::WriteLine("{0,-20} {1,-10}", "Default:", - value.ToString("N", nfi)); - - // Displays the value with other patterns. - for (int i = 0; i <= 4; i++) { - nfi->NumberNegativePattern = i; - Console::WriteLine("{0,-20} {1,-10}", - String::Format("Pattern {0}:", - nfi->NumberNegativePattern), - value.ToString("N", nfi)); - } -} -// The example displays the following output: -// Default: -1,234.00 -// Pattern 0: (1,234.00) -// Pattern 1: -1,234.00 -// Pattern 2: - 1,234.00 -// Pattern 3: 1,234.00- -// Pattern 4: 1,234.00 - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp deleted file mode 100644 index 37dced94673..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "Hello" ); - myQ->Enqueue( "World" ); - myQ->Enqueue( "!" ); - - // Displays the properties and values of the Queue. - Console::WriteLine( "myQ" ); - Console::WriteLine( "\tCount: {0}", myQ->Count ); - Console::Write( "\tValues:" ); - PrintValues( myQ ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myQ - Count: 3 - Values: Hello World ! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp deleted file mode 100644 index 7ff5770c590..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( Queue^ myQ ); -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "The" ); - myQ->Enqueue( "quick" ); - myQ->Enqueue( "brown" ); - myQ->Enqueue( "fox" ); - myQ->Enqueue( "jumps" ); - - // Displays the count and values of the Queue. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myQ->Count ); - Console::Write( " Values:" ); - PrintValues( myQ ); - - // Clears the Queue. - myQ->Clear(); - - // Displays the count and values of the Queue. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myQ->Count ); - Console::Write( " Values:" ); - PrintValues( myQ ); -} - -void PrintValues( Queue^ myQ ) -{ - IEnumerator^ myEnum = myQ->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::Write( " {0}", myObj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Values: The quick brown fox jumps - After Clear, - Count : 0 - Values: - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp deleted file mode 100644 index da270065dbb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( Array^ myArr, char mySeparator ); -int main() -{ - // Creates and initializes the source Queue. - Queue^ mySourceQ = gcnew Queue; - mySourceQ->Enqueue( "three" ); - mySourceQ->Enqueue( "napping" ); - mySourceQ->Enqueue( "cats" ); - mySourceQ->Enqueue( "in" ); - mySourceQ->Enqueue( "the" ); - mySourceQ->Enqueue( "barn" ); - - // Creates and initializes the one-dimensional target Array. - Array^ myTargetArray = Array::CreateInstance( String::typeid, 15 ); - myTargetArray->SetValue( "The", 0 ); - myTargetArray->SetValue( "quick", 1 ); - myTargetArray->SetValue( "brown", 2 ); - myTargetArray->SetValue( "fox", 3 ); - myTargetArray->SetValue( "jumps", 4 ); - myTargetArray->SetValue( "over", 5 ); - myTargetArray->SetValue( "the", 6 ); - myTargetArray->SetValue( "lazy", 7 ); - myTargetArray->SetValue( "dog", 8 ); - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Queue to the target Array, starting at index 6. - mySourceQ->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Queue to a new standard array. - array^myStandardArray = mySourceQ->ToArray(); - - // Displays the values of the new standard array. - Console::WriteLine( "The new standard array contains the following:" ); - PrintValues( myStandardArray, ' ' ); -} - -void PrintValues( Array^ myArr, char mySeparator ) -{ - IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, myObj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - The new standard array contains the following: - three napping cats in the barn - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp deleted file mode 100644 index 7238b539959..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "The" ); - myQ->Enqueue( "quick" ); - myQ->Enqueue( "brown" ); - myQ->Enqueue( "fox" ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); - - // Removes an element from the Queue. - Console::WriteLine( "(Dequeue)\t{0}", myQ->Dequeue() ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); - - // Removes another element from the Queue. - Console::WriteLine( "(Dequeue)\t{0}", myQ->Dequeue() ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); - - // Views the first element in the Queue but does not remove it. - Console::WriteLine( "(Peek) \t{0}", myQ->Peek() ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Queue values: The quick brown fox - (Dequeue) The - Queue values: quick brown fox - (Dequeue) quick - Queue values: brown fox - (Peek) brown - Queue values: brown fox - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index ce3246510e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "The" ); - myQ->Enqueue( "quick" ); - myQ->Enqueue( "brown" ); - myQ->Enqueue( "fox" ); - - // Creates a synchronized wrapper around the Queue. - Queue^ mySyncdQ = Queue::Synchronized( myQ ); - - // Displays the sychronization status of both Queues. - Console::WriteLine( "myQ is {0}.", myQ->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdQ is {0}.", mySyncdQ->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* -This code produces the following output. - -myQ is not synchronized. -mySyncdQ is synchronized. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index 8bfdf62af62..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesQueue -{ -public: - static void Main() - { - // - Queue^ myCollection = gcnew Queue(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesQueue::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp deleted file mode 100644 index 9d881778d4a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Cryptography; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - array^ random = gcnew array(100); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - rng->GetBytes( random ); // The array is now filled with cryptographically strong random bytes. - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp deleted file mode 100644 index c9dcb18468c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Cryptography; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - array^ random = gcnew array(100); - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - rng->GetNonZeroBytes( random ); // The array is now filled with cryptographically strong random bytes, and none are zero. - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp deleted file mode 100644 index ebd4a81690e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -int main() -{ - - // Creates a resource writer. - IResourceWriter^ writer = gcnew ResourceWriter( "myResources.resources" ); - - // Adds resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Writes the resources to the file or stream, and closes it. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp deleted file mode 100644 index aa1b6553ab8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Print the byte array in a readable format. -void PrintByteArray( array^array ) -{ - int i; - for ( i = 0; i < array->Length; i++ ) - { - Console::Write( String::Format( "{0:X2}", array[ i ] ) ); - if ( (i % 4) == 3 ) - Console::Write( " " ); - - } - Console::WriteLine(); -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "Usage: hashdir " ); - return 0; - } - - try - { - - // Create a DirectoryInfo object representing the specified directory. - DirectoryInfo^ dir = gcnew DirectoryInfo( args[ 1 ] ); - - // Get the FileInfo objects for every file in the directory. - array^files = dir->GetFiles(); - - // Initialize a SHA256 hash object. - SHA256 ^ mySHA256 = SHA256Managed::Create(); - array^hashValue; - - // Compute and print the hash values for each file in directory. - System::Collections::IEnumerator^ myEnum = files->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FileInfo^ fInfo = safe_cast(myEnum->Current); - - // Create a fileStream for the file. - FileStream^ fileStream = fInfo->Open( FileMode::Open ); - - // Compute the hash of the fileStream. - hashValue = mySHA256->ComputeHash( fileStream ); - - // Write the name of the file to the Console. - Console::Write( "{0}: ", fInfo->Name ); - - // Write the hash value to the Console. - PrintByteArray( hashValue ); - - // Close the file. - fileStream->Close(); - } - return 0; - } - catch ( DirectoryNotFoundException^ ) - { - Console::WriteLine( "Error: The directory specified could not be found." ); - } - catch ( IOException^ ) - { - Console::WriteLine( "Error: A file in the directory could not be accessed." ); - } - -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp deleted file mode 100644 index 471fe0f815a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - SHA384^ shaM = gcnew SHA384Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp deleted file mode 100644 index 6a0aa345a43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - - SHA384^ shaM = gcnew SHA384Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp deleted file mode 100644 index 2a84c2dc7ba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - SHA512^ shaM = gcnew SHA512Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp deleted file mode 100644 index a22a11fb2ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - - SHA512^ shaM = gcnew SHA512Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp deleted file mode 100644 index c7e0914d780..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp +++ /dev/null @@ -1,27 +0,0 @@ -using namespace System; -using namespace System::Collections; - -public ref class SamplesSortedList -{ -public: - static void Main() - { - // Creates and initializes a new SortedList. - SortedList^ mySortedList = gcnew SortedList(); - mySortedList->Add("Third", "!"); - mySortedList->Add("Second", "World"); - mySortedList->Add("First", "Hello"); - - // - for each (DictionaryEntry de in mySortedList) - { - //... - } - // - } -}; - -int main() -{ - SamplesSortedList::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp deleted file mode 100644 index bc3817bdcfe..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -public ref class SamplesSortedList -{ -public: - static void PrintKeysAndValues( SortedList^ myList ) - { - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); - } - -}; - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "Third", "!" ); - mySL->Add( "Second", "World" ); - mySL->Add( "First", "Hello" ); - - // Displays the properties and values of the SortedList. - Console::WriteLine( "mySL" ); - Console::WriteLine( " Count: {0}", mySL->Count ); - Console::WriteLine( " Capacity: {0}", mySL->Capacity ); - Console::WriteLine( " Keys and Values:" ); - SamplesSortedList::PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -mySL -Count: 3 -Capacity: 16 -Keys and Values: --KEY- -VALUE- -First: Hello -Second: World -Third: ! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp deleted file mode 100644 index ce1205d460a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "one", "The" ); - mySL->Add( "two", "quick" ); - mySL->Add( "three", "brown" ); - mySL->Add( "four", "fox" ); - - // Displays the SortedList. - Console::WriteLine( "The SortedList contains the following:" ); - PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -The SortedList contains the following: - -KEY- -VALUE- - four: fox - one: The - three: brown - two: quick -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp deleted file mode 100644 index d4b3dbf1600..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "one", "The" ); - mySL->Add( "two", "quick" ); - mySL->Add( "three", "brown" ); - mySL->Add( "four", "fox" ); - mySL->Add( "five", "jumps" ); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); - - // Trims the SortedList. - mySL->TrimToSize(); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "After TrimToSize," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); - - // Clears the SortedList. - mySL->Clear(); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); - - // Trims the SortedList again. - mySL->TrimToSize(); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "After the second TrimToSize," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -Initially, - Count : 5 - Capacity : 16 - Values: - -KEY- -VALUE- - five: jumps - four: fox - one: The - three: brown - two: quick - -After TrimToSize, - Count : 5 - Capacity : 5 - Values: - -KEY- -VALUE- - five: jumps - four: fox - one: The - three: brown - two: quick - -After Clear, - Count : 0 - Capacity : 16 - Values: - -KEY- -VALUE- - -After the second TrimToSize, - Count : 0 - Capacity : 16 - Values: - -KEY- -VALUE- - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp deleted file mode 100644 index e233d2f4884..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i, myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 2, "two" ); - mySL->Add( 4, "four" ); - mySL->Add( 1, "one" ); - mySL->Add( 3, "three" ); - mySL->Add( (int^)0, "zero" ); - - // Displays the values of the SortedList. - Console::WriteLine( "The SortedList contains the following values:" ); - PrintIndexAndKeysAndValues( mySL ); - - // Searches for a specific key. - int myKey = 2; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, mySL->ContainsKey( myKey ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); - myKey = 6; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, mySL->ContainsKey( myKey ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); - - // Searches for a specific value. - String^ myValue = "three"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, mySL->ContainsValue( myValue ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); - myValue = "nine"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, mySL->ContainsValue( myValue ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); -} - -/* -This code produces the following output. - -The SortedList contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 three - [4]: 4 four - -The key "2" is in the SortedList. -The key "6" is NOT in the SortedList. -The value "three" is in the SortedList. -The value "nine" is NOT in the SortedList. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 5bb708f958a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^ myArr, Char mySeparator ); -int main() -{ - - // Creates and initializes the source SortedList. - SortedList^ mySourceList = gcnew SortedList; - mySourceList->Add( 2, "cats" ); - mySourceList->Add( 3, "in" ); - mySourceList->Add( 1, "napping" ); - mySourceList->Add( 4, "the" ); - mySourceList->Add( 0, "three" ); - mySourceList->Add( 5, "barn" ); - - // Creates and initializes the one-dimensional target Array. - array^tempArray = {"The","quick","brown","fox","jumps","over","the","lazy","dog"}; - array^myTargetArray = gcnew array(15); - int i = 0; - IEnumerator^ myEnum = tempArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ s = safe_cast(myEnum->Current); - myTargetArray[ i ].Key = i; - myTargetArray[ i ].Value = s; - i++; - } - - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source SortedList to the target SortedList, starting at index 6. - mySourceList->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^ myArr, Char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ].Value ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp deleted file mode 100644 index 987dd455be0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 1.3, "fox" ); - mySL->Add( 1.4, "jumps" ); - mySL->Add( 1.5, "over" ); - mySL->Add( 1.2, "brown" ); - mySL->Add( 1.1, "quick" ); - mySL->Add( 1.0, "The" ); - mySL->Add( 1.6, "the" ); - mySL->Add( 1.8, "dog" ); - mySL->Add( 1.7, "lazy" ); - - // Gets the key and the value based on the index. - int myIndex = 3; - Console::WriteLine( "The key at index {0} is {1}.", myIndex, mySL->GetKey( myIndex ) ); - Console::WriteLine( "The value at index {0} is {1}.", myIndex, mySL->GetByIndex( myIndex ) ); - - // Gets the list of keys and the list of values. - IList^ myKeyList = mySL->GetKeyList(); - IList^ myValueList = mySL->GetValueList(); - - // Prints the keys in the first column and the values in the second column. - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < mySL->Count; i++ ) - Console::WriteLine( "\t{0}\t{1}", myKeyList[ i ], myValueList[ i ] ); -} - -/* -This code produces the following output. - -The key at index 3 is 1.3. -The value at index 3 is fox. - -KEY- -VALUE- - 1 The - 1.1 quick - 1.2 brown - 1.3 fox - 1.4 jumps - 1.5 over - 1.6 the - 1.7 lazy - 1.8 dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp deleted file mode 100644 index e9197a41dd1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i, myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 1, "one" ); - mySL->Add( 3, "three" ); - mySL->Add( 2, "two" ); - mySL->Add( 4, "four" ); - mySL->Add( 0, "zero" ); - - // Displays the values of the SortedList. - Console::WriteLine( "The SortedList contains the following values:" ); - PrintIndexAndKeysAndValues( mySL ); - - // Searches for a specific key. - int myKey = 2; - Console::WriteLine( "The key \"{0}\" is at index {1}.", myKey, mySL->IndexOfKey( myKey ) ); - - // Searches for a specific value. - String^ myValue = "three"; - Console::WriteLine( "The value \"{0}\" is at index {1}.", myValue, mySL->IndexOfValue( myValue ) ); -} - -/* -This code produces the following output. - -The SortedList contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 three - [4]: 4 four - -The key "2" is at index 2. -The value "three" is at index 3. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 3808b907c27..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 2, "two" ); - mySL->Add( 3, "three" ); - mySL->Add( 1, "one" ); - mySL->Add( (int^)0, "zero" ); - mySL->Add( 4, "four" ); - - // Creates a synchronized wrapper around the SortedList. - SortedList^ mySyncdSL = SortedList::Synchronized( mySL ); - - // Displays the sychronization status of both SortedLists. - Console::WriteLine( "mySL is {0}.", mySL->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdSL is {0}.", mySyncdSL->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* -This code produces the following output. - -mySL is not synchronized. -mySyncdSL is synchronized. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index fb191eafec5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesSortedList -{ -public: - static void Main() - { - // - SortedList^ myCollection = gcnew SortedList(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesSortedList::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp deleted file mode 100644 index 86e30997f0a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "3c", "dog" ); - mySL->Add( "2c", "over" ); - mySL->Add( "1c", "brown" ); - mySL->Add( "1a", "The" ); - mySL->Add( "1b", "quick" ); - mySL->Add( "3a", "the" ); - mySL->Add( "3b", "lazy" ); - mySL->Add( "2a", "fox" ); - mySL->Add( "2b", "jumps" ); - - // Displays the SortedList. - Console::WriteLine( "The SortedList initially contains the following:" ); - PrintKeysAndValues( mySL ); - - // Removes the element with the key "3b". - mySL->Remove( "3b" ); - - // Displays the current state of the SortedList. - Console::WriteLine( "After removing \"lazy\":" ); - PrintKeysAndValues( mySL ); - - // Removes the element at index 5. - mySL->RemoveAt( 5 ); - - // Displays the current state of the SortedList. - Console::WriteLine( "After removing the element at index 5:" ); - PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -The SortedList initially contains the following: - -KEY- -VALUE- - 1a: The - 1b: quick - 1c: brown - 2a: fox - 2b: jumps - 2c: over - 3a: the - 3b: lazy - 3c: dog - -After removing "lazy": - -KEY- -VALUE- - 1a: The - 1b: quick - 1c: brown - 2a: fox - 2b: jumps - 2c: over - 3a: the - 3c: dog - -After removing the element at index 5: - -KEY- -VALUE- - 1a: The - 1b: quick - 1c: brown - 2a: fox - 2b: jumps - 3a: the - 3c: dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp deleted file mode 100644 index 71da886cdc1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i, myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 2, "two" ); - mySL->Add( 3, "three" ); - mySL->Add( 1, "one" ); - mySL->Add( 0, "zero" ); - mySL->Add( 4, "four" ); - - // Displays the values of the SortedList. - Console::WriteLine( "The SortedList contains the following values:" ); - PrintIndexAndKeysAndValues( mySL ); - - // Replaces the values at index 3 and index 4. - mySL->SetByIndex( 3, "III" ); - mySL->SetByIndex( 4, "IV" ); - - // Displays the updated values of the SortedList. - Console::WriteLine( "After replacing the value at index 3 and index 4," ); - PrintIndexAndKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -The SortedList contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 three - [4]: 4 four - -After replacing the value at index 3 and index 4, - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 III - [4]: 4 IV -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp deleted file mode 100644 index fd38bcf4520..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "Hello" ); - myStack->Push( "World" ); - myStack->Push( "!" ); - - // Displays the properties and values of the Stack. - Console::WriteLine( "myStack" ); - Console::WriteLine( "\tCount: {0}", myStack->Count ); - Console::Write( "\tValues:" ); - PrintValues( myStack ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myStack - Count: 3 - Values: ! World Hello - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp deleted file mode 100644 index a60b6d00fde..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "The" ); - myStack->Push( "quick" ); - myStack->Push( "brown" ); - myStack->Push( "fox" ); - myStack->Push( "jumps" ); - - // Displays the count and values of the Stack. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myStack->Count ); - Console::Write( " Values:" ); - PrintValues( myStack ); - - // Clears the Stack. - myStack->Clear(); - - // Displays the count and values of the Stack. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myStack->Count ); - Console::Write( " Values:" ); - PrintValues( myStack ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Values: jumps fox brown quick The - After Clear, - Count : 0 - Values: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp deleted file mode 100644 index ae4b0f72df0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( Array^ myArr, char mySeparator ); -int main() -{ - // Creates and initializes the source Stack. - Stack^ mySourceQ = gcnew Stack; - mySourceQ->Push( "barn" ); - mySourceQ->Push( "the" ); - mySourceQ->Push( "in" ); - mySourceQ->Push( "cats" ); - mySourceQ->Push( "napping" ); - mySourceQ->Push( "three" ); - - // Creates and initializes the one-dimensional target Array. - Array^ myTargetArray = Array::CreateInstance( String::typeid, 15 ); - myTargetArray->SetValue( "The", 0 ); - myTargetArray->SetValue( "quick", 1 ); - myTargetArray->SetValue( "brown", 2 ); - myTargetArray->SetValue( "fox", 3 ); - myTargetArray->SetValue( "jumps", 4 ); - myTargetArray->SetValue( "over", 5 ); - myTargetArray->SetValue( "the", 6 ); - myTargetArray->SetValue( "lazy", 7 ); - myTargetArray->SetValue( "dog", 8 ); - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Stack to the target Array, starting at index 6. - mySourceQ->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Stack to a new standard array. - array^myStandardArray = mySourceQ->ToArray(); - - // Displays the values of the new standard array. - Console::WriteLine( "The new standard array contains the following:" ); - PrintValues( myStandardArray, ' ' ); -} - -void PrintValues( Array^ myArr, char mySeparator ) -{ - IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, myObj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - The new standard array contains the following: - three napping cats in the barn - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 7b964e928e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "The" ); - myStack->Push( "quick" ); - myStack->Push( "brown" ); - myStack->Push( "fox" ); - - // Creates a synchronized wrapper around the Stack. - Stack^ mySyncdStack = Stack::Synchronized( myStack ); - - // Displays the sychronization status of both Stacks. - Console::WriteLine( "myStack is {0}.", myStack->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdStack is {0}.", mySyncdStack->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* -This code produces the following output. - -myStack is not synchronized. -mySyncdStack is synchronized. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index d44a2d7b9a1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesStack -{ -public: - static void Main() - { - // - Stack^ myCollection = gcnew Stack(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesStack::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp deleted file mode 100644 index 1e77a8f04a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection, char mySeparator ); -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "The" ); - myStack->Push( "quick" ); - myStack->Push( "brown" ); - myStack->Push( "fox" ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); - - // Removes an element from the Stack. - Console::WriteLine( "(Pop)\t\t{0}", myStack->Pop() ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); - - // Removes another element from the Stack. - Console::WriteLine( "(Pop)\t\t{0}", myStack->Pop() ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); - - // Views the first element in the Stack but does not remove it. - Console::WriteLine( "(Peek)\t\t{0}", myStack->Peek() ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); -} - -void PrintValues( IEnumerable^ myCollection, char mySeparator ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Stack values: fox brown quick The - (Pop) fox - Stack values: brown quick The - (Pop) brown - Stack values: quick The - (Peek) quick - Stack values: quick The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp deleted file mode 100644 index 63fd237a4c2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Write ); - if ( fs->CanRead && fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt can be both written to and read from." ); - } - else - if ( fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt is writable." ); - } -} - -//This code outputs "MyFile.txt is writable." -//To get the output message "MyFile.txt can be both written to and read from.", -//change the FileAccess parameter to ReadWrite in the FileStream constructor. -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp deleted file mode 100644 index e644fe2a10f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -public ref class Block -{ -public: - static void Main() - { - Stream^ s = gcnew MemoryStream(); - for (int i = 0; i < 100; i++) - { - s->WriteByte((Byte)i); - } - s->Position = 0; - - // Now read s into a byte buffer. - array^ bytes = gcnew array(s->Length); - int numBytesToRead = (int) s->Length; - int numBytesRead = 0; - while (numBytesToRead > 0) - { - // Read may return anything from 0 to 10. - int n = s->Read(bytes, numBytesRead, 10); - // The end of the file is reached. - if (n == 0) - { - break; - } - numBytesRead += n; - numBytesToRead -= n; - } - s->Close(); - // numBytesToRead should be 0 now, and numBytesRead should - // equal 100. - Console::WriteLine("number of bytes read: {0:d}", numBytesRead); - } -}; - -int main() -{ - Block::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp deleted file mode 100644 index 035727fe0c6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - FileStream^ sb = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate ); - array^b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'}; - StreamWriter^ sw = gcnew StreamWriter( sb ); - sw->Write( b, 3, 8 ); - sw->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp deleted file mode 100644 index cf774966a53..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -public ref class SomeClass -{ -// -private: - static BooleanSwitch^ boolSwitch = gcnew BooleanSwitch("mySwitch", - "Switch in config file"); - -public: - static void Main( ) - { - //... - Console::WriteLine("Boolean switch {0} configured as {1}", - boolSwitch->DisplayName, ((Boolean^)boolSwitch->Enabled)->ToString()); - if (boolSwitch->Enabled) - { - //... - } - } -// -}; - -int main() -{ - SomeClass::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp deleted file mode 100644 index 35f255928a0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -// -// The following are possible values for the new switch. -public enum class MethodTracingSwitchLevel -{ - Off = 0, - EnteringMethod = 1, - ExitingMethod = 2, - Both = 3 -}; - - -// -// -public ref class MyMethodTracingSwitch: public Switch -{ -protected: - bool outExit; - bool outEnter; - MethodTracingSwitchLevel level; - -public: - MyMethodTracingSwitch( String^ displayName, String^ description ) - : Switch( displayName, description ) - {} - - property MethodTracingSwitchLevel Level - { - MethodTracingSwitchLevel get() - { - return level; - } - - void set( MethodTracingSwitchLevel value ) - { - SetSwitchSetting( (int)value ); - } - } - -protected: - void SetSwitchSetting( int value ) - { - if ( value < 0 ) - { - value = 0; - } - - if ( value > 3 ) - { - value = 3; - } - - level = (MethodTracingSwitchLevel)value; - outEnter = false; - if ((value == (int)MethodTracingSwitchLevel::EnteringMethod) || - (value == (int)MethodTracingSwitchLevel::Both)) - { - outEnter = true; - } - - outExit = false; - if ((value == (int)MethodTracingSwitchLevel::ExitingMethod) || - (value == (int)MethodTracingSwitchLevel::Both)) - { - outExit = true; - } - } - -public: - property bool OutputExit - { - bool get() - { - return outExit; - } - } - - property bool OutputEnter - { - bool get() - { - return outEnter; - } - } -}; - - -// -// -public ref class Class1 -{ -private: - - /* Create an instance of MyMethodTracingSwitch.*/ - static MyMethodTracingSwitch^ mySwitch = - gcnew MyMethodTracingSwitch( "Methods","Trace entering and exiting method" ); - -public: - static void main() - { - // Add the console listener to see trace messages as console output - Trace::Listeners->Add(gcnew ConsoleTraceListener(true)); - Debug::AutoFlush = true; - - // Set the switch level to both enter and exit - mySwitch->Level = MethodTracingSwitchLevel::Both; - - // Write a diagnostic message if the switch is set to entering. - Debug::WriteLineIf(mySwitch->OutputEnter, "Entering Main"); - - // Insert code to handle processing here... - - // Write another diagnostic message if the switch is set to exiting. - Debug::WriteLineIf(mySwitch->OutputExit, "Exiting Main"); - } -}; -// - -int main() -{ - Class1::main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp deleted file mode 100644 index 830c7d9c618..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -// -void main() -{ - #if defined(TRACE) - // Create a file for output named TestFile.txt. - Stream^ myFile = File::Create( "TestFile.txt" ); - - // Create a new text writer using the output stream and - // add it to the trace listeners. - TextWriterTraceListener^ myTextListener = - gcnew TextWriterTraceListener( myFile ); - Trace::Listeners->Add( myTextListener ); - - // Write output to the file. - Trace::Write( "Test output " ); - - // Flush the output. - Trace::Flush(); - Trace::Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp deleted file mode 100644 index e338a01270a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -void main() -{ - #if defined(TRACE) - TextWriterTraceListener^ myTextListener = nullptr; - - // Create a file for output named TestFile.txt. - String^ myFileName = "TestFile.txt"; - StreamWriter^ myOutputWriter = gcnew StreamWriter( myFileName,true ); - - // Add a TextWriterTraceListener for the file. - if ( myOutputWriter ) - { - myTextListener = gcnew TextWriterTraceListener( myOutputWriter ); - Trace::Listeners->Add( myTextListener ); - } - - // Write trace output to all trace listeners. - Trace::WriteLine( - String::Concat( DateTime::Now.ToString(), " - Trace output" ) ); - if ( myTextListener ) - { - // Remove and close the file writer/trace listener. - myTextListener->Flush(); - Trace::Listeners->Remove( myTextListener ); - myTextListener->Close(); - } - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp deleted file mode 100644 index a8af3ae4585..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -// -void main() -{ - #if defined(TRACE) - // Create a text writer that writes to the console screen and add - // it to the trace listeners. - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - - // Write the output to the console screen. - myWriter->Write( "Write to console screen. " ); - myWriter->WriteLine( "Again, write to the Console screen." ); - - // Flush and close the output. - myWriter->Flush(); - myWriter->Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp deleted file mode 100644 index 17598cbac6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -// -void main() -{ - #if defined(TRACE) - // Create a text writer that writes to the console screen and add - // it to the trace listeners. - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - - // Write the output to the console screen. - myWriter->Write( "Write to the Console screen. " ); - myWriter->WriteLine( "Again, write to console screen." ); - - // Flush and close the output. - myWriter->Flush(); - myWriter->Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp deleted file mode 100644 index aed5e7442ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Sample -{ -protected: - void Method() - { - // - #if defined(TRACE) - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - #endif - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp deleted file mode 100644 index bfaeea7c89b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// Specify /DTRACE when compiling. - -#using -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - #if defined(TRACE) - Trace::Listeners->Add( gcnew TextWriterTraceListener( Console::Out ) ); - Trace::AutoFlush = true; - Trace::Indent(); - Trace::WriteLine( "Entering Main" ); - #endif - Console::WriteLine( "Hello World." ); - #if defined(TRACE) - Trace::WriteLine( "Exiting Main" ); - Trace::Unindent(); - #endif - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp deleted file mode 100644 index bf1accda6fd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -protected: - // Create an index for an array. - int index; - - void Method() - { - // Perform some action that sets the index. - // Test that the index value is valid. - #if defined(TRACE) - Trace::Assert( index > -1 ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp deleted file mode 100644 index b8c99bf228b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -public: - static void MyMethod( Type^ type, Type^ baseType ) - { - #if defined(TRACE) - Trace::Assert( type != nullptr, "Type parameter is null" ); - #endif - - // Perform some processing. - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp deleted file mode 100644 index 862da8804df..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -public: - static void MyMethod( Type^ type, Type^ baseType ) - { - #if defined(TRACE) - Trace::Assert( type != nullptr, "Type parameter is null", "Can't get object for null type" ); - #endif - - // Perform some processing. - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp deleted file mode 100644 index 7f8c353e0c2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - enum class Option - { - First, Second - }; - -protected: - double result; - -public: - void Method( Option option ) - { - try - { - // try something here - } - // - catch ( Exception^ ) - { - #if defined(TRACE) - Trace::Fail( "Unknown Option " + option + ", using the default." ); - #endif - } - // - - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(TRACE) - Trace::Fail(String::Format("Unknown Option {0}", option)); - #endif - result = 1.0; - break; - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp deleted file mode 100644 index 377a4428493..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - enum class Option - { - First, Second - }; - -protected: - double result; - -public: - void Method( Option option, String^ userInput ) - { - int value = 0; - int newValue = 1; - try - { - value = Int32::Parse( userInput ); - } - // - catch ( Exception^ ) - { - #if defined(TRACE) - Trace::Fail( String::Format( "Invalid value: {0}", value ), - "Resetting value to newValue." ); - #endif - value = newValue; - } - // - - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(TRACE) - Trace::Fail( String::Format( "Unsupported option {0}", option ), - "Result set to 1.0" ); - #endif - result = 1.0; - break; - } - // - } - -}; - -void main() -{ - Form1^ myForm = gcnew Form1; - myForm->Method( Form1::Option::Second, "not an integer string" ); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp deleted file mode 100644 index 00e2126d795..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Specify /DTRACE when compiling. - -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -void main() -{ - #if defined(TRACE) - // Create a file for output named TestFile.txt. - FileStream^ myFileStream = - gcnew FileStream( "TestFile.txt", FileMode::Append ); - - // Create a new text writer using the output stream - // and add it to the trace listeners. - TextWriterTraceListener^ myTextListener = - gcnew TextWriterTraceListener( myFileStream ); - Trace::Listeners->Add( myTextListener ); - - // Write output to the file. - Trace::WriteLine( "Test output" ); - - // Flush and close the output stream. - Trace::Flush(); - Trace::Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp deleted file mode 100644 index 8465839ad87..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - Trace::WriteLine( "List of errors:" ); - Trace::Indent(); - Trace::WriteLine( "Error 1: File not found" ); - Trace::WriteLine( "Error 2: Directory not found" ); - Trace::Unindent(); - Trace::WriteLine( "End of list of errors" ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp deleted file mode 100644 index aaba2c756c3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Class1 -{ -public: - void Method() - { - // - // Create a ConsoletTraceListener and add it to the trace listeners. - #if defined(TRACE) - ConsoleTraceListener^ myWriter = gcnew ConsoleTraceListener( ); - Trace::Listeners->Add( myWriter ); - #endif - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp deleted file mode 100644 index b5c173d444f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set - // to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "My error message. " ); - } - - // Write a second message if the TraceSwitch level is set - // to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( "My second error message." ); - } - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp deleted file mode 100644 index 6aa428982f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( myObject ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( " is not a valid value for this method." ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp deleted file mode 100644 index c37eb6cb2bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::Write( String::Concat( myObject, - " is not a valid object for category: " ), category ); - } - - // Write a second message if the TraceSwitch level is set to - // Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::WriteLine( " Please use a different category." ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp deleted file mode 100644 index 815cd36e34c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::Write( myObject, category ); - } - - // Write a second message if the TraceSwitch level is set to - // Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::WriteLine( " Object is not valid for this category." ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp deleted file mode 100644 index 49f4eaff259..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod() - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to - // Error or higher. - Trace::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message." ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp deleted file mode 100644 index 14dfd2e3487..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, myObject ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - " is not a valid value for this method." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp deleted file mode 100644 index fa99d333ccc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - Trace::WriteIf( generalSwitch->TraceVerbose, - String::Concat( myObject, - " is not a valid object for category: " ), category ); - - // Write a second message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteLineIf( generalSwitch->TraceError, - " Please use a different category." ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp deleted file mode 100644 index 7b433a3415c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - Trace::WriteIf( generalSwitch->TraceVerbose, myObject, category ); - - // Write a second message if the TraceSwitch level is set to - // Error or higher. - Trace::WriteLineIf( generalSwitch->TraceError, - " Object is not valid for this category." ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp deleted file mode 100644 index 69e7837f9bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "Invalid object. " ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( myObject ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp deleted file mode 100644 index 408ce11e5e2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "My error message. " ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( "My second error message.", category ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp deleted file mode 100644 index 9b663621991..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "Invalid object for category. " ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( myObject, category ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp deleted file mode 100644 index e0248f58cc3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, "Invalid object. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, myObject ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp deleted file mode 100644 index f0ced96de43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message.", category ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp deleted file mode 100644 index 3b1d19efcba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, - "Invalid object for category. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - myObject, category ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp deleted file mode 100644 index 0839abd6837..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - /* Create a listener, which outputs to the console screen, and - * add it to the trace listeners. */ - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp deleted file mode 100644 index f2af2f1ef67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "mySwitch","Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( mySwitch->TraceError ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp deleted file mode 100644 index 1c6a7b5ea20..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; - -public ref class TraceErr -{ -// -private: - static TraceSwitch^ appSwitch = gcnew TraceSwitch("mySwitch", - "Switch in config file"); - -public: - static void Main(array^ args) - { - //... - Console::WriteLine("Trace switch {0} configured as {1}", - appSwitch->DisplayName, appSwitch->Level.ToString()); - if (appSwitch->TraceError) - { - //... - } - } -// -}; - -int main() -{ - array^ args = gcnew array{}; - TraceErr::Main(args); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp deleted file mode 100644 index 7806bc0fb37..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( mySwitch->TraceError ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp deleted file mode 100644 index b3d9962e4cc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Info or higher. - if ( mySwitch->TraceInfo ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp deleted file mode 100644 index 9135da63a48..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Warning or higher. - if ( mySwitch->TraceWarning ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp b/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp deleted file mode 100644 index 6f8b7354593..00000000000 --- a/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -using namespace System; -using namespace System::Runtime::ConstrainedExecution; - -[assembly:ReliabilityContractAttribute( - Consistency::MayCorruptInstance, Cer::None)]; -namespace ReliabilityLibrary -{ - class SomeClass {}; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp deleted file mode 100644 index 56d68e22b91..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -#using - -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Net; -using namespace System; - -// -//Uses the DnsPermissionAttribute to restrict access only to those who have permission. - -[DnsPermission(SecurityAction::Demand,Unrestricted=true)] -public ref class MyClass -{ -public: - static IPAddress^ GetIPAddress() - { - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - return ipAddress; - } - -}; - -int main() -{ - try - { - - //Grants Access. - Console::WriteLine( " Access granted\n The local host IP Address is :{0}", MyClass::GetIPAddress() ); - } - // Denies Access. - catch ( SecurityException^ securityException ) - { - Console::WriteLine( "Access denied" ); - Console::WriteLine( securityException->ToString() ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp deleted file mode 100644 index 4613eef8236..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -using namespace System; -using namespace System::Runtime::Serialization; - -// Class added so sample will compile -ref class Node -{ -public: - Node( int /*i*/ ){} -}; - -// -// A serializable LinkedList example. For the full LinkedList implementation -// see the Serialization sample. -[Serializable] -ref class LinkedList: public ISerializable -{ -private: - Node^ m_head; - Node^ m_tail; - - // Serializes the object. -public: - virtual void GetObjectData( SerializationInfo^ info, StreamingContext /*context*/ ) - { - // Stores the m_head and m_tail references in the SerializationInfo info. - info->AddValue( "head", m_head, m_head->GetType() ); - info->AddValue( "tail", m_tail, m_tail->GetType() ); - } - - // Constructor that is called automatically during deserialization. -private: - // Reconstructs the object from the information in SerializationInfo info - LinkedList( SerializationInfo^ info, StreamingContext /*context*/ ) - { - Node^ temp = gcnew Node( 0 ); - // Retrieves the values of Type temp.GetType() from SerializationInfo info - m_head = dynamic_cast(info->GetValue( "head", temp->GetType() )); - m_tail = dynamic_cast(info->GetValue( "tail", temp->GetType() )); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp deleted file mode 100644 index 1b5f86b7e5c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -This program demonstrates the 'SocketPermission(PermissionState)', -'SocketPermission(NetworkAccess, TransportType, String*, int) constructors, -'FromXml', 'Intersect', 'AddPermission' methods and 'AllPorts' field -of 'SocketPermission' class. - -This program provides a class called 'DateClient' that functions as a client -for a 'DateServer'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateClient' class -provides a method called 'GetDate' which returns the current date on the server. -The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -TransportType, String*, int)' constructor. A third 'SocketPermission' Object* is -formed from the intersection of the above two 'SocketPermission' objects with the -use of the 'Intersect' method of 'SocketPermission' class. This 'SocketPermission' -Object* is used by the 'GetDate' method to verify the permissions of the calling -method. If the calling method has the requisite permissions the 'GetDate' method -connects to the 'DateServer' and returns the current date that the 'DateServer' -sends. If any exception occurs the 'GetDate' method returns an empty String*. - -Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Security; -using namespace System::Security::Permissions; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateClient_SocketPermission_Constructor" ); - Console::WriteLine( "\tDateClient_SocketPermission_Constructor " ); - Console::WriteLine( "\tThe ipaddress argument is the ip address of the Date server." ); - Console::WriteLine( "\tThe port argument is the port of the Date server." ); -} - -public ref class DateClient -{ -private: - Socket^ serverSocket; - Encoding^ asciiEncoding; - IPAddress^ serverAddress; - - int serverPort; - -public: - // The constructor takes the address and port of the remote server. - DateClient( IPAddress^ ipAddress, int port ) - { - serverAddress = ipAddress; - serverPort = port; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - asciiEncoding = Encoding::ASCII; - } - - String^ GetDate() - { -// -// -// -// -// -// - SocketPermission^ socketPermission1 = gcnew SocketPermission( PermissionState::Unrestricted ); - - // Create a 'SocketPermission' Object* for two ip addresses. - SocketPermission^ socketPermission2 = gcnew SocketPermission( PermissionState::None ); - SecurityElement^ securityElement1 = socketPermission2->ToXml(); - // 'SocketPermission' Object* for 'Connect' permission - SecurityElement^ securityElement2 = gcnew SecurityElement( "ConnectAccess" ); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All'ports for the ip-address. - SecurityElement^ securityElement3 = gcnew SecurityElement( "URI","192.168.144.238#-1#3" ); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and - // for 'All' ports for the ip-address. - SecurityElement^ securityElement4 = gcnew SecurityElement( "URI","192.168.144.240#-1#3" ); - securityElement2->AddChild( securityElement3 ); - securityElement2->AddChild( securityElement4 ); - securityElement1->AddChild( securityElement2 ); - - // Obtain a 'SocketPermission' Object* using 'FromXml' method. - socketPermission2->FromXml( securityElement1 ); - - Console::WriteLine( "\nDisplays the result of FromXml method : \n" ); - Console::WriteLine( socketPermission2 ); - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission^ socketPermission3 = - gcnew SocketPermission( NetworkAccess::Connect, - TransportType::All, - "192.168.144.238", - SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3->AddPermission( NetworkAccess::Connect, - TransportType::All, - "192.168.144.239", - SocketPermission::AllPorts ); - - Console::WriteLine( "Displays the result of AddPermission method : \n" ); - Console::WriteLine( socketPermission3 ); - - // Find the intersection between two 'SocketPermission' objects. - socketPermission1 = dynamic_cast(socketPermission2->Intersect( socketPermission3 )); - - Console::WriteLine( "Displays the result of Intersect method :\n " ); - Console::WriteLine( socketPermission1 ); - - // Demand that the calling method have the requsite socket permission. - socketPermission1->Demand(); -// -// -// -// -// -// - // Get the current date from the remote date server. - try - { - int bytesReceived; - array^getByte = gcnew array(100); - serverSocket->Connect( gcnew IPEndPoint( serverAddress,serverPort ) ); - bytesReceived = serverSocket->Receive( getByte, getByte->Length, SocketFlags::None ); - return asciiEncoding->GetString( getByte, 0, bytesReceived ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return ""; - } - } -}; - -// demonstrates the caller of the 'GetDate' method for the 'DateClient' object. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 2 ) - { - PrintUsage(); - return 0; - } - - try - { - DateClient^ myDateClient = gcnew DateClient( IPAddress::Parse( args[ 0 ] ),Int32::Parse( args[ 1 ] ) ); - String^ currentDate = myDateClient->GetDate(); - Console::WriteLine( "The current date and time is : " ); - Console::WriteLine( " {0}", currentDate ); - } - // This exception is thrown by the called method in the context of improper permissions. - catch ( SecurityException^ e ) - { - Console::WriteLine( "\nSecurityException raised : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp b/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp deleted file mode 100644 index 427b6c42002..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -This program demonstrates the 'ToXml' and 'IsUnrestricted' method and 'ConnectList' property of -'SocketPermission' class. - -This program provides a class called 'DateClient' that functions as a client -for a 'DateServer'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateClient' class -provides a method called 'GetDate' which returns the current date on the server. -The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -TransportType, String*, int)' constructor. A third 'SocketPermission' Object* is -formed from the union of the above two 'SocketPermission' objects with the use of the -'Union' method of 'SocketPermission' class. This 'SocketPermission' Object* is used by -the 'GetDate' method to verify the permissions of the calling method. If the calling -method has the requisite permissions the 'GetDate' method connects to the 'DateServer' -and returns the current date that the 'DateServer' sends. If any exception occurs -the 'GetDate' method returns an empty String*. - -Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Security; -using namespace System::Security::Permissions; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateClient_SocketPermission_ToXml" ); - Console::WriteLine( "\tDateClient_SocketPermission_ToXml " ); - Console::WriteLine( "\tThe ipaddress argument is the ip address of the Date server." ); - Console::WriteLine( "\tThe port argument is the port of the Date server." ); -} - -public ref class DateClient -{ -private: - Socket^ serverSocket; - Encoding^ asciiEncoding; - IPAddress^ serverAddress; - int serverPort; - - // The constructor takes the address and port of the remote server. -public: - DateClient( IPAddress^ serverIpAddress, int port ) - { - serverAddress = serverIpAddress; - serverPort = port; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - asciiEncoding = Encoding::ASCII; - } - -private: - - // Print a security element and all its children, in a depth-first manner. - void PrintSecurityElement( SecurityElement^ securityElementObj, int depth ) - { - Console::WriteLine( "Depth : {0}", depth ); - Console::WriteLine( "Tag : {0}", securityElementObj->Tag ); - Console::WriteLine( "Text : {0}", securityElementObj->Text ); - if ( securityElementObj->Children != nullptr ) - Console::WriteLine( "Children : {0}", securityElementObj->Children->Count ); - - if ( securityElementObj->Attributes != nullptr ) - { - IEnumerator^ attributeEnumerator = securityElementObj->Attributes->GetEnumerator(); - while ( attributeEnumerator->MoveNext() ) - Console::WriteLine( "Attribute - \" {0}\" , Value - \" {1}\"", (dynamic_cast(attributeEnumerator))->Key, (dynamic_cast(attributeEnumerator))->Value ); - } - - Console::WriteLine( "" ); - if ( securityElementObj->Children != nullptr ) - { - depth += 1; - for ( int i = 0; i < securityElementObj->Children->Count; i++ ) - PrintSecurityElement( dynamic_cast(securityElementObj->Children[ i ]), depth ); - } - } - - -public: - String^ GetDate() - { - // - // - // - SocketPermission^ socketPermission1 = gcnew SocketPermission( PermissionState::Unrestricted ); - - // Create a 'SocketPermission' Object* for two ip addresses. - SocketPermission^ socketPermission2 = gcnew SocketPermission( PermissionState::None ); - SecurityElement^ securityElement4 = socketPermission2->ToXml(); - - // 'SocketPermission' Object* for 'Connect' permission - SecurityElement^ securityElement1 = gcnew SecurityElement( "ConnectAccess" ); - - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement^ securityElement2 = gcnew SecurityElement( "URI","192.168.144.238#-1#3" ); - - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement^ securityElement3 = gcnew SecurityElement( "URI","192.168.144.240#-1#3" ); - securityElement1->AddChild( securityElement2 ); - securityElement1->AddChild( securityElement3 ); - securityElement4->AddChild( securityElement1 ); - - // Obtain a 'SocketPermission' Object* using 'FromXml' method. - socketPermission2->FromXml( securityElement4 ); - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission^ socketPermission3 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::All,"192.168.144.238",SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3->AddPermission( NetworkAccess::Connect, TransportType::All, "192.168.144.239", SocketPermission::AllPorts ); - Console::WriteLine( "\nChecks the Socket permissions using IsUnrestricted method : " ); - if ( socketPermission1->IsUnrestricted() ) - Console::WriteLine( "Socket permission is unrestricted" ); - else - Console::WriteLine( "Socket permission is restricted" ); - - Console::WriteLine(); - Console::WriteLine( "Display result of ConnectList property : \n" ); - IEnumerator^ enumerator = socketPermission3->ConnectList; - while ( enumerator->MoveNext() ) - { - Console::WriteLine( "The hostname is : {0}", dynamic_cast(enumerator->Current)->Hostname ); - Console::WriteLine( "The port is : {0}", dynamic_cast(enumerator->Current)->Port ); - Console::WriteLine( "The Transport type is : {0}", dynamic_cast(enumerator->Current)->Transport ); - } - - Console::WriteLine( "" ); - Console::WriteLine( "Display Security Elements :\n " ); - PrintSecurityElement( socketPermission2->ToXml(), 0 ); - - // Get a 'SocketPermission' Object* which is a union of two other 'SocketPermission' objects. - socketPermission1 = dynamic_cast(socketPermission3->Union( socketPermission2 )); - - // Demand that the calling method have the socket permission. - socketPermission1->Demand(); - // - // - // - - // Get the current date from the remote date server. - try - { - int bytesReceived; - array^getByte = gcnew array(100); - serverSocket->Connect( gcnew IPEndPoint( serverAddress,serverPort ) ); - bytesReceived = serverSocket->Receive( getByte, getByte->Length, static_cast(0) ); - return asciiEncoding->GetString( getByte, 0, bytesReceived ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return ""; - } - } -}; - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' Object*. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 2 ) - { - PrintUsage(); - return 0; - } - - try - { - DateClient^ myDateClient = gcnew DateClient( IPAddress::Parse( args[ 0 ] ),Int32::Parse( args[ 1 ] ) ); - String^ currentDate = myDateClient->GetDate(); - Console::WriteLine( "The current date and time is : " ); - Console::WriteLine( " {0}", currentDate ); - } - // This exception is thrown by the called method in the context of improper permissions. - catch ( SecurityException^ e ) - { - Console::WriteLine( "\nSecurityException raised : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp b/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp deleted file mode 100644 index 9e6468dcd8f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// NCLMailPerms -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Security::Permissions; - -namespace SmtpPermissionsExamples -{ - public ref class TestSmtpPermissions - { - public: - // - static SmtpPermission^ CreateConnectPermission() - { - SmtpPermission^ connectAccess = - gcnew SmtpPermission(SmtpAccess::Connect); - Console::WriteLine("Access? {0}", connectAccess->Access); - return connectAccess; - } - // - - // - static SmtpPermission^ CreateUnrestrictedPermission() - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - Console::WriteLine("Is unrestricted? {0}", - allAccess->IsUnrestricted()); - return allAccess; - } - // - - // - static SmtpPermission^ CreatePermissionCopy(SmtpPermission^ p) - { - SmtpPermission^ copy = (SmtpPermission^) p->Copy(); - return copy; - } - // - - // - static SmtpPermission^ CreateUnrestrictedPermission2() - { - SmtpPermission^ allAccess = gcnew SmtpPermission(true); - Console::WriteLine("Is unrestricted? {0}", - allAccess->IsUnrestricted()); - return allAccess; - } - // - - // - static SmtpPermission^ GiveFullAccess( - SmtpPermission^ permission) - { - permission->AddPermission(SmtpAccess::Connect); - return permission; - } - // - - // - static SmtpPermission^ IntersectionWithFull( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return (SmtpPermission^) permission->Intersect(allAccess); - } - // - - // - static bool CheckSubSet( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return permission->IsSubsetOf(allAccess); - } - // - - // - static SmtpPermission^ UnionWithFull( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return (SmtpPermission^) permission->Union(allAccess); - } - // - }; -}; - -int main() -{ -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp b/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp deleted file mode 100644 index c38764723e0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// NclNetworkInfoPerms -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -static void CreatePermission() -{ - - // - // - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ unrestricted = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::Unrestricted ); - - // - Console::WriteLine( L"Is unrestricted? {0}", unrestricted->IsUnrestricted() ); - - // - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ read = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read ); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ copyPermission = dynamic_cast(read->Copy()); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ unionPermission = dynamic_cast(read->Union( unrestricted )); - Console::WriteLine( L"Is subset?{0}", read->IsSubsetOf( unionPermission ) ); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ intersectPermission = dynamic_cast(read->Intersect( unrestricted )); - - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ permission = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::None ); - permission->AddPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read ); - Console::WriteLine( L"Access is {0}", permission->Access ); - - // -} - -int main() -{ - CreatePermission(); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp deleted file mode 100644 index 252b3995880..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Security::Permissions; -using namespace System::Collections; - -void MySocketPermission() -{ -// -// - // Creates a SocketPermission restricting access to and from all URIs. - SocketPermission^ mySocketPermission1 = gcnew SocketPermission( PermissionState::None ); - - // The socket to which this permission will apply will allow connections from www.contoso.com. - mySocketPermission1->AddPermission( NetworkAccess::Accept, TransportType::Tcp, "www.contoso.com", 11000 ); - - // Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com. - SocketPermission^ mySocketPermission2 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::Tcp, "www.southridgevideo.com",11002 ); - - // Creates a SocketPermission from the union of two SocketPermissions. - SocketPermission^ mySocketPermissionUnion = - (SocketPermission^)( mySocketPermission1->Union( mySocketPermission2 ) ); - - // Checks to see if the union was successfully created by using the IsSubsetOf method. - if ( mySocketPermission1->IsSubsetOf( mySocketPermissionUnion ) && - mySocketPermission2->IsSubsetOf( mySocketPermissionUnion ) ) - { - Console::WriteLine( "This union contains permissions from both mySocketPermission1 and mySocketPermission2" ); - - // Prints the allowable accept URIs to the console. - Console::WriteLine( "This union accepts connections on :" ); - - IEnumerator^ myEnumerator = mySocketPermissionUnion->AcceptList; - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( safe_cast( myEnumerator->Current )->ToString() ); - } - - // Prints the allowable connect URIs to the console. - Console::WriteLine( "This union permits connections to :" ); - - myEnumerator = mySocketPermissionUnion->ConnectList; - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( safe_cast( myEnumerator->Current )->ToString() ); - } - } -// - -// - // Creates a SocketPermission from the intersect of two SocketPermissions. - SocketPermission^ mySocketPermissionIntersect = - (SocketPermission^)( mySocketPermission1->Intersect( mySocketPermissionUnion ) ); - - // mySocketPermissionIntersect should now contain the permissions of mySocketPermission1. - if ( mySocketPermission1->IsSubsetOf( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "This is expected" ); - } - - // mySocketPermissionIntersect should not contain the permissios of mySocketPermission2. - if ( mySocketPermission2->IsSubsetOf( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "This should not print" ); - } -// - -// - // Creates a copy of the intersect SocketPermission. - SocketPermission^ mySocketPermissionIntersectCopy = - (SocketPermission^)( mySocketPermissionIntersect->Copy() ); - if ( mySocketPermissionIntersectCopy->Equals( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "Copy successfull" ); - } -// - - // Converts a SocketPermission to XML format and then immediately converts it back to a SocketPermission. - mySocketPermission1->FromXml( mySocketPermission1->ToXml() ); - - // Checks to see if permission for this socket resource is unrestricted. If it is, then there is no need to - // demand that permissions be enforced. - if ( mySocketPermissionUnion->IsUnrestricted() ) - { - //Do nothing. There are no restrictions. - } - else - { - // Enforces the permissions found in mySocketPermissionUnion on any Socket Resources used below this statement. - mySocketPermissionUnion->Demand(); - } - - IPHostEntry^ myIpHostEntry = Dns::Resolve( "www.contoso.com" ); - IPEndPoint^ myLocalEndPoint = gcnew IPEndPoint( myIpHostEntry->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( myLocalEndPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - s->Connect( myLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::Write( "Exception Thrown: " ); - Console::WriteLine( e->ToString() ); - } - - // Perform all socket operations in here. - s->Close(); -// -} - -int main() -{ - MySocketPermission(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp deleted file mode 100644 index f4e56ffd6bf..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -/* -* Demonstrate how to use the WebPermissionAttribute to specify the Accept property. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - // Deny access to a specific resource by setting the Accept property. - [method:WebPermission(SecurityAction::Deny,Accept="http://www.contoso.com/Private.htm")] - - static void CheckAcceptPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Accept, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - // Pass the security check when accessing allowed resources. - CheckAcceptPermission( "http://www.contoso.com/" ); - Console::WriteLine( "Public page has passed Accept permission check" ); - - try - { - // Throw a SecurityException when trying to access not allowed resources. - CheckAcceptPermission( "http://www.contoso.com/Private.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Exception trying to access private resource: {0}", e->Message ); - } - } -// -}; - -int main() -{ - WebPermissionAttribute_AcceptConnect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp deleted file mode 100644 index 05d097162a9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -// Demonstrate how to use the WebPermissionAttribute to specify an allowable ConnectPattern. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -// -public: - // Deny access to a specific resource by setting the ConnectPattern property. - [method:WebPermission(SecurityAction::Deny,ConnectPattern="http://www.contoso.com/")] - - void Connect() - { - // Create a Connection. - HttpWebRequest^ myWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://www.contoso.com" )); - Console::WriteLine( "This line should never be printed" ); - } -// -// -}; - -int main() -{ - try - { - WebPermissionAttribute_AcceptConnect^ myWebAttrib = gcnew WebPermissionAttribute_AcceptConnect; - myWebAttrib->Connect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Security Exception raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp deleted file mode 100644 index fd594b719b1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -/* -This program demonstrates the 'Connect' and 'Accept' properties of the class 'WebPermissionAttribute'. -The program uses declarative security for calling the code in 'Connect' method. -By using the 'Accept' and 'Connect' properties of 'WebPermissionAttribute' accept and connect access -has been given to the uri www.contoso.com. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Text::RegularExpressions; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - [method:WebPermission(SecurityAction::Deny,AcceptPattern="http://www\\.contoso\\.com/Private/.*")] - static void CheckAcceptPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Accept, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - // Passes a security check. - CheckAcceptPermission( "http://www.contoso.com/Public/page.htm" ); - Console::WriteLine( "Public page has passed Accept permission check" ); - - try - { - // Throws a SecurityException. - CheckAcceptPermission( "http://www.contoso.com/Private/page.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception: {0}", e->Message ); - } - } -// -}; - -int main() -{ - WebPermissionAttribute_AcceptConnect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp deleted file mode 100644 index d369bcc8ee1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::connect; - -// Demonstrate how to use the WebPermissionAttribute Connect property. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_Connect -{ -// -public: - // Set the WebPermissionAttribute Connect property. - [method:WebPermission(SecurityAction::Deny,Connect="http://www.contoso.com/Private.htm")] - - static void demoDenySite() - { - //Pass the security check. - CheckConnectPermission( "http://www.contoso.com/Public.htm" ); - Console::WriteLine( "Public page has passed connect permission check" ); - - try - { - //Throw a SecurityException. - CheckConnectPermission( "http://www.contoso.com/Private.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception {0}", e->Message ); - } - } - - static void CheckConnectPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Connect, uriToCheck ); - permissionToCheck->Demand(); - } -// -}; - -int main() -{ - WebPermissionAttribute_Connect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp deleted file mode 100644 index 648da93ee85..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Connect; - -// Demonstrate how to use the WebPermissionAttribute ConnectPattern property. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Text::RegularExpressions; - -public ref class WebPermissionAttribute_Connect -{ -// -public: - // Set the WebPermissionAttribute ConnectPattern property. - [WebPermission(SecurityAction::Deny,ConnectPattern="http://www\\.contoso\\.com/Private/.*")] - - static void CheckConnectPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Connect, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - //Pass the security check. - CheckConnectPermission( "http://www.contoso.com/Public/page.htm" ); - Console::WriteLine( "Public page has passed Connect permission check" ); - - try - { - //Throw a SecurityException. - CheckConnectPermission( "http://www.contoso.com/Private/page.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception {0}", e->Message ); - } - } -}; -// - -int main() -{ - WebPermissionAttribute_Connect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp deleted file mode 100644 index 8606c8f6c78..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - // Set the declarative security for the URI. - [WebPermission(SecurityAction::Deny,Connect="http://www.contoso.com/")] - void Connect() - { - // Throw an exception. - try - { - HttpWebRequest^ myWebRequest = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e ); - } -// - } -}; - -int main() -{ - try - { - WebPermissionAttribute_AcceptConnect^ myWebAttrib = gcnew WebPermissionAttribute_AcceptConnect; - myWebAttrib->Connect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Security Exception raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp deleted file mode 100644 index df794666883..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp +++ /dev/null @@ -1,99 +0,0 @@ - - -// System::Net::WebPermission::ConnectList;System::Net::WebPermission::AcceptList; -/** -* This program demonstrates the use of the ConnectList and AcceptList WebPermission -* class prerties. -* It first creates a WebPermission object with Permissionstate set to None and then -* sets the Connect and Accept access right to some predefined URLs. -* The using the AcceptList and ConnectList properties it displays the URLs that have -* the Accept and Connect permission set, respectively. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class WebPermission_AcceptConnectList -{ -public: - void DisplayAcceptConnect() - { - // Create a 'WebPermission' object with permission state set to 'None'. - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Allow 'Connect' access right to first set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.contoso.com" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.alpineskihouse.com" ); - - // Allow 'Accept' access right to second set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.contoso.com" ); - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.adventure-works.com" ); - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.alpineskihouse.com" ); - - // Check whether all callers higher in the call stack have been granted the permission or not. - myWebPermission1->Demand(); - Console::WriteLine( "The Attributes, Values and Children of the 'WebPermission' object are :\n" ); - - // Display the Attributes, Values and Children of the XML encoded instance. - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - - // - // Gets all URIs with Connect permission. - IEnumerator^ myEnum = myWebPermission1->ConnectList; - Console::WriteLine( "\nThe URIs with Connect permission are :\n" ); - while ( myEnum->MoveNext() ) - { - Console::WriteLine( "\tThe URI is : {0}", myEnum->Current ); - } - // - - // - // Get all URI's with Accept permission. - IEnumerator^ myEnum1 = myWebPermission1->AcceptList; - Console::WriteLine( "\n\nThe URIs with Accept permission are :\n" ); - while ( myEnum1->MoveNext() ) - { - Console::WriteLine( "\tThe URI is : {0}", myEnum1->Current ); - } - // - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtabel. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-Attribute-\t-Value-" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - - Console::WriteLine(); - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : \n" ); - while ( myEnumerator1->MoveNext() ) - Console::Write( myEnumerator1->Current ); - } - -}; - -int main() -{ - try - { - WebPermission_AcceptConnectList * myWebPermission_AcceptConnectList = new WebPermission_AcceptConnectList; - myWebPermission_AcceptConnectList->DisplayAcceptConnect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp deleted file mode 100644 index 7ecf4f0e7a0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// System::Net::WebPermission::WebPermission(NetworkAccess, Regex); - -/* -This program demonstrates the 'WebPermission(NetworkAccess, Regex)' constructor of 'WebPermission' class. -First a 'Regex' Object* is created that will accept all the urls which is having the hostfragment of -'www.contoso.com'.Then a 'WebPermission' Object* created by passing the 'NetworkAccess' permission and -'Regex' Object* as parameters. It checks the 'WebPermission' for all the url's having the host fragment -as 'www.contoso.com'. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Text::RegularExpressions; -using namespace System::Collections; - -class WebPermission_regexConstructor -{ -public: - void CreateRegexConstructor() - { -// - // Create an instance of 'Regex' that accepts all URL's containing the host - // fragment 'www.contoso.com'. - Regex^ myRegex = gcnew Regex( "http://www.contoso.com/.*" ); - - // Create a WebPermission that gives the permissions to all the hosts containing - // the same fragment. - WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex ); - - // Checks all callers higher in the call stack have been granted the permission. - myWebPermission->Demand(); -// - - Console::WriteLine( "Attribute and Values of WebPermission are : \n" ); - // Display the Attributes, Values and Children of the XML encoded copied instance. - PrintKeysAndValues( myWebPermission->ToXml()->Attributes, myWebPermission->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-ATTRIBUTES-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "\nThe Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermission_regexConstructor * myWebPermissionRegex = new WebPermission_regexConstructor; - myWebPermissionRegex->CreateRegexConstructor(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp deleted file mode 100644 index 8b3e407874a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// System::Net::WebPermission::WebPermission(PermissionState);System::Net::WebPermission::Copy; - -/** -* This program demonstrates the WebPermission(PermissionState) constructor and -* Copy method of the WebPermission class . -* It creates a WebPermission instance with Permissionstate set to None and -* sets the access right to one pair of URLs. -* Then it uses the Copy method to create another instance of WebPermission class -* Finally, the attributes , values and childrens of both the XML encoded instances -* are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class CopyWebPermission -{ -public: - void CreateCopy() - { -// - // Create a WebPermission instance. - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Allow access to the first set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.microsoft.com/default.htm" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.msn.com" ); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission1->Demand(); -// - -// - // Create another WebPermission instance that is the copy of the above WebPermission instance. - WebPermission^ myWebPermission2 = (WebPermission^)(myWebPermission1->Copy()); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission2->Demand(); -// - - Console::WriteLine( "The Attributes and Values are :\n" ); - // Display the Attributes, Values and Children of the XML encoded instance. - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - Console::WriteLine( "\nCopied Instance Attributes and Values are:\n" ); - - // Display the Attributes, Values and Children of the XML encoded copied instance. - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Gets the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are: " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - CopyWebPermission^ myCopyWebPermission = gcnew CopyWebPermission; - myCopyWebPermission->CreateCopy(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp deleted file mode 100644 index ea42dec4dbc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// System::Net::WebPermission::ToXml;System::Net::WebPermission::FromXml; - -/** -* This program shows the use of the ToXml and FromXml methods of the WebPermission class. -* It creates a WebPermission instance with the Permissionstate set to None and -* displays the attributes and the values of the XML encoded instance . -* Then a SecurityElement instance is created and it's attributes are -* set. -* Finally, using the FromXml method the WebPermission instance is reconstructed from -* the above SecurityElement instance and the attributes are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -public ref class WebPermission_FromToXml -{ -public: - void CallXml() - { -// - // Create a WebPermission without permission on the protected resource - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Create a SecurityElement by calling the ToXml method on the WebPermission - // instance and display its attributes (which hold the XML encoding of - // the WebPermission). - Console::WriteLine( "Attributes and Values of the WebPermission are:" ); - myWebPermission1->ToXml(); - - // Create another WebPermission with no permission on the protected resource - WebPermission^ myWebPermission2 = gcnew WebPermission( PermissionState::None ); - - //Converts the new WebPermission from XML using myWebPermission1. - myWebPermission2->FromXml( myWebPermission1->ToXml() ); -// - - Console::WriteLine( "The Attributes and Values of 'WebPermission' instance after reconstruction are: \n" ); - // Display the Attributes and values of the XML encoded instances. - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable ) - { - // Get the enumerator to iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } -}; - -int main() -{ - try - { - WebPermission_FromToXml^ myWebPermission_FromToXml = gcnew WebPermission_FromToXml; - myWebPermission_FromToXml->CallXml(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp deleted file mode 100644 index 692f71b9fea..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// System::Net::WebPermission::WebPermission(); -// System::Net::WebPermission->AddPermission(NetworkAccess, stringuri); -// System::Net::WebPermission::Intersect; - -/** -* This program shows the use of the WebPermission() constructor, the AddPermission, -* and Intersect' methods of the WebPermission' class. -* It first creates two WebPermission objects with no arguments, with each of them -* setting the access rights to one pair of URLs. -* Then it displays the attributes , values and childrens of the XML encoded instances. -* Finally, it creates a third WebPermission Object* using the logical intersection of the -* first two objects. It does so by using the Intersect method. -* It then displays the attributes , values and childrens of the related XML encoded -* instances. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class WebPermissionIntersect -{ -public: - void CreateIntersect() - { -// - // Create two WebPermission instances. - WebPermission^ myWebPermission1 = gcnew WebPermission; - WebPermission^ myWebPermission2 = gcnew WebPermission; - -// - // Allow access to the first set of resources. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.contoso.com/default.htm" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com/default.htm" ); - - // Check whether if the callers higher in the call stack have been granted - // access permissions. - myWebPermission1->Demand(); -// - - // Allow access right to the second set of resources. - myWebPermission2->AddPermission( NetworkAccess::Connect, "http://www.alpineskihouse.com/default.htm" ); - myWebPermission2->AddPermission( NetworkAccess::Connect, "http://www.baldwinmuseumofscience.com/default.htm" ); - myWebPermission2->Demand(); - -// - // Display the attributes , values and childrens of the XML encoded instances. - Console::WriteLine( "Attributes and values of first 'WebPermission' instance are :" ); - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - - Console::WriteLine( "\nAttributes and values of second 'WebPermission' instance are : " ); - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - -// - // Create a third WebPermission instance via the logical intersection of the previous - // two WebPermission instances. - WebPermission^ myWebPermission3 = (WebPermission^)(myWebPermission1->Intersect( myWebPermission2 )); - - Console::WriteLine( "\nAttributes and Values of the WebPermission instance after the Intersect are:\n" ); - Console::WriteLine( myWebPermission3->ToXml() ); -// - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionIntersect * myWebPermissionIntersect = new WebPermissionIntersect; - myWebPermissionIntersect->CreateIntersect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp deleted file mode 100644 index aa616240be8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// System::Net::WebPermission->AddPermission(NetworkAccess, regex); -// System::Net::WebPermission::IsSubsetOf; - -/** -* This program shows how to use the AddPermission(NetworkAccess, regex) and -* IsSubset methods of WebPermission class. -* It creates two WebPermission instances with the Connect access rights for the -* specified URIs. -* For he first WebPermission instance, a Connect access right is given to the -* URLs with the host fragment www.microsoft.com. This is done by using -* the AddPermission(NetworkAccess, regex) method. -* Then, a third WebPermission instance is created with the Connect access right to -* the URLs of the first and second WebPermission instances. -* Finally, the attributes, values and children of that instance are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -using namespace System::Text::RegularExpressions; - -class WebPermissionIsSubset -{ -public: - void CheckSubset() - { -// - // Create a WebPermission. - WebPermission^ myWebPermission1 = gcnew WebPermission; - - // Allow Connect access to the specified URLs. - myWebPermission1->AddPermission( NetworkAccess::Connect, gcnew Regex( "http://www\\.contoso\\.com/.*", - (RegexOptions)(RegexOptions::Compiled | RegexOptions::IgnoreCase | RegexOptions::Singleline) ) ); - - myWebPermission1->Demand(); -// - - // Create another WebPermission with the specified URL. - WebPermission^ myWebPermission2 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com" ); - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission2->Demand(); - -// - WebPermission^ myWebPermission3 = nullptr; - - // Check which permissions have the Connect access to more number of URLs. - if ( myWebPermission2->IsSubsetOf( myWebPermission1 ) ) - { - Console::WriteLine( "\n WebPermission2 is the Subset of WebPermission1\n" ); - myWebPermission3 = myWebPermission1; - } - else if ( myWebPermission1->IsSubsetOf( myWebPermission2 ) ) - { - Console::WriteLine( "\n WebPermission1 is the Subset of WebPermission2" ); - myWebPermission3 = myWebPermission2; - } - else - { - // Create the third permission. - myWebPermission3 = (WebPermission^)(myWebPermission1->Union( myWebPermission2 )); - } -// - - // Prints the attributes, values and children of XML encoded instances. - Console::WriteLine( "\nAttributes and Values of third WebPermission instance are : " ); - PrintKeysAndValues( myWebPermission3->ToXml()->Attributes, myWebPermission3->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionIsSubset * myWebPermissionIsSubset = new WebPermissionIsSubset; - myWebPermissionIsSubset->CheckSubset(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp deleted file mode 100644 index 5f132c99a7c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// System::Net::WebPermission->AddPermission(NetworkAccess, regex);System::Net::WebPermission::IsSubsetOf; - -/** -* This program shows the use of the AddPermission(NetworkAccess, regex) and -* IsSubset methods of the WebPermission class. -* It creates two WebPermission instances with the Connect access rights for the specified -* URIs. The second URI being a subset of the first one. -* Then the IsSubsetOf method is called to verify that the second URI is indeed a subset -* of the firts one. The result of the call to the IsSubsetOf is then displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -using namespace System::Text::RegularExpressions; - -static void myIsSubsetExample() -{ -// - // Create the target permission. - WebPermission^ targetPermission = gcnew WebPermission; - targetPermission->AddPermission( NetworkAccess::Connect, gcnew Regex( "www\\.contoso\\.com/Public/.*" ) ); - - // Create the permission for a URI matching target. - WebPermission^ connectPermission = gcnew WebPermission; - connectPermission->AddPermission( NetworkAccess::Connect, "www.contoso.com/Public/default.htm" ); - - //The following statement prints true. - Console::WriteLine( "Is the second URI a subset of the first one?: {0}", connectPermission->IsSubsetOf( targetPermission ) ); -// -} - -int main() -{ - // Verify that the second URI is a subset of the first one. - myIsSubsetExample(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp deleted file mode 100644 index ccc6b055614..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Text::RegularExpressions; -using namespace System::Collections; - -void MySample() -{ -// - // Create a Regex that accepts all URLs containing the host fragment www.contoso.com. - Regex^ myRegex = gcnew Regex( "http://www\\.contoso\\.com/.*" ); - - // Create a WebPermission that gives permissions to all the hosts containing the same host fragment. - WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex ); - - //Add connect privileges for a www.adventure-works.com. - myWebPermission->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com" ); - - //Add accept privileges for www.alpineskihouse.com. - myWebPermission->AddPermission( NetworkAccess::Accept, "http://www.alpineskihouse.com/" ); - - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission->Demand(); - - // Get all the URIs with Connect permission. - IEnumerator^ myConnectEnum = myWebPermission->ConnectList; - Console::WriteLine( "\nThe 'URIs' with 'Connect' permission are :\n" ); - while ( myConnectEnum->MoveNext() ) - { - Console::WriteLine( "\t{0}", myConnectEnum->Current ); - } - - // Get all the URIs with Accept permission. - IEnumerator^ myAcceptEnum = myWebPermission->AcceptList; - Console::WriteLine( "\n\nThe 'URIs' with 'Accept' permission is :\n" ); - - while ( myAcceptEnum->MoveNext() ) - { - Console::WriteLine( "\t{0}", myAcceptEnum->Current ); - } -// -} - -int main() -{ - MySample(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp deleted file mode 100644 index 9610688f608..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// System::Net::WebPermission::WebPermission(NetworkAccess, uriString);System::Net::WebPermission::Union; - -/** -* This program shows the use of the WebPermission(NetworkAccess access, String* uriString) -* constructor and Union method of the WebPermission' class. -* It creates two instance of the WebPermission class with the specified access -* rights to the predefined URIs. -* It displays the attributes , values and childrens of those XML encoded -* instances. -* Then, using the Union method, it creates a third WebPermission instance -* via a logical union of the first two. -* Finally, it displays the attributes , values and childrens of those XML encoded -* instances. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class WebPermissionUnion -{ -public: - void CreateUnion() - { -// - // Create a WebPermission::instance. - WebPermission^ myWebPermission1 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com/default.htm" ); - myWebPermission1->Demand(); -// - - // Create another WebPermission instance. - WebPermission^ myWebPermission2 = gcnew WebPermission( NetworkAccess::Connect,"http://www.adventure-works.com" ); - myWebPermission2->Demand(); - - // Print the attributes, values and childrens of the XML encoded instances. - Console::WriteLine( "Attributes and values of the first WebPermission are : " ); - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - - Console::WriteLine( "\nAttributes and values of the second WebPermission are : " ); - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - -// - // Create another WebPermission that is the Union of previous two WebPermission - // instances. - WebPermission^ myWebPermission3 = (WebPermission^)(myWebPermission1->Union( myWebPermission2 )); - Console::WriteLine( "\nAttributes and values of the WebPermission after the Union are : " ); - // Display the attributes, values and children. - Console::WriteLine( myWebPermission3->ToXml() ); -// - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - - Console::WriteLine(); - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionUnion^ myWebPermissionUnion = gcnew WebPermissionUnion; - myWebPermissionUnion->CreateUnion(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs deleted file mode 100644 index 85272db70cb..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System.AddIn.Pipeline; -namespace LibraryContractsHostAdapters -{ - public class BookInfoContractToViewHostAdapter : LibraryContractsHAV.BookInfo - { - private Library.IBookInfoContract _contract; - - private ContractHandle _handle; - - public BookInfoContractToViewHostAdapter(Library.IBookInfoContract contract) - { - _contract = contract; - _handle = new ContractHandle(contract); - } - - public override string ID() - { - return _contract.ID(); - } - public override string Author() - { - return _contract.Author(); - } - public override string Title() - { - return _contract.Title(); - } - public override string Genre() - { - return _contract.Genre(); - } - public override string Price() - { - return _contract.Price(); - } - public override string Publish_Date() - { - return _contract.Publish_Date(); - } - public override string Description() - { - return _contract.Description(); - } - - internal Library.IBookInfoContract GetSourceContract() { - return _contract; - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs deleted file mode 100644 index 68f94470b83..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -namespace LibraryContractsHostAdapters -{ -public class BookInfoHostAdapter -{ - - internal static LibraryContractsHAV.BookInfo ContractToViewAdapter(Library.IBookInfoContract contract) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) && - (contract.GetType().Equals(typeof(BookInfoViewToContractHostAdapter)))) - { - return ((BookInfoViewToContractHostAdapter)(contract)).GetSourceView(); - } - else { - return new BookInfoContractToViewHostAdapter(contract); - } - } - - internal static Library.IBookInfoContract ViewToContractAdapter(LibraryContractsHAV.BookInfo view) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) && - (view.GetType().Equals(typeof(BookInfoContractToViewHostAdapter)))) - { - return ((BookInfoContractToViewHostAdapter)(view)).GetSourceContract(); - } - else { - return new BookInfoViewToContractHostAdapter(view); - } - } -} -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs deleted file mode 100644 index c54d68911a7..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System.AddIn.Pipeline; -namespace LibraryContractsHostAdapters -{ -public class BookInfoViewToContractHostAdapter : ContractBase, Library.IBookInfoContract -{ - private LibraryContractsHAV.BookInfo _view; - - public BookInfoViewToContractHostAdapter(LibraryContractsHAV.BookInfo view) - { - _view = view; - } - - public virtual string ID() - { - return _view.ID(); - } - public virtual string Author() - { - return _view.Author(); - } - public virtual string Title() - { - return _view.Title(); - } - public virtual string Genre() - { - return _view.Genre(); - } - public virtual string Price() - { - return _view.Price(); - } - public virtual string Publish_Date() - { - return _view.Publish_Date(); - } - public virtual string Description() - { - return _view.Description(); - } - internal LibraryContractsHAV.BookInfo GetSourceView() - { - return _view; - } -} -} -// \ No newline at end of file diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs deleted file mode 100644 index 5ae55a0e328..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; - -namespace LibraryContractsAddInAdapters -{ - public class BookInfoAddInAdapter - { - internal static LibraryContractsBase.BookInfo ContractToViewAdapter(Library.IBookInfoContract contract) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) && - (contract.GetType().Equals(typeof(BookInfoViewToContractAddInAdapter)))) - { - return ((BookInfoViewToContractAddInAdapter)(contract)).GetSourceView(); - } - else - { - return new BookInfoContractToViewAddInAdapter(contract); - } - } - - internal static Library.IBookInfoContract ViewToContractAdapter(LibraryContractsBase.BookInfo view) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) && - (view.GetType().Equals(typeof(BookInfoContractToViewAddInAdapter)))) - { - return ((BookInfoContractToViewAddInAdapter)(view)).GetSourceContract(); - } - else - { - return new BookInfoViewToContractAddInAdapter(view); - } - } - } -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs deleted file mode 100644 index 5b622c29606..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using System.AddIn.Pipeline; -namespace LibraryContractsAddInAdapters -{ - -public class BookInfoContractToViewAddInAdapter : LibraryContractsBase.BookInfo -{ - private Library.IBookInfoContract _contract; - private System.AddIn.Pipeline.ContractHandle _handle; - public BookInfoContractToViewAddInAdapter(Library.IBookInfoContract contract) - { - _contract = contract; - _handle = new ContractHandle(contract); - } - - public override string ID() - { - return _contract.ID(); - } - public override string Author() - { - return _contract.Author(); - } - public override string Title() - { - return _contract.Title(); - } - public override string Genre() - { - return _contract.Genre(); - } - public override string Price() - { - return _contract.Price(); - } - public override string Publish_Date() - { - return _contract.Publish_Date(); - } - public override string Description() - { - return _contract.Description(); - } - - internal Library.IBookInfoContract GetSourceContract() { - return _contract; - } -} -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs deleted file mode 100644 index 34e5741b020..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; - -namespace LibraryContractsAddInAdapters -{ -public class BookInfoViewToContractAddInAdapter : System.AddIn.Pipeline.ContractBase, Library.IBookInfoContract -{ - private LibraryContractsBase.BookInfo _view; - public BookInfoViewToContractAddInAdapter(LibraryContractsBase.BookInfo view) - { - _view = view; - } - public virtual string ID() - { - return _view.ID(); - } - public virtual string Author() - { - return _view.Author(); - } - public virtual string Title() - { - return _view.Title(); - } - public virtual string Genre() - { - return _view.Genre(); - } - public virtual string Price() - { - return _view.Price(); - } - public virtual string Publish_Date() - { - return _view.Publish_Date(); - } - public virtual string Description() - { - return _view.Description(); - } - - internal LibraryContractsBase.BookInfo GetSourceView() { - return _view; - } -} -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs deleted file mode 100644 index c1a316ec94e..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.312 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ -using System.IO; -using System; -namespace LibraryContractsAddInAdapters { - - -public class LibraryManagerAddInAdapter -{ - - internal static LibraryContractsBase.LibraryManager ContractToViewAdapter(Library.ILibraryManagerContract contract) - { - StreamWriter sw = new StreamWriter(@"c:\meow\adaptercalls.txt", true); - sw.WriteLine("Called LibraryManagerAddInAdapter.ContractToViewAdapter"); - sw.Close(); - if (contract.GetType().Equals(typeof(LibraryManagerViewToContractAddInAdapter))) - { - return ((LibraryManagerViewToContractAddInAdapter)(contract)).GetSourceView(); - } - else { - return new LibraryManagerContractToViewAddInAdapter(contract); - } - } - - internal static Library.ILibraryManagerContract ViewToContractAdapter(LibraryContractsBase.LibraryManager view) - { - StreamWriter sw = new StreamWriter(@"c:\meow\adaptercalls.txt", true); - sw.WriteLine("Called LibraryManagerAddInAdapter.ViewToContractAdapter"); - sw.Close(); - if (view.GetType().Equals(typeof(LibraryManagerContractToViewAddInAdapter))) - { - return ((LibraryManagerContractToViewAddInAdapter)(view)).GetSourceContract(); - } - else { - return new LibraryManagerViewToContractAddInAdapter(view); - } - } -} -} - diff --git a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs b/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs deleted file mode 100644 index f9deeb81e5a..00000000000 --- a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -using System; -using System.CodeDom; -using System.CodeDom.Compiler; - -public class UsingTheCodeDOM -{ - public static void Main() - { - // - CodeCompileUnit compileUnit = new CodeCompileUnit(); - // - - // - CodeNamespace samples = new CodeNamespace("Samples"); - // - - // - samples.Imports.Add(new CodeNamespaceImport("System")); - // - - // - compileUnit.Namespaces.Add( samples ); - // - - // - CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1"); - // - - // - samples.Types.Add(class1); - // - - // - CodeEntryPointMethod start = new CodeEntryPointMethod(); - CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression( - new CodeTypeReferenceExpression("System.Console"), - "WriteLine", new CodePrimitiveExpression("Hello World!")); - start.Statements.Add(cs1); - // - - // - class1.Members.Add( start ); - // - - CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp"); - codeProvider.GenerateCodeFromCompileUnit(compileUnit, Console.Out, new CodeGeneratorOptions()); - } -} -// diff --git a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs b/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs deleted file mode 100644 index 166d3b9a4e9..00000000000 --- a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs +++ /dev/null @@ -1,111 +0,0 @@ -// -using System; -using System.IO; -using System.CodeDom; -using System.CodeDom.Compiler; -using Microsoft.CSharp; - -class Example -{ - public static void Main() - { - string sourcefile; - string exefile; - - CodeCompileUnit codeUnit = new CodeCompileUnit(); - sourcefile = GenerateCSharpCode(codeUnit); - exefile = sourcefile.Substring(0, sourcefile.LastIndexOf('.')) + ".exe"; - Console.WriteLine("outfile: {0}", exefile); - CompileCSharpCode(sourcefile, exefile); - } - - // - public static string GenerateCSharpCode(CodeCompileUnit compileunit) - { - // Generate the code with the C# code provider. - // - CSharpCodeProvider provider = new CSharpCodeProvider(); - // - - // Build the output file name. - string sourceFile; - if (provider.FileExtension[0] == '.') - { - sourceFile = "HelloWorld" + provider.FileExtension; - } - else - { - sourceFile = "HelloWorld." + provider.FileExtension; - } - - // Create a TextWriter to a StreamWriter to the output file. - using (StreamWriter sw = new StreamWriter(sourceFile, false)) - { - IndentedTextWriter tw = new IndentedTextWriter(sw, " "); - - // Generate source code using the code provider. - provider.GenerateCodeFromCompileUnit(compileunit, tw, - new CodeGeneratorOptions()); - - // Close the output file. - tw.Close(); - } - - return sourceFile; - } - // - - // - public static bool CompileCSharpCode(string sourceFile, string exeFile) - { - CSharpCodeProvider provider = new CSharpCodeProvider(); - - // Build the parameters for source compilation. - CompilerParameters cp = new CompilerParameters(); - - // Add an assembly reference. - cp.ReferencedAssemblies.Add( "System.dll" ); - - // Generate an executable instead of - // a class library. - cp.GenerateExecutable = true; - - // Set the assembly file name to generate. - cp.OutputAssembly = exeFile; - - // Save the assembly as a physical file. - cp.GenerateInMemory = false; - - // Invoke compilation. - CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile); - - if (cr.Errors.Count > 0) - { - // Display compilation errors. - Console.WriteLine("Errors building {0} into {1}", - sourceFile, cr.PathToAssembly); - foreach (CompilerError ce in cr.Errors) - { - Console.WriteLine(" {0}", ce.ToString()); - Console.WriteLine(); - } - } - else - { - Console.WriteLine("Source {0} built into {1} successfully.", - sourceFile, cr.PathToAssembly); - } - - // Return the results of compilation. - if (cr.Errors.Count > 0) - { - return false; - } - else - { - return true; - } - } - // -} -// diff --git a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs b/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs deleted file mode 100644 index 8db49e05961..00000000000 --- a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* The following example creates an assembly which is used to demonstrate - the methods, properties and constructors of the 'AssemblyInstaller' class. -*/ - -using System; -using System.ComponentModel; -using System.Configuration.Install; -using System.Collections; - -namespace MyAssembly -{ - [RunInstallerAttribute(true)] - public class MyProjectInstaller : Installer - { - static void Main() - { - Console.WriteLine( "Hello World" ); - } - } -} diff --git a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs b/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs deleted file mode 100644 index 8db49e05961..00000000000 --- a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* The following example creates an assembly which is used to demonstrate - the methods, properties and constructors of the 'AssemblyInstaller' class. -*/ - -using System; -using System.ComponentModel; -using System.Configuration.Install; -using System.Collections; - -namespace MyAssembly -{ - [RunInstallerAttribute(true)] - public class MyProjectInstaller : Installer - { - static void Main() - { - Console.WriteLine( "Hello World" ); - } - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs b/snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs deleted file mode 100644 index 74a4a0c5ef9..00000000000 --- a/snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Data.Linq; -using System.Data.Linq.Mapping; -using System.Data.Common; - -namespace cs_testbed -{ - class Program - { - static void Main(string[] args) - { - - Northwnd db = new Northwnd(@"c:\northwnd.mdf"); - Console.ReadLine(); - } - } -} diff --git a/snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs b/snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs deleted file mode 100644 index e6dff76f5cf..00000000000 --- a/snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace cs_ColumnAttributes2 -{ - class Program - { - static void Main(string[] args) - { - } - } -} diff --git a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs b/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs deleted file mode 100644 index 9647657c61c..00000000000 --- a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs +++ /dev/null @@ -1,62 +0,0 @@ -// System.Diagnostics.CounterCreationDataCollection.CounterCreationDataCollection(CounterCreationData[]) - -/* - The following program demonstrates 'CounterCreationDataCollection(CounterCreationData[])' - constructor of 'CounterCreationDataCollection' class. - An instance of 'CounterCreationDataCollection' is created by passing an array of - 'CounterCreationData' to the constructor. The counters of the 'CounterCreationDataCollection' - are displayed to the console. - - */ -using System; -using System.Diagnostics; - -public class CounterCreationExample -{ - public static void Main() - { - try - { - // - string myCategoryName; - int numberOfCounters; - Console.Write("Enter the category Name : "); - myCategoryName = Console.ReadLine(); - // Check if the category already exists or not. - if (!PerformanceCounterCategory.Exists(myCategoryName)) - { - Console.Write("Enter the number of counters : "); - numberOfCounters = int.Parse(Console.ReadLine()); - CounterCreationData[] myCounterCreationData = - new CounterCreationData[numberOfCounters]; - - for (int i = 0; i < numberOfCounters; i++) - { - Console.Write("Enter the counter name for {0} counter : ", i); - myCounterCreationData[i] = new CounterCreationData(); - myCounterCreationData[i].CounterName = Console.ReadLine(); - } - CounterCreationDataCollection myCounterCollection = - new CounterCreationDataCollection(myCounterCreationData); - // Create the category. - PerformanceCounterCategory.Create(myCategoryName, - "Sample Category", - PerformanceCounterCategoryType.SingleInstance, myCounterCollection); - - Console.WriteLine("The list of counters in 'CounterCollection' are :"); - for (int i = 0; i < myCounterCollection.Count; i++) - Console.WriteLine("Counter {0} is '{1}'", i, myCounterCollection[i].CounterName); - } - else - { - Console.WriteLine("The category already exists"); - } - // - } - catch (Exception e) - { - Console.WriteLine("Exception: {0}.", e.Message); - return; - } - } -} diff --git a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs b/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs deleted file mode 100644 index 9647657c61c..00000000000 --- a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs +++ /dev/null @@ -1,62 +0,0 @@ -// System.Diagnostics.CounterCreationDataCollection.CounterCreationDataCollection(CounterCreationData[]) - -/* - The following program demonstrates 'CounterCreationDataCollection(CounterCreationData[])' - constructor of 'CounterCreationDataCollection' class. - An instance of 'CounterCreationDataCollection' is created by passing an array of - 'CounterCreationData' to the constructor. The counters of the 'CounterCreationDataCollection' - are displayed to the console. - - */ -using System; -using System.Diagnostics; - -public class CounterCreationExample -{ - public static void Main() - { - try - { - // - string myCategoryName; - int numberOfCounters; - Console.Write("Enter the category Name : "); - myCategoryName = Console.ReadLine(); - // Check if the category already exists or not. - if (!PerformanceCounterCategory.Exists(myCategoryName)) - { - Console.Write("Enter the number of counters : "); - numberOfCounters = int.Parse(Console.ReadLine()); - CounterCreationData[] myCounterCreationData = - new CounterCreationData[numberOfCounters]; - - for (int i = 0; i < numberOfCounters; i++) - { - Console.Write("Enter the counter name for {0} counter : ", i); - myCounterCreationData[i] = new CounterCreationData(); - myCounterCreationData[i].CounterName = Console.ReadLine(); - } - CounterCreationDataCollection myCounterCollection = - new CounterCreationDataCollection(myCounterCreationData); - // Create the category. - PerformanceCounterCategory.Create(myCategoryName, - "Sample Category", - PerformanceCounterCategoryType.SingleInstance, myCounterCollection); - - Console.WriteLine("The list of counters in 'CounterCollection' are :"); - for (int i = 0; i < myCounterCollection.Count; i++) - Console.WriteLine("Counter {0} is '{1}'", i, myCounterCollection[i].CounterName); - } - else - { - Console.WriteLine("The category already exists"); - } - // - } - catch (Exception e) - { - Console.WriteLine("Exception: {0}.", e.Message); - return; - } - } -} diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs deleted file mode 100644 index 22233dce8a3..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs +++ /dev/null @@ -1,373 +0,0 @@ -// Notice that the sample is conditionally compiled for Everett vs. -// Whidbey builds. Whidbey introduced new APIs that are not available -// in Everett. Snippet IDs do not overlap between Whidbey and Everett; -// Snippet #1 is Everett, Snippet #2 and #3 are Whidbey. - -#if (BELOW_WHIDBEY_BUILD) - -// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Runtime.InteropServices; - -public class App -{ - - private static PerformanceCounter PC; - private static PerformanceCounter BPC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - SetupCategory(); - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - - - - private static bool SetupCategory() - { - - if ( !PerformanceCounterCategory.Exists("AverageTimer32SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData averageTimer32 = new CounterCreationData(); - averageTimer32.CounterType = PerformanceCounterType.AverageTimer32; - averageTimer32.CounterName = "AverageTimer32Sample"; - CCDC.Add(averageTimer32); - - // Add the base counter. - CounterCreationData averageTimer32Base = new CounterCreationData(); - averageTimer32Base.CounterType = PerformanceCounterType.AverageBase; - averageTimer32Base.CounterName = "AverageTimer32SampleBase"; - CCDC.Add(averageTimer32Base); - - // Create the category. - PerformanceCounterCategory.Create("AverageTimer32SampleCategory", - "Demonstrates usage of the AverageTimer32 performance counter type", - CCDC); - - return(true); - } - else - { - Console.WriteLine("Category exists - " + "AverageTimer32SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter("AverageTimer32SampleCategory", - "AverageTimer32Sample", - false); - - BPC = new PerformanceCounter("AverageTimer32SampleCategory", - "AverageTimer32SampleBase", - false); - - PC.RawValue = 0; - BPC.RawValue = 0; - } - - - private static void CollectSamples(ArrayList samplesList) - { - - long perfTime = 0; - Random r = new Random( DateTime.Now.Millisecond ); - - // Loop for the samples. - for (int i = 0; i < 10; i++) { - - QueryPerformanceCounter(out perfTime); - PC.RawValue = perfTime; - - BPC.IncrementBy(10); - - System.Threading.Thread.Sleep(1000); - Console.WriteLine("Next value = " + PC.NextValue().ToString()); - samplesList.Add(PC.NextSample()); - } - - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSample.Calculate((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - } - } - - - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - // PERF_AVERAGE_TIMER - // Description - This counter type measures the time it takes, on - // average, to complete a process or operation. Counters of this - // type display a ratio of the total elapsed time of the sample - // interval to the number of processes or operations completed - // during that time. This counter type measures time in ticks - // of the system clock. The F variable represents the number of - // ticks per second. The value of F is factored into the equation - // so that the result can be displayed in seconds. - // - // Generic type - Average - // - // Formula - ((N1 - N0) / F) / (D1 - D0), where the numerator (N) - // represents the number of ticks counted during the last - // sample interval, F represents the frequency of the ticks, - // and the denominator (D) represents the number of operations - // completed during the last sample interval. - // - // Average - ((Nx - N0) / F) / (Dx - D0) - // - // Example - PhysicalDisk\ Avg. Disk sec/Transfer - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Int64 n1 = s1.RawValue; - Int64 n0 = s0.RawValue; - ulong f = (ulong)s1.SystemFrequency; - Int64 d1 = s1.BaseValue; - Int64 d0 = s0.BaseValue; - - double numerator = (double)(n1 - n0); - double denominator = (double)(d1 - d0); - Single counterValue = (Single)(( numerator / f ) / denominator); - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } - - - [DllImport("Kernel32.dll")] - public static extern bool QueryPerformanceCounter(out long value); - -} - -// -#else -// Build sample for Whidbey or higher. - -// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Runtime.InteropServices; - -public class App -{ - - private static PerformanceCounter PC; - private static PerformanceCounter BPC; - - private const String categoryName = "AverageTimer32SampleCategory"; - private const String counterName = "AverageTimer32Sample"; - private const String baseCounterName = "AverageTimer32SampleBase"; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if (!PerformanceCounterCategory.Exists(categoryName)) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData averageTimer32 = new CounterCreationData(); - averageTimer32.CounterType = PerformanceCounterType.AverageTimer32; - averageTimer32.CounterName = counterName; - CCDC.Add(averageTimer32); - - // Add the base counter. - CounterCreationData averageTimer32Base = new CounterCreationData(); - averageTimer32Base.CounterType = PerformanceCounterType.AverageBase; - averageTimer32Base.CounterName = baseCounterName; - CCDC.Add(averageTimer32Base); - - // Create the category. - PerformanceCounterCategory.Create(categoryName, - "Demonstrates usage of the AverageTimer32 performance counter type", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - Console.WriteLine("Category created - " + categoryName); - - return (true); - } - else - { - Console.WriteLine("Category exists - " + categoryName); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter(categoryName, - counterName, - false); - - BPC = new PerformanceCounter(categoryName, - baseCounterName, - false); - - PC.RawValue = 0; - BPC.RawValue = 0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random(DateTime.Now.Millisecond); - - // Loop for the samples. - for (int i = 0; i < 10; i++) - { - - PC.RawValue = Stopwatch.GetTimestamp(); - - BPC.IncrementBy(10); - - System.Threading.Thread.Sleep(1000); - - Console.WriteLine("Next value = " + PC.NextValue().ToString()); - samplesList.Add(PC.NextSample()); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - OutputSample((CounterSample)samplesList[i + 1]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSample.Calculate((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - // PERF_AVERAGE_TIMER - // Description - This counter type measures the time it takes, on - // average, to complete a process or operation. Counters of this - // type display a ratio of the total elapsed time of the sample - // interval to the number of processes or operations completed - // during that time. This counter type measures time in ticks - // of the system clock. The F variable represents the number of - // ticks per second. The value of F is factored into the equation - // so that the result can be displayed in seconds. - // - // Generic type - Average - // - // Formula - ((N1 - N0) / F) / (D1 - D0), where the numerator (N) - // represents the number of ticks counted during the last - // sample interval, F represents the frequency of the ticks, - // and the denominator (D) represents the number of operations - // completed during the last sample interval. - // - // Average - ((Nx - N0) / F) / (Dx - D0) - // - // Example - PhysicalDisk\ Avg. Disk sec/Transfer - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Int64 n1 = s1.RawValue; - Int64 n0 = s0.RawValue; - ulong f = (ulong)s1.SystemFrequency; - Int64 d1 = s1.BaseValue; - Int64 d0 = s0.BaseValue; - - double numerator = (double)(n1 - n0); - double denominator = (double)(d1 - d0); - Single counterValue = (Single)((numerator / f) / denominator); - return (counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// - -#endif diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs deleted file mode 100644 index 18eee683b86..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs +++ /dev/null @@ -1,137 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class NumberOfItems64 -{ - - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - if ( !PerformanceCounterCategory.Exists("NumberOfItems32SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData NOI64 = new CounterCreationData(); - NOI64.CounterType = PerformanceCounterType.NumberOfItems64; - NOI64.CounterName = "NumberOfItems32Sample"; - CCDC.Add(NOI64); - - // Create the category. - PerformanceCounterCategory.Create("NumberOfItems32SampleCategory", - "Demonstrates usage of the NumberOfItems32 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - return(true); - } - else - { - Console.WriteLine("Category exists - NumberOfItems32SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counter. - PC = new PerformanceCounter("NumberOfItems32SampleCategory", - "NumberOfItems32Sample", - false); - - PC.RawValue=0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random( DateTime.Now.Millisecond ); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - Console.Write(j + " = " + value); - - PC.IncrementBy(value); - - if ((j % 10) == 9) - { - OutputSample(PC.NextSample()); - samplesList.Add( PC.NextSample() ); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single counterValue = s1.RawValue; - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs deleted file mode 100644 index a7de24e7aa0..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs +++ /dev/null @@ -1,136 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class NumberOfItems64 -{ - - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Perfomance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - if ( !PerformanceCounterCategory.Exists("NumberOfItems64SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData NOI64 = new CounterCreationData(); - NOI64.CounterType = PerformanceCounterType.NumberOfItems64; - NOI64.CounterName = "NumberOfItems64Sample"; - CCDC.Add(NOI64); - - // Create the category. - PerformanceCounterCategory.Create("NumberOfItems64SampleCategory", - "Demonstrates usage of the NumberOfItems64 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - return(true); - } - else - { - Console.WriteLine("Category exists - NumberOfItems64SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter("NumberOfItems64SampleCategory", - "NumberOfItems64Sample", - false); - - PC.RawValue=0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random( DateTime.Now.Millisecond ); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - Console.Write(j + " = " + value); - - PC.IncrementBy(value); - - if ((j % 10) == 9) - { - OutputSample(PC.NextSample()); - samplesList.Add( PC.NextSample() ); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single counterValue = s1.RawValue; - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} -// diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs deleted file mode 100644 index 6cdc59d744b..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -// Provides a SampleFraction counter to measure the percentage of the user processor -// time for this process to total processor time for the process. -public class App -{ - - private static PerformanceCounter perfCounter; - private static PerformanceCounter basePerfCounter; - private static Process thisProcess = Process.GetCurrentProcess(); - - public static void Main() - { - - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - if (!PerformanceCounterCategory.Exists("SampleFractionCategory")) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData sampleFraction = new CounterCreationData(); - sampleFraction.CounterType = PerformanceCounterType.SampleFraction; - sampleFraction.CounterName = "SampleFractionSample"; - CCDC.Add(sampleFraction); - - // Add the base counter. - CounterCreationData sampleFractionBase = new CounterCreationData(); - sampleFractionBase.CounterType = PerformanceCounterType.SampleBase; - sampleFractionBase.CounterName = "SampleFractionSampleBase"; - CCDC.Add(sampleFractionBase); - - // Create the category. - PerformanceCounterCategory.Create("SampleFractionCategory", - "Demonstrates usage of the SampleFraction performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - return (true); - } - else - { - Console.WriteLine("Category exists - SampleFractionCategory"); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counters. - - perfCounter = new PerformanceCounter("SampleFractionCategory", - "SampleFractionSample", - false); - - basePerfCounter = new PerformanceCounter("SampleFractionCategory", - "SampleFractionSampleBase", - false); - - perfCounter.RawValue = thisProcess.UserProcessorTime.Ticks; - basePerfCounter.RawValue = thisProcess.TotalProcessorTime.Ticks; - } - private static void CollectSamples(ArrayList samplesList) - { - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - perfCounter.IncrementBy(thisProcess.UserProcessorTime.Ticks); - - basePerfCounter.IncrementBy(thisProcess.TotalProcessorTime.Ticks); - - if ((j % 10) == 9) - { - OutputSample(perfCounter.NextSample()); - samplesList.Add(perfCounter.NextSample()); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - OutputSample((CounterSample)samplesList[i + 1]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // Description - This counter type provides A percentage counter that shows the - // average ratio of user proccessor time to total processor time during the last - // two sample intervals. - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single numerator = (Single)s1.RawValue - (Single)s0.RawValue; - Single denomenator = (Single)s1.BaseValue - (Single)s0.BaseValue; - Single counterValue = 100 * (numerator / denomenator); - return (counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs deleted file mode 100644 index 38559236e96..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs +++ /dev/null @@ -1,159 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class App -{ - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Perfomance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if ( !PerformanceCounterCategory.Exists("RateOfCountsPerSecond32SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData rateOfCounts32 = new CounterCreationData(); - rateOfCounts32.CounterType = PerformanceCounterType.RateOfCountsPerSecond32; - rateOfCounts32.CounterName = "RateOfCountsPerSecond32Sample"; - CCDC.Add(rateOfCounts32); - - // Create the category. - PerformanceCounterCategory.Create("RateOfCountsPerSecond32SampleCategory", - "Demonstrates usage of the RateOfCountsPerSecond32 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - return(true); - } - else - { - Console.WriteLine("Category exists - RateOfCountsPerSecond32SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counter. - PC = new PerformanceCounter("RateOfCountsPerSecond32SampleCategory", - "RateOfCountsPerSecond32Sample", - false); - - PC.RawValue=0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random( DateTime.Now.Millisecond ); - - // Initialize the performance counter. - PC.NextSample(); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - PC.IncrementBy(value); - Console.Write(j + " = " + value); - - if ((j % 10) == 9) - { - Console.WriteLine("; NextValue() = " + PC.NextValue().ToString()); - OutputSample(PC.NextSample()); - samplesList.Add( PC.NextSample() ); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // PERF_COUNTER_COUNTER - // Description - This counter type shows the average number of operations completed - // during each second of the sample interval. Counters of this type - // measure time in ticks of the system clock. The F variable represents - // the number of ticks per second. The value of F is factored into the - // equation so that the result can be displayed in seconds. - // - // Generic type - Difference - // - // Formula - (N1 - N0) / ( (D1 - D0) / F), where the numerator (N) represents the number - // of operations performed during the last sample interval, the denominator - // (D) represents the number of ticks elapsed during the last sample - // interval, and F is the frequency of the ticks. - // - // Average - (Nx - N0) / ((Dx - D0) / F) - // - // Example - System\ File Read Operations/sec - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single numerator = (Single)(s1.RawValue - s0.RawValue); - Single denomenator = (Single)(s1.TimeStamp - s0.TimeStamp) / (Single)s1.SystemFrequency; - Single counterValue = numerator / denomenator; - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs deleted file mode 100644 index 3dca5cb9acf..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs +++ /dev/null @@ -1,158 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class App -{ - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Perfomance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if (!PerformanceCounterCategory.Exists("RateOfCountsPerSecond64SampleCategory")) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData rateOfCounts64 = new CounterCreationData(); - rateOfCounts64.CounterType = PerformanceCounterType.RateOfCountsPerSecond64; - rateOfCounts64.CounterName = "RateOfCountsPerSecond64Sample"; - CCDC.Add(rateOfCounts64); - - // Create the category. - PerformanceCounterCategory.Create("RateOfCountsPerSecond64SampleCategory", - "Demonstrates usage of the RateOfCountsPerSecond64 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - return (true); - } - else - { - Console.WriteLine("Category exists - RateOfCountsPerSecond64SampleCategory"); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counter. - PC = new PerformanceCounter("RateOfCountsPerSecond64SampleCategory", - "RateOfCountsPerSecond64Sample", - false); - - PC.RawValue = 0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random(DateTime.Now.Millisecond); - - // Initialize the performance counter. - PC.NextSample(); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - PC.IncrementBy(value); - Console.Write(j + " = " + value); - - if ((j % 10) == 9) - { - Console.WriteLine("; NextValue() = " + PC.NextValue().ToString()); - OutputSample(PC.NextSample()); - samplesList.Add(PC.NextSample()); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - OutputSample((CounterSample)samplesList[i + 1]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // PERF_COUNTER_COUNTER - // Description - This counter type shows the average number of operations completed - // during each second of the sample interval. Counters of this type - // measure time in ticks of the system clock. The F variable represents - // the number of ticks per second. The value of F is factored into the - // equation so that the result can be displayed in seconds. - // - // Generic type - Difference - // - // Formula - (N1 - N0) / ( (D1 - D0) / F), where the numerator (N) represents the number - // of operations performed during the last sample interval, the denominator - // (D) represents the number of ticks elapsed during the last sample - // interval, and F is the frequency of the ticks. - // - // Average - (Nx - N0) / ((Dx - D0) / F) - // - // Example - System\ File Read Operations/sec - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single numerator = (Single)(s1.RawValue - s0.RawValue); - Single denomenator = (Single)(s1.TimeStamp - s0.TimeStamp) / (Single)s1.SystemFrequency; - Single counterValue = numerator / denomenator; - return (counterValue); - } - - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs deleted file mode 100644 index 293d0bd9e2d..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs +++ /dev/null @@ -1,171 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class App -{ - private static PerformanceCounter PC; - private static PerformanceCounter BPC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the counters. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if (!PerformanceCounterCategory.Exists("RawFractionSampleCategory")) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData rf = new CounterCreationData(); - rf.CounterType = PerformanceCounterType.RawFraction; - rf.CounterName = "RawFractionSample"; - CCDC.Add(rf); - - // Add the base counter. - CounterCreationData rfBase = new CounterCreationData(); - rfBase.CounterType = PerformanceCounterType.RawBase; - rfBase.CounterName = "RawFractionSampleBase"; - CCDC.Add(rfBase); - - // Create the category. - PerformanceCounterCategory.Create("RawFractionSampleCategory", - "Demonstrates usage of the RawFraction performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - return (true); - } - else - { - Console.WriteLine("Category exists - RawFractionSampleCategory"); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter("RawFractionSampleCategory", - "RawFractionSample", - false); - - BPC = new PerformanceCounter("RawFractionSampleCategory", - "RawFractionSampleBase", - false); - - PC.RawValue = 0; - BPC.RawValue = 0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random(DateTime.Now.Millisecond); - - // Initialize the performance counter. - PC.NextSample(); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - int value = r.Next(1, 10); - Console.Write(j + " = " + value); - - // Increment the base every time, because the counter measures the number - // of high hits (raw fraction value) against all the hits (base value). - BPC.Increment(); - - // Get the % of samples that are 9 or 10 out of all the samples taken. - if (value >= 9) - PC.Increment(); - - // Copy out the next value every ten times around the loop. - if ((j % 10) == 9) - { - Console.WriteLine("; NextValue() = " + PC.NextValue().ToString()); - OutputSample(PC.NextSample()); - samplesList.Add(PC.NextSample()); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < samplesList.Count; i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // Formula from MSDN - - // Description - This counter type shows the ratio of a subset to its set as a percentage. - // For example, it compares the number of bytes in use on a disk to the - // total number of bytes on the disk. Counters of this type display the - // current percentage only, not an average over time. - // - // Generic type - Instantaneous, Percentage - // Formula - (N0 / D0), where D represents a measured attribute and N represents one - // component of that attribute. - // - // Average - SUM (N / D) /x - // Example - Paging File\% Usage Peak - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample rfSample) - { - Single numerator = (Single)rfSample.RawValue; - Single denomenator = (Single)rfSample.BaseValue; - Single counterValue = (numerator / denomenator) * 100; - return (counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// \ No newline at end of file diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs deleted file mode 100644 index 6f774eb4ea8..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, s1.Length - position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, s1.Length - position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, s1.Length - position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, s2.Length - position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs deleted file mode 100644 index 4cdb5f27662..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs +++ /dev/null @@ -1,127 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, - s1.Length - position, CompareOptions.None)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, - s2.Length - position, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, - s1.Length - position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, - s2.Length - position, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, - s1.Length - position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, - s2.Length - position, CompareOptions.IgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, - s1.Length - position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, - s2.Length - position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, - s1.Length - position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, - s2.Length - position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, - s1.Length - position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, - s2.Length - position, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs deleted file mode 100644 index e858a3e4585..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs deleted file mode 100644 index 9b2b2ea5a91..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, CompareOptions.None)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, CompareOptions.IgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs b/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs deleted file mode 100644 index af8d6d515f6..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, position + 1)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, position + 1)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, position + 1)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, position + 1)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, position + 1)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, position + 1)); - } -} -// The example displays the following output: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs b/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs deleted file mode 100644 index 479b93e1aef..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs +++ /dev/null @@ -1,127 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, - position + 1, CompareOptions.None)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, - position + 1, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, - position + 1, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, - position + 1, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, - position + 1, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, - position + 1, CompareOptions.IgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, - position + 1, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, - position + 1, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, - position + 1, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, - position + 1, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, - position + 1, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, - position + 1, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// -// Ordinal comparisons: -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs b/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs deleted file mode 100644 index b8b49bd76cb..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, CompareOptions.None)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, CompareOptions.IgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// -// Ordinal comparisons: -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// -1 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// diff --git a/snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs b/snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs deleted file mode 100644 index 7fb7c040e49..00000000000 --- a/snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string[] names = { "johann_doe@bücher.com", "vi@мойдомен.рф", "ia@παράδειγμα.δοκιμή", - "webmaster@mycharity\u3002org", - "admin@prose\u0000ware.com", "john_doe@proseware..com", - "jane_doe@a.org", "me@my_company.com" }; - IdnMapping idn = new IdnMapping(); - - foreach (var thisName in names) { - string name = thisName; - try { - int position = name.LastIndexOf("@"); - if (position >= 0) - name = name.Substring(position + 1); - - string punyCode = idn.GetAscii(name); - string name2 = idn.GetUnicode(punyCode); - Console.WriteLine("{0} --> {1} --> {2}", name, punyCode, name2); - Console.WriteLine("Original: {0}", ShowCodePoints(name)); - Console.WriteLine("Restored: {0}", ShowCodePoints(name2)); - } - catch (ArgumentException) { - Console.WriteLine("{0} is not a valid domain name.", name); - } - Console.WriteLine(); - } - } - - private static string ShowCodePoints(string str1) - { - string output = ""; - foreach (var ch in str1) - output += $"U+{(ushort)ch:X4} "; - - return output; - } -} -// The example displays the following output: -// bücher.com --> xn--bcher-kva.com --> bücher.com -// Original: U+0062 U+00FC U+0063 U+0068 U+0065 U+0072 U+002E U+0063 U+006F U+006D -// Restored: U+0062 U+00FC U+0063 U+0068 U+0065 U+0072 U+002E U+0063 U+006F U+006D -// -// мойдомен.рф --> xn--d1acklchcc.xn--p1ai --> мойдомен.рф -// Original: U+043C U+043E U+0439 U+0434 U+043E U+043C U+0435 U+043D U+002E U+0440 U+0444 -// Restored: U+043C U+043E U+0439 U+0434 U+043E U+043C U+0435 U+043D U+002E U+0440 U+0444 -// -// παράδειγμα.δοκιμή --> xn--hxajbheg2az3al.xn--jxalpdlp --> παράδειγμα.δοκιμή -// Original: U+03C0 U+03B1 U+03C1 U+03AC U+03B4 U+03B5 U+03B9 U+03B3 U+03BC U+03B1 U+002E U+03B4 U+03BF U+03BA U+03B9 U+03BC U+03AE -// Restored: U+03C0 U+03B1 U+03C1 U+03AC U+03B4 U+03B5 U+03B9 U+03B3 U+03BC U+03B1 U+002E U+03B4 U+03BF U+03BA U+03B9 U+03BC U+03AE -// -// mycharity。org --> mycharity.org --> mycharity.org -// Original: U+006D U+0079 U+0063 U+0068 U+0061 U+0072 U+0069 U+0074 U+0079 U+3002 U+006F U+0072 U+0067 -// Restored: U+006D U+0079 U+0063 U+0068 U+0061 U+0072 U+0069 U+0074 U+0079 U+002E U+006F U+0072 U+0067 -// -// prose ware.com is not a valid domain name. -// -// proseware..com is not a valid domain name. -// -// a.org --> a.org --> a.org -// Original: U+0061 U+002E U+006F U+0072 U+0067 -// Restored: U+0061 U+002E U+006F U+0072 U+0067 -// -// my_company.com --> my_company.com --> my_company.com -// Original: U+006D U+0079 U+005F U+0063 U+006F U+006D U+0070 U+0061 U+006E U+0079 U+002E U+0063 U+006F U+006D -// Restored: U+006D U+0079 U+005F U+0063 U+006F U+006D U+0070 U+0061 U+006E U+0079 U+002E U+0063 U+006F U+006D -// diff --git a/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs b/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs deleted file mode 100644 index f866647919c..00000000000 --- a/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using System.IO; -using System.IO.Compression; - -namespace ConsoleApplication -{ - class Program - { - static void Main(string[] args) - { - string startPath = @"c:\example\start"; - string zipPath = @"c:\example\result.zip"; - - ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true); - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.IO/FileStream/Overview/example2.cs b/snippets/csharp/System.IO/FileStream/Overview/example2.cs deleted file mode 100644 index 3e82970f4f2..00000000000 --- a/snippets/csharp/System.IO/FileStream/Overview/example2.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Threading.Tasks; -using System.Windows; -using System.IO; - -namespace WpfApplication1 -{ - public partial class MainWindow2 : Window - { - public MainWindow2() - { - InitializeComponent(); - } - - // - private async void Button_Click(object sender, RoutedEventArgs e) - { - string UserDirectory = @"c:\Users\exampleuser\"; - - using (StreamReader SourceReader = File.OpenText(UserDirectory + "BigFile.txt")) - { - using (StreamWriter DestinationWriter = File.CreateText(UserDirectory + "CopiedFile.txt")) - { - await CopyFilesAsync(SourceReader, DestinationWriter); - } - } - } - - public async Task CopyFilesAsync(StreamReader Source, StreamWriter Destination) - { - char[] buffer = new char[0x1000]; - int numRead; - while ((numRead = await Source.ReadAsync(buffer, 0, buffer.Length)) != 0) - { - await Destination.WriteAsync(buffer, 0, numRead); - } - } - // - } -} diff --git a/snippets/csharp/System.IO/StreamReader/Overview/source2.cs b/snippets/csharp/System.IO/StreamReader/Overview/source2.cs deleted file mode 100644 index 5fe7a2b67ff..00000000000 --- a/snippets/csharp/System.IO/StreamReader/Overview/source2.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; -using System.IO; - -public class CompBuf -{ - private const string FILE_NAME = "MyFile.txt"; - - public static void Main() - { - if (!File.Exists(FILE_NAME)) - { - Console.WriteLine($"{FILE_NAME} does not exist!"); - return; - } - FileStream fsIn = new FileStream(FILE_NAME, FileMode.Open, - FileAccess.Read, FileShare.Read); - // Create an instance of StreamReader that can read - // characters from the FileStream. - using (StreamReader sr = new StreamReader(fsIn)) - { - string input; - // While not at the end of the file, read lines from the file. - while (sr.Peek() > -1) - { - input = sr.ReadLine(); - Console.WriteLine(input); - } - } - } -} -// diff --git a/snippets/csharp/System.IO/StreamReader/Overview/source3.cs b/snippets/csharp/System.IO/StreamReader/Overview/source3.cs deleted file mode 100644 index 1ed6500a096..00000000000 --- a/snippets/csharp/System.IO/StreamReader/Overview/source3.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; -using System.IO; - -public class ReadBuf -{ - private const string FILE_NAME = "MyFile.txt"; - - public static void Main() - { - if (!File.Exists(FILE_NAME)) - { - Console.WriteLine($"{FILE_NAME} does not exist."); - return; - } - FileStream f = new FileStream(FILE_NAME, FileMode.Open, - FileAccess.Read, FileShare.Read); - // Create an instance of BinaryReader that can - // read bytes from the FileStream. - using (BinaryReader br = new BinaryReader(f)) - { - byte input; - // While not at the end of the file, read lines from the file. - while (br.PeekChar() > -1 ) - { - input = br.ReadByte(); - Console.WriteLine(input); - } - } - } -} -// diff --git a/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs b/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs deleted file mode 100644 index 3f000b094bd..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - This program demonstrates the 'Constructor' of 'DnsPermission' class. - It creates an instance of 'DnsPermission' class and checks for permission.Then it - creates a 'SecurityElement' object and prints it's attributes which hold the XML - encoding of 'DnsPermission' instance . -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main() { - try { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } -// - public void useDns() { - - // Create a DnsPermission instance. - DnsPermission permission = new DnsPermission(PermissionState.Unrestricted); - - // Check for permission. - permission.Demand(); - // Create a SecurityElement object to hold XML encoding of the DnsPermission instance. - SecurityElement securityElementObj = permission.ToXml(); - Console.WriteLine("Tag, Attributes and Values of 'DnsPermission' instance :"); - Console.WriteLine("\n\tTag :" + securityElementObj.Tag); - // Print the attributes and values. - PrintKeysAndValues(securityElementObj.Attributes); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\n\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs b/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs deleted file mode 100644 index c327b9de562..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - This program demonstrates the 'Copy' method of 'DnsPermission' class. - It creates an identical copy of 'DnsPermission' instance. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main() { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.UseDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } - -// - public void UseDns() { - // Create a DnsPermission instance. - DnsPermission myPermission = new DnsPermission(PermissionState.Unrestricted); - // Check for permission. - myPermission.Demand(); - // Create an identical copy of the above 'DnsPermission' object. - DnsPermission myPermissionCopy = (DnsPermission)myPermission.Copy(); - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :"); - // Print the attributes and values. - PrintKeysAndValues(myPermission.ToXml().Attributes); - Console.WriteLine("Attribute and values of copied instance :"); - PrintKeysAndValues(myPermissionCopy.ToXml().Attributes); - } - - private void PrintKeysAndValues(Hashtable myHashtable) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs b/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs deleted file mode 100644 index 28c3c9d7083..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs +++ /dev/null @@ -1,85 +0,0 @@ -/* - This program demonstrates the 'FromXml' method of 'DnsPermission' class. - It creates an instance of 'DnsPermission' class and prints the XML encoding of that instance.Then it - creates a 'SecurityElement' object and adds the attributes corresponding to the above 'DnsPermission' - object. A new 'DnsPermission' instance is reconstructed from the 'SecurityElement' instance by calling - 'FromXml' method and it's XML encoding is printed. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main() { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.ConstructDnsPermission(); - } -// - public void ConstructDnsPermission() { - try - { - // Create a DnsPermission instance. - DnsPermission permission = new DnsPermission(PermissionState.None); - // Create a SecurityElement instance by calling the ToXml method on the - // DnsPermission instance. - // Print its attributes, which hold the XML encoding of the DnsPermission - // instance. - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :"); - PrintKeysAndValues(permission.ToXml().Attributes); - - // Create a SecurityElement instance. - SecurityElement securityElementObj = new SecurityElement("IPermission"); - // Add attributes and values of the SecurityElement instance corresponding to - // the permission instance. - securityElementObj.AddAttribute("version", "1"); - securityElementObj.AddAttribute("Unrestricted", "true"); - securityElementObj.AddAttribute("class","System.Net.DnsPermission"); - - // Reconstruct a DnsPermission instance from an XML encoding. - DnsPermission permission1 = new DnsPermission(PermissionState.None); - permission1.FromXml(securityElementObj); - - // Print the attributes and values of the constructed DnsPermission object. - Console.WriteLine("After reconstruction Attributes and Values of new DnsPermission instance :"); - PrintKeysAndValues(permission1.ToXml().Attributes); - } - catch(NullReferenceException e) - { - Console.WriteLine("NullReferenceException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(ArgumentNullException e) - { - Console.WriteLine("ArgumentNullException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs b/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs deleted file mode 100644 index bf9d445d89f..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - This program demonstrates the 'Intersect' and 'Union' methods of 'DnsPermission' class. - It creates a 'DnsPermission' instance that is the Union/Intersection of current permission - instance and specified permission instance. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - private DnsPermission dnsPermission1; - private DnsPermission dnsPermission2; - - public static void Main() { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } - // - private void MyUnion() - { - // Create a DnsPermission instance that is the union of the current DnsPermission - // instance and the specified DnsPermission instance. - DnsPermission permission = (DnsPermission)dnsPermission1.Union(dnsPermission2); - // Print the attributes and the values of the union instance of DnsPermission. - PrintKeysAndValues(permission.ToXml().Attributes); - } -// - public void useDns() { - // Create a DnsPermission instance. - dnsPermission1 = new DnsPermission(PermissionState.Unrestricted); - dnsPermission2 = new DnsPermission(PermissionState.None); - // Check for permission. - dnsPermission1.Demand(); - dnsPermission2.Demand(); - Console.WriteLine("Attributes and Values of first DnsPermission instance :"); - PrintKeysAndValues(dnsPermission1.ToXml().Attributes); - Console.WriteLine("Attributes and Values of second DnsPermission instance :"); - PrintKeysAndValues(dnsPermission2.ToXml().Attributes); - Console.WriteLine("Union of both instances : "); - MyUnion(); - Console.WriteLine("Intersection of both instances : "); - MyIntersection(); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash tabble. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// - // Create a DnsPermission instance that is the intersection of current - // DnsPermission instance and the specified DnsPermission instance. - private void MyIntersection() - { - DnsPermission permission = (DnsPermission)dnsPermission1.Intersect(dnsPermission2); - // Print the attributes and the values of the intersection instance of - // DnsPermission. - PrintKeysAndValues(permission.ToXml().Attributes); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs b/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs deleted file mode 100644 index 69c71eb6ec1..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - This program demonstrates the 'IsSubsetOf' method of 'DnsPermission' class. - 'IsSubsetOf' method returns true, if the current DnsPermission instance allows no - more access to DNS servers than does the specified 'DnsPermission' instance. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - private DnsPermission permission; - - public static void Main() { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } -// - public void useDns() { - // Create a DnsPermission instance. - permission = new DnsPermission(PermissionState.Unrestricted); - DnsPermission dnsPermission1 = new DnsPermission(PermissionState.None); - // Check for permission. - permission.Demand(); - dnsPermission1.Demand(); - // Print the attributes and values. - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :"); - PrintKeysAndValues(permission.ToXml().Attributes); - Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :"); - PrintKeysAndValues(dnsPermission1.ToXml().Attributes); - Subset(dnsPermission1); - } - - private void Subset(DnsPermission Permission1) - { - if(permission.IsSubsetOf(Permission1)) - Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance."); - else - Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance."); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs b/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs deleted file mode 100644 index 0369b3cd3c7..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* - This program demonstrates the 'IsUnrestricted' method of 'DnsPermission' class. - It checks the overall permission state of the object and it will return true if the - 'DnsPermission' instance was created with unrestricted permission state otherwise false. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main(String[] Args) { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } -// - public void useDns() { - // Create a DnsPermission instance. - DnsPermission permission = new DnsPermission(PermissionState.Unrestricted); - // Check for permission. - permission.Demand(); - Console.WriteLine("Attributes and Values of DnsPermission instance :"); - // Print the attributes and values. - PrintKeysAndValues(permission.ToXml().Attributes); - // Check the permission state. - if (permission.IsUnrestricted()) - Console.WriteLine("Overall permissions : Unrestricted"); - else - Console.WriteLine("Overall permissions : Restricted"); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs b/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs deleted file mode 100644 index dda75739c35..00000000000 --- a/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Net; -using System.IO; -using System.Windows.Forms; - -public class Form1: Form -{ - public void Method() - { -// - Uri proxyURI = new Uri("http://webproxy:80"); - GlobalProxySelection.Select = new WebProxy(proxyURI); -// - } -} diff --git a/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs b/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs deleted file mode 100644 index e0230a24d8a..00000000000 --- a/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs +++ /dev/null @@ -1,157 +0,0 @@ -/* - This program demonstrates the 'SocketPermission(PermissionState)', - 'SocketPermission(NetworkAccess, TransportType, string, int) constructors, - 'FromXml', 'Intersect', 'AddPermission' methods and 'AllPorts' field - of 'SocketPermission' class. - - This program provides a class called 'DateClient' that functions as a client - for a 'DateServer'. A 'DateServer' is a server that provides the current date on - the server in response to a request from a client. The 'DateClient' class - provides a method called 'GetDate' which returns the current date on the server. - The 'GetDate' is the method that shows the use of 'SocketPermission' class. An - instance of 'SocketPermission' is obtained using the 'FromXml' method. Another - instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, - TransportType, string, int)' constructor. A third 'SocketPermission' object is - formed from the intersection of the above two 'SocketPermission' objects with the - use of the 'Intersect' method of 'SocketPermission' class. This 'SocketPermission' - object is used by the 'GetDate' method to verify the permissions of the calling - method. If the calling method has the requisite permissions the 'GetDate' method - connects to the 'DateServer' and returns the current date that the 'DateServer' - sends. If any exception occurs the 'GetDate' method returns an empty string. - - Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Collections; -using System.Security; -using System.Security.Permissions; - -public class DateClient { - - private Socket serverSocket; - private Encoding asciiEncoding; - private IPAddress serverAddress; - - private int serverPort; - - // The constructor takes the address and port of the remote server. - public DateClient(IPAddress ipAddress, int port) { - serverAddress = ipAddress; - serverPort = port; - serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - asciiEncoding = Encoding.ASCII; - } - - public String GetDate() { -// -// -// -// -// -// - SocketPermission socketPermission1 = new SocketPermission(PermissionState.Unrestricted); - - // Create a 'SocketPermission' object for two ip addresses. - SocketPermission socketPermission2 = new SocketPermission(PermissionState.None); - SecurityElement securityElement1 = socketPermission2.ToXml(); - // 'SocketPermission' object for 'Connect' permission - SecurityElement securityElement2 = new SecurityElement("ConnectAccess"); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All'ports for the ip-address. - SecurityElement securityElement3 = new SecurityElement("URI", "192.168.144.238#-1#3"); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and - // for 'All' ports for the ip-address. - SecurityElement securityElement4 = new SecurityElement("URI", "192.168.144.240#-1#3"); - securityElement2.AddChild(securityElement3); - securityElement2.AddChild(securityElement4); - securityElement1.AddChild(securityElement2); - - // Obtain a 'SocketPermission' object using 'FromXml' method. - socketPermission2.FromXml(securityElement1); - - Console.WriteLine("\nDisplays the result of FromXml method : \n"); - Console.WriteLine(socketPermission2.ToString()); - - // Create another 'SocketPermission' object with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission socketPermission3 = - new SocketPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.238", - SocketPermission.AllPorts); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3.AddPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.239", - SocketPermission.AllPorts); - - Console.WriteLine("Displays the result of AddPermission method : \n"); - Console.WriteLine(socketPermission3.ToString()); - - // Find the intersection between two 'SocketPermission' objects. - socketPermission1 = (SocketPermission)socketPermission2.Intersect(socketPermission3); - - Console.WriteLine("Displays the result of Intersect method :\n "); - Console.WriteLine(socketPermission1.ToString()); - - // Demand that the calling method have the requsite socket permission. - socketPermission1.Demand(); -// -// -// -// -// -// - // Get the current date from the remote date server. - try { - int bytesReceived; - byte[] getByte = new byte[100]; - serverSocket.Connect(new IPEndPoint( serverAddress, serverPort)); - bytesReceived = serverSocket.Receive( getByte, getByte.Length, 0 ); - return asciiEncoding.GetString( getByte, 0, bytesReceived ); - } - catch(Exception e) - { - Console.WriteLine("\nException raised : {0}", e.Message); - return ""; - } - } -}; - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' object. -public class UserDateClient { - - public static void Main(String[] args) { - if(args.Length != 2) - { - PrintUsage(); - return; - } - try { - DateClient myDateClient = new DateClient(IPAddress.Parse(args[0]), Int32.Parse(args[1])); - String currentDate = myDateClient.GetDate(); - Console.WriteLine("The current date and time is : "); - Console.WriteLine("{0}", currentDate); - } - // This exception is thrown by the called method in the context of improper permissions. - catch(SecurityException e) { - Console.WriteLine("\nSecurityException raised : {0}", e.Message); - } - catch(Exception e) { - Console.WriteLine("\nException raised : {0}", e.Message); - } - } - - private static void PrintUsage() { - Console.WriteLine("Usage : DateClient_SocketPermission_Constructor"); - Console.WriteLine("\tDateClient_SocketPermission_Constructor "); - Console.WriteLine("\tThe ipaddress argument is the ip address of the Date server."); - Console.WriteLine("\tThe port argument is the port of the Date server."); - } -}; diff --git a/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs b/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs deleted file mode 100644 index 02b1ca72f21..00000000000 --- a/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs +++ /dev/null @@ -1,186 +0,0 @@ -/* - This program demonstrates the 'ToXml' and 'IsUnrestricted' method and 'ConnectList' property of - 'SocketPermission' class. - - This program provides a class called 'DateClient' that functions as a client - for a 'DateServer'. A 'DateServer' is a server that provides the current date on - the server in response to a request from a client. The 'DateClient' class - provides a method called 'GetDate' which returns the current date on the server. - The 'GetDate' is the method that shows the use of 'SocketPermission' class. An - instance of 'SocketPermission' is obtained using the 'FromXml' method. Another - instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, - TransportType, string, int)' constructor. A third 'SocketPermission' object is - formed from the union of the above two 'SocketPermission' objects with the use of the - 'Union' method of the 'SocketPermission' class. This 'SocketPermission' object is used by - the 'GetDate' method to verify the permissions of the calling method. If the calling - method has the requisite permissions the 'GetDate' method connects to the 'DateServer' - and returns the current date that the 'DateServer' sends. If any exception occurs - the 'GetDate' method returns an empty string. - - Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -// -// -// -using System; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Collections; -using System.Security; -using System.Security.Permissions; - -public class DateClient { - - private Socket serverSocket; - private Encoding asciiEncoding; - private IPAddress serverAddress; - - private int serverPort; - - // The constructor takes the address and port of the remote server. - public DateClient(IPAddress serverIpAddress, int port) { - serverAddress = serverIpAddress; - serverPort = port; - serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - asciiEncoding = Encoding.ASCII; - } - - // Print a security element and all its children, in a depth-first manner. - private void PrintSecurityElement(SecurityElement securityElementObj, int depth) { - - Console.WriteLine("Depth : {0}", depth); - Console.WriteLine("Tag : {0}", securityElementObj.Tag); - Console.WriteLine("Text : {0}", securityElementObj.Text); - if(securityElementObj.Children != null) - Console.WriteLine("Children : {0}", securityElementObj.Children.Count); - - if(securityElementObj.Attributes != null) { - IEnumerator attributeEnumerator = securityElementObj.Attributes.GetEnumerator(); - while(attributeEnumerator.MoveNext()) - Console.WriteLine("Attribute - \"{0}\" , Value - \"{1}\"", ((IDictionaryEnumerator)attributeEnumerator).Key, - ((IDictionaryEnumerator)attributeEnumerator).Value); - } - - Console.WriteLine(""); - - if(securityElementObj.Children != null) { - depth += 1; - for(int i = 0; i < securityElementObj.Children.Count; i++) - PrintSecurityElement((SecurityElement)(securityElementObj.Children[i]), depth); - } - } - - public String GetDate() - { - - SocketPermission socketPermission1 = new SocketPermission(PermissionState.Unrestricted); - - // Create a 'SocketPermission' object for two ip addresses. - SocketPermission socketPermission2 = new SocketPermission(PermissionState.None); - SecurityElement securityElement4 = socketPermission2.ToXml(); - // 'SocketPermission' object for 'Connect' permission - SecurityElement securityElement1 = new SecurityElement("ConnectAccess"); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement securityElement2 = new SecurityElement("URI", "192.168.144.238#-1#3"); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement securityElement3 = new SecurityElement("URI", "192.168.144.240#-1#3"); - securityElement1.AddChild(securityElement2); - securityElement1.AddChild(securityElement3); - securityElement4.AddChild(securityElement1); - - // Obtain a 'SocketPermission' object using 'FromXml' method. - socketPermission2.FromXml(securityElement4); - - // Create another 'SocketPermission' object with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission socketPermission3 = - new SocketPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.238", - SocketPermission.AllPorts); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3.AddPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.239", - SocketPermission.AllPorts); - - Console.WriteLine("\nChecks the Socket permissions using IsUnrestricted method : "); - if(socketPermission1.IsUnrestricted()) - Console.WriteLine("Socket permission is unrestricted"); - else - Console.WriteLine("Socket permission is restricted"); - - Console.WriteLine(); - - Console.WriteLine("Display result of ConnectList property : \n"); - IEnumerator enumerator = socketPermission3.ConnectList; - while(enumerator.MoveNext()) { - Console.WriteLine("The hostname is : {0}", ((EndpointPermission)enumerator.Current).Hostname); - Console.WriteLine("The port is : {0}", ((EndpointPermission)enumerator.Current).Port); - Console.WriteLine("The Transport type is : {0}", ((EndpointPermission)enumerator.Current).Transport); - } - Console.WriteLine(""); - - Console.WriteLine("Display Security Elements :\n "); - PrintSecurityElement(socketPermission2.ToXml(), 0); - - // Get a 'SocketPermission' object which is a union of two other 'SocketPermission' objects. - socketPermission1 = (SocketPermission)socketPermission3.Union(socketPermission2); - - // Demand that the calling method have the socket permission. - socketPermission1.Demand(); - - // Get the current date from the remote date server. - try { - int bytesReceived; - byte[] getByte = new byte[100]; - serverSocket.Connect(new IPEndPoint( serverAddress, serverPort)); - bytesReceived = serverSocket.Receive( getByte, getByte.Length, 0 ); - return asciiEncoding.GetString( getByte, 0, bytesReceived ); - } - catch(Exception e) - { - Console.WriteLine("\nException raised : {0}", e.Message); - return ""; - } - } -}; -// -// -// - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' object. -public class UserDateClient { - - public static void Main(String[] args) { - if(args.Length != 2) - { - PrintUsage(); - return; - } - try { - DateClient myDateClient = new DateClient(IPAddress.Parse(args[0]), Int32.Parse(args[1])); - String currentDate = myDateClient.GetDate(); - Console.WriteLine("The current date and time is : "); - Console.WriteLine("{0}", currentDate); - } - // This exception is thrown by the called method in the context of improper permissions. - catch(SecurityException e) { - Console.WriteLine("\nSecurityException raised : {0}", e.Message); - } - catch(Exception e) { - Console.WriteLine("\nException raised : {0}", e.Message); - } - } - - private static void PrintUsage() { - Console.WriteLine("Usage : DateClient_SocketPermission_ToXml"); - Console.WriteLine("\tDateClient_SocketPermission_ToXml "); - Console.WriteLine("\tThe ipaddress argument is the ip address of the Date server."); - Console.WriteLine("\tThe port argument is the port of the Date server."); - } -}; diff --git a/snippets/csharp/System.Net/SocketPermission/Overview/source.cs b/snippets/csharp/System.Net/SocketPermission/Overview/source.cs deleted file mode 100644 index 18465949600..00000000000 --- a/snippets/csharp/System.Net/SocketPermission/Overview/source.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Text; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.Security.Permissions; -using System.Collections; - -public class MySocketPermissionExample{ - -public static void MySocketPermission(){ -// -// - - // Creates a SocketPermission restricting access to and from all URIs. - SocketPermission mySocketPermission1 = new SocketPermission(PermissionState.None); - - // The socket to which this permission will apply will allow connections from www.contoso.com. - mySocketPermission1.AddPermission(NetworkAccess.Accept, TransportType.Tcp, "www.contoso.com", 11000); - - // Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com. - SocketPermission mySocketPermission2 = - new SocketPermission(NetworkAccess.Connect, TransportType.Tcp, "www.southridgevideo.com", 11002); - - // Creates a SocketPermission from the union of two SocketPermissions. - SocketPermission mySocketPermissionUnion = - (SocketPermission)mySocketPermission1.Union(mySocketPermission2); - - // Checks to see if the union was successfully created by using the IsSubsetOf method. - if (mySocketPermission1.IsSubsetOf(mySocketPermissionUnion) && - mySocketPermission2.IsSubsetOf(mySocketPermissionUnion)){ - Console.WriteLine("This union contains permissions from both mySocketPermission1 and mySocketPermission2"); - - // Prints the allowable accept URIs to the console. - Console.WriteLine("This union accepts connections on :"); - - IEnumerator myEnumerator = mySocketPermissionUnion.AcceptList; - while (myEnumerator.MoveNext()) { - Console.WriteLine(((EndpointPermission)myEnumerator.Current).ToString()); - } - - // Prints the allowable connect URIs to the console. - Console.WriteLine("This union permits connections to :"); - - myEnumerator = mySocketPermissionUnion.ConnectList; - while (myEnumerator.MoveNext()) { - Console.WriteLine(((EndpointPermission)myEnumerator.Current).ToString()); - } - } - -// -// - - // Creates a SocketPermission from the intersect of two SocketPermissions. - SocketPermission mySocketPermissionIntersect = - (SocketPermission)mySocketPermission1.Intersect(mySocketPermissionUnion); - - // mySocketPermissionIntersect should now contain the permissions of mySocketPermission1. - if (mySocketPermission1.IsSubsetOf(mySocketPermissionIntersect)){ - Console.WriteLine("This is expected"); - } - // mySocketPermissionIntersect should not contain the permissios of mySocketPermission2. - if (mySocketPermission2.IsSubsetOf(mySocketPermissionIntersect)){ - Console.WriteLine("This should not print"); - } - -// - -// -// Creates a copy of the intersect SocketPermission. - SocketPermission mySocketPermissionIntersectCopy = - (SocketPermission)mySocketPermissionIntersect.Copy(); - - if (mySocketPermissionIntersectCopy.Equals(mySocketPermissionIntersect)){ - Console.WriteLine("Copy successfull"); - } - -// - - // Converts a SocketPermission to XML format and then immediately converts it back to a SocketPermission. - mySocketPermission1.FromXml(mySocketPermission1.ToXml()); - - // Checks to see if permission for this socket resource is unrestricted. If it is, then there is no need to - // demand that permissions be enforced. - if (mySocketPermissionUnion.IsUnrestricted()){ - - //Do nothing. There are no restrictions. - } - else{ - // Enforces the permissions found in mySocketPermissionUnion on any Socket Resources used below this statement. - mySocketPermissionUnion.Demand(); - } - - IPHostEntry myIpHostEntry = Dns.Resolve("www.contoso.com"); - IPEndPoint myLocalEndPoint = new IPEndPoint(myIpHostEntry.AddressList[0], 11000); - - Socket s = new Socket(myLocalEndPoint.Address.AddressFamily, - SocketType.Stream, - ProtocolType.Tcp); - try{ - s.Connect(myLocalEndPoint); - } - catch (Exception e){ - Console.WriteLine("Exception Thrown: " + e.ToString()); - } - - // Perform all socket operations in here. - - s.Close(); -// -} - -public static void Main(){ -MySocketPermissionExample.MySocketPermission(); -} -} diff --git a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs b/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs deleted file mode 100644 index 97372f19217..00000000000 --- a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs +++ /dev/null @@ -1,73 +0,0 @@ -// System.Net.WebPermission.WebPermission(NetworkAccess,Regex); -/* - This program demonstrates the 'WebPermission(NetworkAccess,Regex)' constructor of 'WebPermission' class. - First a 'Regex' object is created that will accept all the urls which is having the hostfragment of - 'www.contoso.com'.Then a 'WebPermission' object created by passing the 'NetworkAccess' permission and - 'Regex' object as parameters. It checks the 'WebPermission' for all the url's having the host fragment - as 'www.contoso.com'. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Text.RegularExpressions; -using System.Collections; - -class WebPermission_regexConstructor { - - static void Main() - { - try - { - WebPermission_regexConstructor myWebPermissionRegex = new WebPermission_regexConstructor(); - myWebPermissionRegex.CreateRegexConstructor(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException raised: " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception raised: " + e.Message); - } - } - - public void CreateRegexConstructor() - { - -// - - // Create an instance of 'Regex' that accepts all URL's containing the host - // fragment 'www.contoso.com'. - Regex myRegex = new Regex(@"http://www\.contoso\.com/.*"); - - // Create a WebPermission that gives the permissions to all the hosts containing - // the same fragment. - WebPermission myWebPermission = new WebPermission(NetworkAccess.Connect,myRegex); - - // Checks all callers higher in the call stack have been granted the permission. - myWebPermission.Demand(); - -// - - Console.WriteLine("Attribute and Values of WebPermission are : \n"); - // Display the Attributes,Values and Children of the XML encoded copied instance. - PrintKeysAndValues(myWebPermission.ToXml().Attributes,myWebPermission.ToXml().Children); - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-ATTRIBUTES-\t-VALUE-"); - while (myEnumerator.MoveNext()) - {Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);} - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("\nThe Children are : "); - while (myEnumerator1.MoveNext()) - {Console.Write("\t{0}", myEnumerator1.Current);} - } - } \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs b/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs deleted file mode 100644 index 3ce63eb2464..00000000000 --- a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs +++ /dev/null @@ -1,84 +0,0 @@ -// System.Net.WebPermission.WebPermission(PermissionState);System.Net.WebPermission.Copy; -/** - * This program demonstrates the WebPermission(PermissionState) constructor and - * Copy method of the WebPermission class . - * It creates a WebPermission instance with Permissionstate set to None and - * sets the access right to one pair of URLs. - * Then it uses the Copy method to create another instance of WebPermission class - * Finally, the attributes , values and childrens of both the XML encoded instances - * are displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class CopyWebPermission { - - static void Main() - { - try - { - CopyWebPermission myCopyWebPermission = new CopyWebPermission(); - myCopyWebPermission.CreateCopy(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CreateCopy() - { - -// - // Create a WebPermission instance. - WebPermission myWebPermission1 = new WebPermission(PermissionState.None); - - // Allow access to the first set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.microsoft.com/default.htm"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.msn.com"); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission1.Demand(); - -// - -// - // Create another WebPermission instance that is the copy of the above WebPermission instance. - WebPermission myWebPermission2 = (WebPermission) myWebPermission1.Copy(); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission2.Demand(); - -// - Console.WriteLine("The Attributes and Values are :\n"); - // Display the Attributes,Values and Children of the XML encoded instance. - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission1.ToXml().Children); - - Console.WriteLine("\nCopied Instance Attributes and Values are :\n"); - // Display the Attributes,Values and Children of the XML encoded copied instance. - PrintKeysAndValues(myWebPermission2.ToXml().Attributes,myWebPermission2.ToXml().Children); - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - - // Gets the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } - } \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs b/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs deleted file mode 100644 index b2ed0a605bc..00000000000 --- a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs +++ /dev/null @@ -1,88 +0,0 @@ -// System.Net.WebPermission.WebPermission(NetworkAccess, uriString);System.Net.WebPermission.Union; - -/** - * This program shows the use of the WebPermission(NetworkAccess access,string uriString) - * constructor and Union method of the WebPermission' class. - * It creates two instance of the WebPermission class with the specified access - * rights to the predefined URIs. - * It displays the attributes , values and childrens of those XML encoded - * instances. - * Then, using the Union method, it creates a third WebPermission instance - * via a logical union of the first two. - * Finally, it displays the attributes , values and childrens of those XML encoded - * instances. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermissionUnion -{ - - static void Main() - { - try - { - WebPermissionUnion myWebPermissionUnion = new WebPermissionUnion(); - myWebPermissionUnion.CreateUnion(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CreateUnion() - { -// - - // Create a WebPermission.instance. - WebPermission myWebPermission1 = new WebPermission(NetworkAccess.Connect,"http://www.contoso.com/default.htm"); - myWebPermission1.Demand(); - -// - - // Create another WebPermission instance. - WebPermission myWebPermission2 = new WebPermission(NetworkAccess.Connect,"http://www.adventure-works.com"); - myWebPermission2.Demand(); - - // Print the attributes, values and childrens of the XML encoded instances. - Console.WriteLine("Attributes and values of the first WebPermission are : "); - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission1.ToXml().Children); - - Console.WriteLine("\nAttributes and values of the second WebPermission are : "); - PrintKeysAndValues(myWebPermission2.ToXml().Attributes,myWebPermission2.ToXml().Children); - -// - - // Create another WebPermission that is the Union of previous two WebPermission - // instances. - WebPermission myWebPermission3 =(WebPermission) myWebPermission1.Union(myWebPermission2); - Console.WriteLine("\nAttributes and values of the WebPermission after the Union are : "); - // Display the attributes,values and children. - Console.WriteLine(myWebPermission3.ToXml().ToString()); - -// - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } - } diff --git a/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs b/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs deleted file mode 100644 index d58ea637ea7..00000000000 --- a/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs +++ /dev/null @@ -1,93 +0,0 @@ -// System.Net.WebPermission.ConnectList;System.Net.WebPermission.AcceptList; - -/** - * This program demonstrates the use of the ConnectList and AcceptList WebPermission - * class properties. - * It first creates a WebPermission object with Permissionstate set to None and then - * sets the Connect and Accept access right to some predefined URLs. - * The using the AcceptList and ConnectList properties it displays the URLs that have - * the Accept and Connect permission set, respectively. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermission_AcceptConnectList -{ - static void Main() - { - try - { - WebPermission_AcceptConnectList myWebPermission_AcceptConnectList = new WebPermission_AcceptConnectList(); - myWebPermission_AcceptConnectList.DisplayAcceptConnect(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void DisplayAcceptConnect() - { - // Create a 'WebPermission' object with permission state set to 'None'. - WebPermission myWebPermission1 = new WebPermission(PermissionState.None); - - // Allow 'Connect' access right to first set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.contoso.com"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.alpineskihouse.com"); - - // Allow 'Accept' access right to second set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Accept,"http://www.contoso.com"); - myWebPermission1.AddPermission(NetworkAccess.Accept,"http://www.adventure-works.com"); - myWebPermission1.AddPermission(NetworkAccess.Accept,"http://www.alpineskihouse.com"); - - // Check whether all callers higher in the call stack have been granted the permission or not. - myWebPermission1.Demand(); - - Console.WriteLine("The Attributes,Values and Children of the 'WebPermission' object are :\n"); - // Display the Attributes,Values and Children of the XML encoded instance. - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission1.ToXml().Children); - -// - - // Gets all URIs with Connect permission. - IEnumerator myEnum = myWebPermission1.ConnectList; - Console.WriteLine("\nThe URIs with Connect permission are :\n"); - while (myEnum.MoveNext()) - { Console.WriteLine("\tThe URI is : "+myEnum.Current); } - -// - -// - - // Get all URI's with Accept permission. - IEnumerator myEnum1 = myWebPermission1.AcceptList; - Console.WriteLine("\n\nThe URIs with Accept permission are :\n"); - while (myEnum1.MoveNext()) - { Console.WriteLine("\tThe URI is : "+myEnum1.Current); } - -// - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtabel. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-Attribute-\t-Value-"); - while (myEnumerator.MoveNext()) - {Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);} - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : \n"); - while (myEnumerator1.MoveNext()) - {Console.Write( myEnumerator1.Current);} - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs b/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs deleted file mode 100644 index df66b84442a..00000000000 --- a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs +++ /dev/null @@ -1,97 +0,0 @@ -// System.Net.WebPermission.WebPermission(); -// System.Net.WebPermission.AddPermission(NetworkAccess,stringuri); -// System.Net.WebPermission.Intersect; -/** - * This program shows the use of the WebPermission() constructor, the AddPermission, - * and Intersect' methods of the WebPermission' class. - * It first creates two WebPermission objects with no arguments, with each of them - * setting the access rights to one pair of URLs. - * Then it displays the attributes , values and childrens of the XML encoded instances. - * Finally, it creates a third WebPermission object using the logical intersection of the - * first two objects. It does so by using the Intersect method. - * It then displays the attributes , values and childrens of the related XML encoded - * instances. - */ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermissionIntersect -{ - static void Main(String[] Args) - { - try - { - WebPermissionIntersect myWebPermissionIntersect = new WebPermissionIntersect(); - myWebPermissionIntersect.CreateIntersect(); - }catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CreateIntersect() - { -// - // Create two WebPermission instances. - WebPermission myWebPermission1 = new WebPermission(); - WebPermission myWebPermission2 = new WebPermission(); - -// - - // Allow access to the first set of resources. - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.contoso.com/default.htm"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com/default.htm"); - - // Check whether if the callers higher in the call stack have been granted - // access permissions. - myWebPermission1.Demand(); - -// - // Allow access right to the second set of resources. - myWebPermission2.AddPermission(NetworkAccess.Connect,"http://www.alpineskihouse.com/default.htm"); - myWebPermission2.AddPermission(NetworkAccess.Connect,"http://www.baldwinmuseumofscience.com/default.htm"); - myWebPermission2.Demand(); - -// - - // Display the attributes , values and childrens of the XML encoded instances. - Console.WriteLine("Attributes and values of first 'WebPermission' instance are :"); - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission2.ToXml().Children); - - Console.WriteLine("\nAttributes and values of second 'WebPermission' instance are : "); - PrintKeysAndValues(myWebPermission2.ToXml().Attributes,myWebPermission2.ToXml().Children); - -// - - // Create a third WebPermission instance via the logical intersection of the previous - // two WebPermission instances. - WebPermission myWebPermission3 =(WebPermission) myWebPermission1.Intersect(myWebPermission2); - - Console.WriteLine("\nAttributes and Values of the WebPermission instance after the Intersect are:\n"); - Console.WriteLine(myWebPermission3.ToXml().ToString()); - -// - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } -} diff --git a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs b/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs deleted file mode 100644 index 7ea6a58bf1c..00000000000 --- a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs +++ /dev/null @@ -1,103 +0,0 @@ -// System.Net.WebPermission.AddPermission(NetworkAccess, regex); -// System.Net.WebPermission.IsSubsetOf; -/** - * This program shows how to use the AddPermission(NetworkAccess, regex) and - * IsSubset methods of WebPermission class. - * It creates two WebPermission instances with the Connect access rights for the - * specified URIs. - * For he first WebPermission instance, a Connect access right is given to the - * URLs with the host fragment www.microsoft.com. This is done by using - * the AddPermission(NetworkAccess, regex) method. - * Then, a third WebPermission instance is created with the Connect access right to - * the URLs of the first and second WebPermission instances. - * Finally, the attributes, values and children of that instance are displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; -using System.Text.RegularExpressions; - -class WebPermissionIsSubset{ - - static void Main() - { - try - { - WebPermissionIsSubset myWebPermissionIsSubset = new WebPermissionIsSubset(); - myWebPermissionIsSubset.CheckSubset(); - } - - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CheckSubset() - { -// - // Create a WebPermission. - WebPermission myWebPermission1 = new WebPermission(); - - // Allow Connect access to the specified URLs. - myWebPermission1.AddPermission(NetworkAccess.Connect,new Regex("http://www\\.contoso\\.com/.*", - RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline)); - - myWebPermission1.Demand(); - -// - - // Create another WebPermission with the specified URL. - WebPermission myWebPermission2 = new WebPermission(NetworkAccess.Connect,"http://www.contoso.com"); - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission2.Demand(); - -// - - WebPermission myWebPermission3 = null; - // Check which permissions have the Connect access to more number of URLs. - if(myWebPermission2.IsSubsetOf(myWebPermission1)) - { - Console.WriteLine("\n WebPermission2 is the Subset of WebPermission1\n"); - myWebPermission3 = myWebPermission1; - } - else if(myWebPermission1.IsSubsetOf(myWebPermission2)) - { - Console.WriteLine("\n WebPermission1 is the Subset of WebPermission2"); - myWebPermission3 = myWebPermission2; - } - else - { - // Create the third permission. - myWebPermission3 = (WebPermission)myWebPermission1.Union(myWebPermission2); - } - -// - // Prints the attributes , values and childrens of XML encoded instances. - - Console.WriteLine("\nAttributes and Values of third WebPermission instance are : "); - PrintKeysAndValues(myWebPermission3.ToXml().Attributes,myWebPermission3.ToXml().Children); - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } - } \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs b/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs deleted file mode 100644 index cb870401c9a..00000000000 --- a/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs +++ /dev/null @@ -1,71 +0,0 @@ -// System.Net.WebPermission.ToXml;System.Net.WebPermission.FromXml; -/** - * This program shows the use of the ToXml and FromXml methods of the WebPermission class. - * It creates a WebPermission instance with the Permissionstate set to None and - * displays the attributes and the values of the XML encoded instance . - * Then a SecurityElement instance is created and it's attributes are - * set. - * Finally, using the FromXml method the WebPermission instance is reconstructed from - * the above SecurityElement instance and the attributes are displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermission_FromToXml { - - static void Main() - { - try - { - WebPermission_FromToXml myWebPermission_FromToXml = new WebPermission_FromToXml(); - myWebPermission_FromToXml.CallXml(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CallXml() - { -// - - // Create a WebPermission without permission on the protected resource. - WebPermission myWebPermission1 = new WebPermission(PermissionState.None); - - // Create a SecurityElement by calling the ToXml method on the WebPermission - // instance and display its attributes (which hold the XML encoding of - // the WebPermission). - Console.WriteLine("Attributes and Values of the WebPermission are :"); - myWebPermission1.ToXml().ToString(); - - // Create another WebPermission with no permission on the protected resource. - WebPermission myWebPermission2 = new WebPermission(PermissionState.None); - - //Converts the new WebPermission from XML using myWebPermission1. - myWebPermission2.FromXml(myWebPermission1.ToXml()); - -// - - Console.WriteLine("The Attributes and Values of 'WebPermission' instance after reconstruction are: \n"); - // Display the Attributes and values of the XML encoded instances. - PrintKeysAndValues(myWebPermission2.ToXml().Attributes); - } - - private void PrintKeysAndValues(Hashtable myHashtable) - { - // Get the enumerator to iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } - } diff --git a/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs b/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs deleted file mode 100644 index 3550b42d0bf..00000000000 --- a/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs +++ /dev/null @@ -1,42 +0,0 @@ -// System.Net.WebPermission.AddPermission(NetworkAccess, regex);System.Net.WebPermission.IsSubsetOf; -/** - * This program shows the use of the AddPermission(NetworkAccess, regex) and - * IsSubset methods of the WebPermission class. - * It creates two WebPermission instances with the Connect access rights for the specified - * URIs. The second URI being a subset of the first one. - * Then the IsSubsetOf method is called to verify that the second URI is indeed a subset - * of the firts one. The result of the call to the IsSubsetOf is then displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; -using System.Text.RegularExpressions; - -public class Sample -{ - - public static void myIsSubsetExample() - { -// - - // Create the target permission. - WebPermission targetPermission = new WebPermission(); - targetPermission.AddPermission(NetworkAccess.Connect, new Regex("www\\.contoso\\.com/Public/.*")); - - // Create the permission for a URI matching target. - WebPermission connectPermission = new WebPermission(); - connectPermission.AddPermission(NetworkAccess.Connect, "www.contoso.com/Public/default.htm"); - - //The following statement prints true. - Console.WriteLine("Is the second URI a subset of the first one?: " + connectPermission.IsSubsetOf(targetPermission)); - -// - } - public static void Main() - { - // Verify that the second URI is a subset of the first one. - myIsSubsetExample(); - } -} diff --git a/snippets/csharp/System.Net/WebPermission/Overview/regex.cs b/snippets/csharp/System.Net/WebPermission/Overview/regex.cs deleted file mode 100644 index 87a4f3d56a6..00000000000 --- a/snippets/csharp/System.Net/WebPermission/Overview/regex.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Text.RegularExpressions; -using System.Collections; - -class WebPermissionExample -{ - - public static void MySample() - { -// - - // Create a Regex that accepts all URLs containing the host fragment www.contoso.com. - Regex myRegex = new Regex(@"http://www\.contoso\.com/.*"); - - // Create a WebPermission that gives permissions to all the hosts containing the same host fragment. - WebPermission myWebPermission = new WebPermission(NetworkAccess.Connect,myRegex); - - //Add connect privileges for a www.adventure-works.com. - myWebPermission.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com"); - - //Add accept privileges for www.alpineskihouse.com. - myWebPermission.AddPermission(NetworkAccess.Accept, "http://www.alpineskihouse.com/"); - - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission.Demand(); - - // Get all the URIs with Connect permission. - IEnumerator myConnectEnum = myWebPermission.ConnectList; - Console.WriteLine("\nThe 'URIs' with 'Connect' permission are :\n"); - while (myConnectEnum.MoveNext()) - {Console.WriteLine("\t" + myConnectEnum.Current);} - - // Get all the URIs with Accept permission. - IEnumerator myAcceptEnum = myWebPermission.AcceptList; - Console.WriteLine("\n\nThe 'URIs' with 'Accept' permission is :\n"); - - while (myAcceptEnum.MoveNext()) - {Console.WriteLine("\t" + myAcceptEnum.Current);} - -// - } - - public static void Main() - { - MySample(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs deleted file mode 100644 index 987cf41fedb..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs +++ /dev/null @@ -1,49 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - -/* - * Demonstrate how to use the WebPermissionAttribute to specify the Accept property. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; - -public class WebPermissionAttribute_AcceptConnect{ -// - -// Deny access to a specific resource by setting the Accept property. -[WebPermission(SecurityAction.Deny, Accept=@"http://www.contoso.com/Private.htm")] - -public static void CheckAcceptPermission(string uriToCheck) -{ - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Accept, uriToCheck); - permissionToCheck.Demand(); -} - -public static void demoDenySite() -{ - //Pass the security check when accessing allowed resources. - CheckAcceptPermission("http://www.contoso.com/"); - Console.WriteLine("Public page has passed Accept permission check"); - - try - { - //Throw a SecurityException when trying to access not allowed resources. - CheckAcceptPermission("http://www.contoso.com/Private.htm"); - Console.WriteLine("This line will not be printed"); - } - catch (SecurityException e) - { - Console.WriteLine("Exception trying to access private resource:" + e.Message); - } - } - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs deleted file mode 100644 index 74d3922b31b..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs +++ /dev/null @@ -1,47 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; -/* -This program demonstrates the 'Connect' and 'Accept' properties of the class 'WebPermissionAttribute'. -The program uses declarative security for calling the code in 'Connect' method. -By using the 'Accept' and 'Connect' properties of 'WebPermissionAttribute' accept and connect access -has been given to the uri www.contoso.com. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; -using System.Text.RegularExpressions; - -public class WebPermissionAttribute_AcceptConnect{ -// -[WebPermission(SecurityAction.Deny, AcceptPattern=@"http://www\.contoso\.com/Private/.*")] - -public static void CheckAcceptPermission(string uriToCheck) { - - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Accept, uriToCheck); - permissionToCheck.Demand(); -} - -public static void demoDenySite() { - //Passes a security check. - CheckAcceptPermission("http://www.contoso.com/Public/page.htm"); - Console.WriteLine("Public page has passed Accept permission check"); - - try { - //Throws a SecurityException. - CheckAcceptPermission("http://www.contoso.com/Private/page.htm"); - Console.WriteLine("This line will not be printed"); -} - catch (SecurityException e) { - Console.WriteLine("Expected exception: " + e.Message); - } - } - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs deleted file mode 100644 index b558991d521..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs +++ /dev/null @@ -1,45 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.connect; - -// Demonstrate how to use the WebPermissionAttribute Connect property. - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; - -public class WebPermissionAttribute_Connect{ -// - -// Set the WebPermissionAttribute Connect property. -[WebPermission(SecurityAction.Deny, Connect=@"http://www.contoso.com/Private.htm")] - -public static void demoDenySite() -{ - //Pass the security check. - CheckConnectPermission("http://www.contoso.com/Public.htm"); - Console.WriteLine("Public page has passed connect permission check"); - - try - { - //Throw a SecurityException. - CheckConnectPermission("http://www.contoso.com/Private.htm"); - Console.WriteLine("This line will not be printed"); - } - catch (SecurityException e) { - Console.WriteLine("Expected exception" + e.Message); - } - } - -public static void CheckConnectPermission(string uriToCheck) { - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Connect, uriToCheck); - permissionToCheck.Demand(); -} - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs deleted file mode 100644 index 6aa267ea890..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs +++ /dev/null @@ -1,48 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Connect; - -// Demonstrate how to use the WebPermissionAttribute ConnectPattern property. - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; -using System.Text.RegularExpressions; - -public class WebPermissionAttribute_Connect -{ - // - - // Set the WebPermissionAttribute ConnectPattern property. - [WebPermission(SecurityAction.Deny, ConnectPattern=@"http://www\.contoso\.com/Private/.*")] - -public static void CheckConnectPermission(string uriToCheck) -{ - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Connect, uriToCheck); - permissionToCheck.Demand(); -} - -public static void demoDenySite() { - //Pass the security check. - CheckConnectPermission("http://www.contoso.com/Public/page.htm"); - Console.WriteLine("Public page has passed Connect permission check"); - - try - { - //Throw a SecurityException. - CheckConnectPermission("http://www.contoso.com/Private/page.htm"); - Console.WriteLine("This line will not be printed"); - } - catch (SecurityException e) - { - Console.WriteLine("Expected exception" + e.Message); - } - } - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs b/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs deleted file mode 100644 index fccdc85ef47..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs +++ /dev/null @@ -1,47 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - -// Demonstrate how to use the WebPermissionAttribute to specify an allowable ConnectPattern. - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; - -public class WebPermissionAttribute_AcceptConnect{ - -// -// - - // Deny access to a specific resource by setting the ConnectPattern property. - [WebPermission(SecurityAction.Deny, ConnectPattern=@"http://www\.contoso\.com/")] - -public void Connect() - { - // Create a Connection. - HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create("http://www.contoso.com"); - Console.WriteLine("This line should never be printed"); - } - -// -// - - static void Main() - { - - try - { - - WebPermissionAttribute_AcceptConnect myWebAttrib = new WebPermissionAttribute_AcceptConnect(); - myWebAttrib.Connect(); - } - catch(SecurityException e) - { - Console.WriteLine("Security Exception raised : "+e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception raised : "+ e.Message); - } - } - } diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs deleted file mode 100644 index eede76956de..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - // - BigInteger bigIntFromDouble = new BigInteger(179032.6541); - Console.WriteLine(bigIntFromDouble); - BigInteger bigIntFromInt64 = new BigInteger(934157136952); - Console.WriteLine(bigIntFromInt64); - // The example displays the following output: - // 179032 - // 934157136952 - // - - Console.WriteLine(); - - // - long longValue = 6315489358112; - BigInteger assignedFromLong = longValue; - Console.WriteLine(assignedFromLong); - // The example displays the following output: - // 6315489358112 - // - - Console.WriteLine(); - Console.WriteLine("Casting:"); - // - BigInteger assignedFromDouble = (BigInteger) 179032.6541; - Console.WriteLine(assignedFromDouble); - BigInteger assignedFromDecimal = (BigInteger) 64312.65m; - Console.WriteLine(assignedFromDecimal); - // The example displays the following output: - // 179032 - // 64312 - // - - Console.WriteLine(); - - // - byte[] byteArray = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; - BigInteger newBigInt = new BigInteger(byteArray); - Console.WriteLine("The value of newBigInt is {0} (or 0x{0:x}).", newBigInt); - // The example displays the following output: - // The value of newBigInt is 4759477275222530853130 (or 0x102030405060708090a). - // - - Console.WriteLine(); - - // - string positiveString = "91389681247993671255432112000000"; - string negativeString = "-90315837410896312071002088037140000"; - BigInteger posBigInt = 0; - BigInteger negBigInt = 0; - - try { - posBigInt = BigInteger.Parse(positiveString); - Console.WriteLine(posBigInt); - } - catch (FormatException) - { - Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", - positiveString); - } - - if (BigInteger.TryParse(negativeString, out negBigInt)) - Console.WriteLine(negBigInt); - else - Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", - negativeString); - - // The example displays the following output: - // 9.1389681247993671255432112E+31 - // -9.0315837410896312071002088037E+34 - // - - Console.WriteLine(); - - // - BigInteger number = BigInteger.Pow(UInt64.MaxValue, 3); - Console.WriteLine(number); - // The example displays the following output: - // 6277101735386680762814942322444851025767571854389858533375 - // - } -} diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs deleted file mode 100644 index 0ae0bb0204e..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Globalization; -using System.Numerics; - -public class Example -{ - public static void Main() - { - RoundtripBigInteger(); - Console.WriteLine(); - RoundtripInt16(); - Console.WriteLine(); - HandleSignsInByteArray(); - Console.WriteLine(); - RoundtripAmbiguous(); - Console.WriteLine(); - RoundtripWithHex(); - } - - private static void RoundtripBigInteger() - { - Console.WriteLine("Round-trip bytes"); - - // - BigInteger number = BigInteger.Pow(Int64.MaxValue, 2); - Console.WriteLine(number); - - // Write the BigInteger value to a byte array. - byte[] bytes = number.ToByteArray(); - - // Display the byte array. - foreach (byte byteValue in bytes) - Console.Write("0x{0:X2} ", byteValue); - Console.WriteLine(); - - // Restore the BigInteger value from a Byte array. - BigInteger newNumber = new BigInteger(bytes); - Console.WriteLine(newNumber); - // The example displays the following output: - // 8.5070591730234615847396907784E+37 - // 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x3F - // - // 8.5070591730234615847396907784E+37 - // - } - - private static void RoundtripInt16() - { - Console.WriteLine(); - Console.WriteLine("Round-trip an Int16 value:"); - // - short originalValue = 30000; - Console.WriteLine(originalValue); - - // Convert the Int16 value to a byte array. - byte[] bytes = BitConverter.GetBytes(originalValue); - - // Display the byte array. - foreach (byte byteValue in bytes) - Console.Write("0x{0} ", byteValue.ToString("X2")); - Console.WriteLine(); - - // Pass byte array to the BigInteger constructor. - BigInteger number = new BigInteger(bytes); - Console.WriteLine(number); - // The example displays the following output: - // 30000 - // 0x30 0x75 - // 30000 - // - } - - private static void HandleSignsInByteArray() - { - // - int negativeNumber = -1000000; - uint positiveNumber = 4293967296; - - byte[] negativeBytes = BitConverter.GetBytes(negativeNumber); - BigInteger negativeBigInt = new BigInteger(negativeBytes); - Console.WriteLine(negativeBigInt.ToString("N0")); - - byte[] tempPosBytes = BitConverter.GetBytes(positiveNumber); - byte[] positiveBytes = new byte[tempPosBytes.Length + 1]; - Array.Copy(tempPosBytes, positiveBytes, tempPosBytes.Length); - BigInteger positiveBigInt = new BigInteger(positiveBytes); - Console.WriteLine(positiveBigInt.ToString("N0")); - // The example displays the following output: - // -1,000,000 - // 4,293,967,296 - // - } - - private static void RoundtripAmbiguous() - { - Console.WriteLine("Round-trip an Ambiguous Value:"); - // - BigInteger positiveValue = 15777216; - BigInteger negativeValue = -1000000; - - Console.WriteLine("Positive value: " + positiveValue.ToString("N0")); - byte[] bytes = positiveValue.ToByteArray(); - - foreach (byte byteValue in bytes) - Console.Write("{0:X2} ", byteValue); - Console.WriteLine(); - positiveValue = new BigInteger(bytes); - Console.WriteLine("Restored positive value: " + positiveValue.ToString("N0")); - - Console.WriteLine(); - - Console.WriteLine("Negative value: " + negativeValue.ToString("N0")); - bytes = negativeValue.ToByteArray(); - foreach (byte byteValue in bytes) - Console.Write("{0:X2} ", byteValue); - Console.WriteLine(); - negativeValue = new BigInteger(bytes); - Console.WriteLine("Restored negative value: " + negativeValue.ToString("N0")); - // The example displays the following output: - // Positive value: 15,777,216 - // C0 BD F0 00 - // Restored positive value: 15,777,216 - // - // Negative value: -1,000,000 - // C0 BD F0 - // Restored negative value: -1,000,000 - // - } - - private static void RoundtripWithHex() - { - // - BigInteger negativeNumber = -1000000; - BigInteger positiveNumber = 15777216; - - string negativeHex = negativeNumber.ToString("X"); - string positiveHex = positiveNumber.ToString("X"); - - BigInteger negativeNumber2, positiveNumber2; - negativeNumber2 = BigInteger.Parse(negativeHex, - NumberStyles.HexNumber); - positiveNumber2 = BigInteger.Parse(positiveHex, - NumberStyles.HexNumber); - - Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", - negativeNumber, negativeHex, negativeNumber2); - Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", - positiveNumber, positiveHex, positiveNumber2); - // The example displays the following output: - // Converted -1,000,000 to F0BDC0 back to -1,000,000. - // Converted 15,777,216 to 0F0BDC0 back to 15,777,216. - // - } -} diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs deleted file mode 100644 index 10320826e8b..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -using System; -using System.Globalization; -using System.Numerics; - -public struct HexValue -{ - public int Sign; - public string Value; -} - -public class Example -{ - public static void Main() - { - uint positiveNumber = 4039543321; - int negativeNumber = -255423975; - - // Convert the numbers to hex strings. - HexValue hexValue1, hexValue2; - hexValue1.Value = positiveNumber.ToString("X"); - hexValue1.Sign = Math.Sign(positiveNumber); - - hexValue2.Value = Convert.ToString(negativeNumber, 16); - hexValue2.Sign = Math.Sign(negativeNumber); - - // Round-trip the hexadecimal values to BigInteger values. - string hexString; - BigInteger positiveBigInt, negativeBigInt; - - hexString = (hexValue1.Sign == 1 ? "0" : "") + hexValue1.Value; - positiveBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber); - Console.WriteLine("Converted {0} to {1} and back to {2}.", - positiveNumber, hexValue1.Value, positiveBigInt); - - hexString = (hexValue2.Sign == 1 ? "0" : "") + hexValue2.Value; - negativeBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber); - Console.WriteLine("Converted {0} to {1} and back to {2}.", - negativeNumber, hexValue2.Value, negativeBigInt); - } -} -// The example displays the following output: -// Converted 4039543321 to F0C68A19 and back to 4039543321. -// Converted -255423975 to f0c68a19 and back to -255423975. -// diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs deleted file mode 100644 index e2f59bd6737..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Diagnostics; -using System.Numerics; - -public class Example -{ - public static void Main() - { - ShowSimpleAdd(); - PerformBigIntegerOperation(); - PerformWithIntermediary(); - } - - private static void ShowSimpleAdd() - { - // - BigInteger number = BigInteger.Multiply(Int64.MaxValue, 3); - number++; - Console.WriteLine(number); - // - } - - private static void PerformBigIntegerOperation() - { - Stopwatch sw = Stopwatch.StartNew(); - - // - BigInteger number = Int64.MaxValue ^ 5; - int repetitions = 1000000; - // Perform some repetitive operation 1 million times. - for (int ctr = 0; ctr <= repetitions; ctr++) - { - // Perform some operation. If it fails, exit the loop. - if (!SomeOperationSucceeds()) break; - // The following code executes if the operation succeeds. - number++; - } - // - - sw.Stop(); - Console.WriteLine("Incrementing a BigInteger: " + sw.Elapsed.ToString()); - } - - private static void PerformWithIntermediary() - { - Stopwatch sw = Stopwatch.StartNew(); - - // - BigInteger number = Int64.MaxValue ^ 5; - int repetitions = 1000000; - int actualRepetitions = 0; - // Perform some repetitive operation 1 million times. - for (int ctr = 0; ctr <= repetitions; ctr++) - { - // Perform some operation. If it fails, exit the loop. - if (!SomeOperationSucceeds()) break; - // The following code executes if the operation succeeds. - actualRepetitions++; - } - number += actualRepetitions; - // - - sw.Stop(); - Console.WriteLine("Incrementing a BigInteger: " + sw.Elapsed.ToString()); - } - - private static bool SomeOperationSucceeds() - { - return true; - } -} - -// -// CAPS bug: snippet2 is seen as duplicated, even though it isn't. -// \ No newline at end of file diff --git a/snippets/csharp/System.Numerics/Complex/Overview/create1.cs b/snippets/csharp/System.Numerics/Complex/Overview/create1.cs deleted file mode 100644 index f478a4fadd0..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/create1.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - // Create a complex number by calling its class constructor. - Complex c1 = new Complex(12, 6); - Console.WriteLine(c1); - - // Assign a Double to a complex number. - Complex c2 = 3.14; - Console.WriteLine(c2); - - // Cast a Decimal to a complex number. - Complex c3 = (Complex) 12.3m; - Console.WriteLine(c3); - - // Assign the return value of a method to a Complex variable. - Complex c4 = Complex.Pow(Complex.One, -1); - Console.WriteLine(c4); - - // Assign the value returned by an operator to a Complex variable. - Complex c5 = Complex.One + Complex.One; - Console.WriteLine(c5); - - // Instantiate a complex number from its polar coordinates. - Complex c6 = Complex.FromPolarCoordinates(10, .524); - Console.WriteLine(c6); - } -} -// The example displays the following output: -// (12, 6) -// (3.14, 0) -// (12.3, 0) -// (1, 0) -// (2, 0) -// (8.65824721882145, 5.00347430269914) -// \ No newline at end of file diff --git a/snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs b/snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs deleted file mode 100644 index 0fb304b1f0b..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -using System; -using System.Numerics; - -public class ComplexFormatter :IFormatProvider, ICustomFormatter -{ - public object GetFormat(Type formatType) - { - if (formatType == typeof(ICustomFormatter)) - return this; - else - return null; - } - - public string Format(string format, object arg, - IFormatProvider provider) - { - if (arg is Complex) - { - Complex c1 = (Complex) arg; - // Check if the format string has a precision specifier. - int precision; - string fmtString = String.Empty; - if (format.Length > 1) { - try { - precision = Int32.Parse(format.Substring(1)); - } - catch (FormatException) { - precision = 0; - } - fmtString = "N" + precision.ToString(); - } - if (format.Substring(0, 1).Equals("I", StringComparison.OrdinalIgnoreCase)) - return c1.Real.ToString(fmtString) + " + " + c1.Imaginary.ToString(fmtString) + "i"; - else if (format.Substring(0, 1).Equals("J", StringComparison.OrdinalIgnoreCase)) - return c1.Real.ToString(fmtString) + " + " + c1.Imaginary.ToString(fmtString) + "j"; - else - return c1.ToString(format, provider); - } - else - { - if (arg is IFormattable) - return ((IFormattable) arg).ToString(format, provider); - else if (arg != null) - return arg.ToString(); - else - return String.Empty; - } - } -} -// - -// -public class Example -{ - public static void Main() - { - Complex c1 = new Complex(12.1, 15.4); - Console.WriteLine("Formatting with ToString(): " + - c1.ToString()); - Console.WriteLine("Formatting with ToString(format): " + - c1.ToString("N2")); - Console.WriteLine("Custom formatting with I0: " + - String.Format(new ComplexFormatter(), "{0:I0}", c1)); - Console.WriteLine("Custom formatting with J3: " + - String.Format(new ComplexFormatter(), "{0:J3}", c1)); - } -} -// The example displays the following output: -// Formatting with ToString(): (12.1, 15.4) -// Formatting with ToString(format): (12.10, 15.40) -// Custom formatting with I0: 12 + 15i -// Custom formatting with J3: 12.100 + 15.400j -// diff --git a/snippets/csharp/System.Numerics/Complex/Overview/nan1.cs b/snippets/csharp/System.Numerics/Complex/Overview/nan1.cs deleted file mode 100644 index edad7d52998..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/nan1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - Complex c1 = new Complex(Double.MaxValue / 2, Double.MaxValue /2); - - Complex c2 = c1 / Complex.Zero; - Console.WriteLine(c2.ToString()); - c2 = c2 * new Complex(1.5, 1.5); - Console.WriteLine(c2.ToString()); - Console.WriteLine(); - - Complex c3 = c1 * new Complex(2.5, 3.5); - Console.WriteLine(c3.ToString()); - c3 = c3 + new Complex(Double.MinValue / 2, Double.MaxValue / 2); - Console.WriteLine(c3); - } -} -// The example displays the following output: -// (NaN, NaN) -// (NaN, NaN) -// (NaN, Infinity) -// (NaN, Infinity) -// \ No newline at end of file diff --git a/snippets/csharp/System.Numerics/Complex/Overview/precision1.cs b/snippets/csharp/System.Numerics/Complex/Overview/precision1.cs deleted file mode 100644 index 3bb618c475b..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/precision1.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - // - Complex value = new Complex(Double.MinValue/2, Double.MinValue/2); - Complex value2 = Complex.Exp(Complex.Log(value)); - Console.WriteLine("{0} \n{1} \nEqual: {2}", value, value2, - value == value2); - // The example displays the following output: - // (-8.98846567431158E+307, -8.98846567431158E+307) - // (-8.98846567431161E+307, -8.98846567431161E+307) - // Equal: False - // - - Console.WriteLine(); - ShowPlatform(); - } - - private static void ShowPlatform() - { - // - Complex minusOne = new Complex(-1, 0); - Console.WriteLine(Complex.Sqrt(minusOne)); - // The example displays the following output: - // (6.12303176911189E-17, 1) on 32-bit systems. - // (6.12323399573677E-17,1) on IA64 systems. - // - } -} - -// Complex minusOne = new Complex(-1,0); -// Complex.Sqrt(minusOne) returns Complex(6.12303176911189E-17, 1) where as it returns Complex on IA64. diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs deleted file mode 100644 index dd9ae0313c0..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs +++ /dev/null @@ -1,27 +0,0 @@ -/* - Note : Calls EmitClass class from 'MyEmitTestAssembly.dll' using reflection emit. -*/ - -using System; - -public class MyAssemblyResourceApplication -{ - public static void Main() - { - try - { - CallEmitMethod(); - } - catch(TypeLoadException) - { - Console.WriteLine("Unable to load EmitClass type " + - "from MyEmitTestAssembly.dll!"); - } - } - - private static void CallEmitMethod() - { - EmitClass myEmit = new EmitClass(); - Console.WriteLine(myEmit.Display()); - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs deleted file mode 100644 index 10eefad292b..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs +++ /dev/null @@ -1,28 +0,0 @@ -/* - Supporting file for AssemblyBuilder_DefineUnmanagedResource2.cs - Note : Calls EmitClass class from 'MyEmitTestAssembly.dll' using reflection emit. -*/ - -using System; - -public class MyAssemblyResourceApplication -{ - public static void Main() - { - try - { - CallEmitMethod(); - } - catch(TypeLoadException) - { - Console.WriteLine("Unable to load EmitClass type " + - "from MyEmitTestAssembly.dll!"); - } - } - - private static void CallEmitMethod() - { - EmitClass myEmit = new EmitClass(); - Console.WriteLine(myEmit.Display()); - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Reflection/Assembly/Load/load2.cs b/snippets/csharp/System.Reflection/Assembly/Load/load2.cs deleted file mode 100644 index 171d21cc774..00000000000 --- a/snippets/csharp/System.Reflection/Assembly/Load/load2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; -using System.Reflection; - -class Class1 -{ - public static void Main() - { - // You must supply a valid fully qualified assembly name. - // - Assembly myDll = - Assembly.Load("myDll, Version=1.0.0.1, Culture=neutral, PublicKeyToken=9b35aa32c18d4fb1"); - // - - // Display all the types contained in the specified assembly. - foreach (Type oType in myDll.GetTypes()) { - Console.WriteLine(oType.Name); - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs b/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs deleted file mode 100644 index 4956bf1631f..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; -using System.Reflection; - -// -// Set version number for the assembly. -[assembly:AssemblyVersionAttribute("4.3.2.1")] -// Set culture as German. -[assembly:AssemblyCultureAttribute("de")] -// - -// -[assembly:AssemblyKeyFileAttribute("myKey.snk")] -[assembly:AssemblyDelaySignAttribute(true)] -// - -namespace DummySpace -{ - class DummyClass - { - public static void Main() - { - Console.WriteLine("DummySpace.DummyClass.Main()"); - } - } -} -// diff --git a/snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs b/snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs deleted file mode 100644 index ec6884776eb..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; -using System.Reflection; - -// -[assembly:AssemblyKeyFileAttribute("keyfile.snk")] -// -namespace KeyFileAttrib -{ - public class Dummy - { - public static void Main() - { - Console.WriteLine("KeyFileAttrib.Dummy.Main()"); - } - } -} -// diff --git a/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs b/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs deleted file mode 100644 index 06ff187cb75..00000000000 --- a/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class ExampleAttribute : Attribute -{ - private string stringVal; - - public ExampleAttribute() - { - stringVal = "This is the default string."; - } - - public string StringValue - { - get { return stringVal; } - set { stringVal = value; } - } -} - -[Example(StringValue="This is a string.")] -class Class1 -{ - public static void Main() - { - System.Reflection.MemberInfo info = typeof(Class1); - foreach (object attrib in info.GetCustomAttributes(true)) - { - Console.WriteLine(attrib); - } - } -} -// diff --git a/snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs b/snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs deleted file mode 100644 index ee13728e908..00000000000 --- a/snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -using System; -using System.Reflection; - -interface i -{ - int GetValuue() ; -}; - // DeclaringType for MyVar is i. - - class A : i - { - public int MyVar() { return 0; } - }; - // DeclaringType for MyVar is A. - - class B : A - { - new int MyVar() { return 0; } - }; - // DeclaringType for MyVar is B. - - class C : A - { - }; - // DeclaringType for MyVar is A. - - -namespace MyNamespace2 -{ - class Mymemberinfo - { - - public static void Main(string[] args) - { - - Console.WriteLine ("\nReflection.MemberInfo"); - - //Get the Type and MemberInfo. - Type MyType =Type.GetType("System.IO.BufferedStream"); - MemberInfo[] Mymemberinfoarray = MyType.GetMembers(); - - //Get and display the DeclaringType method. - Console.WriteLine("\nThere are {0} members in {1}.", Mymemberinfoarray.Length, MyType.FullName); - - foreach (MemberInfo Mymemberinfo in Mymemberinfoarray) - { - Console.WriteLine("Declaring type of {0} is {1}.", Mymemberinfo.Name, Mymemberinfo.DeclaringType); - } - } - } -} - -namespace MyNamespace3 -{ - class A - { - virtual public void M () {} - } - class B: A - { - override public void M () {} - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs b/snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs deleted file mode 100644 index 4c2c5bd85fb..00000000000 --- a/snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; -using System.Resources; - -public class Example -{ - public static void Main() - { - ResourceManager rm = new ResourceManager("Strings", - typeof(Example).Assembly); - string timeString = rm.GetString("TimeHeader"); - Console.WriteLine("{0} {1:T}", timeString, DateTime.Now); - } -} -// The example displays output like the following: -// The current time is 2:03:14 PM -// diff --git a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs b/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs deleted file mode 100644 index 80fec0df394..00000000000 --- a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; -using System.Globalization; -using System.Reflection; -using System.Resources; -using System.Threading; - -[assembly:NeutralResourcesLanguageAttribute("en")] -public class Example -{ - public static void Main() - { - // Select the current culture randomly to test resource fallback. - string[] cultures = { "de-DE", "en-us", "fr-FR" }; - Random rnd = new Random(); - int index = rnd.Next(0, cultures.Length); - Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultures[index]); - Console.WriteLine("The current culture is {0}", - CultureInfo.CurrentUICulture.Name); - - // Retrieve the resource. - ResourceManager rm = new ResourceManager("ExampleResources" , - typeof(Example).Assembly); - string greeting = rm.GetString("Greeting"); - - Console.Write("Enter your name: "); - string name = Console.ReadLine(); - Console.WriteLine("{0} {1}!", greeting, name); - } -} -// diff --git a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs b/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs deleted file mode 100644 index be014baff7e..00000000000 --- a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -using System.Resources; - -[assembly:NeutralResourcesLanguage("en-US")] -// -public class Example {} diff --git a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs b/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs deleted file mode 100644 index 59e51063d69..00000000000 --- a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -using System.Resources; - -[assembly:NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] -// -public class Example {} diff --git a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs b/snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs deleted file mode 100644 index c19d57c8237..00000000000 --- a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Generic; -using System.Resources; - -public class Example -{ - public static void Main() - { - string resxFile = @".\CarResources.resx"; - List autos = new List(); - SortedList headers = new SortedList(); - - using (ResXResourceReader resxReader = new ResXResourceReader(resxFile)) - { - foreach (DictionaryEntry entry in resxReader) { - if (((string) entry.Key).StartsWith("EarlyAuto")) - autos.Add((Automobile) entry.Value); - else if (((string) entry.Key).StartsWith("Header")) - headers.Add((string) entry.Key, (string) entry.Value); - } - } - string[] headerColumns = new string[headers.Count]; - headers.GetValueList().CopyTo(headerColumns, 0); - Console.WriteLine("{0,-8} {1,-10} {2,-4} {3,-5} {4,-9}\n", - headerColumns); - foreach (var auto in autos) - Console.WriteLine("{0,-8} {1,-10} {2,4} {3,5} {4,9}", - auto.Make, auto.Model, auto.Year, - auto.Doors, auto.Cylinders); - } -} -// The example displays the following output: -// Make Model Year Doors Cylinders -// -// Ford Model N 1906 0 4 -// Ford Model T 1909 2 4 -// - -[Serializable()] public class Automobile -{ - private string carMake; - private string carModel; - private int carYear; - private int carDoors; - private int carCylinders; - - public Automobile(string make, string model, int year) : - this(make, model, year, 0, 0) - { } - - public Automobile(string make, string model, int year, - int doors, int cylinders) - { - this.carMake = make; - this.carModel = model; - this.carYear = year; - this.carDoors = doors; - this.carCylinders = cylinders; - } - - public string Make { - get { return this.carMake; } - } - - public string Model { - get {return this.carModel; } - } - - public int Year { - get { return this.carYear; } - } - - public int Doors { - get { return this.carDoors; } - } - - public int Cylinders { - get { return this.carCylinders; } - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs b/snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs deleted file mode 100644 index 551026945f1..00000000000 --- a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Resources; -using System.Windows.Forms; - -public class CarDisplayApp : Form -{ - private const string resxFile = @".\CarResources.resx"; - Automobile[] cars; - - public static void Main() - { - CarDisplayApp app = new CarDisplayApp(); - Application.Run(app); - } - - public CarDisplayApp() - { - // Instantiate controls. - PictureBox pictureBox = new PictureBox(); - pictureBox.Location = new Point(10, 10); - this.Controls.Add(pictureBox); - DataGridView grid = new DataGridView(); - grid.Location = new Point(10, 60); - this.Controls.Add(grid); - - // Get resources from .resx file. - using (ResXResourceSet resxSet = new ResXResourceSet(resxFile)) - { - // Retrieve the string resource for the title. - this.Text = resxSet.GetString("Title"); - // Retrieve the image. - Icon image = (Icon) resxSet.GetObject("Information", true); - if (image != null) - pictureBox.Image = image.ToBitmap(); - - // Retrieve Automobile objects. - List carList = new List(); - string resName = "EarlyAuto"; - Automobile auto; - int ctr = 1; - do { - auto = (Automobile) resxSet.GetObject(resName + ctr.ToString()); - ctr++; - if (auto != null) - carList.Add(auto); - } while (auto != null); - cars = carList.ToArray(); - grid.DataSource = cars; - } - } -} -// - -[Serializable()] public class Automobile -{ - private string carMake; - private string carModel; - private int carYear; - private int carDoors; - private int carCylinders; - - public Automobile(string make, string model, int year) : - this(make, model, year, 0, 0) - { } - - public Automobile(string make, string model, int year, - int doors, int cylinders) - { - this.carMake = make; - this.carModel = model; - this.carYear = year; - this.carDoors = doors; - this.carCylinders = cylinders; - } - - public string Make { - get { return this.carMake; } - } - - public string Model { - get {return this.carModel; } - } - - public int Year { - get { return this.carYear; } - } - - public int Doors { - get { return this.carDoors; } - } - - public int Cylinders { - get { return this.carCylinders; } - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs deleted file mode 100644 index 1dd0a824c4f..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Resources; - -public class Example -{ - public static void Main() - { - CallCtor1(); - CallCtor2(); - } - - static void CallCtor1() - { - // - ResourceManager rm = new ResourceManager("MyCompany.StringResources", - typeof(Example).Assembly); - // - } - - static void CallCtor2() - { - // - ResourceManager rm = new ResourceManager(typeof(MyCompany.StringResources)); - // - } -} - -namespace MyCompany -{ - class StringResources {} -} \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/example.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/example.cs deleted file mode 100644 index 87cec1b7930..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/example.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -public class Example -{ - public static void Main() - { - // Create array of supported cultures - string[] cultures = {"en-CA", "en-US", "fr-FR", "ru-RU" }; - Random rnd = new Random(); - int cultureNdx = rnd.Next(0, cultures.Length); - CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; - ResourceManager rm = new ResourceManager("Greetings", typeof(Example).Assembly); - try { - CultureInfo newCulture = new CultureInfo(cultures[cultureNdx]); - Thread.CurrentThread.CurrentCulture = newCulture; - Thread.CurrentThread.CurrentUICulture = newCulture; - string greeting = String.Format("The current culture is {0}.\n{1}", - Thread.CurrentThread.CurrentUICulture.Name, - rm.GetString("HelloString")); - Console.WriteLine(greeting); - } - catch (CultureNotFoundException e) { - Console.WriteLine("Unable to instantiate culture {0}", e.InvalidCultureName); - } - finally { - Thread.CurrentThread.CurrentCulture = originalCulture; - Thread.CurrentThread.CurrentUICulture = originalCulture; - } - } -} -// The example displays output like the following: -// The current culture is ru-RU. -// Всем привет! -// diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs deleted file mode 100644 index 546ace48d36..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -[assembly: NeutralResourcesLanguage("en-US")] - -public class Example -{ - public static void Main() - { - string[] cultureNames = { "en-US", "en-CA", "ru-RU", "fr-FR" }; - ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("Strings", "Resources", null); - - foreach (var cultureName in cultureNames) { - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureName); - string greeting = rm.GetString("Greeting", CultureInfo.CurrentCulture); - Console.WriteLine("\n{0}!", greeting); - Console.Write(rm.GetString("Prompt", CultureInfo.CurrentCulture)); - string name = Console.ReadLine(); - if (!String.IsNullOrEmpty(name)) - Console.WriteLine("{0}, {1}!", greeting, name); - } - Console.WriteLine(); - } -} -// The example displays output like the following: -// Hello! -// What is your name? Dakota -// Hello, Dakota! -// -// Hello! -// What is your name? Koani -// Hello, Koani! -// -// Здравствуйте! -// Как вас зовут?Samuel -// Здравствуйте, Samuel! -// -// Bon jour! -// Comment vous appelez-vous?Yiska -// Bon jour, Yiska! -// \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs deleted file mode 100644 index cc900bf8b94..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -[assembly: NeutralResourcesLanguageAttribute("en-US")] - -public class Example -{ - public static void Main() - { - string[] cultureNames = { "en-US", "fr-FR", "ru-RU", "es-ES" }; - Random rnd = new Random(); - ResourceManager rm = new ResourceManager("Strings", - typeof(Example).Assembly); - - for (int ctr = 0; ctr <= cultureNames.Length; ctr++) { - string cultureName = cultureNames[rnd.Next(0, cultureNames.Length)]; - CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName); - Thread.CurrentThread.CurrentCulture = culture; - Thread.CurrentThread.CurrentUICulture = culture; - - Console.WriteLine("Current culture: {0}", culture.NativeName); - string timeString = rm.GetString("TimeHeader"); - Console.WriteLine("{0} {1:T}\n", timeString, DateTime.Now); - } - } -} -// The example displays output like the following: -// Current culture: English (United States) -// The current time is 9:34:18 AM -// -// Current culture: Español (España, alfabetización internacional) -// The current time is 9:34:18 -// -// Current culture: русский (Россия) -// Текущее время — 9:34:18 -// -// Current culture: français (France) -// L'heure actuelle est 09:34:18 -// -// Current culture: русский (Россия) -// Текущее время — 9:34:18 -// diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs deleted file mode 100644 index 00301bf8a46..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -using System; -using System.Resources; -using System.Reflection; -using System.Threading; -using System.Globalization; - -class Example -{ - public static void Main() - { - string day; - string year; - string holiday; - string celebrate = "{0} will occur on {1} in {2}.\n"; - - // Create a resource manager. - ResourceManager rm = new ResourceManager("rmc", - typeof(Example).Assembly); - - Console.WriteLine("Obtain resources using the current UI culture."); - - // Get the resource strings for the day, year, and holiday - // using the current UI culture. - day = rm.GetString("day"); - year = rm.GetString("year"); - holiday = rm.GetString("holiday"); - Console.WriteLine(celebrate, holiday, day, year); - - // Obtain the es-MX culture. - CultureInfo ci = new CultureInfo("es-MX"); - - Console.WriteLine("Obtain resources using the es-MX culture."); - - // Get the resource strings for the day, year, and holiday - // using the specified culture. - day = rm.GetString("day", ci); - year = rm.GetString("year", ci); - holiday = rm.GetString("holiday", ci); -// --------------------------------------------------------------- -// Alternatively, comment the preceding 3 code statements and -// uncomment the following 4 code statements: -// ---------------------------------------------------------------- -// Set the current UI culture to "es-MX" (Spanish-Mexico). -// Thread.CurrentThread.CurrentUICulture = ci; - -// Get the resource strings for the day, year, and holiday -// using the current UI culture. Use those strings to -// display a message. -// day = rm.GetString("day"); -// year = rm.GetString("year"); -// holiday = rm.GetString("holiday"); -// --------------------------------------------------------------- - -// Regardless of the alternative that you choose, display a message -// using the retrieved resource strings. - Console.WriteLine(celebrate, holiday, day, year); - } -} -/* -This example displays the following output: - - Obtain resources using the current UI culture. - "5th of May" will occur on Friday in 2006. - - Obtain resources using the es-MX culture. - "Cinco de Mayo" will occur on Viernes in 2006. -*/ -// \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs b/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs deleted file mode 100644 index 25b9cbfd39e..00000000000 --- a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -// -[assembly:InternalsVisibleTo("Friend1a")] -[assembly:InternalsVisibleTo("Friend1b")] -// - -public class StringUtilities -{ - internal string ToTitleCase(string value) - { - string retval = null; - for (int ctr = 0; ctr <= value.Length - 1; ctr++) - if (ctr == 0) - retval += Char.ToUpper(value[ctr]); - else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1])) - retval += Char.ToUpper(value[ctr]); - else - retval += value[ctr]; - return retval; - } -} diff --git a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs b/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs deleted file mode 100644 index 981dd1b35e9..00000000000 --- a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -// -[assembly:InternalsVisibleTo("Friend2a"), - InternalsVisibleTo("Friend2b")] -// - -namespace Utilities -{ - public class StringUtilities - { - internal static string ToTitleCase(string value) - { - string retval = null; - for (int ctr = 0; ctr <= value.Length - 1; ctr++) - if (ctr == 0) - retval += Char.ToUpper(value[ctr]); - else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1])) - retval += Char.ToUpper(value[ctr]); - else - retval += value[ctr]; - return retval; - } - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs b/snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs deleted file mode 100644 index c513ddcbeff..00000000000 --- a/snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -// -using System.Runtime.InteropServices; -// - -// -public interface INew -{ - void NewMethod(); -} -// - -// -public interface ICustomMarshaler -{ - Object MarshalNativeToManaged( IntPtr pNativeData ); - IntPtr MarshalManagedToNative( Object ManagedObj ); - void CleanUpNativeData( IntPtr pNativeData ); - void CleanUpManagedData( Object ManagedObj ); - int GetNativeDataSize(); -} -// - -namespace scope1 -{ -// -interface IUserData -{ - void DoSomeStuff(INew pINew); -} -// -} - -namespace scope2 -{ -// -interface IUserData -{ - void DoSomeStuff( - [MarshalAs(UnmanagedType.CustomMarshaler, - MarshalType="NewOldMarshaler")] - INew pINew - ); -} -// -} - -// -public NewOldMarshaler : ICustomMarshaler -{ - public static ICustomMarshaler GetInstance(string pstrCookie) - => return new NewOldMarshaler(); - - public Object MarshalNativeToManaged( IntPtr pNativeData ) => throw new NotImplementedException(); - public IntPtr MarshalManagedToNative( Object ManagedObj ) => throw new NotImplementedException(); - public void CleanUpNativeData( IntPtr pNativeData ) => throw new NotImplementedException(); - public void CleanUpManagedData( Object ManagedObj ) => throw new NotImplementedException(); - public int GetNativeDataSize() => throw new NotImplementedException(); -} -// - -class StubClass -{ - public static void Main() {} -} \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs b/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs deleted file mode 100644 index dcb3edcc1bd..00000000000 --- a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -// Remote object. -public class RemoteObject : MarshalByRefObject -{ - private int callCount = 0; - - public int GetCount() - { - Console.WriteLine("GetCount has been called."); - callCount++; - return(callCount); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs b/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs deleted file mode 100644 index 51ab04ee482..00000000000 --- a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Runtime.Remoting.Channels.Ipc; - -public class Server -{ - public static void Main(string[] args) - { - // Create the server channel. - IpcChannel serverChannel = - new IpcChannel("localhost:9090"); - - // Register the server channel. - System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel( - serverChannel); - - // Expose an object for remote calls. - System.Runtime.Remoting.RemotingConfiguration. - RegisterWellKnownServiceType( - typeof(RemoteObject), "RemoteObject.rem", - System.Runtime.Remoting.WellKnownObjectMode.Singleton); - - // Wait for the user prompt. - Console.WriteLine("Press ENTER to exit the server."); - Console.ReadLine(); - Console.WriteLine("The server is exiting."); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs b/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs deleted file mode 100644 index bfc7711be08..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - -public class MyClient -{ - public static void Main() - { - ChannelServices.RegisterChannel(new TcpChannel()); - ActivatedClientTypeEntry myActivatedClientTypeEntry = - new ActivatedClientTypeEntry(typeof(HelloServer), - "tcp://localhost:8082"); - // Register 'HelloServer' Type on the client end so that it can be - // activated on the server. - RemotingConfiguration.RegisterActivatedClientType( - myActivatedClientTypeEntry); - // Obtain a proxy object for the remote object. - HelloServer myHelloServer = new HelloServer("ParameterString"); - if (myHelloServer == null) - { - System.Console.WriteLine("Could not locate server"); - } - else - { - Console.WriteLine("Calling remote object"); - Console.WriteLine(myHelloServer.HelloMethod("Bill")); - } - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs b/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs deleted file mode 100644 index f3155c401d0..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -public class HelloServer : MarshalByRefObject -{ - public HelloServer(String myString) - { - Console.WriteLine("HelloServer activated"); - Console.WriteLine("Paramater passed to the constructor is "+myString); - } - public String HelloMethod(String myName) - { - Console.WriteLine("HelloMethod : {0}",myName); - return "Hi there " + myName; - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs deleted file mode 100644 index 4c67c89a18f..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - -public class ServerClass -{ - static void Main() - { - ChannelServices.RegisterChannel(new TcpChannel(8085)); - RemotingConfiguration.RegisterActivatedServiceType(typeof(MyServerImpl)); - Console.WriteLine("Press enter to stop this process."); - Console.ReadLine(); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs deleted file mode 100644 index 007015ae622..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated..."); - } - - public String MyMethod(String name) - { - return "The client requests to "+name; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs deleted file mode 100644 index ab949209afb..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - -public class ServerClass -{ - static void Main() - { - ChannelServices.RegisterChannel(new TcpChannel(8085), false); - RemotingConfiguration.RegisterActivatedServiceType(typeof(MyServerImpl)); - Console.WriteLine("Press enter to stop this process."); - Console.ReadLine(); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs deleted file mode 100644 index f19ff43b19b..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - int i; - public MyServerImpl() - { - i=0; - Console.WriteLine("Server Activated..."); - } - - public String MyMethod(String name) - { - i=i+1; - return "The client requests to "+name +i+" time"; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs deleted file mode 100644 index e19a1d17372..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - - public class Sample { - - public static void Main() - { - ChannelServices.RegisterChannel( new TcpChannel(8085)); - RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyServerImpl), - "SayHello", WellKnownObjectMode.Singleton); - Console.WriteLine("Press to exit..."); - Console.ReadLine(); - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs deleted file mode 100644 index 4779f341780..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated"); - } - - public String MyMethod(String name) - { - return "The string from client is " + name; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs deleted file mode 100644 index e19a1d17372..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - - public class Sample { - - public static void Main() - { - ChannelServices.RegisterChannel( new TcpChannel(8085)); - RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyServerImpl), - "SayHello", WellKnownObjectMode.Singleton); - Console.WriteLine("Press to exit..."); - Console.ReadLine(); - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs deleted file mode 100644 index ed75db7d4c9..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated"); - } - - public String MyMethod(String name) - { - Console.WriteLine(name); - return "The string from server : " + name; - } - } diff --git a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs b/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs deleted file mode 100644 index 0ced5a65dd6..00000000000 --- a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs +++ /dev/null @@ -1,216 +0,0 @@ -#define debug -//#define debug -// This custom permission is intended only for the purposes of illustration. -// The following code shows how to create a custom permission that inherits -// from CodeAccessPermission. The code implements all required overrides. -// A wildcard character ('*') is implemented for the Name property. -using System; -using System.Security; -using System.Security.Permissions; -using System.IO; -using System.Security.Policy; -using System.Collections; -using System.Text; -// Use the command line option '/keyfile' or appropriate project settings to sign this assembly. -[assembly:System.Security.AllowPartiallyTrustedCallersAttribute()] - -namespace MyPermission -{ - [Serializable()] sealed public class NameIdPermission : CodeAccessPermission, IUnrestrictedPermission - { - private String m_Name; - private bool m_Unrestricted; - - public NameIdPermission(String name) - { - m_Name = name; - } - - public NameIdPermission(PermissionState state) - { - if (state == PermissionState.None) - { - m_Name = ""; - } - else - if (state == PermissionState.Unrestricted) - { - throw new ArgumentException("Unrestricted state is not allowed for identity permissions."); - } - else - { - throw new ArgumentException("Invalid permission state."); - } - } - - public String Name - { - set{m_Name = value;} - get{ return m_Name;} - } - public override IPermission Copy() - { - string name = m_Name; - return new NameIdPermission( name ); - } - - public bool IsUnrestricted() - { - // Always false, unrestricted state is not allowed. - return m_Unrestricted; - } - - private bool VerifyType(IPermission target) - { - return (target is NameIdPermission); - } - - public override bool IsSubsetOf(IPermission target) - { -#if(debug) - Console.WriteLine ("************* Entering IsSubsetOf *********************"); -#endif - if (target == null) - { - Console.WriteLine ("IsSubsetOf: target == null"); - return false; - } -#if(debug) - - Console.WriteLine ("This is = " + (( NameIdPermission)this).Name); - Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name); -#endif - try - { - NameIdPermission operand = ( NameIdPermission)target; - - // The following check for unrestricted permission is only included as an example for - // permissions that allow the unrestricted state. It is of no value for this permission. - if (true == operand.m_Unrestricted) - { - return true; - } - else if (true == this.m_Unrestricted) - { - return false; - } - - if (this.m_Name != null) - { - if (operand.m_Name == null) return false; - - if (this.m_Name == "") return true; - } - - if (this.m_Name.Equals (operand.m_Name)) - { - return true; - } - else - { - // Check for wild card character '*'. - int i = operand.m_Name.LastIndexOf ("*"); - - if (i > 0) - { - string prefix = operand.m_Name.Substring (0, i); - - if (this.m_Name.StartsWith (prefix)) - { - return true; - } - } - } - - return false; - } - catch (InvalidCastException) - { - throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName)); - } - } - - public override IPermission Intersect(IPermission target) - { - Console.WriteLine ("************* Entering Intersect *********************"); - if (target == null) - { - return null; - } -#if(debug) - Console.WriteLine ("This is = " + (( NameIdPermission)this).Name); - Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name); -#endif - if (!VerifyType(target)) - { - throw new ArgumentException (String.Format ("Argument is wrong type.", this.GetType ().FullName)); - } - - NameIdPermission operand = ( NameIdPermission)target; - - if (operand.IsSubsetOf (this)) return operand.Copy (); - else if (this.IsSubsetOf (operand)) return this.Copy (); - else - return null; - } - - public override IPermission Union(IPermission target) - { -#if(debug) - Console.WriteLine ("************* Entering Union *********************"); -#endif - if (target == null) - { - return this; - } -#if(debug) - Console.WriteLine ("This is = " + (( NameIdPermission)this).Name); - Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name); -#endif - if (!VerifyType(target)) - { - throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName)); - } - - NameIdPermission operand = ( NameIdPermission)target; - - if (operand.IsSubsetOf (this)) return this.Copy (); - else if (this.IsSubsetOf (operand)) return operand.Copy (); - else - return null; - } - - public override void FromXml(SecurityElement e) - { - // The following code for unrestricted permission is only included as an example for - // permissions that allow the unrestricted state. It is of no value for this permission. - String elUnrestricted = e.Attribute("Unrestricted"); - if (null != elUnrestricted) - { - m_Unrestricted = bool.Parse(elUnrestricted); - return; - } - - String elName = e.Attribute( "Name" ); - m_Name = elName == null ? null : elName; - } - - public override SecurityElement ToXml() - { - // Use the SecurityElement class to encode the permission to XML. - SecurityElement esd = new SecurityElement("IPermission"); - String name = typeof( NameIdPermission).AssemblyQualifiedName; - esd.AddAttribute("class", name); - esd.AddAttribute("version", "1.0"); - - // The following code for unrestricted permission is only included as an example for - // permissions that allow the unrestricted state. It is of no value for this permission. - if (m_Unrestricted) - { - esd.AddAttribute("Unrestricted", true.ToString()); - } - if (m_Name != null) esd.AddAttribute( "Name", m_Name ); - return esd; - } - } -} diff --git a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs b/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs deleted file mode 100644 index ece46675a7b..00000000000 --- a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs +++ /dev/null @@ -1,55 +0,0 @@ -//---------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -//---------------------------------------------------------------- -using System; -using System.Configuration; -using System.ServiceModel.Activities; -using System.ServiceModel.Configuration; -using System.ServiceModel.Description; - -namespace Microsoft.Samples.WF.CreationEndpoint -{ - //config element for CreationEndpoint - public class CreationEndpointElement : StandardEndpointElement - { - protected override Type EndpointType - { - get { return typeof(CreationEndpoint); } - } - - protected override ConfigurationPropertyCollection Properties - { - get - { - ConfigurationPropertyCollection properties = base.Properties; - properties.Add(new ConfigurationProperty("name", typeof(String), null, ConfigurationPropertyOptions.IsRequired)); - return properties; - } - } - - protected override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription) - { - return new CreationEndpoint(); - } - - protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement channelEndpointElement) - { - } - - protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement) - { - } - - protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement) - { - } - - protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement) - { - } - } - - public class CreationEndpointCollection : StandardEndpointCollectionElement - { - } -} diff --git a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs b/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs deleted file mode 100644 index 85b0b8477aa..00000000000 --- a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs +++ /dev/null @@ -1,67 +0,0 @@ -//---------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -//---------------------------------------------------------------- - -using System; -using System.Activities.Statements; -using System.ServiceModel; -using System.ServiceModel.Activities; - -namespace Microsoft.Samples.WF.CreationEndpoint -{ - class Program - { - static void Main(string[] args) - { - Sequence workflow; - WorkflowServiceHost host=null; - - try - { - workflow = CreateWorkflow(); - host = new WorkflowServiceHost(workflow, new Uri("net.pipe://localhost")); - CreationEndpoint creationEp = new CreationEndpoint(new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), new EndpointAddress("net.pipe://localhost/workflowCreationEndpoint")); - host.AddServiceEndpoint(creationEp); - host.Open(); - //client using NetNamedPipeBinding - IWorkflowCreation client = new ChannelFactory(creationEp.Binding, creationEp.Address).CreateChannel(); - //client using BasicHttpBinding - IWorkflowCreation client2 = new ChannelFactory(new BasicHttpBinding(), new EndpointAddress("http://localhost/workflowCreationEndpoint")).CreateChannel(); - //create instance - Console.WriteLine("Workflow Instance created using CreationEndpoint added in code. Instance Id: {0}", client.Create(null)); - //create another instance - Console.WriteLine("Workflow Instance created using CreationEndpoint added in config. Instance Id: {0}", client2.Create(null)); - Console.WriteLine("Press return to exit ..."); - Console.ReadLine(); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - finally - { - if (host != null) - { - host.Close(); - } - } - } - - static Sequence CreateWorkflow() - { - Sequence workflow = new Sequence - { - DisplayName = "CreationService", - Activities = - { - new WriteLine - { - Text = "Hello World" - } - } - }; - - return workflow; - } - } -} diff --git a/snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs b/snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs deleted file mode 100644 index b52726025c2..00000000000 --- a/snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs +++ /dev/null @@ -1,274 +0,0 @@ -// The following example illustrates deriving a service implementation from -// the System.ServiceProcess.ServiceBase class. This simple service starts -// a worker thread, and handles various service commands. -// The main service thread and the worker thread write their trace output -// to c:\service_log.txt. - -// - -// Turn on constant for trace output. -#define TRACE - -using System; -using System.ComponentModel; -using System.IO; -using System.ServiceProcess; -using System.Threading; -using System.Diagnostics; - -namespace SimpleServiceSample -{ - // Define custom commands for the SimpleService. - public enum SimpleServiceCustomCommands {StopWorker=128, RestartWorker, CheckWorker}; - - // Define a simple service implementation. - public class SimpleService : System.ServiceProcess.ServiceBase - { - private const String logFile = @"C:\service_log.txt"; - private static TextWriterTraceListener serviceTraceListener = null; - private Thread workerThread = null; - - // - public SimpleService() - { - CanPauseAndContinue = true; - ServiceName = "SimpleService"; - } - // - - static void Main() - { - - // Create a file for trace output. - // A new file is created each time. If a - // previous log file exists, it is overwritten. - StreamWriter myFile = File.CreateText(logFile); - - // Create a new trace listener writing to the text file, - // and add it to the trace listeners. - serviceTraceListener = new TextWriterTraceListener(myFile); - Trace.Listeners.Add(serviceTraceListener); - - Trace.AutoFlush = true; - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Service main method starting...", - "Main"); - - // Load the service into memory. - System.ServiceProcess.ServiceBase.Run(new SimpleService()); - - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Service main method exiting...", - "Main"); - - // Remove and close the trace listener for this service. - Trace.Listeners.Remove(serviceTraceListener); - - serviceTraceListener.Close(); - serviceTraceListener = null; - myFile.Close(); - } - - private void InitializeComponent() - { - // Initialize the operating properties for the service. - this.CanPauseAndContinue = true; - this.CanShutdown = true; - this.ServiceName = "SimpleService"; - } - - // Start the service. - protected override void OnStart(string[] args) - { - // Start a separate thread which does the actual work. - - if ((workerThread == null) || - ((workerThread.ThreadState & - (System.Threading.ThreadState.Unstarted | System.Threading.ThreadState.Stopped)) != 0)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Starting service worker thread.", - "OnStart"); - - workerThread = new Thread(new ThreadStart(ServiceWorkerMethod)); - workerThread.Start(); - } - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnStart"); - } - } - - // - // Stop this service. - protected override void OnStop() - { - // Signal the worker thread to exit. - if ((workerThread != null) && (workerThread.IsAlive)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Stopping service worker thread.", - "OnStop"); - - workerThread.Abort(); - - // Wait up to 500 milliseconds for the thread to terminate. - workerThread.Join(500); - } - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnStop"); - } - } - // - - // - // Pause the service. - protected override void OnPause() - { - // Pause the worker thread. - if ((workerThread != null) && - (workerThread.IsAlive) && - ((workerThread.ThreadState & - (System.Threading.ThreadState.Suspended | System.Threading.ThreadState.SuspendRequested)) == 0)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Suspending service worker thread.", - "OnPause"); - - workerThread.Suspend(); - } - - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnPause"); - } - } - // - - // - // Continue a paused service. - protected override void OnContinue() - { - - // Signal the worker thread to continue. - if ((workerThread != null) && - ((workerThread.ThreadState & - (System.Threading.ThreadState.Suspended | System.Threading.ThreadState.SuspendRequested)) != 0)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Resuming service worker thread.", - "OnContinue"); - - workerThread.Resume(); - } - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnContinue"); - } - } - // - - // - // Handle a custom command. - protected override void OnCustomCommand(int command) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Custom command received: " + - command.ToString(), - "OnCustomCommand"); - - // If the custom command is recognized, - // then signal the worker thread appropriately. - - switch (command) - { - case (int) SimpleServiceCustomCommands.StopWorker: - // Signal the worker thread to terminate. - // For this custom command, the main service - // continues to run without a worker thread. - OnStop(); - break; - - case (int) SimpleServiceCustomCommands.RestartWorker: - - // Restart the worker thread if necessary. - OnStart(null); - break; - - case (int) SimpleServiceCustomCommands.CheckWorker: - - // Log the current worker thread state. - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnCustomCommand"); - - break; - - default: - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Unrecognized custom command ignored!", - "OnCustomCommand"); - break; - } - } - // - - // Define a simple method that runs as the worker thread of - // the service. - public void ServiceWorkerMethod() - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Starting service worker thread.", - "Worker"); - - try - { - do - { - // Wake up every 10 seconds and write - // a message to the trace output. - - Thread.Sleep(10000); - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - heartbeat cycle.", - "Worker"); - } - while (true); - } - catch (ThreadAbortException) - { - // Another thread has signalled that this thread - // must terminate. Typically, this occurs when - // the main service thread gets a service stop - // command. - - // Write a trace line indicating the worker thread - // is exiting. Notice that this simple thread does - // not have any local objects or data to clean up. - - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Thread abort signalled.", - "Worker"); - } - - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Exiting service worker thread.", - "Worker"); - } - } -} -// diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs deleted file mode 100644 index 7cfee1e737d..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Text.RegularExpressions; - -public class RegexSplit -{ - public static void Main() - { - RegexSplit rs = new RegexSplit(); - - Console.WriteLine("Splitting 10 occurrences on a null string starting at 'a'"); - rs.Split14(); - -// Console.WriteLine("Calling static Regex.Split(string, string, RegexOptions)"); -// rs.Split11(); -// Console.WriteLine("Calling static Regex.Split with capturing parentheses and RegexOptions:"); -// rs.Split12(); -// Console.WriteLine("Calling static Regex.Split with multiple capturing parentheses and RegexOptions:"); -// rs.Split13(); - } - - private void Split14() - { - string input = "characters"; - Regex regex = new Regex(""); - string[] substrings = regex.Split(input, input.Length, input.IndexOf("a")); - Console.Write("{"); - for(int ctr = 0; ctr < substrings.Length; ctr++) - { - Console.Write(substrings[ctr]); - if (ctr < substrings.Length - 1) - Console.Write(", "); - } - Console.WriteLine("}"); - // The example produces the following output: - // {, c, h, a, r, a, c, t, e, rs} - } -} diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs deleted file mode 100644 index 2c9cfaa3c32..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - string input = @"07/14/2007"; - string pattern = @"(-)|(/)"; - - foreach (string result in Regex.Split(input, pattern)) - { - Console.WriteLine("'{0}'", result); - } - } -} -// In .NET 1.0 and 1.1, the method returns an array of -// 3 elements, as follows: -// '07' -// '14' -// '2007' -// -// In .NET 2.0 and later, the method returns an array of -// 5 elements, as follows: -// '07' -// '/' -// '14' -// '/' -// '2007' -// diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs deleted file mode 100644 index 77e5691f6ef..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - string input = @"07/14/2007"; - string pattern = @"(-)|(/)"; - Regex regex = new Regex(pattern); - foreach (string result in regex.Split(input)) - { - Console.WriteLine("'{0}'", result); - } - } -} -// Under .NET 1.0 and 1.1, the method returns an array of -// 3 elements, as follows: -// '07' -// '14' -// '2007' -// -// Under .NET 2.0 and later, the method returns an array of -// 5 elements, as follows: -// '07' -// '/' -// '14' -// '/' -// '2007' -// diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs deleted file mode 100644 index 9c43556a1e2..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - string pattern = "(-)|([|])"; // possible delimiters found in string - string input = "apple|apricot|plum|pear|pomegranate|pineapple|peach"; - - Regex regex = new Regex(pattern); - // Split on delimiters from 15th character on - string[] substrings = regex.Split(input, 4, 15); - foreach (string match in substrings) - { - Console.WriteLine("'{0}'", match); - } - } -} -// In .NET 2.0 and later, the method returns an array of -// 7 elements, as follows: -// apple|apricot|plum' -// '|' -// 'pear' -// '|' -// 'pomegranate' -// '|' -// 'pineapple|peach' -// In .NET 1.0 and 1.1, the method returns an array of -// 4 elements, as follows: -// 'apple|apricot|plum' -// 'pear' -// 'pomegranate' -// 'pineapple|peach' -// diff --git a/snippets/csharp/System.Text/Encoding/GetString/getstring.cs b/snippets/csharp/System.Text/Encoding/GetString/getstring.cs deleted file mode 100644 index bb9ec21d5f9..00000000000 --- a/snippets/csharp/System.Text/Encoding/GetString/getstring.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.IO; - -namespace ConsoleApplication1 { - class MyBinaryFile { - string m_author = null; - static void Main(string[] args) { - MyBinaryFile bf1 = new MyBinaryFile(); - bf1.Author = "Marin Millar"; - bf1.Save("a.dat"); - - MyBinaryFile bf2 = new MyBinaryFile(); - bf2.Load("a.dat"); - Console.WriteLine(bf2.Author); - - bf2.PrintEncodingInfo(System.Text.Encoding.Default); - } - public MyBinaryFile() { - } - public string Author { - set { - m_author = value; - } - get { - return m_author; - } - } - public void Save(string filename) { - FileStream fs = File.Open(filename, FileMode.Create); - WriteAuthor(fs, m_author); - fs.Flush(); - fs.Close(); - } - private void WriteAuthor(Stream binary_file, string author) { - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - // Get buffer size required for conversion - int buffersize = encoding.GetByteCount(author); - if (buffersize < 30) { - buffersize = 30; - } - // Write string into binary file with UTF8 encoding - byte[] buffer = new byte[buffersize]; - encoding.GetBytes(author, 0, author.Length, buffer, 0); - binary_file.Write(buffer, 0, 30); - } - public void Load(string filename) { - FileStream fs = File.OpenRead(filename); - m_author = ReadAuthor(fs); - fs.Close(); - } - // - private string ReadAuthor(Stream binary_file) { - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - // Read string from binary file with UTF8 encoding - byte[] buffer = new byte[30]; - binary_file.Read(buffer, 0, 30); - return encoding.GetString(buffer); - } -/* This code produces the following output. - -Marin Millar -BodyName: iso-8859-1 -HeaderName: Windows-1252 -WebName: Windows-1252 -CodePage: 1252 -EncodingName: Western European (Windows) -WindowsCodePage: 1252 -MailNewsDisplay: True -MailNewsSave: True -BrowserDisplay: True -BrowserSave: True -*/ - // - private void PrintEncodingInfo(System.Text.Encoding encoding) { - // Print information of encoding - Console.WriteLine("BodyName: " + encoding.BodyName); - Console.WriteLine("HeaderName: " + encoding.HeaderName); - Console.WriteLine("WebName: " + encoding.WebName); - Console.WriteLine("CodePage: " + encoding.CodePage); - Console.WriteLine("EncodingName: " + encoding.EncodingName); - Console.WriteLine("WindowsCodePage: " + encoding.WindowsCodePage); - Console.WriteLine("MailNewsDisplay: " + encoding.IsMailNewsDisplay); - Console.WriteLine("MailNewsSave: " + encoding.IsMailNewsSave); - Console.WriteLine("BrowserDisplay: " + encoding.IsBrowserDisplay); - Console.WriteLine("BrowserSave: " + encoding.IsBrowserSave); - } - } -} diff --git a/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs b/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs deleted file mode 100644 index 453828692e9..00000000000 --- a/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - Encoding enc = Encoding.GetEncoding(1253); - Encoding altEnc = Encoding.GetEncoding("windows-1253"); - Console.WriteLine("{0} = Code Page {1}: {2}", enc.EncodingName, - altEnc.CodePage, enc.Equals(altEnc)); - string greekAlphabet = "Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η " + - "Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ " + - "Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ " + - "Φ φ Χ χ Ψ ψ Ω ω"; - Console.OutputEncoding = Encoding.UTF8; - byte[] bytes = enc.GetBytes(greekAlphabet); - Console.WriteLine("{0,-12} {1,20} {2,20:X2}", "Character", - "Unicode Code Point", "Code Page 1253"); - for (int ctr = 0; ctr < bytes.Length; ctr++) { - if (greekAlphabet[ctr].Equals(' ')) - continue; - - Console.WriteLine("{0,-12} {1,20} {2,20:X2}", greekAlphabet[ctr], - GetCodePoint(greekAlphabet[ctr]), bytes[ctr]); - } - } - - private static string GetCodePoint(char ch) - { - string retVal = "u+"; - byte[] bytes = Encoding.Unicode.GetBytes(ch.ToString()); - for (int ctr = bytes.Length - 1; ctr >= 0; ctr--) - retVal += bytes[ctr].ToString("X2"); - - return retVal; - } -} -// The example displays the following output: -// Character Unicode Code Point Code Page 1253 -// Α u+0391 C1 -// α u+03B1 E1 -// Β u+0392 C2 -// β u+03B2 E2 -// Γ u+0393 C3 -// γ u+03B3 E3 -// Δ u+0394 C4 -// δ u+03B4 E4 -// Ε u+0395 C5 -// ε u+03B5 E5 -// Ζ u+0396 C6 -// ζ u+03B6 E6 -// Η u+0397 C7 -// η u+03B7 E7 -// Θ u+0398 C8 -// θ u+03B8 E8 -// Ι u+0399 C9 -// ι u+03B9 E9 -// Κ u+039A CA -// κ u+03BA EA -// Λ u+039B CB -// λ u+03BB EB -// Μ u+039C CC -// μ u+03BC EC -// Ν u+039D CD -// ν u+03BD ED -// Ξ u+039E CE -// ξ u+03BE EE -// Ο u+039F CF -// ο u+03BF EF -// Π u+03A0 D0 -// π u+03C0 F0 -// Ρ u+03A1 D1 -// ρ u+03C1 F1 -// Σ u+03A3 D3 -// σ u+03C3 F3 -// ς u+03C2 F2 -// Τ u+03A4 D4 -// τ u+03C4 F4 -// Υ u+03A5 D5 -// υ u+03C5 F5 -// Φ u+03A6 D6 -// φ u+03C6 F6 -// Χ u+03A7 D7 -// χ u+03C7 F7 -// Ψ u+03A8 D8 -// ψ u+03C8 F8 -// Ω u+03A9 D9 -// ω u+03C9 F9 -// \ No newline at end of file diff --git a/snippets/csharp/System.Text/StringBuilder/Append/Append1.cs b/snippets/csharp/System.Text/StringBuilder/Append/Append1.cs deleted file mode 100644 index 9fb709bf3a4..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Append/Append1.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Text; - -[assembly: CLSCompliant(true)] -public class Class1 -{ - public static void Main() - { - // - char[] characters = {'/', '<', '<', ' ', '>', '>', '\\'}; - const int beginPosition = 0; - const int endPosition = 3; - - string title = "The Hound of the Baskervilles"; - - StringBuilder sb = new StringBuilder(); - sb.Append(characters, beginPosition, 4); - sb.Append(title); - sb.Append(characters, endPosition, 4); - Console.WriteLine(sb.ToString()); - // The example displays the following output: - // /<< The Hound of the Baskervilles >>\ - // - } -} diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs deleted file mode 100644 index ed96e1ca314..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder(); - sb.Append("This is the beginning of a sentence, "); - sb.Replace("the beginning of ", ""); - sb.Insert(sb.ToString().IndexOf("a ") + 2, "complete "); - sb.Replace(",", "."); - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// This is a complete sentence. -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs deleted file mode 100644 index 8f5afae20ea..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder("This is the beginning of a sentence, "); - sb.Replace("the beginning of ", "").Insert(sb.ToString().IndexOf("a ") + 2, - "complete ").Replace(",", "."); - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// This is a complete sentence. -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs deleted file mode 100644 index 0102f817293..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Globalization; -using System.Text; - -public class Example -{ - public static void Main() - { - Random rnd = new Random(); - StringBuilder sb = new StringBuilder(); - - // Generate 10 random numbers and store them in a StringBuilder. - for (int ctr = 0; ctr <= 9; ctr++) - sb.Append(rnd.Next().ToString("N5")); - - Console.WriteLine("The original string:"); - Console.WriteLine(sb.ToString()); - - // Decrease each number by one. - for (int ctr = 0; ctr < sb.Length; ctr++) { - if (Char.GetUnicodeCategory(sb[ctr]) == UnicodeCategory.DecimalDigitNumber) { - int number = (int) Char.GetNumericValue(sb[ctr]); - number--; - if (number < 0) number = 9; - - sb[ctr] = number.ToString()[0]; - } - } - Console.WriteLine("\nThe new string:"); - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// The original string: -// 1,457,531,530.00000940,522,609.000001,668,113,564.000001,998,992,883.000001,792,660,834.00 -// 000101,203,251.000002,051,183,075.000002,066,000,067.000001,643,701,043.000001,702,382,508 -// .00000 -// -// The new string: -// 0,346,420,429.99999839,411,598.999990,557,002,453.999990,887,881,772.999990,681,559,723.99 -// 999090,192,140.999991,940,072,964.999991,955,999,956.999990,532,690,932.999990,691,271,497 -// .99999 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs deleted file mode 100644 index 393dcba2227..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -using System; -using System.Reflection; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder(); - ShowSBInfo(sb); - sb.Append("This is a sentence."); - ShowSBInfo(sb); - for (int ctr = 0; ctr <= 10; ctr++) { - sb.Append("This is an additional sentence."); - ShowSBInfo(sb); - } - } - - private static void ShowSBInfo(StringBuilder sb) - { - foreach (var prop in sb.GetType().GetProperties()) { - if (prop.GetIndexParameters().Length == 0) - Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); - } - Console.WriteLine(); - } -} -// The example displays the following output: -// Capacity: 16 MaxCapacity: 2,147,483,647 Length: 0 -// Capacity: 32 MaxCapacity: 2,147,483,647 Length: 19 -// Capacity: 64 MaxCapacity: 2,147,483,647 Length: 50 -// Capacity: 128 MaxCapacity: 2,147,483,647 Length: 81 -// Capacity: 128 MaxCapacity: 2,147,483,647 Length: 112 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 143 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 174 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 205 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 236 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 267 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 298 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 329 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 360 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs deleted file mode 100644 index 3c31f9dbf2c..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder("A StringBuilder object"); - ShowSBInfo(sb); - // Remove "object" from the text. - string textToRemove = "object"; - int pos = sb.ToString().IndexOf(textToRemove); - if (pos >= 0) { - sb.Remove(pos, textToRemove.Length); - ShowSBInfo(sb); - } - // Clear the StringBuilder contents. - sb.Clear(); - ShowSBInfo(sb); - } - - public static void ShowSBInfo(StringBuilder sb) - { - Console.WriteLine("\nValue: {0}", sb.ToString()); - foreach (var prop in sb.GetType().GetProperties()) { - if (prop.GetIndexParameters().Length == 0) - Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); - } - Console.WriteLine(); - } -} -// The example displays the following output: -// Value: A StringBuilder object -// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 22 -// -// Value: A StringBuilder -// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 16 -// -// Value: -// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 0 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs deleted file mode 100644 index e811b7c5061..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with no text. - StringBuilder sb = new StringBuilder(); - // Append some text. - sb.Append('*', 10).Append(" Adding Text to a StringBuilder Object ").Append('*', 10); - sb.AppendLine("\n"); - sb.AppendLine("Some code points and their corresponding characters:"); - // Append some formatted text. - for (int ctr = 50; ctr <= 60; ctr++) { - sb.AppendFormat("{0,12:X4} {1,12}", ctr, Convert.ToChar(ctr)); - sb.AppendLine(); - } - // Find the end of the introduction to the column. - int pos = sb.ToString().IndexOf("characters:") + 11 + - Environment.NewLine.Length; - // Insert a column header. - sb.Insert(pos, String.Format("{2}{0,12:X4} {1,12}{2}", "Code Unit", - "Character", "\n")); - - // Convert the StringBuilder to a string and display it. - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// ********** Adding Text to a StringBuilder Object ********** -// -// Some code points and their corresponding characters: -// -// Code Unit Character -// 0032 2 -// 0033 3 -// 0034 4 -// 0035 5 -// 0036 6 -// 0037 7 -// 0038 8 -// 0039 9 -// 003A : -// 003B ; -// 003C < -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs deleted file mode 100644 index 0ccf5009804..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public unsafe static void Main() - { - string value = "This is the first sentence" + "."; - fixed (char* start = value) - { - value = String.Concat(value, "This is the second sentence. "); - fixed (char* current = value) - { - Console.WriteLine(start == current); - } - } - } -} -// The example displays the following output: -// False -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs deleted file mode 100644 index 9626a43ef01..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - string value = "An ordinary string"; - int index = value.IndexOf("An ") + 3; - int capacity = 0xFFFF; - - // Instantiate a StringBuilder from a string. - StringBuilder sb1 = new StringBuilder(value); - ShowSBInfo(sb1); - - // Instantiate a StringBuilder from string and define a capacity. - StringBuilder sb2 = new StringBuilder(value, capacity); - ShowSBInfo(sb2); - - // Instantiate a StringBuilder from substring and define a capacity. - StringBuilder sb3 = new StringBuilder(value, index, - value.Length - index, - capacity ); - ShowSBInfo(sb3); - } - - public static void ShowSBInfo(StringBuilder sb) - { - Console.WriteLine("\nValue: {0}", sb.ToString()); - foreach (var prop in sb.GetType().GetProperties()) { - if (prop.GetIndexParameters().Length == 0) - Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); - } - Console.WriteLine(); - } -} -// The example displays the following output: -// Value: An ordinary string -// Capacity: 18 MaxCapacity: 2,147,483,647 Length: 18 -// -// Value: An ordinary string -// Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 18 -// -// Value: ordinary string -// Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 15 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs deleted file mode 100644 index 76cbcf070c4..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - Random rnd = new Random(); - string[] tempF = { "47.6F", "51.3F", "49.5F", "62.3F" }; - string[] tempC = { "21.2C", "16.1C", "23.5C", "22.9C" }; - string[][] temps = { tempF, tempC }; - - StringBuilder sb = new StringBuilder(); - var f = new StringBuilderFinder(sb, "F"); - var baseDate = new DateTime(2013, 5, 1); - String[] temperatures = temps[rnd.Next(2)]; - bool isFahrenheit = false; - foreach (var temperature in temperatures) { - if (isFahrenheit) - sb.AppendFormat("{0:d}: {1}\n", baseDate, temperature); - else - isFahrenheit = f.SearchAndAppend(String.Format("{0:d}: {1}\n", - baseDate, temperature)); - baseDate = baseDate.AddDays(1); - } - if (isFahrenheit) { - sb.Insert(0, "Average Daily Temperature in Degrees Fahrenheit"); - sb.Insert(47, "\n\n"); - } - else { - sb.Insert(0, "Average Daily Temperature in Degrees Celsius"); - sb.Insert(44, "\n\n"); - } - Console.WriteLine(sb.ToString()); - } -} - -public class StringBuilderFinder -{ - private StringBuilder sb; - private String text; - - public StringBuilderFinder(StringBuilder sb, String textToFind) - { - this.sb = sb; - this.text = textToFind; - } - - public bool SearchAndAppend(String stringToSearch) - { - sb.Append(stringToSearch); - return stringToSearch.Contains(text); - } -} -// The example displays output similar to the following: -// Average Daily Temperature in Degrees Celsius -// -// 5/1/2013: 21.2C -// 5/2/2013: 16.1C -// 5/3/2013: 23.5C -// 5/4/2013: 22.9C -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs deleted file mode 100644 index ea20040bbd2..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -using System; -using System.Text; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with 4 successive occurrences - // of each character in the English alphabet. - StringBuilder sb = new StringBuilder(); - for (ushort ctr = (ushort)'a'; ctr <= (ushort) 'z'; ctr++) - sb.Append(Convert.ToChar(ctr), 4); - - // Create a parallel string object. - String sbString = sb.ToString(); - // Determine where each new character sequence begins. - String pattern = @"(\w)\1+"; - MatchCollection matches = Regex.Matches(sbString, pattern); - - // Uppercase the first occurrence of the sequence, and separate it - // from the previous sequence by an underscore character. - for (int ctr = matches.Count - 1; ctr >= 0; ctr--) { - Match m = matches[ctr]; - sb[m.Index] = Char.ToUpper(sb[m.Index]); - if (m.Index > 0) sb.Insert(m.Index, "_"); - } - // Display the resulting string. - sbString = sb.ToString(); - int line = 0; - do { - int nChars = line * 80 + 79 <= sbString.Length ? - 80 : sbString.Length - line * 80; - Console.WriteLine(sbString.Substring(line * 80, nChars)); - line++; - } while (line * 80 < sbString.Length); - } -} -// The example displays the following output: -// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ -// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs deleted file mode 100644 index 4d927c66cc5..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with 4 successive occurrences - // of each character in the English alphabet. - StringBuilder sb = new StringBuilder(); - for (ushort ctr = (ushort) 'a'; ctr <= (ushort) 'z'; ctr++) - sb.Append(Convert.ToChar(ctr), 4); - - // Iterate the text to determine when a new character sequence occurs. - int position = 0; - Char current = '\u0000'; - do { - if (sb[position] != current) { - current = sb[position]; - sb[position] = Char.ToUpper(sb[position]); - if (position > 0) - sb.Insert(position, "_"); - position += 2; - } - else { - position++; - } - } while (position <= sb.Length - 1); - // Display the resulting string. - String sbString = sb.ToString(); - int line = 0; - do { - int nChars = line * 80 + 79 <= sbString.Length ? - 80 : sbString.Length - line * 80; - Console.WriteLine(sbString.Substring(line * 80, nChars)); - line++; - } while (line * 80 < sbString.Length); - } -} -// The example displays the following output: -// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ -// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs deleted file mode 100644 index 67112fb6c4e..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -using System; -using System.Text; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with 4 successive occurrences - // of each character in the English alphabet. - StringBuilder sb = new StringBuilder(); - for (ushort ctr = (ushort)'a'; ctr <= (ushort) 'z'; ctr++) - sb.Append(Convert.ToChar(ctr), 4); - - // Convert it to a string. - String sbString = sb.ToString(); - - // Use a regex to uppercase the first occurrence of the sequence, - // and separate it from the previous sequence by an underscore. - string pattern = @"(\w)(\1+)"; - sbString = Regex.Replace(sbString, pattern, - m => (m.Index > 0 ? "_" : "") + - m.Groups[1].Value.ToUpper() + - m.Groups[2].Value); - - // Display the resulting string. - int line = 0; - do { - int nChars = line * 80 + 79 <= sbString.Length ? - 80 : sbString.Length - line * 80; - Console.WriteLine(sbString.Substring(line * 80, nChars)); - line++; - } while (line * 80 < sbString.Length); - } -} -// The example displays the following output: -// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ -// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs deleted file mode 100644 index 8e9426d47e3..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -public struct OperationTime -{ - public OperationTime(int ctr, TimeSpan elapsed) - { - Operations = ctr; - ElapsedTime = elapsed; - } - - public int Operations; - public TimeSpan ElapsedTime; -} - -public class Example -{ - public static void Main() - { - List stringTimes = new List(); - List builderTimes = new List(); - - // Begin the time for a string - Stopwatch sTimer = new Stopwatch(); - Stopwatch sbTimer = new Stopwatch(); - - // We want to include object instantiation in the timer. - sTimer.Start(); - string baseS1 = "Beginning"; - sTimer.Stop(); - - sbTimer.Start(); - StringBuilder baseS2 = new StringBuilder("Beginning"); - sbTimer.Stop(); - - // Record time for every 10 operations for a 100 operation string concatenation. - sTimer.Start(); - for (int ctr = 1; ctr <= 100; ctr++) { - baseS1 += "a"; - if (ctr % 10 == 0) { - sTimer.Stop(); - stringTimes.Add(new OperationTime(ctr, sTimer.Elapsed)); - sTimer.Start(); - } - }; - sTimer.Stop(); - - sbTimer.Start(); - for (int ctr = 1; ctr <= 100; ctr++) { - baseS2.Append("a"); - if (ctr % 10 == 0) { - sbTimer.Stop(); - builderTimes.Add(new OperationTime(ctr, sbTimer.Elapsed)); - sbTimer.Start(); - } - } - sbTimer.Stop(); - - // Display performance information - Console.WriteLine("{0,10} {1,20} {2,20}", - "Operations", "String Time", "StringBuilder Time"); - - for (int ctr = 0; ctr < stringTimes.Count; ctr++) - Console.WriteLine("{0,10} {1,20} {2,20}", stringTimes[ctr].Operations, - stringTimes[ctr].ElapsedTime, builderTimes[ctr].ElapsedTime); - } -} -// The example displays the following output: -// Operations String Time StringBuilder Time -// 10 00:00:00.0000019 00:00:00.0000087 -// 20 00:00:00.0000025 00:00:00.0000087 -// 30 00:00:00.0000032 00:00:00.0000090 -// 40 00:00:00.0000038 00:00:00.0000090 -// 50 00:00:00.0000090 00:00:00.0000094 -// 60 00:00:00.0000097 00:00:00.0000097 -// 70 00:00:00.0000103 00:00:00.0000097 -// 80 00:00:00.0000110 00:00:00.0000100 -// 90 00:00:00.0000181 00:00:00.0000100 -// 100 00:00:00.0000188 00:00:00.0000103 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs deleted file mode 100644 index 9e66c7977fb..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder MyStringBuilder = new StringBuilder("Hello World!"); - MyStringBuilder.Replace('!', '?'); - Console.WriteLine(MyStringBuilder); - } -} -// The example displays the following output: -// Hello World? -// diff --git a/snippets/csharp/System/Action/Overview/Delegate.cs b/snippets/csharp/System/Action/Overview/Delegate.cs deleted file mode 100644 index a7fe2739ddf..00000000000 --- a/snippets/csharp/System/Action/Overview/Delegate.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; -using System.Windows.Forms; - -public delegate void ShowValue(); - -public class Name -{ - private string instanceName; - - public Name(string name) - { - this.instanceName = name; - } - - public void DisplayToConsole() - { - Console.WriteLine(this.instanceName); - } - - public void DisplayToWindow() - { - MessageBox.Show(this.instanceName); - } -} - -public class testTestDelegate -{ - public static void Main() - { - Name testName = new Name("Koani"); - ShowValue showMethod = testName.DisplayToWindow; - showMethod(); - } -} -// diff --git a/snippets/csharp/System/AppContext/Overview/Example4.cs b/snippets/csharp/System/AppContext/Overview/Example4.cs deleted file mode 100644 index 5a906d1f2b1..00000000000 --- a/snippets/csharp/System/AppContext/Overview/Example4.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.Reflection; - -[assembly: AssemblyVersion("1.0.0.0")] - -public static class StringLibrary -{ - public static int SubstringStartsAt(string fullString, string substr) - { - return fullString.IndexOf(substr, StringComparison.Ordinal); - } -} -// - -namespace App -{ - // - using System; - - public class Example - { - public static void Main() - { - string value = "The archaeologist"; - string substring = "archæ"; - int position = StringLibrary.SubstringStartsAt(value, substring); - if (position >= 0) - Console.WriteLine("'{0}' found in '{1}' starting at position {2}", - substring, value, position); - else - Console.WriteLine("'{0}' not found in '{1}'", substring, value); - } - } - // The example displays the following output: - // 'archæ' not found in 'The archaeologist' - // -} diff --git a/snippets/csharp/System/AppContext/Overview/Example6.cs b/snippets/csharp/System/AppContext/Overview/Example6.cs deleted file mode 100644 index e33b85efd30..00000000000 --- a/snippets/csharp/System/AppContext/Overview/Example6.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.Reflection; - -[assembly: AssemblyVersion("2.0.0.0")] - -public static class StringLibrary -{ - public static int SubstringStartsAt(string fullString, string substr) - { - return fullString.IndexOf(substr, StringComparison.CurrentCulture); - } -} -// - -namespace App -{ - // - using System; - - public class Example - { - public static void Main() - { - string value = "The archaeologist"; - string substring = "archæ"; - int position = StringLibrary.SubstringStartsAt(value, substring); - if (position >= 0) - Console.WriteLine("'{0}' found in '{1}' starting at position {2}", - substring, value, position); - else - Console.WriteLine("'{0}' not found in '{1}'", substring, value); - } - } - // The example displays the following output: - // 'archæ' found in 'The archaeologist' starting at position 4 - // -} diff --git a/snippets/csharp/System/AppContext/Overview/Example8.cs b/snippets/csharp/System/AppContext/Overview/Example8.cs deleted file mode 100644 index 5fad1b348bb..00000000000 --- a/snippets/csharp/System/AppContext/Overview/Example8.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Reflection; - -[assembly: AssemblyVersion("2.0.0.0")] - -public static class StringLibrary -{ - public static int SubstringStartsAt(string fullString, string substr) - { - bool flag; - if (AppContext.TryGetSwitch("StringLibrary.DoNotUseCultureSensitiveComparison", out flag) && flag) - return fullString.IndexOf(substr, StringComparison.Ordinal); - else - return fullString.IndexOf(substr, StringComparison.CurrentCulture); - } -} -// - -namespace App -{ - // - using System; - - public class Example - { - public static void Main() - { - string value = "The archaeologist"; - string substring = "archæ"; - int position = StringLibrary.SubstringStartsAt(value, substring); - if (position >= 0) - Console.WriteLine("'{0}' found in '{1}' starting at position {2}", - substring, value, position); - else - Console.WriteLine("'{0}' not found in '{1}'", substring, value); - } - } - // The example displays the following output: - // 'archæ' found in 'The archaeologist' starting at position 4 - // -} diff --git a/snippets/csharp/System/AppContext/Overview/ForConsumers1.cs b/snippets/csharp/System/AppContext/Overview/ForConsumers1.cs deleted file mode 100644 index 6cf41198aeb..00000000000 --- a/snippets/csharp/System/AppContext/Overview/ForConsumers1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; -using System.IO; -using System.Runtime.Versioning; - -[assembly:TargetFramework(".NETFramework,Version=v4.6.2")] - -public class Example -{ - public static void Main() - { - Console.WriteLine(Path.GetDirectoryName("file://c/temp/dirlist.txt")); - } -} -// The example displays the following output: -// Unhandled Exception: System.ArgumentException: The path is not of a legal form. -// at System.IO.Path.NewNormalizePathLimitedChecks(String path, Int32 maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.InternalGetDirectoryName(String path) -// at Example.Main() -// diff --git a/snippets/csharp/System/AppContext/Overview/GetSwitches3.cs b/snippets/csharp/System/AppContext/Overview/GetSwitches3.cs deleted file mode 100644 index 9360ee49e99..00000000000 --- a/snippets/csharp/System/AppContext/Overview/GetSwitches3.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -using System; -using System.Configuration; -using System.Globalization; -using System.Xml; - -public class Example -{ - private const string SettingName = "AppContextSwitchOverrides"; - private const string SwitchName = "Switch.Application.Utilities.SwitchName"; - - public static void Main() - { - bool flag = false; - - // Determine whether the caller has used the AppContext class directly. - if (!AppContext.TryGetSwitch(SwitchName, out flag)) { - // If switch is not defined directly, attempt to retrieve it from a configuration file. - try { - Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - if (config == null) return; - - ConfigurationSection sec = config.GetSection("runtime"); - if (sec != null) { - string rawXml = sec.SectionInformation.GetRawXml(); - if (string.IsNullOrEmpty(rawXml)) return; - - var doc = new XmlDocument(); - doc.LoadXml(rawXml); - XmlNode root = doc.FirstChild; - // Navigate the children. - if (root.HasChildNodes) { - foreach (XmlNode node in root.ChildNodes) { - if (node.Name.Equals(SettingName, StringComparison.Ordinal)) { - // Get attribute value - XmlAttribute attr = node.Attributes["value"]; - string[] nameValuePair = attr.Value.Split('='); - // Determine whether the switch we want is present. - if (SwitchName.Equals(nameValuePair[0], StringComparison.Ordinal)) { - bool tempFlag = false; - if (bool.TryParse(CultureInfo.InvariantCulture.TextInfo.ToTitleCase(nameValuePair[1]), - out tempFlag)) - AppContext.SetSwitch(nameValuePair[0], tempFlag); - } - } - } - } - } - } - catch (ConfigurationErrorsException) - {} - } - } -} -// diff --git a/snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs b/snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs deleted file mode 100644 index d047a6f0c06..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs +++ /dev/null @@ -1,160 +0,0 @@ -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.Collections; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ -// Create a state object that holds each requested host name, -// an associated IPHostEntry object or a SocketException. - public class HostRequest - { - // Stores the requested host name. - private string hostName; - // Stores any SocketException returned by the Dns EndGetHostByName method. - private SocketException e; - // Stores an IPHostEntry returned by the Dns EndGetHostByName method. - private IPHostEntry entry; - - public HostRequest(string name) - { - hostName = name; - } - - public string HostName - { - get - { - return hostName; - } - } - - public SocketException ExceptionObject - { - get - { - return e; - } - set - { - e = value; - } - } - - public IPHostEntry HostEntry - { - get - { - return entry; - } - set - { - entry = value; - } - } - } - - public class UseDelegateAndStateForAsyncCallback - { - // The number of pending requests. - static int requestCounter; - static ArrayList hostData = new ArrayList(); - static void UpdateUserInterface() - { - // Print a message to indicate that the application - // is still working on the remaining requests. - Console.WriteLine("{0} requests remaining.", requestCounter); - } - public static void Main() - { - // Create the delegate that will process the results of the - // asynchronous request. - AsyncCallback callBack = new AsyncCallback(ProcessDnsInformation); - string host; - do - { - Console.Write(" Enter the name of a host computer or to finish: "); - host = Console.ReadLine(); - if (host.Length > 0) - { - // Increment the request counter in a thread safe manner. - Interlocked.Increment(ref requestCounter); - // Create and store the state object for this request. - HostRequest request = new HostRequest(host); - hostData.Add(request); - // Start the asynchronous request for DNS information. - Dns.BeginGetHostEntry(host, callBack, request); - } - } while (host.Length > 0); - // The user has entered all of the host names for lookup. - // Now wait until the threads complete. - while (requestCounter > 0) - { - UpdateUserInterface(); - } - // Display the results. - foreach(HostRequest r in hostData) - { - if (r.ExceptionObject != null) - { - Console.WriteLine("Request for host {0} returned the following error: {1}.", - r.HostName, r.ExceptionObject.Message); - } - else - { - // Get the results. - IPHostEntry h = r.HostEntry; - string[] aliases = h.Aliases; - IPAddress[] addresses = h.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases for {0}", r.HostName); - for (int j = 0; j < aliases.Length; j++) - { - Console.WriteLine("{0}", aliases[j]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses for {0}", r.HostName); - for (int k = 0; k < addresses.Length; k++) - { - Console.WriteLine("{0}",addresses[k].ToString()); - } - } - } - } - } - - // The following method is invoked when each asynchronous operation completes. - static void ProcessDnsInformation(IAsyncResult result) - { - // Get the state object associated with this request. - HostRequest request = (HostRequest) result.AsyncState; - try - { - // Get the results and store them in the state object. - IPHostEntry host = Dns.EndGetHostEntry(result); - request.HostEntry = host; - } - catch (SocketException e) - { - // Store any SocketExceptions. - request.ExceptionObject = e; - } - finally - { - // Decrement the request counter in a thread-safe manner. - Interlocked.Decrement(ref requestCounter); - } - } - } -} -// diff --git a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs b/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs deleted file mode 100644 index 47e992c42e8..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs +++ /dev/null @@ -1,61 +0,0 @@ -// AsynchSampler -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. -*/ - -using System; -using System.Net; -using System.Net.Sockets; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class BlockUntilOperationCompletes - { - public static void Main(string[] args) - { - // Make sure the caller supplied a host name. - if (args.Length == 0 || args[0].Length == 0) - { - // Print a message and exit. - Console.WriteLine("You must specify the name of a host computer."); - return; - } - // Start the asynchronous request for DNS information. - // This example does not use a delegate or user-supplied object - // so the last two arguments are null. - IAsyncResult result = Dns.BeginGetHostEntry(args[0], null, null); - Console.WriteLine("Processing your request for information..."); - // Do any additional work that can be done here. - try - { - // EndGetHostByName blocks until the process completes. - IPHostEntry host = Dns.EndGetHostEntry(result); - string[] aliases = host.Aliases; - IPAddress[] addresses = host.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases"); - for (int i = 0; i < aliases.Length; i++) - { - Console.WriteLine("{0}", aliases[i]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses"); - for (int i = 0; i < addresses.Length; i++) - { - Console.WriteLine("{0}",addresses[i].ToString()); - } - } - } - catch (SocketException e) - { - Console.WriteLine("An exception occurred while processing the request: {0}", e.Message); - } - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs b/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs deleted file mode 100644 index 65aae9f1582..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. - -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class WaitUntilOperationCompletes - { - public static void Main(string[] args) - { - // Make sure the caller supplied a host name. - if (args.Length == 0 || args[0].Length == 0) - { - // Print a message and exit. - Console.WriteLine("You must specify the name of a host computer."); - return; - } - // Start the asynchronous request for DNS information. - IAsyncResult result = Dns.BeginGetHostEntry(args[0], null, null); - Console.WriteLine("Processing request for information..."); - // Wait until the operation completes. - result.AsyncWaitHandle.WaitOne(); - // The operation completed. Process the results. - try - { - // Get the results. - IPHostEntry host = Dns.EndGetHostEntry(result); - string[] aliases = host.Aliases; - IPAddress[] addresses = host.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases"); - for (int i = 0; i < aliases.Length; i++) - { - Console.WriteLine("{0}", aliases[i]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses"); - for (int i = 0; i < addresses.Length; i++) - { - Console.WriteLine("{0}",addresses[i].ToString()); - } - } - } - catch (SocketException e) - { - Console.WriteLine("Exception occurred while processing the request: {0}", - e.Message); - } - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs b/snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs deleted file mode 100644 index 57b1a056665..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. -This example polls to detect the end of the asynchronous operation. -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class PollUntilOperationCompletes - { - static void UpdateUserInterface() - { - // Print a period to indicate that the application - // is still working on the request. - Console.Write("."); - } - public static void Main(string[] args) - { - // Make sure the caller supplied a host name. - if (args.Length == 0 || args[0].Length == 0) - { - // Print a message and exit. - Console.WriteLine("You must specify the name of a host computer."); - return; - } - // Start the asychronous request for DNS information. - IAsyncResult result = Dns.BeginGetHostEntry(args[0], null, null); - Console.WriteLine("Processing request for information..."); - - // Poll for completion information. - // Print periods (".") until the operation completes. - while (!result.IsCompleted) - { - UpdateUserInterface(); - } - // The operation is complete. Process the results. - // Print a new line. - Console.WriteLine(); - try - { - IPHostEntry host = Dns.EndGetHostEntry(result); - string[] aliases = host.Aliases; - IPAddress[] addresses = host.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases"); - for (int i = 0; i < aliases.Length; i++) - { - Console.WriteLine("{0}", aliases[i]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses"); - for (int i = 0; i < addresses.Length; i++) - { - Console.WriteLine("{0}",addresses[i].ToString()); - } - } - } - catch (SocketException e) - { - Console.WriteLine("An exception occurred while processing the request: {0}", e.Message); - } - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs b/snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs deleted file mode 100644 index 5bdc7826176..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs +++ /dev/null @@ -1,140 +0,0 @@ -// -using System; -using System.Threading; -using System.Runtime.Remoting.Messaging; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - // Create a class that factors a number. - public class PrimeFactorFinder - { - public static bool Factorize( - int number, - ref int primefactor1, - ref int primefactor2) - { - primefactor1 = 1; - primefactor2 = number; - - // Factorize using a low-tech approach. - for (int i=2;i diff --git a/snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs b/snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs deleted file mode 100644 index d6d28fe797e..00000000000 --- a/snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -namespace CustAttrs3CS { - // Set a GUID and ProgId attribute for this class. - [Guid("BF235B41-52D1-46CC-9C55-046793DB363F")] - [ProgId("CustAttrs3CS.ClassWithGuidAndProgId")] - public class ClassWithGuidAndProgId { - } - - class DemoClass { - static void Main(string[] args) { - // Get the Class type to access its metadata. - Type clsType = typeof(ClassWithGuidAndProgId); - - // Iterate through all the attributes for the class. - foreach(Attribute attr in Attribute.GetCustomAttributes(clsType)) { - // Check for the Guid attribute. - if (attr.GetType() == typeof(GuidAttribute)) { - // Display the GUID. - Console.WriteLine("Class {0} has a GUID.", clsType.Name); - Console.WriteLine("GUID: {" + - ((GuidAttribute)attr).Value + "}."); - } - - // Check for the ProgId attribute. - else if (attr.GetType() == typeof(ProgIdAttribute)) { - // Display the ProgId. - Console.WriteLine("Class {0} has a ProgId.", clsType.Name); - Console.WriteLine("ProgId: \"{0}\".", - ((ProgIdAttribute)attr).Value); - } - } - } - } -} - -/* - * Output: - * Class ClassWithGuidAndProgId has a GUID. - * GUID: {BF235B41-52D1-46CC-9C55-046793DB363F}. - * Class ClassWithGuidAndProgId has a ProgId. - * ProgId: "CustAttrs3CS.ClassWithGuidAndProgId". - */ -// diff --git a/snippets/csharp/System/Boolean/Overview/binary1.cs b/snippets/csharp/System/Boolean/Overview/binary1.cs deleted file mode 100644 index 6ce7165dcbd..00000000000 --- a/snippets/csharp/System/Boolean/Overview/binary1.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool[] flags = { true, false }; - foreach (var flag in flags) { - // Get binary representation of flag. - Byte value = BitConverter.GetBytes(flag)[0]; - Console.WriteLine("Original value: {0}", flag); - Console.WriteLine("Binary value: {0} ({1})", value, - GetBinaryString(value)); - // Restore the flag from its binary representation. - bool newFlag = BitConverter.ToBoolean( new Byte[] { value }, 0); - Console.WriteLine("Restored value: {0}\n", flag); - } - } - - private static string GetBinaryString(Byte value) - { - string retVal = Convert.ToString(value, 2); - return new string('0', 8 - retVal.Length) + retVal; - } -} -// The example displays the following output: -// Original value: True -// Binary value: 1 (00000001) -// Restored value: True -// -// Original value: False -// Binary value: 0 (00000000) -// Restored value: False -// diff --git a/snippets/csharp/System/Boolean/Overview/conversion1.cs b/snippets/csharp/System/Boolean/Overview/conversion1.cs deleted file mode 100644 index 6c8e607f66a..00000000000 --- a/snippets/csharp/System/Boolean/Overview/conversion1.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Byte byteValue = 12; - Console.WriteLine(Convert.ToBoolean(byteValue)); - Byte byteValue2 = 0; - Console.WriteLine(Convert.ToBoolean(byteValue2)); - int intValue = -16345; - Console.WriteLine(Convert.ToBoolean(intValue)); - long longValue = 945; - Console.WriteLine(Convert.ToBoolean(longValue)); - SByte sbyteValue = -12; - Console.WriteLine(Convert.ToBoolean(sbyteValue)); - double dblValue = 0; - Console.WriteLine(Convert.ToBoolean(dblValue)); - float sngValue = .0001f; - Console.WriteLine(Convert.ToBoolean(sngValue)); - } -} -// The example displays the following output: -// True -// False -// True -// True -// True -// False -// True -// diff --git a/snippets/csharp/System/Boolean/Overview/conversion3.cs b/snippets/csharp/System/Boolean/Overview/conversion3.cs deleted file mode 100644 index 7b6af6d34e4..00000000000 --- a/snippets/csharp/System/Boolean/Overview/conversion3.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool flag = true; - - byte byteValue; - byteValue = Convert.ToByte(flag); - Console.WriteLine("{0} -> {1}", flag, byteValue); - - sbyte sbyteValue; - sbyteValue = Convert.ToSByte(flag); - Console.WriteLine("{0} -> {1}", flag, sbyteValue); - - double dblValue; - dblValue = Convert.ToDouble(flag); - Console.WriteLine("{0} -> {1}", flag, dblValue); - - int intValue; - intValue = Convert.ToInt32(flag); - Console.WriteLine("{0} -> {1}", flag, intValue); - } -} -// The example displays the following output: -// True -> 1 -// True -> 1 -// True -> 1 -// True -> 1 -// diff --git a/snippets/csharp/System/Boolean/Overview/format3.cs b/snippets/csharp/System/Boolean/Overview/format3.cs deleted file mode 100644 index 7df289388b1..00000000000 --- a/snippets/csharp/System/Boolean/Overview/format3.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - String[] cultureNames = { "", "en-US", "fr-FR", "ru-RU" }; - foreach (var cultureName in cultureNames) { - bool value = true; - CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName); - BooleanFormatter formatter = new BooleanFormatter(culture); - - string result = string.Format(formatter, "Value for '{0}': {1}", culture.Name, value); - Console.WriteLine(result); - } - } -} - -public class BooleanFormatter : ICustomFormatter, IFormatProvider -{ - private CultureInfo culture; - - public BooleanFormatter() : this(CultureInfo.CurrentCulture) - { } - - public BooleanFormatter(CultureInfo culture) - { - this.culture = culture; - } - - public Object GetFormat(Type formatType) - { - if (formatType == typeof(ICustomFormatter)) - return this; - else - return null; - } - - public string Format(string fmt, Object arg, IFormatProvider formatProvider) - { - // Exit if another format provider is used. - if (!formatProvider.Equals(this)) return null; - - // Exit if the type to be formatted is not a Boolean - if (!(arg is Boolean)) return null; - - bool value = (bool) arg; - switch (culture.Name) { - case "en-US": - return value.ToString(); - case "fr-FR": - if (value) - return "vrai"; - else - return "faux"; - case "ru-RU": - if (value) - return "верно"; - else - return "неверно"; - default: - return value.ToString(); - } - } -} -// The example displays the following output: -// Value for '': True -// Value for 'en-US': True -// Value for 'fr-FR': vrai -// Value for 'ru-RU': верно -// diff --git a/snippets/csharp/System/Boolean/Overview/operations1.cs b/snippets/csharp/System/Boolean/Overview/operations1.cs deleted file mode 100644 index 8948f200e66..00000000000 --- a/snippets/csharp/System/Boolean/Overview/operations1.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -using System; -using System.IO; -using System.Threading; - -public class Example -{ - public static void Main() - { - // Initialize flag variables. - bool isRedirected = false; - bool isBoth = false; - String fileName = ""; - StreamWriter sw = null; - - // Get any command line arguments. - String[] args = Environment.GetCommandLineArgs(); - // Handle any arguments. - if (args.Length > 1) { - for (int ctr = 1; ctr < args.Length; ctr++) { - String arg = args[ctr]; - if (arg.StartsWith("/") || arg.StartsWith("-")) { - switch (arg.Substring(1).ToLower()) - { - case "f": - isRedirected = true; - if (args.Length < ctr + 2) { - ShowSyntax("The /f switch must be followed by a filename."); - return; - } - fileName = args[ctr + 1]; - ctr++; - break; - case "b": - isBoth = true; - break; - default: - ShowSyntax(String.Format("The {0} switch is not supported", - args[ctr])); - return; - } - } - } - } - - // If isBoth is True, isRedirected must be True. - if (isBoth && ! isRedirected) { - ShowSyntax("The /f switch must be used if /b is used."); - return; - } - - // Handle output. - if (isRedirected) { - sw = new StreamWriter(fileName); - if (!isBoth) - Console.SetOut(sw); - } - String msg = String.Format("Application began at {0}", DateTime.Now); - Console.WriteLine(msg); - if (isBoth) sw.WriteLine(msg); - Thread.Sleep(5000); - msg = String.Format("Application ended normally at {0}", DateTime.Now); - Console.WriteLine(msg); - if (isBoth) sw.WriteLine(msg); - if (isRedirected) sw.Close(); - } - - private static void ShowSyntax(String errMsg) - { - Console.WriteLine(errMsg); - Console.WriteLine("\nSyntax: Example [[/f [/b]]\n"); - } -} -// - -public class Evaluation -{ - public void SomeMethod() - { - bool booleanValue = false; - - // - if (booleanValue ) { - // - } - - // - if (booleanValue) { - // - } - } -} diff --git a/snippets/csharp/System/Boolean/Overview/operations2.cs b/snippets/csharp/System/Boolean/Overview/operations2.cs deleted file mode 100644 index cdc198f24ae..00000000000 --- a/snippets/csharp/System/Boolean/Overview/operations2.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool[] hasServiceCharges = { true, false }; - Decimal subtotal = 120.62m; - Decimal shippingCharge = 2.50m; - Decimal serviceCharge = 5.00m; - - foreach (var hasServiceCharge in hasServiceCharges) { - Decimal total = subtotal + shippingCharge + - (hasServiceCharge ? serviceCharge : 0); - Console.WriteLine("hasServiceCharge = {1}: The total is {0:C2}.", - total, hasServiceCharge); - } - } -} -// The example displays output like the following: -// hasServiceCharge = True: The total is $128.12. -// hasServiceCharge = False: The total is $123.12. -// diff --git a/snippets/csharp/System/Boolean/Overview/parse2.cs b/snippets/csharp/System/Boolean/Overview/parse2.cs deleted file mode 100644 index 6b2242e125b..00000000000 --- a/snippets/csharp/System/Boolean/Overview/parse2.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string[] values = { null, String.Empty, "True", "False", - "true", "false", " true ", - "TrUe", "fAlSe", "fa lse", "0", - "1", "-1", "string" }; - // Parse strings using the Boolean.Parse method. - foreach (var value in values) { - try { - bool flag = Boolean.Parse(value); - Console.WriteLine("'{0}' --> {1}", value, flag); - } - catch (ArgumentException) { - Console.WriteLine("Cannot parse a null string."); - } - catch (FormatException) { - Console.WriteLine("Cannot parse '{0}'.", value); - } - } - Console.WriteLine(); - // Parse strings using the Boolean.TryParse method. - foreach (var value in values) { - bool flag = false; - if (Boolean.TryParse(value, out flag)) - Console.WriteLine("'{0}' --> {1}", value, flag); - else - Console.WriteLine("Unable to parse '{0}'", value); - } - } -} -// The example displays the following output: -// Cannot parse a null string. -// Cannot parse ''. -// 'True' --> True -// 'False' --> False -// 'true' --> True -// 'false' --> False -// ' true ' --> True -// 'TrUe' --> True -// 'fAlSe' --> False -// Cannot parse 'fa lse'. -// Cannot parse '0'. -// Cannot parse '1'. -// Cannot parse '-1'. -// Cannot parse 'string'. -// -// Unable to parse '' -// Unable to parse '' -// 'True' --> True -// 'False' --> False -// 'true' --> True -// 'false' --> False -// ' true ' --> True -// 'TrUe' --> True -// 'fAlSe' --> False -// Cannot parse 'fa lse'. -// Unable to parse '0' -// Unable to parse '1' -// Unable to parse '-1' -// Unable to parse 'string' -// diff --git a/snippets/csharp/System/Boolean/Overview/parse3.cs b/snippets/csharp/System/Boolean/Overview/parse3.cs deleted file mode 100644 index 50b3fbce057..00000000000 --- a/snippets/csharp/System/Boolean/Overview/parse3.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - String[] values = { "09", "12.6", "0", "-13 " }; - foreach (var value in values) { - bool success, result; - int number; - success = Int32.TryParse(value, out number); - if (success) { - // The method throws no exceptions. - result = Convert.ToBoolean(number); - Console.WriteLine("Converted '{0}' to {1}", value, result); - } - else { - Console.WriteLine("Unable to convert '{0}'", value); - } - } - } -} -// The example displays the following output: -// Converted '09' to True -// Unable to convert '12.6' -// Converted '0' to False -// Converted '-13 ' to True -// diff --git a/snippets/csharp/System/Boolean/Overview/size1.cs b/snippets/csharp/System/Boolean/Overview/size1.cs deleted file mode 100644 index 052002b8a1c..00000000000 --- a/snippets/csharp/System/Boolean/Overview/size1.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; - -public struct BoolStruct -{ - public bool flag1; - public bool flag2; - public bool flag3; - public bool flag4; - public bool flag5; -} - -public class Example -{ - public static void Main() - { - unsafe { - BoolStruct b = new BoolStruct(); - bool* addr = (bool*) &b; - Console.WriteLine("Size of BoolStruct: {0}", sizeof(BoolStruct)); - Console.WriteLine("Field offsets:"); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag1 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag2 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag3 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag4 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag5 - addr); - } - } -} -// The example displays the following output: -// Size of BoolStruct: 5 -// Field offsets: -// flag1: 0 -// flag1: 1 -// flag1: 2 -// flag1: 3 -// flag1: 4 -// \ No newline at end of file diff --git a/snippets/csharp/System/Boolean/Overview/tostring1.cs b/snippets/csharp/System/Boolean/Overview/tostring1.cs deleted file mode 100644 index 0569b2ffa6c..00000000000 --- a/snippets/csharp/System/Boolean/Overview/tostring1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool raining = false; - bool busLate = true; - - Console.WriteLine("It is raining: {0}", raining); - Console.WriteLine("The bus is late: {0}", busLate); - } -} -// The example displays the following output: -// It is raining: False -// The bus is late: True -// diff --git a/snippets/csharp/System/Boolean/Overview/tostring2.cs b/snippets/csharp/System/Boolean/Overview/tostring2.cs deleted file mode 100644 index 31f935003af..00000000000 --- a/snippets/csharp/System/Boolean/Overview/tostring2.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool raining = false; - bool busLate = true; - - Console.WriteLine("It is raining: {0}", - raining ? "Yes" : "No"); - Console.WriteLine("The bus is late: {0}", - busLate ? "Yes" : "No" ); - } -} -// The example displays the following output: -// It is raining: No -// The bus is late: Yes -// diff --git a/snippets/csharp/System/Byte/Overview/bitwise1.cs b/snippets/csharp/System/Byte/Overview/bitwise1.cs deleted file mode 100644 index a866deaa853..00000000000 --- a/snippets/csharp/System/Byte/Overview/bitwise1.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string[] values = { Convert.ToString(12, 16), - Convert.ToString(123, 16), - Convert.ToString(245, 16) }; - - byte mask = 0xFE; - foreach (string value in values) { - Byte byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier); - Console.WriteLine("{0} And {1} = {2}", byteValue, mask, - byteValue & mask); - } - } -} -// The example displays the following output: -// 12 And 254 = 12 -// 123 And 254 = 122 -// 245 And 254 = 244 -// diff --git a/snippets/csharp/System/Byte/Overview/bitwise2.cs b/snippets/csharp/System/Byte/Overview/bitwise2.cs deleted file mode 100644 index 70ba5cbe84f..00000000000 --- a/snippets/csharp/System/Byte/Overview/bitwise2.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Globalization; - -public struct ByteString -{ - public string Value; - public int Sign; -} - -public class Example -{ - public static void Main() - { - ByteString[] values = CreateArray(-15, 123, 245); - - byte mask = 0x14; // Mask all bits but 2 and 4. - - foreach (ByteString strValue in values) { - byte byteValue = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier); - Console.WriteLine("{0} ({1}) And {2} ({3}) = {4} ({5})", - strValue.Sign * byteValue, - Convert.ToString(byteValue, 2), - mask, Convert.ToString(mask, 2), - (strValue.Sign & Math.Sign(mask)) * (byteValue & mask), - Convert.ToString(byteValue & mask, 2)); - } - } - - private static ByteString[] CreateArray(params int[] values) - { - List byteStrings = new List(); - - foreach (object value in values) { - ByteString temp = new ByteString(); - int sign = Math.Sign((int) value); - temp.Sign = sign; - - // Change two's complement to magnitude-only representation. - temp.Value = Convert.ToString(((int) value) * sign, 16); - - byteStrings.Add(temp); - } - return byteStrings.ToArray(); - } -} -// The example displays the following output: -// -15 (1111) And 20 (10100) = 4 (100) -// 123 (1111011) And 20 (10100) = 16 (10000) -// 245 (11110101) And 20 (10100) = 20 (10100) -// diff --git a/snippets/csharp/System/Byte/Overview/byteinstantiation1.cs b/snippets/csharp/System/Byte/Overview/byteinstantiation1.cs deleted file mode 100644 index 688e8e3d084..00000000000 --- a/snippets/csharp/System/Byte/Overview/byteinstantiation1.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - InstantiateByAssignment(); - InstantiateByNarrowingConversion(); - Parse(); - } - - private static void InstantiateByAssignment() - { - // - byte value1 = 64; - byte value2 = 255; - // - Console.WriteLine("{0} {1}", value1, value2); - } - - private static void InstantiateByNarrowingConversion() - { - // - int int1 = 128; - try { - byte value1 = (byte) int1; - Console.WriteLine(value1); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of a byte.", int1); - } - - double dbl2 = 3.997; - try { - byte value2 = (byte) dbl2; - Console.WriteLine(value2); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of a byte.", dbl2); - } - // The example displays the following output: - // 128 - // 3 - // - } - - private static void Parse() - { - // - string string1 = "244"; - try { - byte byte1 = Byte.Parse(string1); - Console.WriteLine(byte1); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a byte.", string1); - } - catch (FormatException) { - Console.WriteLine("'{0}' is out of range of a byte.", string1); - } - - string string2 = "F9"; - try { - byte byte2 = Byte.Parse(string2, - System.Globalization.NumberStyles.HexNumber); - Console.WriteLine(byte2); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a byte.", string2); - } - catch (FormatException) { - Console.WriteLine("'{0}' is out of range of a byte.", string2); - } - // The example displays the following output: - // 244 - // 249 - // - } -} diff --git a/snippets/csharp/System/Byte/Overview/formatting1.cs b/snippets/csharp/System/Byte/Overview/formatting1.cs deleted file mode 100644 index e6514d26275..00000000000 --- a/snippets/csharp/System/Byte/Overview/formatting1.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CallToString(); - Console.WriteLine("-----"); - CallConvert(); - } - - private static void CallToString() - { - // - byte[] numbers = { 0, 16, 104, 213 }; - foreach (byte number in numbers) { - // Display value using default formatting. - Console.Write("{0,-3} --> ", number.ToString()); - // Display value with 3 digits and leading zeros. - Console.Write(number.ToString("D3") + " "); - // Display value with hexadecimal. - Console.Write(number.ToString("X2") + " "); - // Display value with four hexadecimal digits. - Console.WriteLine(number.ToString("X4")); - } - // The example displays the following output: - // 0 --> 000 00 0000 - // 16 --> 016 10 0010 - // 104 --> 104 68 0068 - // 213 --> 213 D5 00D5 - // - } - - private static void CallConvert() - { - // - byte[] numbers ={ 0, 16, 104, 213 }; - Console.WriteLine("{0} {1,8} {2,5} {3,5}", - "Value", "Binary", "Octal", "Hex"); - foreach (byte number in numbers) { - Console.WriteLine("{0,5} {1,8} {2,5} {3,5}", - number, Convert.ToString(number, 2), - Convert.ToString(number, 8), - Convert.ToString(number, 16)); - } - // The example displays the following output: - // Value Binary Octal Hex - // 0 0 0 0 - // 16 10000 20 10 - // 104 1101000 150 68 - // 213 11010101 325 d5 - // - } -} diff --git a/snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs b/snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs deleted file mode 100644 index 54907ae9df9..00000000000 --- a/snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -using System; -using System.Globalization; - -class Example -{ - public static void Main() - { - // Define a string with a variety of character categories. - String s = "The red car drove down the long, narrow, secluded road."; - // Determine the category of each character. - foreach (var ch in s) - Console.WriteLine("'{0}': {1}", ch, Char.GetUnicodeCategory(ch)); - } -} -// The example displays the following output: -// 'T': UppercaseLetter -// 'h': LowercaseLetter -// 'e': LowercaseLetter -// ' ': SpaceSeparator -// 'r': LowercaseLetter -// 'e': LowercaseLetter -// 'd': LowercaseLetter -// ' ': SpaceSeparator -// 'c': LowercaseLetter -// 'a': LowercaseLetter -// 'r': LowercaseLetter -// ' ': SpaceSeparator -// 'd': LowercaseLetter -// 'r': LowercaseLetter -// 'o': LowercaseLetter -// 'v': LowercaseLetter -// 'e': LowercaseLetter -// ' ': SpaceSeparator -// 'd': LowercaseLetter -// 'o': LowercaseLetter -// 'w': LowercaseLetter -// 'n': LowercaseLetter -// ' ': SpaceSeparator -// 't': LowercaseLetter -// 'h': LowercaseLetter -// 'e': LowercaseLetter -// ' ': SpaceSeparator -// 'l': LowercaseLetter -// 'o': LowercaseLetter -// 'n': LowercaseLetter -// 'g': LowercaseLetter -// ',': OtherPunctuation -// ' ': SpaceSeparator -// 'n': LowercaseLetter -// 'a': LowercaseLetter -// 'r': LowercaseLetter -// 'r': LowercaseLetter -// 'o': LowercaseLetter -// 'w': LowercaseLetter -// ',': OtherPunctuation -// ' ': SpaceSeparator -// 's': LowercaseLetter -// 'e': LowercaseLetter -// 'c': LowercaseLetter -// 'l': LowercaseLetter -// 'u': LowercaseLetter -// 'd': LowercaseLetter -// 'e': LowercaseLetter -// 'd': LowercaseLetter -// ' ': SpaceSeparator -// 'r': LowercaseLetter -// 'o': LowercaseLetter -// 'a': LowercaseLetter -// 'd': LowercaseLetter -// '.': OtherPunctuation -// diff --git a/snippets/csharp/System/Char/Overview/grapheme1.cs b/snippets/csharp/System/Char/Overview/grapheme1.cs deleted file mode 100644 index d61be7b56af..00000000000 --- a/snippets/csharp/System/Char/Overview/grapheme1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter("chars1.txt"); - char[] chars = { '\u0061', '\u0308' }; - string strng = new String(chars); - sw.WriteLine(strng); - sw.Close(); - } -} -// The example produces the following output: -// ä -// diff --git a/snippets/csharp/System/Char/Overview/normalized.cs b/snippets/csharp/System/Char/Overview/normalized.cs deleted file mode 100644 index 8c79a32820e..00000000000 --- a/snippets/csharp/System/Char/Overview/normalized.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string combining = "\u0061\u0308"; - ShowString(combining); - - string normalized = combining.Normalize(); - ShowString(normalized); - } - - private static void ShowString(string s) - { - Console.Write("Length of string: {0} (", s.Length); - for (int ctr = 0; ctr < s.Length; ctr++) { - Console.Write("U+{0:X4}", Convert.ToUInt16(s[ctr])); - if (ctr != s.Length - 1) Console.Write(" "); - } - Console.WriteLine(")\n"); - } -} -// The example displays the following output: -// Length of string: 2 (U+0061 U+0308) -// -// Length of string: 1 (U+00E4) -// diff --git a/snippets/csharp/System/Char/Overview/surrogate1.cs b/snippets/csharp/System/Char/Overview/surrogate1.cs deleted file mode 100644 index a412f04384b..00000000000 --- a/snippets/csharp/System/Char/Overview/surrogate1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\chars2.txt"); - int utf32 = 0x1D160; - string surrogate = Char.ConvertFromUtf32(utf32); - sw.WriteLine("U+{0:X6} UTF-32 = {1} ({2}) UTF-16", - utf32, surrogate, ShowCodePoints(surrogate)); - sw.Close(); - } - - private static string ShowCodePoints(string value) - { - string retval = null; - foreach (var ch in value) - retval += String.Format("U+{0:X4} ", Convert.ToUInt16(ch)); - - return retval.Trim(); - } -} -// The example produces the following output: -// U+01D160 UTF-32 = ð (U+D834 U+DD60) UTF-16 -// diff --git a/snippets/csharp/System/Char/Overview/textelements2.cs b/snippets/csharp/System/Char/Overview/textelements2.cs deleted file mode 100644 index 562d83b3a26..00000000000 --- a/snippets/csharp/System/Char/Overview/textelements2.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string result = String.Empty; - for (int ctr = 0x10107; ctr <= 0x10110; ctr++) // Range of Aegean numbers. - result += Char.ConvertFromUtf32(ctr); - - Console.WriteLine("The string contains {0} characters.", result.Length); - } -} -// The example displays the following output: -// The string contains 20 characters. -// diff --git a/snippets/csharp/System/Char/Overview/textelements2a.cs b/snippets/csharp/System/Char/Overview/textelements2a.cs deleted file mode 100644 index 32239ae9920..00000000000 --- a/snippets/csharp/System/Char/Overview/textelements2a.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string result = String.Empty; - for (int ctr = 0x10107; ctr <= 0x10110; ctr++) // Range of Aegean numbers. - result += Char.ConvertFromUtf32(ctr); - - StringInfo si = new StringInfo(result); - Console.WriteLine("The string contains {0} characters.", - si.LengthInTextElements); - } -} -// The example displays the following output: -// The string contains 10 characters. -// diff --git a/snippets/csharp/System/Console/ReadLine/readline1.cs b/snippets/csharp/System/Console/ReadLine/readline1.cs deleted file mode 100644 index 66248342384..00000000000 --- a/snippets/csharp/System/Console/ReadLine/readline1.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - if (!Console.IsInputRedirected) { - Console.WriteLine("This example requires that input be redirected from a file."); - return; - } - - Console.WriteLine("About to call Console.ReadLine in a loop."); - Console.WriteLine("----"); - String s; - int ctr = 0; - do { - ctr++; - s = Console.ReadLine(); - Console.WriteLine("Line {0}: {1}", ctr, s); - } while (s != null); - Console.WriteLine("---"); - } -} -// The example displays the following output: -// About to call Console.ReadLine in a loop. -// ---- -// Line 1: This is the first line. -// Line 2: This is the second line. -// Line 3: This is the third line. -// Line 4: This is the fourth line. -// Line 5: -// --- -// \ No newline at end of file diff --git a/snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs b/snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs deleted file mode 100644 index f12196bc715..00000000000 --- a/snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; - -public enum Continent -{ - Africa, Antarctica, Asia, Australia, Europe, - NorthAmerica, SouthAmerica -}; - -public class Example -{ - public static void Main() - { - // Convert a Continent to a Double. - Continent cont = Continent.NorthAmerica; - Console.WriteLine("{0:N2}", - Convert.ChangeType(cont, typeof(Double), null)); - - // Convert a Double to a Continent. - Double number = 6.0; - try { - Console.WriteLine("{0}", - Convert.ChangeType(number, typeof(Continent), null)); - } - catch (InvalidCastException) { - Console.WriteLine("Cannot convert a Double to a Continent"); - } - - Console.WriteLine("{0}", (Continent) number); - } -} -// The example displays the following output: -// 5.00 -// Cannot convert a Double to a Continent -// SouthAmerica -// diff --git a/snippets/csharp/System/Convert/ToDouble/todecimal.cs b/snippets/csharp/System/Convert/ToDouble/todecimal.cs deleted file mode 100644 index 2b316be160f..00000000000 --- a/snippets/csharp/System/Convert/ToDouble/todecimal.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -// Example of the Convert.ToDecimal( String ) and -// Convert.ToDecimal( String, IFormatProvider ) methods. -using System; -using System.Globalization; - -class ToDecimalProviderDemo -{ - static string formatter = "{0,-22}{1,-20}{2}"; - - // Get the exception type name; remove the namespace prefix. - static string GetExceptionType( Exception ex ) - { - string exceptionType = ex.GetType( ).ToString( ); - return exceptionType.Substring( - exceptionType.LastIndexOf( '.' ) + 1 ); - } - - static void ConvertToDecimal( string numericStr, - IFormatProvider provider ) - { - object defaultValue; - object providerValue; - - // Convert numericStr to decimal without a format provider. - try - { - defaultValue = Convert.ToDecimal( numericStr ); - } - catch( Exception ex ) - { - defaultValue = GetExceptionType( ex ); - } - - // Convert numericStr to decimal with a format provider. - try - { - providerValue = Convert.ToDecimal( numericStr, provider ); - } - catch( Exception ex ) - { - providerValue = GetExceptionType( ex ); - } - - Console.WriteLine( formatter, numericStr, defaultValue, - providerValue ); - } - - static void Main( ) - { - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo provider = new NumberFormatInfo( ); - - provider.NumberDecimalSeparator = ","; - provider.NumberGroupSeparator = "."; - provider.NumberGroupSizes = new int[ ] { 3 }; - - Console.WriteLine( - "This example of\n Convert.ToDecimal( String ) and \n" + - " Convert.ToDecimal( String, IFormatProvider ) \n" + - "generates the following output when run in the " + - "[{0}] culture.", - CultureInfo.CurrentCulture.Name ); - Console.WriteLine( "\nSeveral " + - "strings are converted to decimal values, using \n" + - "default formatting and a NumberFormatInfo object.\n"); - Console.WriteLine( formatter, "String to convert", - "Default/exception", "Provider/exception" ); - Console.WriteLine( formatter, "-----------------", - "-----------------", "------------------" ); - - // Convert strings, with and without an IFormatProvider. - ConvertToDecimal( "123456789", provider ); - ConvertToDecimal( "12345.6789", provider ); - ConvertToDecimal( "12345,6789", provider ); - ConvertToDecimal( "123,456.789", provider ); - ConvertToDecimal( "123.456,789", provider ); - ConvertToDecimal( "123,456,789.0123", provider ); - ConvertToDecimal( "123.456.789,0123", provider ); - } -} - -/* -This example of - Convert.ToDecimal( String ) and - Convert.ToDecimal( String, IFormatProvider ) -generates the following output when run in the [en-US] culture. - -Several strings are converted to decimal values, using -default formatting and a NumberFormatInfo object. - -String to convert Default/exception Provider/exception ------------------ ----------------- ------------------ -123456789 123456789 123456789 -12345.6789 12345.6789 123456789 -12345,6789 123456789 12345.6789 -123,456.789 123456.789 FormatException -123.456,789 FormatException 123456.789 -123,456,789.0123 123456789.0123 FormatException -123.456.789,0123 FormatException 123456789.0123 -*/ -// diff --git a/snippets/csharp/System/Convert/ToDouble/todouble2.cs b/snippets/csharp/System/Convert/ToDouble/todouble2.cs deleted file mode 100644 index b92d88a32ee..00000000000 --- a/snippets/csharp/System/Convert/ToDouble/todouble2.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - string[] values = { "1,5304e16", "1.5304e16", "1,034.1233", - "1,03221", "1630.34034" }; - System.Globalization.CultureInfo[] cultures = - { new System.Globalization.CultureInfo("en-US"), - new System.Globalization.CultureInfo("fr-FR"), - new System.Globalization.CultureInfo("es-ES") }; - - foreach (System.Globalization.CultureInfo culture in cultures) - { - Console.WriteLine("Conversions using {0} culture:", culture.Name); - foreach (string value in values) - { - Console.Write(" {0,-15} --> ", value); - try { - Console.WriteLine("{0}", Convert.ToDouble(value, culture)); - } - catch (FormatException) { - Console.WriteLine("Bad Format"); - } - catch (OverflowException) { - Console.WriteLine("Overflow"); - } - } - Console.WriteLine(); - } - // The example displays the following output: - // Conversions using en-US culture: - // 1,5304e16 --> 1.5304E+20 - // 1.5304e16 --> 1.5304E+16 - // 1,034.1233 --> 1034.1233 - // 1,03221 --> 103221 - // 1630.34034 --> 1630.34034 - // - // Conversions using fr-FR culture: - // 1,5304e16 --> 1.5304E+16 - // 1.5304e16 --> Bad Format - // 1,034.1233 --> Bad Format - // 1,03221 --> 1.03221 - // 1630.34034 --> Bad Format - // - // Conversions using es-ES culture: - // 1,5304e16 --> 1.5304E+16 - // 1.5304e16 --> 1.5304E+20 - // 1,034.1233 --> Bad Format - // 1,03221 --> 1.03221 - // 1630.34034 --> 163034034 - // - } -} diff --git a/snippets/csharp/System/Convert/ToDouble/tosingle.cs b/snippets/csharp/System/Convert/ToDouble/tosingle.cs deleted file mode 100644 index 16faefca6cb..00000000000 --- a/snippets/csharp/System/Convert/ToDouble/tosingle.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -// Example of the Convert.ToSingle( String ) and -// Convert.ToSingle( String, IFormatProvider ) methods. -using System; -using System.Globalization; - -class ToSingleProviderDemo -{ - static string formatter = "{0,-22}{1,-20}{2}"; - - // Get the exception type name; remove the namespace prefix. - static string GetExceptionType( Exception ex ) - { - string exceptionType = ex.GetType( ).ToString( ); - return exceptionType.Substring( - exceptionType.LastIndexOf( '.' ) + 1 ); - } - - static void ConvertToSingle( string numericStr, - IFormatProvider provider ) - { - object defaultValue; - object providerValue; - - // Convert numericStr to float without a format provider. - try - { - defaultValue = Convert.ToSingle( numericStr ); - } - catch( Exception ex ) - { - defaultValue = GetExceptionType( ex ); - } - - // Convert numericStr to float with a format provider. - try - { - providerValue = Convert.ToSingle( numericStr, provider ); - } - catch( Exception ex ) - { - providerValue = GetExceptionType( ex ); - } - - Console.WriteLine( formatter, numericStr, defaultValue, - providerValue ); - } - - static void Main( ) - { - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo provider = new NumberFormatInfo( ); - - provider.NumberDecimalSeparator = ","; - provider.NumberGroupSeparator = "."; - provider.NumberGroupSizes = new int[ ] { 3 }; - - Console.WriteLine( - "This example of\n Convert.ToSingle( String ) and \n" + - " Convert.ToSingle( String, IFormatProvider ) \n" + - "generates the following output when run in the " + - "[{0}] culture.", - CultureInfo.CurrentCulture.Name ); - Console.WriteLine( "\nSeveral " + - "strings are converted to float values, using \n" + - "default formatting and a NumberFormatInfo object.\n"); - Console.WriteLine( formatter, "String to convert", - "Default/exception", "Provider/exception" ); - Console.WriteLine( formatter, "-----------------", - "-----------------", "------------------" ); - - // Convert strings, with and without an IFormatProvider. - ConvertToSingle( "1234567", provider ); - ConvertToSingle( "1234.567", provider ); - ConvertToSingle( "1234,567", provider ); - ConvertToSingle( "12,345.67", provider ); - ConvertToSingle( "12.345,67", provider ); - ConvertToSingle( "1,234,567.89", provider ); - ConvertToSingle( "1.234.567,89", provider ); - } -} - -/* -This example of - Convert.ToSingle( String ) and - Convert.ToSingle( String, IFormatProvider ) -generates the following output when run in the [en-US] culture. - -Several strings are converted to float values, using -default formatting and a NumberFormatInfo object. - -String to convert Default/exception Provider/exception ------------------ ----------------- ------------------ -1234567 1234567 1234567 -1234.567 1234.567 1234567 -1234,567 1234567 1234.567 -12,345.67 12345.67 FormatException -12.345,67 FormatException 12345.67 -1,234,567.89 1234568 FormatException -1.234.567,89 FormatException 1234568 -*/ -// diff --git a/snippets/csharp/System/Convert/ToString/datetime.cs b/snippets/csharp/System/Convert/ToString/datetime.cs deleted file mode 100644 index a7f75926f3c..00000000000 --- a/snippets/csharp/System/Convert/ToString/datetime.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -// Example of the Convert.ToString( DateTime ) and -// Convert.ToString( DateTime, IFormatProvider ) methods. -using System; -using System.Globalization; - -class DateTimeIFormatProviderDemo -{ - static void DisplayDateNCultureName( DateTime testDate, - string cultureName ) - { - // Create the CultureInfo object for the specified culture, - // and use it as the IFormatProvider when converting the date. - CultureInfo culture = new CultureInfo( cultureName ); - string dateString = Convert.ToString( testDate, culture ); - - // Bracket the culture name, and display the name and date. - Console.WriteLine(" {0,-12}{1}", - String.Concat( "[", cultureName, "]" ), dateString ); - } - - static void Main( ) - { - // Specify the date to be formatted under various cultures. - DateTime tDate = new DateTime( 2003, 4, 15, 20, 30, 40, 333 ); - - Console.WriteLine( "This example of \n" + - " Convert.ToString( DateTime ) and \n" + - " Convert.ToString( DateTime, IFormatProvider )\n" + - "generates the following output. It creates " + - "CultureInfo objects \nfor several cultures " + - "and formats a DateTime value with each.\n" ); - - // Format the date without an IFormatProvider. - Console.WriteLine( " {0,-12}{1}", - null, "No IFormatProvider" ); - Console.WriteLine( " {0,-12}{1}", - null, "------------------" ); - Console.WriteLine( " {0,-12}{1}\n", - String.Concat( "[", CultureInfo.CurrentCulture.Name, "]" ), - Convert.ToString( tDate ) ); - - // Format the date with IFormatProvider for several cultures. - Console.WriteLine( " {0,-12}{1}", - "Culture", "With IFormatProvider" ); - Console.WriteLine( " {0,-12}{1}", - "-------", "--------------------" ); - - DisplayDateNCultureName( tDate, "" ); - DisplayDateNCultureName( tDate, "en-US" ); - DisplayDateNCultureName( tDate, "es-AR" ); - DisplayDateNCultureName( tDate, "fr-FR" ); - DisplayDateNCultureName( tDate, "hi-IN" ); - DisplayDateNCultureName( tDate, "ja-JP" ); - DisplayDateNCultureName( tDate, "nl-NL" ); - DisplayDateNCultureName( tDate, "ru-RU" ); - DisplayDateNCultureName( tDate, "ur-PK" ); - } -} - -/* -This example of - Convert.ToString( DateTime ) and - Convert.ToString( DateTime, IFormatProvider ) -generates the following output. It creates CultureInfo objects -for several cultures and formats a DateTime value with each. - - No IFormatProvider - ------------------ - [en-US] 4/15/2003 8:30:40 PM - - Culture With IFormatProvider - ------- -------------------- - [] 04/15/2003 20:30:40 - [en-US] 4/15/2003 8:30:40 PM - [es-AR] 15/04/2003 08:30:40 p.m. - [fr-FR] 15/04/2003 20:30:40 - [hi-IN] 15-04-2003 20:30:40 - [ja-JP] 2003/04/15 20:30:40 - [nl-NL] 15-4-2003 20:30:40 - [ru-RU] 15.04.2003 20:30:40 - [ur-PK] 15/04/2003 8:30:40 PM -*/ -// diff --git a/snippets/csharp/System/Convert/ToString/numeric.cs b/snippets/csharp/System/Convert/ToString/numeric.cs deleted file mode 100644 index 7351a1d97a6..00000000000 --- a/snippets/csharp/System/Convert/ToString/numeric.cs +++ /dev/null @@ -1,109 +0,0 @@ -// -// Example of the Convert.ToString( numeric types ) and -// Convert.ToString( numeric types, IFormatProvider ) methods. -using System; -using System.Globalization; - -class ConvertNumericProviderDemo -{ - static void Main( ) - { - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo provider = new NumberFormatInfo( ); - string formatter = "{0,22} {1}"; - - // These properties will affect the conversion. - provider.NegativeSign = "minus "; - provider.NumberDecimalSeparator = " point "; - - // These properties will not be applied. - provider.NumberDecimalDigits = 2; - provider.NumberGroupSeparator = "."; - provider.NumberGroupSizes = new int[ ] { 3 }; - - // Convert these values using default values and the - // format provider created above. - byte ByteA = 140; - SByte SByteA = -60; - UInt16 UInt16A = 61680; - short Int16A = -3855; - - UInt32 UInt32A = 4042322160; - int Int32A = -252645135; - UInt64 UInt64A = 8138269444283625712; - long Int64A = -1085102592571150095; - - float SingleA = -32.375F; - double DoubleA = 61680.3855; - decimal DecimA = 4042322160.252645135M; - object ObjDouble = (object)( -98765.4321 ); - - Console.WriteLine( "This example of " + - "Convert.ToString( numeric types ) and \n" + - "Convert.ToString( numeric types, IFormatProvider ) \n" + - "converts values of each of the CLR base numeric types " + - "to strings, \nusing default formatting and a " + - "NumberFormatInfo object." ); - Console.WriteLine( - "\nNote: Of the several NumberFormatInfo " + - "properties that are changed, \nonly the negative sign " + - "and decimal separator affect the conversions.\n" ); - Console.WriteLine( formatter, "Default", "Format Provider" ); - Console.WriteLine( formatter, "-------", "---------------" ); - - // Convert the values with and without a format provider. - Console.WriteLine( formatter, Convert.ToString( ByteA ), - Convert.ToString( ByteA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( SByteA ), - Convert.ToString( SByteA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( UInt16A ), - Convert.ToString( UInt16A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( Int16A ), - Convert.ToString( Int16A, provider ) ); - - Console.WriteLine( formatter, Convert.ToString( UInt32A ), - Convert.ToString( UInt32A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( Int32A ), - Convert.ToString( Int32A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( UInt64A ), - Convert.ToString( UInt64A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( Int64A ), - Convert.ToString( Int64A, provider ) ); - - Console.WriteLine( formatter, Convert.ToString( SingleA ), - Convert.ToString( SingleA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( DoubleA ), - Convert.ToString( DoubleA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( DecimA ), - Convert.ToString( DecimA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( ObjDouble ), - Convert.ToString( ObjDouble, provider ) ); - } -} - -/* -This example of Convert.ToString( numeric types ) and -Convert.ToString( numeric types, IFormatProvider ) -converts values of each of the CLR base numeric types to strings, -using default formatting and a NumberFormatInfo object. - -Note: Of the several NumberFormatInfo properties that are changed, -only the negative sign and decimal separator affect the conversions. - - Default Format Provider - ------- --------------- - 140 140 - -60 minus 60 - 61680 61680 - -3855 minus 3855 - 4042322160 4042322160 - -252645135 minus 252645135 - 8138269444283625712 8138269444283625712 - -1085102592571150095 minus 1085102592571150095 - -32.375 minus 32 point 375 - 61680.3855 61680 point 3855 - 4042322160.252645135 4042322160 point 252645135 - -98765.4321 minus 98765 point 4321 -*/ -// diff --git a/snippets/csharp/System/Convert/ToString/tostring4.cs b/snippets/csharp/System/Convert/ToString/tostring4.cs deleted file mode 100644 index 6a61d475f49..00000000000 --- a/snippets/csharp/System/Convert/ToString/tostring4.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -using System; -using System.Globalization; - -public class DummyProvider : IFormatProvider -{ - // Normally, GetFormat returns an object of the requested type - // (usually itself) if it is able; otherwise, it returns Nothing. - public object GetFormat(Type argType) - { - // Display the type of argType and return null. - Console.Write( "{0,-25}", argType.Name); - return null; - } -} - -public class Example -{ - public static void Main() - { - // Create an instance of the IFormatProvider. - IFormatProvider provider = new DummyProvider(); - - // Values to convert using DummyProvider. - int int32A = -252645135; - double doubleA = 61680.3855; - object objDouble = (object) -98765.4321; - DateTime dayTimeA = new DateTime(2009, 9, 11, 13, 45, 0); - bool boolA = true; - string stringA = "Qwerty"; - char charA = '$'; - TimeSpan tSpanA = new TimeSpan(0, 18, 0); - object objOther = provider; - - object[] objects= { int32A, doubleA, objDouble, dayTimeA, - boolA, stringA, charA, tSpanA, objOther }; - - // Call Convert.ToString(Object, provider) method for each value. - foreach (object value in objects) - Console.WriteLine("{0,-20} --> {1,20}", - value, Convert.ToString(value, provider)); - } -} -// The example displays the following output: -// NumberFormatInfo -252645135 --> -252645135 -// NumberFormatInfo 61680.3855 --> 61680.3855 -// NumberFormatInfo -98765.4321 --> -98765.4321 -// DateTimeFormatInfo 9/11/2009 1:45:00 PM --> 9/11/2009 1:45:00 PM -// True --> True -// Qwerty --> Qwerty -// $ --> $ -// 00:18:00 --> 00:18:00 -// DummyProvider --> DummyProvider -// diff --git a/snippets/csharp/System/Double/Overview/comparison1.cs b/snippets/csharp/System/Double/Overview/comparison1.cs deleted file mode 100644 index 446393419b1..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison1.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double value1 = .333333333333333; - double value2 = 1.0/3; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.333333333333333 = 0.33333333333333331: False -// diff --git a/snippets/csharp/System/Double/Overview/comparison2.cs b/snippets/csharp/System/Double/Overview/comparison2.cs deleted file mode 100644 index d3dcf9f1f4a..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double value1 = 100.10142; - value1 = Math.Sqrt(Math.Pow(value1, 2)); - double value2 = Math.Pow(value1 * 3.51, 2); - value2 = Math.Sqrt(value2) / 3.51; - Console.WriteLine("{0} = {1}: {2}\n", - value1, value2, value1.Equals(value2)); - Console.WriteLine("{0:R} = {1:R}", value1, value2); - } -} -// The example displays the following output: -// 100.10142 = 100.10142: False -// -// 100.10142 = 100.10141999999999 -// diff --git a/snippets/csharp/System/Double/Overview/comparison3.cs b/snippets/csharp/System/Double/Overview/comparison3.cs deleted file mode 100644 index 261254d1b09..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison3.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double value1 = .333333333333333; - double value2 = 1.0/3; - int precision = 7; - value1 = Math.Round(value1, precision); - value2 = Math.Round(value2, precision); - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.3333333 = 0.3333333: True -// diff --git a/snippets/csharp/System/Double/Overview/comparison4.cs b/snippets/csharp/System/Double/Overview/comparison4.cs deleted file mode 100644 index 29acc9f0921..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison4.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double one1 = .1 * 10; - double one2 = 0; - for (int ctr = 1; ctr <= 10; ctr++) - one2 += .1; - - Console.WriteLine("{0:R} = {1:R}: {2}", one1, one2, one1.Equals(one2)); - Console.WriteLine("{0:R} is approximately equal to {1:R}: {2}", - one1, one2, - IsApproximatelyEqual(one1, one2, .000000001)); - } - - static bool IsApproximatelyEqual(double value1, double value2, double epsilon) - { - // If they are equal anyway, just return True. - if (value1.Equals(value2)) - return true; - - // Handle NaN, Infinity. - if (Double.IsInfinity(value1) | Double.IsNaN(value1)) - return value1.Equals(value2); - else if (Double.IsInfinity(value2) | Double.IsNaN(value2)) - return value1.Equals(value2); - - // Handle zero to avoid division by zero - double divisor = Math.Max(value1, value2); - if (divisor.Equals(0)) - divisor = Math.Min(value1, value2); - - return Math.Abs((value1 - value2) / divisor) <= epsilon; - } -} -// The example displays the following output: -// 1 = 0.99999999999999989: False -// 1 is approximately equal to 0.99999999999999989: True -// diff --git a/snippets/csharp/System/Double/Overview/convert1.cs b/snippets/csharp/System/Double/Overview/convert1.cs deleted file mode 100644 index 88598de16e6..00000000000 --- a/snippets/csharp/System/Double/Overview/convert1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - dynamic[] values = { Byte.MinValue, Byte.MaxValue, Decimal.MinValue, - Decimal.MaxValue, Int16.MinValue, Int16.MaxValue, - Int32.MinValue, Int32.MaxValue, Int64.MinValue, - Int64.MaxValue, SByte.MinValue, SByte.MaxValue, - Single.MinValue, Single.MaxValue, UInt16.MinValue, - UInt16.MaxValue, UInt32.MinValue, UInt32.MaxValue, - UInt64.MinValue, UInt64.MaxValue }; - double dblValue; - foreach (var value in values) { - if (value.GetType() == typeof(Decimal)) - dblValue = (Double) value; - else - dblValue = value; - Console.WriteLine("{0} ({1}) --> {2:R} ({3})", - value, value.GetType().Name, - dblValue, dblValue.GetType().Name); - } - } -} -// The example displays the following output: -// 0 (Byte) --> 0 (Double) -// 255 (Byte) --> 255 (Double) -// -79228162514264337593543950335 (Decimal) --> -7.9228162514264338E+28 (Double) -// 79228162514264337593543950335 (Decimal) --> 7.9228162514264338E+28 (Double) -// -32768 (Int16) --> -32768 (Double) -// 32767 (Int16) --> 32767 (Double) -// -2147483648 (Int32) --> -2147483648 (Double) -// 2147483647 (Int32) --> 2147483647 (Double) -// -9223372036854775808 (Int64) --> -9.2233720368547758E+18 (Double) -// 9223372036854775807 (Int64) --> 9.2233720368547758E+18 (Double) -// -128 (SByte) --> -128 (Double) -// 127 (SByte) --> 127 (Double) -// -3.402823E+38 (Single) --> -3.4028234663852886E+38 (Double) -// 3.402823E+38 (Single) --> 3.4028234663852886E+38 (Double) -// 0 (UInt16) --> 0 (Double) -// 65535 (UInt16) --> 65535 (Double) -// 0 (UInt32) --> 0 (Double) -// 4294967295 (UInt32) --> 4294967295 (Double) -// 0 (UInt64) --> 0 (Double) -// 18446744073709551615 (UInt64) --> 1.8446744073709552E+19 (Double) -// diff --git a/snippets/csharp/System/Double/Overview/convert2.cs b/snippets/csharp/System/Double/Overview/convert2.cs deleted file mode 100644 index 9de1d2b7a75..00000000000 --- a/snippets/csharp/System/Double/Overview/convert2.cs +++ /dev/null @@ -1,147 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double[] values = { Double.MinValue, -67890.1234, -12345.6789, - 12345.6789, 67890.1234, Double.MaxValue, - Double.NaN, Double.PositiveInfinity, - Double.NegativeInfinity }; - checked { - foreach (var value in values) { - try { - Int64 lValue = (long) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - lValue, lValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Int64.", value); - } - try { - UInt64 ulValue = (ulong) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - ulValue, ulValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to UInt64.", value); - } - try { - Decimal dValue = (decimal) value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - dValue, dValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Decimal.", value); - } - try { - Single sValue = (float) value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - sValue, sValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Single.", value); - } - Console.WriteLine(); - } - } - } -} -// The example displays the following output for conversions performed -// in a checked context: -// Unable to convert -1.79769313486232E+308 to Int64. -// Unable to convert -1.79769313486232E+308 to UInt64. -// Unable to convert -1.79769313486232E+308 to Decimal. -// -1.79769313486232E+308 (Double) --> -Infinity (Single) -// -// -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// Unable to convert -67890.1234 to UInt64. -// -67890.1234 (Double) --> -67890.1234 (Decimal) -// -67890.1234 (Double) --> -67890.13 (Single) -// -// -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// Unable to convert -12345.6789 to UInt64. -// -12345.6789 (Double) --> -12345.6789 (Decimal) -// -12345.6789 (Double) --> -12345.68 (Single) -// -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64) -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64) -// 12345.6789 (Double) --> 12345.6789 (Decimal) -// 12345.6789 (Double) --> 12345.68 (Single) -// -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64) -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64) -// 67890.1234 (Double) --> 67890.1234 (Decimal) -// 67890.1234 (Double) --> 67890.13 (Single) -// -// Unable to convert 1.79769313486232E+308 to Int64. -// Unable to convert 1.79769313486232E+308 to UInt64. -// Unable to convert 1.79769313486232E+308 to Decimal. -// 1.79769313486232E+308 (Double) --> Infinity (Single) -// -// Unable to convert NaN to Int64. -// Unable to convert NaN to UInt64. -// Unable to convert NaN to Decimal. -// NaN (Double) --> NaN (Single) -// -// Unable to convert Infinity to Int64. -// Unable to convert Infinity to UInt64. -// Unable to convert Infinity to Decimal. -// Infinity (Double) --> Infinity (Single) -// -// Unable to convert -Infinity to Int64. -// Unable to convert -Infinity to UInt64. -// Unable to convert -Infinity to Decimal. -// -Infinity (Double) --> -Infinity (Single) -// The example displays the following output for conversions performed -// in an unchecked context: -// -1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -1.79769313486232E+308 (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -1.79769313486232E+308 to Decimal. -// -1.79769313486232E+308 (Double) --> -Infinity (Single) -// -// -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// -67890.1234 (Double) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64) -// -67890.1234 (Double) --> -67890.1234 (Decimal) -// -67890.1234 (Double) --> -67890.13 (Single) -// -// -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// -12345.6789 (Double) --> 18446744073709539271 (0xFFFFFFFFFFFFCFC7) (UInt64) -// -12345.6789 (Double) --> -12345.6789 (Decimal) -// -12345.6789 (Double) --> -12345.68 (Single) -// -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64) -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64) -// 12345.6789 (Double) --> 12345.6789 (Decimal) -// 12345.6789 (Double) --> 12345.68 (Single) -// -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64) -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64) -// 67890.1234 (Double) --> 67890.1234 (Decimal) -// 67890.1234 (Double) --> 67890.13 (Single) -// -// 1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// 1.79769313486232E+308 (Double) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert 1.79769313486232E+308 to Decimal. -// 1.79769313486232E+308 (Double) --> Infinity (Single) -// -// NaN (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// NaN (Double) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert NaN to Decimal. -// NaN (Double) --> NaN (Single) -// -// Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// Infinity (Double) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert Infinity to Decimal. -// Infinity (Double) --> Infinity (Single) -// -// -Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -Infinity (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -Infinity to Decimal. -// -Infinity (Double) --> -Infinity (Single) -// diff --git a/snippets/csharp/System/Double/Overview/exceptional1.cs b/snippets/csharp/System/Double/Overview/exceptional1.cs deleted file mode 100644 index 6ea7b2cc4ab..00000000000 --- a/snippets/csharp/System/Double/Overview/exceptional1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 1.1632875981534209e-225; - Double value2 = 9.1642346778e-175; - Double result = value1 * value2; - Console.WriteLine("{0} * {1} = {2}", value1, value2, result); - Console.WriteLine("{0} = 0: {1}", result, result.Equals(0.0)); - } -} -// The example displays the following output: -// 1.16328759815342E-225 * 9.1642346778E-175 = 0 -// 0 = 0: True -// diff --git a/snippets/csharp/System/Double/Overview/exceptional2.cs b/snippets/csharp/System/Double/Overview/exceptional2.cs deleted file mode 100644 index 42688e53e38..00000000000 --- a/snippets/csharp/System/Double/Overview/exceptional2.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 4.565e153; - Double value2 = 6.9375e172; - Double result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Double.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}\n", - Double.IsNegativeInfinity(result)); - - value1 = -value1; - result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Double.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}", - Double.IsNegativeInfinity(result)); - } -} - -// The example displays the following output: -// PositiveInfinity: True -// NegativeInfinity: False -// -// PositiveInfinity: False -// NegativeInfinity: True -// diff --git a/snippets/csharp/System/Double/Overview/precision1.cs b/snippets/csharp/System/Double/Overview/precision1.cs deleted file mode 100644 index dbad4e74f8b..00000000000 --- a/snippets/csharp/System/Double/Overview/precision1.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - double value = -4.42330604244772E-305; - - double fromLiteral = -4.42330604244772E-305; - double fromVariable = value; - double fromParse = Double.Parse("-4.42330604244772E-305"); - - Console.WriteLine("Double value from literal: {0,29:R}", fromLiteral); - Console.WriteLine("Double value from variable: {0,28:R}", fromVariable); - Console.WriteLine("Double value from Parse method: {0,24:R}", fromParse); - // On 32-bit versions of the .NET Framework, the output is: - // Double value from literal: -4.42330604244772E-305 - // Double value from variable: -4.42330604244772E-305 - // Double value from Parse method: -4.42330604244772E-305 - // - // On other versions of the .NET Framework, the output is: - // Double value from literal: -4.4233060424477198E-305 - // Double value from variable: -4.4233060424477198E-305 - // Double value from Parse method: -4.42330604244772E-305 - // - } -} diff --git a/snippets/csharp/System/Double/Overview/precisionlist1.cs b/snippets/csharp/System/Double/Overview/precisionlist1.cs deleted file mode 100644 index f044ef1880d..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist1.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 1/3.0; - Single sValue2 = 1/3.0f; - Double value2 = (Double) sValue2; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, - value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.33333333333333331 = 0.3333333432674408: False -// diff --git a/snippets/csharp/System/Double/Overview/precisionlist3.cs b/snippets/csharp/System/Double/Overview/precisionlist3.cs deleted file mode 100644 index 9622e3303ff..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist3.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double[] values = { 10.0, 2.88, 2.88, 2.88, 9.0 }; - Double result = 27.64; - Double total = 0; - foreach (var value in values) - total += value; - - if (total.Equals(result)) - Console.WriteLine("The sum of the values equals the total."); - else - Console.WriteLine("The sum of the values ({0}) does not equal the total ({1}).", - total, result); - } -} -// The example displays the following output: -// The sum of the values (36.64) does not equal the total (36.64). -// -// If the index items in the Console.WriteLine statement are changed to {0:R}, -// the example displays the following output: -// The sum of the values (27.639999999999997) does not equal the total (27.64). -// diff --git a/snippets/csharp/System/Double/Overview/precisionlist4.cs b/snippets/csharp/System/Double/Overview/precisionlist4.cs deleted file mode 100644 index b6e51a45d79..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist4.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Doubles.dat"); - Double[] values = { 2.2/1.01, 1.0/3, Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - Double[] restoredValues = new Double[values.Length]; - StreamReader sr = new StreamReader(@".\Doubles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Double.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.17821782178218 <> 2.17821782178218 -// 0.333333333333333 <> 0.333333333333333 -// 3.14159265358979 <> 3.14159265358979 -// diff --git a/snippets/csharp/System/Double/Overview/precisionlist5.cs b/snippets/csharp/System/Double/Overview/precisionlist5.cs deleted file mode 100644 index 7b163065a4b..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist5.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Doubles.dat"); - Double[] values = { 2.2/1.01, 1.0/3, Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - sw.Write("{0:G17}{1}", values[ctr], ctr < values.Length - 1 ? "|" : "" ); - - sw.Close(); - - Double[] restoredValues = new Double[values.Length]; - StreamReader sr = new StreamReader(@".\Doubles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Double.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.17821782178218 = 2.17821782178218 -// 0.333333333333333 = 0.333333333333333 -// 3.14159265358979 = 3.14159265358979 -// diff --git a/snippets/csharp/System/Double/Overview/representation1.cs b/snippets/csharp/System/Double/Overview/representation1.cs deleted file mode 100644 index d82052b7672..00000000000 --- a/snippets/csharp/System/Double/Overview/representation1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value = .1; - Double result1 = value * 10; - Double result2 = 0; - for (int ctr = 1; ctr <= 10; ctr++) - result2 += value; - - Console.WriteLine(".1 * 10: {0:R}", result1); - Console.WriteLine(".1 Added 10 times: {0:R}", result2); - } -} -// The example displays the following output: -// .1 * 10: 1 -// .1 Added 10 times: 0.99999999999999989 -// diff --git a/snippets/csharp/System/Double/Overview/representation2.cs b/snippets/csharp/System/Double/Overview/representation2.cs deleted file mode 100644 index 8d3c74765fd..00000000000 --- a/snippets/csharp/System/Double/Overview/representation2.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value = 123456789012.34567; - Double additional = Double.Epsilon * 1e15; - Console.WriteLine("{0} + {1} = {2}", value, additional, - value + additional); - } -} -// The example displays the following output: -// 123456789012.346 + 4.94065645841247E-309 = 123456789012.346 -// diff --git a/snippets/csharp/System/Enum/Overview/EnumMain.cs b/snippets/csharp/System/Enum/Overview/EnumMain.cs deleted file mode 100644 index 2dcab459ead..00000000000 --- a/snippets/csharp/System/Enum/Overview/EnumMain.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class EnumTest { - enum Days { Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday }; - enum BoilingPoints { Celsius = 100, Fahrenheit = 212 }; - [Flags] - enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 }; - - public static void Main() { - - Type weekdays = typeof(Days); - Type boiling = typeof(BoilingPoints); - - Console.WriteLine("The days of the week, and their corresponding values in the Days Enum are:"); - - foreach ( string s in Enum.GetNames(weekdays) ) - Console.WriteLine( "{0,-11}= {1}", s, Enum.Format( weekdays, Enum.Parse(weekdays, s), "d")); - - Console.WriteLine(); - Console.WriteLine("Enums can also be created which have values that represent some meaningful amount."); - Console.WriteLine("The BoilingPoints Enum defines the following items, and corresponding values:"); - - foreach ( string s in Enum.GetNames(boiling) ) - Console.WriteLine( "{0,-11}= {1}", s, Enum.Format(boiling, Enum.Parse(boiling, s), "d")); - - Colors myColors = Colors.Red | Colors.Blue | Colors.Yellow; - Console.WriteLine(); - Console.WriteLine("myColors holds a combination of colors. Namely: {0}", myColors); - } -} -// diff --git a/snippets/csharp/System/Enum/Overview/Extensions.cs b/snippets/csharp/System/Enum/Overview/Extensions.cs deleted file mode 100644 index fd791c08047..00000000000 --- a/snippets/csharp/System/Enum/Overview/Extensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -using System; - -// Define an enumeration to represent student grades. -public enum Grades { F = 0, D = 1, C = 2, B = 3, A = 4 }; - -// Define an extension method for the Grades enumeration. -public static class Extensions -{ - public static Grades minPassing = Grades.D; - - public static bool Passing(this Grades grade) - { - return grade >= minPassing; - } -} - -class Example -{ - static void Main() - { - Grades g1 = Grades.D; - Grades g2 = Grades.F; - Console.WriteLine("{0} {1} a passing grade.", g1, g1.Passing() ? "is" : "is not"); - Console.WriteLine("{0} {1} a passing grade.", g2, g2.Passing() ? "is" : "is not"); - - Extensions.minPassing = Grades.C; - Console.WriteLine("\nRaising the bar!\n"); - Console.WriteLine("{0} {1} a passing grade.", g1, g1.Passing() ? "is" : "is not"); - Console.WriteLine("{0} {1} a passing grade.", g2, g2.Passing() ? "is" : "is not"); - } -} -// The exmaple displays the following output: -// D is a passing grade. -// F is not a passing grade. -// -// Raising the bar! -// -// D is not a passing grade. -// F is not a passing grade. -// diff --git a/snippets/csharp/System/Enum/Overview/class1.cs b/snippets/csharp/System/Enum/Overview/class1.cs deleted file mode 100644 index a1c20d4f747..00000000000 --- a/snippets/csharp/System/Enum/Overview/class1.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -// -public enum ArrivalStatus { Late=-1, OnTime=0, Early=1 }; -// - -// -public class Example -{ - public static void Main() - { - ArrivalStatus status = ArrivalStatus.OnTime; - Console.WriteLine("Arrival Status: {0} ({0:D})", status); - } -} -// The example displays the following output: -// Arrival Status: OnTime (0) -// diff --git a/snippets/csharp/System/Enum/Overview/class2.cs b/snippets/csharp/System/Enum/Overview/class2.cs deleted file mode 100644 index 68e1a2a0d7a..00000000000 --- a/snippets/csharp/System/Enum/Overview/class2.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -public enum ArrivalStatus { Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - ArrivalStatus status1 = new ArrivalStatus(); - Console.WriteLine("Arrival Status: {0} ({0:D})", status1); - // The example displays the following output: - // Arrival Status: OnTime (0) - // - - // - ArrivalStatus status2 = (ArrivalStatus) 1; - Console.WriteLine("Arrival Status: {0} ({0:D})", status2); - // The example displays the following output: - // Arrival Status: Early (1) - // - - // - int value3 = 2; - ArrivalStatus status3 = (ArrivalStatus) value3; - - int value4 = (int) status3; - // - - // - int number = -1; - ArrivalStatus arrived = (ArrivalStatus) ArrivalStatus.ToObject(typeof(ArrivalStatus), number); - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classbitwise1.cs b/snippets/csharp/System/Enum/Overview/classbitwise1.cs deleted file mode 100644 index 8c0e53712a1..00000000000 --- a/snippets/csharp/System/Enum/Overview/classbitwise1.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; - -// -[Flags] public enum Pets { None=0, Dog=1, Cat=2, Bird=4, Rodent=8, - Reptile=16, Other=32 }; - -// - -public class Example -{ - public static void Main() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - Console.WriteLine("Pets: {0:G} ({0:D})", familyPets); - // The example displays the following output: - // Pets: Dog, Cat (3) - // - - ShowHasFlag(); - ShowIfSet(); - TestForNone(); - } - - private static void ShowHasFlag() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - if (familyPets.HasFlag(Pets.Dog)) - Console.WriteLine("The family has a dog."); - // The example displays the following output: - // The family has a dog. - // - } - - private static void ShowIfSet() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - if ((familyPets & Pets.Dog) == Pets.Dog) - Console.WriteLine("The family has a dog."); - // The example displays the following output: - // The family has a dog. - // - } - - private static void TestForNone() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - if (familyPets == Pets.None) - Console.WriteLine("The family has no pets."); - else - Console.WriteLine("The family has pets."); - // The example displays the following output: - // The family has pets. - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classconversion1.cs b/snippets/csharp/System/Enum/Overview/classconversion1.cs deleted file mode 100644 index 93b36e689e0..00000000000 --- a/snippets/csharp/System/Enum/Overview/classconversion1.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - int[] values = { -3, -1, 0, 1, 5, Int32.MaxValue }; - foreach (var value in values) - { - ArrivalStatus status; - if (Enum.IsDefined(typeof(ArrivalStatus), value)) - status = (ArrivalStatus) value; - else - status = ArrivalStatus.Unknown; - Console.WriteLine("Converted {0:N0} to {1}", value, status); - } - } -} -// The example displays the following output: -// Converted -3 to Unknown -// Converted -1 to Late -// Converted 0 to OnTime -// Converted 1 to Early -// Converted 5 to Unknown -// Converted 2,147,483,647 to Unknown -// diff --git a/snippets/csharp/System/Enum/Overview/classconversion2.cs b/snippets/csharp/System/Enum/Overview/classconversion2.cs deleted file mode 100644 index c80716a2f68..00000000000 --- a/snippets/csharp/System/Enum/Overview/classconversion2.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - ArrivalStatus status = ArrivalStatus.Early; - var number = Convert.ChangeType(status, Enum.GetUnderlyingType(typeof(ArrivalStatus))); - Console.WriteLine("Converted {0} to {1}", status, number); - // The example displays the following output: - // Converted Early to 1 - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classformat1.cs b/snippets/csharp/System/Enum/Overview/classformat1.cs deleted file mode 100644 index 7ed0f38cd3f..00000000000 --- a/snippets/csharp/System/Enum/Overview/classformat1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - string[] formats= { "G", "F", "D", "X"}; - ArrivalStatus status = ArrivalStatus.Late; - foreach (var fmt in formats) - Console.WriteLine(status.ToString(fmt)); - - // The example displays the following output: - // Late - // Late - // -1 - // FFFFFFFF - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classiterate.cs b/snippets/csharp/System/Enum/Overview/classiterate.cs deleted file mode 100644 index 879059e1fc5..00000000000 --- a/snippets/csharp/System/Enum/Overview/classiterate.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - GetEnumByName(); - Console.WriteLine("-----"); - GetEnumByValue(); - } - - private static void GetEnumByName() - { - // - string[] names = Enum.GetNames(typeof(ArrivalStatus)); - Console.WriteLine("Members of {0}:", typeof(ArrivalStatus).Name); - Array.Sort(names); - foreach (var name in names) { - ArrivalStatus status = (ArrivalStatus) Enum.Parse(typeof(ArrivalStatus), name); - Console.WriteLine(" {0} ({0:D})", status); - } - // The example displays the following output: - // Members of ArrivalStatus: - // Early (1) - // Late (-1) - // OnTime (0) - // Unknown (-3) - // - } - - private static void GetEnumByValue() - { - // - var values = Enum.GetValues(typeof(ArrivalStatus)); - Console.WriteLine("Members of {0}:", typeof(ArrivalStatus).Name); - foreach (ArrivalStatus status in values) { - Console.WriteLine(" {0} ({0:D})", status); - } - // The example displays the following output: - // Members of ArrivalStatus: - // OnTime (0) - // Early (1) - // Unknown (-3) - // Late (-1) - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classparse1.cs b/snippets/csharp/System/Enum/Overview/classparse1.cs deleted file mode 100644 index 1606b53aa30..00000000000 --- a/snippets/csharp/System/Enum/Overview/classparse1.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - string number = "-1"; - string name = "Early"; - - try { - ArrivalStatus status1 = (ArrivalStatus) Enum.Parse(typeof(ArrivalStatus), number); - if (!(Enum.IsDefined(typeof(ArrivalStatus), status1))) - status1 = ArrivalStatus.Unknown; - Console.WriteLine("Converted '{0}' to {1}", number, status1); - } - catch (FormatException) { - Console.WriteLine("Unable to convert '{0}' to an ArrivalStatus value.", - number); - } - - ArrivalStatus status2; - if (Enum.TryParse(name, out status2)) { - if (!(Enum.IsDefined(typeof(ArrivalStatus), status2))) - status2 = ArrivalStatus.Unknown; - Console.WriteLine("Converted '{0}' to {1}", name, status2); - } - else { - Console.WriteLine("Unable to convert '{0}' to an ArrivalStatus value.", - number); - } - // The example displays the following output: - // Converted '-1' to Late - // Converted 'Early' to Early - // - } -} diff --git a/snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs b/snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs deleted file mode 100644 index fe362cb59a0..00000000000 --- a/snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - String envName = "AppDomain"; - String envValue = "True"; - - // Determine whether the environment variable exists. - if (Environment.GetEnvironmentVariable(envName) == null) - // If it doesn't exist, create it. - Environment.SetEnvironmentVariable(envName, envValue); - - bool createAppDomain; - Message msg; - if (Boolean.TryParse(Environment.GetEnvironmentVariable(envName), - out createAppDomain) && createAppDomain) { - AppDomain domain = AppDomain.CreateDomain("Domain2"); - msg = (Message) domain.CreateInstanceAndUnwrap(typeof(Example).Assembly.FullName, - "Message"); - msg.Display(); - } - else { - msg = new Message(); - msg.Display(); - } - } -} - -public class Message : MarshalByRefObject -{ - public void Display() - { - Console.WriteLine("Executing in domain {0}", - AppDomain.CurrentDomain.FriendlyName); - } -} -// diff --git a/snippets/csharp/System/FormatException/Overview/FormatExample1.cs b/snippets/csharp/System/FormatException/Overview/FormatExample1.cs deleted file mode 100644 index 5cffb77eff2..00000000000 --- a/snippets/csharp/System/FormatException/Overview/FormatExample1.cs +++ /dev/null @@ -1,108 +0,0 @@ -// -// This code example demonstrates the String.Format() method. -// Formatting for this example uses the "en-US" culture. - -using System; -using System.Globalization; - -class Sample -{ - enum Color {Yellow = 1, Blue, Green}; - static DateTime thisDate = DateTime.Now; - - public static void Main() - { -// Store the output of the String.Format method in a string. - string s = ""; - - Console.Clear(); - -// Format a negative integer or floating-point number in various ways. - Console.WriteLine("Standard Numeric Format Specifiers"); - s = String.Format(CultureInfo.InvariantCulture, - "(C) Currency: . . . . . . . . {0:C}\n" + - "(D) Decimal:. . . . . . . . . {0:D}\n" + - "(E) Scientific: . . . . . . . {1:E}\n" + - "(F) Fixed point:. . . . . . . {1:F}\n" + - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(N) Number: . . . . . . . . . {0:N}\n" + - "(P) Percent:. . . . . . . . . {1:P}\n" + - "(R) Round-trip: . . . . . . . {1:R}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - -123, -123.45f); - Console.WriteLine(s); - -// Format the current date in various ways. - Console.WriteLine("Standard DateTime Format Specifiers"); - s = String.Format(CultureInfo.InvariantCulture.DateTimeFormat, - "(d) Short date: . . . . . . . {0:d}\n" + - "(D) Long date:. . . . . . . . {0:D}\n" + - "(t) Short time: . . . . . . . {0:t}\n" + - "(T) Long time:. . . . . . . . {0:T}\n" + - "(f) Full date/short time: . . {0:f}\n" + - "(F) Full date/long time:. . . {0:F}\n" + - "(g) General date/short time:. {0:g}\n" + - "(G) General date/long time: . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(M) Month:. . . . . . . . . . {0:M}\n" + - "(R) RFC1123:. . . . . . . . . {0:R}\n" + - "(s) Sortable: . . . . . . . . {0:s}\n" + - "(u) Universal sortable: . . . {0:u} (invariant)\n" + - "(U) Universal full: . . . . . {0:U}\n" + - "(Y) Year: . . . . . . . . . . {0:Y}\n", - thisDate); - Console.WriteLine(s); - -// Format a Color enumeration value in various ways. - Console.WriteLine("Standard Enumeration Format Specifiers"); - s = String.Format(CultureInfo.InvariantCulture, - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" + - "(D) Decimal number: . . . . . {0:D}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - Color.Green); - Console.WriteLine(s); - } -} -/* -This example displays the following output to the console: - -Standard Numeric Format Specifiers -(C) Currency: . . . . . . . . (¤123.00) -(D) Decimal:. . . . . . . . . -123 -(E) Scientific: . . . . . . . -1.234500E+002 -(F) Fixed point:. . . . . . . -123.45 -(G) General:. . . . . . . . . -123 - (default):. . . . . . . . -123 (default = 'G') -(N) Number: . . . . . . . . . -123.00 -(P) Percent:. . . . . . . . . -12,345.00 % -(R) Round-trip: . . . . . . . -123.45 -(X) Hexadecimal:. . . . . . . FFFFFF85 - -Standard DateTime Format Specifiers -(d) Short date: . . . . . . . 07/09/2007 -(D) Long date:. . . . . . . . Monday, 09 July 2007 -(t) Short time: . . . . . . . 13:48 -(T) Long time:. . . . . . . . 13:48:05 -(f) Full date/short time: . . Monday, 09 July 2007 13:48 -(F) Full date/long time:. . . Monday, 09 July 2007 13:48:05 -(g) General date/short time:. 07/09/2007 13:48 -(G) General date/long time: . 07/09/2007 13:48:05 - (default):. . . . . . . . 07/09/2007 13:48:05 (default = 'G') -(M) Month:. . . . . . . . . . July 09 -(R) RFC1123:. . . . . . . . . Mon, 09 Jul 2007 13:48:05 GMT -(s) Sortable: . . . . . . . . 2007-07-09T13:48:05 -(u) Universal sortable: . . . 2007-07-09 13:48:05Z (invariant) -(U) Universal full: . . . . . Monday, 09 July 2007 20:48:05 -(Y) Year: . . . . . . . . . . 2007 July - -Standard Enumeration Format Specifiers -(G) General:. . . . . . . . . Green - (default):. . . . . . . . Green (default = 'G') -(F) Flags:. . . . . . . . . . Green (flags or integer) -(D) Decimal number: . . . . . 3 -(X) Hexadecimal:. . . . . . . 00000003 -*/ -// diff --git a/snippets/csharp/System/FormatException/Overview/formatexample3.cs b/snippets/csharp/System/FormatException/Overview/formatexample3.cs deleted file mode 100644 index b5b9f2ce03a..00000000000 --- a/snippets/csharp/System/FormatException/Overview/formatexample3.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -using System; - -public enum Color {Yellow = 1, Blue, Green}; - -class Example -{ - static DateTime thisDate = new DateTime(2009, 6, 30, 19, 14, 0); - - public static void Main() - { - // Store the output of the String.Format method in a string. - string s = ""; - - // Format a negative integer or floating-point number in various ways. - Console.WriteLine("Standard Numeric Format Strings"); - s = String.Format( - "(C) Currency: . . . . . . . . {0:C}\n" + - "(D) Decimal:. . . . . . . . . {0:D}\n" + - "(E) Scientific: . . . . . . . {1:E}\n" + - "(F) Fixed point:. . . . . . . {1:F}\n" + - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(N) Number: . . . . . . . . . {0:N}\n" + - "(P) Percent:. . . . . . . . . {2:P}\n" + - "(R) Round-trip: . . . . . . . {3:R}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - -123, -123.45, -.126, -1.5322980781265591); - Console.WriteLine(s); - - // Format a date in various ways. - Console.WriteLine("Standard Date and Time Format Strings"); - s = String.Format( - "(d) Short date: . . . . . . . {0:d}\n" + - "(D) Long date:. . . . . . . . {0:D}\n" + - "(t) Short time: . . . . . . . {0:t}\n" + - "(T) Long time:. . . . . . . . {0:T}\n" + - "(f) Full date/short time: . . {0:f}\n" + - "(F) Full date/long time:. . . {0:F}\n" + - "(g) General date/short time:. {0:g}\n" + - "(G) General date/long time: . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(M) Month:. . . . . . . . . . {0:M}\n" + - "(R) RFC1123:. . . . . . . . . {0:R}\n" + - "(s) Sortable: . . . . . . . . {0:s}\n" + - "(u) Universal sortable: . . . {0:u} (invariant)\n" + - "(U) Universal full: . . . . . {0:U}\n" + - "(Y) Year: . . . . . . . . . . {0:Y}\n", - thisDate); - Console.WriteLine(s); - - // Format an enumeration value in various ways. - Console.WriteLine("Standard Enumeration Format Specifiers"); - s = String.Format( - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(F) Flags:. . . . . . . . . . {1:F}\n" + - "(D) Decimal number: . . . . . {0:D}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - Color.Green, AttributeTargets.Class | AttributeTargets.Struct); - Console.WriteLine(s); - } -} -// The example displays the following output: -// Standard Numeric Format Specifiers -// (C) Currency: . . . . . . . . (¤123.00) -// (D) Decimal:. . . . . . . . . -123 -// (E) Scientific: . . . . . . . -1.234500E+002 -// (F) Fixed point:. . . . . . . -123.45 -// (G) General:. . . . . . . . . -123 -// (default):. . . . . . . . -123 (default = 'G') -// (N) Number: . . . . . . . . . -123.00 -// (P) Percent:. . . . . . . . . -12,345.00 % -// (R) Round-trip: . . . . . . . -123.45 -// (X) Hexadecimal:. . . . . . . FFFFFF85 -// -// Standard DateTime Format Specifiers -// (d) Short date: . . . . . . . 07/09/2007 -// (D) Long date:. . . . . . . . Monday, 09 July 2007 -// (t) Short time: . . . . . . . 13:48 -// (T) Long time:. . . . . . . . 13:48:05 -// (f) Full date/short time: . . Monday, 09 July 2007 13:48 -// (F) Full date/long time:. . . Monday, 09 July 2007 13:48:05 -// (g) General date/short time:. 07/09/2007 13:48 -// (G) General date/long time: . 07/09/2007 13:48:05 -// (default):. . . . . . . . 07/09/2007 13:48:05 (default = 'G') -// (M) Month:. . . . . . . . . . July 09 -// (R) RFC1123:. . . . . . . . . Mon, 09 Jul 2007 13:48:05 GMT -// (s) Sortable: . . . . . . . . 2007-07-09T13:48:05 -// (u) Universal sortable: . . . 2007-07-09 13:48:05Z (invariant) -// (U) Universal full: . . . . . Monday, 09 July 2007 20:48:05 -// (Y) Year: . . . . . . . . . . 2007 July -// -// Standard Enumeration Format Specifiers -// (G) General:. . . . . . . . . Green -// (default):. . . . . . . . Green (default = 'G') -// (F) Flags:. . . . . . . . . . Green (flags or integer) -// (D) Decimal number: . . . . . 3 -// (X) Hexadecimal:. . . . . . . 00000003 -// diff --git a/snippets/csharp/System/FormattableString/Format/Escaping1.cs b/snippets/csharp/System/FormattableString/Format/Escaping1.cs deleted file mode 100644 index b962b8f4f24..00000000000 --- a/snippets/csharp/System/FormattableString/Format/Escaping1.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -public class Class1 -{ - public static void Main() - { - // - int value = 6324; - string output = string.Format("{0}{1:D}{2}", - "{", value, "}"); - Console.WriteLine(output); - // The example displays the following output: - // {6324} - // - } -} diff --git a/snippets/csharp/System/FormattableString/Format/alignment1.cs b/snippets/csharp/System/FormattableString/Format/alignment1.cs deleted file mode 100644 index 9ecf2abd9e2..00000000000 --- a/snippets/csharp/System/FormattableString/Format/alignment1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string[] names = { "Adam", "Bridgette", "Carla", "Daniel", - "Ebenezer", "Francine", "George" }; - decimal[] hours = { 40, 6.667m, 40.39m, 82, 40.333m, 80, - 16.75m }; - - Console.WriteLine("{0,-20} {1,5}\n", "Name", "Hours"); - for (int ctr = 0; ctr < names.Length; ctr++) - Console.WriteLine("{0,-20} {1,5:N1}", names[ctr], hours[ctr]); - } -} -// The example displays the following output: -// Name Hours -// -// Adam 40.0 -// Bridgette 6.7 -// Carla 40.4 -// Daniel 82.0 -// Ebenezer 40.3 -// Francine 80.0 -// George 16.8 -// diff --git a/snippets/csharp/System/FormattableString/Format/index1.cs b/snippets/csharp/System/FormattableString/Format/index1.cs deleted file mode 100644 index 81c398acfa1..00000000000 --- a/snippets/csharp/System/FormattableString/Format/index1.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - string primes; - primes = String.Format("Prime numbers less than 10: {0}, {1}, {2}, {3}", - 2, 3, 5, 7 ); - Console.WriteLine(primes); - // The example displays the following output: - // Prime numbers less than 10: 2, 3, 5, 7 - // - Console.WriteLine(); - - // - string multiple = String.Format("0x{0:X} {0:E} {0:N}", - Int64.MaxValue); - Console.WriteLine(multiple); - // The example displays the following output: - // 0x7FFFFFFFFFFFFFFF 9.223372E+018 9,223,372,036,854,775,807.00 - // - Console.WriteLine(); - } -} diff --git a/snippets/csharp/System/Guid/Parse/program.cs b/snippets/csharp/System/Guid/Parse/program.cs deleted file mode 100644 index d593707cef5..00000000000 --- a/snippets/csharp/System/Guid/Parse/program.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace guids -{ - class Program - { - // - static void Main(string[] args) - { - Guid GStart = Guid.NewGuid(); - string guidB = GStart.ToString("B"); - - Guid GCurrent = Guid.Parse(guidB); - string guidX = GCurrent.ToString("X"); - - if (Guid.TryParse(guidX, out GCurrent)) - Console.WriteLine(GCurrent.ToString("X")); - else - Console.WriteLine("Last parse operation unsuccessful."); - - if (Guid.TryParseExact(guidX, "X", out GCurrent)) - Console.WriteLine(GCurrent.ToString("X")); - else - Console.WriteLine("Last parse operation unsuccessful."); - } - // - } -} diff --git a/snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs b/snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs deleted file mode 100644 index 82e4dbb60ac..00000000000 --- a/snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Threading; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class AsyncMain - { - public static void Main() - { - // The asynchronous method puts the thread id here. - int threadId; - - // Create an instance of the test class. - AsyncDemo ad = new AsyncDemo(); - - // Create the delegate. - AsyncMethodCaller caller = new AsyncMethodCaller(ad.TestMethod); - - // Initiate the asychronous call. - IAsyncResult result = caller.BeginInvoke(3000, - out threadId, null, null); - - Thread.Sleep(0); - Console.WriteLine("Main thread {0} does some work.", - Thread.CurrentThread.ManagedThreadId); - - // Call EndInvoke to wait for the asynchronous call to complete, - // and to retrieve the results. - string returnValue = caller.EndInvoke(out threadId, result); - - Console.WriteLine("The call executed on thread {0}, with return value \"{1}\".", - threadId, returnValue); - } - } -} - -/* This example produces output similar to the following: - -Main thread 1 does some work. -Test method begins. -The call executed on thread 3, with return value "My call time was 3000.". - */ -// diff --git a/snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs b/snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs deleted file mode 100644 index 0ea31faa82d..00000000000 --- a/snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string[] maleNames= { "Adam", "Bartholomew", "Charles", "David", - "Earl", "Robert", "Stanley", "Wilberforce" }; - string[] selected= Array.FindAll(maleNames, name => { - string fLetter = name.Substring(0, 1); - return fLetter.CompareTo("F") >= 0 && - fLetter.CompareTo("M") <= 0; - } ); - for (int ctr = 0; ctr < selected.Length; ctr++) - Console.WriteLine(selected[ctr]); - } -} -// The example displays the following output: -// Unhandled Exception: -// System.IndexOutOfRangeException: -// Index was outside the bounds of the array. -// at Example.Main() -// diff --git a/snippets/csharp/System/Int32/Overview/Formatting1.cs b/snippets/csharp/System/Int32/Overview/Formatting1.cs deleted file mode 100644 index 28a3494a1ad..00000000000 --- a/snippets/csharp/System/Int32/Overview/Formatting1.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CallToString(); - Console.WriteLine("-----"); - CallConvert(); - } - - private static void CallToString() - { - // - int[] numbers = { -1403, 0, 169, 1483104 }; - foreach (int number in numbers) { - // Display value using default formatting. - Console.Write("{0,-8} --> ", number.ToString()); - // Display value with 3 digits and leading zeros. - Console.Write("{0,11:D3}", number); - // Display value with 1 decimal digit. - Console.Write("{0,13:N1}", number); - // Display value as hexadecimal. - Console.Write("{0,12:X2}", number); - // Display value with eight hexadecimal digits. - Console.WriteLine("{0,14:X8}", number); - } - // The example displays the following output: - // -1403 --> -1403 -1,403.0 FFFFFA85 FFFFFA85 - // 0 --> 000 0.0 00 00000000 - // 169 --> 169 169.0 A9 000000A9 - // 1483104 --> 1483104 1,483,104.0 16A160 0016A160 - // - } - - private static void CallConvert() - { - // - int[] numbers = { -146, 11043, 2781913 }; - Console.WriteLine("{0,8} {1,32} {2,11} {3,10}", - "Value", "Binary", "Octal", "Hex"); - foreach (int number in numbers) { - Console.WriteLine("{0,8} {1,32} {2,11} {3,10}", - number, Convert.ToString(number, 2), - Convert.ToString(number, 8), - Convert.ToString(number, 16)); - } - // The example displays the following output: - // Value Binary Octal Hex - // -146 11111111111111111111111101101110 37777777556 ffffff6e - // 11043 10101100100011 25443 2b23 - // 2781913 1010100111001011011001 12471331 2a72d9 - // - } -} diff --git a/snippets/csharp/System/Int32/Overview/Instantiate1.cs b/snippets/csharp/System/Int32/Overview/Instantiate1.cs deleted file mode 100644 index ea5f8c1b84b..00000000000 --- a/snippets/csharp/System/Int32/Overview/Instantiate1.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - InstantiateByAssignment(); - Console.WriteLine("----"); - InstantiateByNarrowingConversion(); - Console.WriteLine("----"); - Parse(); - Console.WriteLine("----"); - InstantiateByWideningConversion(); - } - - private static void InstantiateByAssignment() - { - // - int number1 = 64301; - int number2 = 25548612; - // - Console.WriteLine("{0} - {1}", number1, number2); - } - - private static void InstantiateByNarrowingConversion() - { - // - long lNumber = 163245617; - try { - int number1 = (int) lNumber; - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int32.", lNumber); - } - - double dbl2 = 35901.997; - try { - int number2 = (int) dbl2; - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int32.", dbl2); - } - - BigInteger bigNumber = 132451; - try { - int number3 = (int) bigNumber; - Console.WriteLine(number3); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int32.", bigNumber); - } - // The example displays the following output: - // 163245617 - // 35902 - // 132451 - // - } - - private static void Parse() - { - // - string string1 = "244681"; - try { - int number1 = Int32.Parse(string1); - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 32-bit integer.", string1); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string1); - } - - string string2 = "F9A3C"; - try { - int number2 = Int32.Parse(string2, - System.Globalization.NumberStyles.HexNumber); - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 32-bit integer.", string2); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string2); - } - // The example displays the following output: - // 244681 - // 1022524 - // - } - - private static void InstantiateByWideningConversion() - { - // - sbyte value1 = 124; - short value2 = 1618; - - int number1 = value1; - int number2 = value2; - // - } -} diff --git a/snippets/csharp/System/Int32/Parse/parse4.cs b/snippets/csharp/System/Int32/Parse/parse4.cs deleted file mode 100644 index b2cfcbc9235..00000000000 --- a/snippets/csharp/System/Int32/Parse/parse4.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; -using System.Globalization; - -public class ParseInt32 -{ - public static void Main() - { - SnippetA(); - SnippetB(); - SnippetC(); - } - - public static void SnippetA() - { - // - string MyString = "12345"; - int MyInt = int.Parse(MyString); - MyInt++; - Console.WriteLine(MyInt); - // The result is "12346". - // - } - - public static void SnippetB() - { - // - CultureInfo MyCultureInfo = new CultureInfo("en-US"); - string MyString = "123,456"; - int MyInt = int.Parse(MyString, MyCultureInfo); - Console.WriteLine(MyInt); - // Raises System.Format exception. - // - } - - public static void SnippetC() - { - // - CultureInfo MyCultureInfo = new CultureInfo("en-US"); - string MyString = "123,456"; - int MyInt = int.Parse(MyString, NumberStyles.AllowThousands, MyCultureInfo); - Console.WriteLine(MyInt); - // The result is "123456". - // - } -} -// diff --git a/snippets/csharp/System/Int64/Overview/formatting1.cs b/snippets/csharp/System/Int64/Overview/formatting1.cs deleted file mode 100644 index 1228d8856bb..00000000000 --- a/snippets/csharp/System/Int64/Overview/formatting1.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CallToString(); - Console.WriteLine("-----"); - CallConvert(); - } - - private static void CallToString() - { - // - long[] numbers = { -1403, 0, 169, 1483104 }; - foreach (var number in numbers) { - // Display value using default formatting. - Console.Write("{0,-8} --> ", number.ToString()); - // Display value with 3 digits and leading zeros. - Console.Write("{0,8:D3}", number); - // Display value with 1 decimal digit. - Console.Write("{0,13:N1}", number); - // Display value as hexadecimal. - Console.Write("{0,18:X2}", number); - // Display value with eight hexadecimal digits. - Console.WriteLine("{0,18:X8}", number); - } - // 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 - // - } - - private static void CallConvert() - { - // - long[] numbers = { -146, 11043, 2781913 }; - foreach (var number in numbers) { - Console.WriteLine("{0} (Base 10):", number); - Console.WriteLine(" Binary: {0}", Convert.ToString(number, 2)); - Console.WriteLine(" Octal: {0}", Convert.ToString(number, 8)); - Console.WriteLine(" Hex: {0}\n", Convert.ToString(number, 16)); - } - // 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 - // - } -} diff --git a/snippets/csharp/System/Int64/Overview/instantiate1.cs b/snippets/csharp/System/Int64/Overview/instantiate1.cs deleted file mode 100644 index 6f98b515156..00000000000 --- a/snippets/csharp/System/Int64/Overview/instantiate1.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - InstantiateByAssignment(); - Console.WriteLine("----"); - InstantiateByNarrowingConversion(); - Console.WriteLine("----"); - Parse(); - Console.WriteLine("----"); - InstantiateByWideningConversion(); - } - - private static void InstantiateByAssignment() - { - // - long number1 = -64301728; - long number2 = 255486129307; - // - Console.WriteLine("{0} - {1}", number1, number2); - } - - private static void InstantiateByNarrowingConversion() - { - // - ulong ulNumber = 163245617943825; - try { - long number1 = (long) ulNumber; - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int64.", ulNumber); - } - - double dbl2 = 35901.997; - try { - long number2 = (long) dbl2; - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int64.", dbl2); - } - - BigInteger bigNumber = (BigInteger) 1.63201978555e30; - try { - long number3 = (long) bigNumber; - Console.WriteLine(number3); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int64.", bigNumber); - } - // The example displays the following output: - // 163245617943825 - // 35902 - // 1,632,019,785,549,999,969,612,091,883,520 is out of range of an Int64. - // - } - - private static void Parse() - { - // - string string1 = "244681903147"; - try { - long number1 = Int64.Parse(string1); - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 64-bit integer.", string1); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string1); - } - - string string2 = "F9A3CFF0A"; - try { - long number2 = Int64.Parse(string2, - System.Globalization.NumberStyles.HexNumber); - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 64-bit integer.", string2); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string2); - } - // The example displays the following output: - // 244681903147 - // 67012198154 - // - } - - private static void InstantiateByWideningConversion() - { - // - sbyte value1 = 124; - short value2 = 1618; - int value3 = Int32.MaxValue; - - long number1 = value1; - long number2 = value2; - long number3 = value3; - // - } -} diff --git a/snippets/csharp/System/InvalidCastException/Overview/Interface1.cs b/snippets/csharp/System/InvalidCastException/Overview/Interface1.cs deleted file mode 100644 index 614b8a40d42..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/Interface1.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - var culture = CultureInfo.InvariantCulture; - IFormatProvider provider = culture; - - DateTimeFormatInfo dt = (DateTimeFormatInfo) provider; - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidCastException: -// Unable to cast object of type //System.Globalization.CultureInfo// to -// type //System.Globalization.DateTimeFormatInfo//. -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/ToString1.cs b/snippets/csharp/System/InvalidCastException/Overview/ToString1.cs deleted file mode 100644 index 6b248a2cb82..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/ToString1.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - object value = 12; - // Cast throws an InvalidCastException exception. - string s = (string) value; - } -} -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/ToString2.cs b/snippets/csharp/System/InvalidCastException/Overview/ToString2.cs deleted file mode 100644 index 210a54af176..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/ToString2.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - object value = 12; - string s = value.ToString(); - Console.WriteLine(s); - } -} -// The example displays the following output: -// 12 -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs b/snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs deleted file mode 100644 index ff589249a2c..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -using System; - -public class Person -{ - String _name; - - public String Name - { - get { return _name; } - set { _name = value; } - } -} - -public class PersonWithId : Person -{ - String _id; - - public string Id - { - get { return _id; } - set { _id = value; } - } -} - -public class Example -{ - public static void Main() - { - Person p = new Person(); - p.Name = "John"; - try { - PersonWithId pid = (PersonWithId) p; - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Conversion failed."); - } - - PersonWithId pid1 = new PersonWithId(); - pid1.Name = "John"; - pid1.Id = "246"; - Person p1 = pid1; - try { - PersonWithId pid1a = (PersonWithId) p1; - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Conversion failed."); - } - - Person p2 = null; - try { - PersonWithId pid2 = (PersonWithId) p2; - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Conversion failed."); - } - } -} -// The example displays the following output: -// Conversion failed. -// Conversion succeeded. -// Conversion succeeded. -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs b/snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs deleted file mode 100644 index 0ab111e2b83..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool flag = true; - try { - IConvertible conv = flag; - Char ch = conv.ToChar(null); - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Cannot convert a Boolean to a Char."); - } - - try { - Char ch = Convert.ToChar(flag); - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Cannot convert a Boolean to a Char."); - } - } -} -// The example displays the following output: -// Cannot convert a Boolean to a Char. -// Cannot convert a Boolean to a Char. -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs deleted file mode 100644 index c642bbfa5b2..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] data = { 1, 2, 3, 4 }; - var average = data.Where(num => num > 4).Average(); - Console.Write("The average of numbers greater than 4 is {0}", - average); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: Sequence contains no elements -// at System.Linq.Enumerable.Average(IEnumerable`1 source) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs deleted file mode 100644 index b6a349a344d..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - var moreThan4 = dbQueryResults.Where(num => num > 4); - - if(moreThan4.Any()) - Console.WriteLine("Average value of numbers greater than 4: {0}:", - moreThan4.Average()); - else - // handle empty collection - Console.WriteLine("The dataset has no values greater than 4."); - } -} -// The example displays the following output: -// The dataset has no values greater than 4. -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs deleted file mode 100644 index 404c72634ab..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var firstNum = dbQueryResults.First(n => n > 4); - - Console.WriteLine("The first value greater than 4 is {0}", - firstNum); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: -// Sequence contains no matching element -// at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs deleted file mode 100644 index 961d3d9224b..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var firstNum = dbQueryResults.FirstOrDefault(n => n > 4); - - if (firstNum == 0) - Console.WriteLine("No value is greater than 4."); - else - Console.WriteLine("The first value greater than 4 is {0}", - firstNum); - } -} -// The example displays the following output: -// No value is greater than 4. -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs deleted file mode 100644 index 1a84c9ebabe..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var singleObject = dbQueryResults.Single(value => value > 4); - - // Display results. - Console.WriteLine("{0} is the only value greater than 4", singleObject); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: -// Sequence contains no matching element -// at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs deleted file mode 100644 index a00ff0fe7e1..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var singleObject = dbQueryResults.SingleOrDefault(value => value > 2); - - if (singleObject != 0) - Console.WriteLine("{0} is the only value greater than 2", - singleObject); - else - // Handle an empty collection. - Console.WriteLine("No value is greater than 2"); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: -// Sequence contains more than one matching element -// at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs b/snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs deleted file mode 100644 index 643a1c1ce7e..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Example -{ - public static void Main() - { - var numbers = new List() { 1, 2, 3, 4, 5 }; - foreach (var number in numbers) { - int square = (int) Math.Pow(number, 2); - Console.WriteLine("{0}^{1}", number, square); - Console.WriteLine("Adding {0} to the collection...\n", square); - numbers.Add(square); - } - } -} -// The example displays the following output: -// 1^1 -// Adding 1 to the collection... -// -// -// Unhandled Exception: System.InvalidOperationException: Collection was modified; -// enumeration operation may not execute. -// at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) -// at System.Collections.Generic.List`1.Enumerator.MoveNextRare() -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs b/snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs deleted file mode 100644 index 965803fc717..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Example -{ - public static void Main() - { - var numbers = new List() { 1, 2, 3, 4, 5 }; - - int upperBound = numbers.Count - 1; - for (int ctr = 0; ctr <= upperBound; ctr++) { - int square = (int) Math.Pow(numbers[ctr], 2); - Console.WriteLine("{0}^{1}", numbers[ctr], square); - Console.WriteLine("Adding {0} to the collection...\n", square); - numbers.Add(square); - } - - Console.WriteLine("Elements now in the collection: "); - foreach (var number in numbers) - Console.Write("{0} ", number); - } -} -// The example displays the following output: -// 1^1 -// Adding 1 to the collection... -// -// 2^4 -// Adding 4 to the collection... -// -// 3^9 -// Adding 9 to the collection... -// -// 4^16 -// Adding 16 to the collection... -// -// 5^25 -// Adding 25 to the collection... -// -// Elements now in the collection: -// 1 2 3 4 5 1 4 9 16 25 -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs b/snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs deleted file mode 100644 index 9283746cbf4..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Example -{ - public static void Main() - { - var numbers = new List() { 1, 2, 3, 4, 5 }; - var temp = new List(); - - // Square each number and store it in a temporary collection. - foreach (var number in numbers) { - int square = (int) Math.Pow(number, 2); - temp.Add(square); - } - - // Combine the numbers into a single array. - int[] combined = new int[numbers.Count + temp.Count]; - Array.Copy(numbers.ToArray(), 0, combined, 0, numbers.Count); - Array.Copy(temp.ToArray(), 0, combined, numbers.Count, temp.Count); - - // Iterate the array. - foreach (var value in combined) - Console.Write("{0} ", value); - } -} -// The example displays the following output: -// 1 2 3 4 5 1 4 9 16 25 -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs deleted file mode 100644 index dd25bd14336..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: Failed to compare two elements in the array. ---> -// System.ArgumentException: At least one object must implement IComparable. -// at System.Collections.Comparer.Compare(Object a, Object b) -// at System.Collections.Generic.ArraySortHelper`1.SwapIfGreater(T[] keys, IComparer`1 comparer, Int32 a, Int32 b) -// at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit) -// at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer) -// --- End of inner exception stack trace --- -// at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer) -// at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer) -// at System.Collections.Generic.List`1.Sort(Int32 index, Int32 count, IComparer`1 comparer) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs deleted file mode 100644 index 24f61b3d9df..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person : IComparable -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } - - public int CompareTo(Person other) - { - return String.Format("{0} {1}", LastName, FirstName). - CompareTo(String.Format("{0} {1}", other.LastName, other.FirstName)); - } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } -} -// The example displays the following output: -// Jane Doe -// John Doe -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs deleted file mode 100644 index 453f5d5d4b2..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } -} - -public class PersonComparer : IComparer -{ - public int Compare(Person x, Person y) - { - return String.Format("{0} {1}", x.LastName, x.FirstName). - CompareTo(String.Format("{0} {1}", y.LastName, y.FirstName)); - } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(new PersonComparer()); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } -} -// The example displays the following output: -// Jane Doe -// John Doe -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs deleted file mode 100644 index 220928e4a0b..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(PersonComparison); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } - - public static int PersonComparison(Person x, Person y) - { - return String.Format("{0} {1}", x.LastName, x.FirstName). - CompareTo(String.Format("{0} {1}", y.LastName, y.FirstName)); - } -} -// The example displays the following output: -// Jane Doe -// John Doe -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs b/snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs deleted file mode 100644 index f9965bcf108..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - var queryResult = new int?[] { 1, 2, null, 4 }; - var map = queryResult.Select(nullableInt => (int)nullableInt); - - // Display list. - foreach (var num in map) - Console.Write("{0} ", num); - Console.WriteLine(); - } -} -// The example displays the following output: -// 1 2 -// Unhandled Exception: System.InvalidOperationException: Nullable object must have a value. -// at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) -// at Example.
b__0(Nullable`1 nullableInt) -// at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs b/snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs deleted file mode 100644 index 56506c0979c..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - var queryResult = new int?[] { 1, 2, null, 4 }; - var numbers = queryResult.Select(nullableInt => (int)nullableInt.GetValueOrDefault()); - - // Display list using Nullable.HasValue. - foreach (var number in numbers) - Console.Write("{0} ", number); - Console.WriteLine(); - - numbers = queryResult.Select(nullableInt => (int) (nullableInt.HasValue ? nullableInt : -1)); - // Display list using Nullable.GetValueOrDefault. - foreach (var number in numbers) - Console.Write("{0} ", number); - Console.WriteLine(); - } -} -// The example displays the following output: -// 1 2 0 4 -// 1 2 -1 4 -// diff --git a/snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs b/snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs deleted file mode 100644 index 1a1e13873e5..00000000000 --- a/snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using Utilities; - -class Example -{ - public static void Main() - { - string eol = ""; - if (StringLibrary.Version.Major >= 2) - eol = StringLibrary.GetendOfLineCharacter(); - else - eol = "\n"; - - Console.Write("The first line." + eol); - Console.Write("The second line." + eol); - } -} -// diff --git a/snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs b/snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs deleted file mode 100644 index 90889cbd520..00000000000 --- a/snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -namespace Utilities -{ - public class StringLibrary - { - public static Version Version { get; } = new Version("1.0"); - - public static String GetEndOfLineCharacter() - { - throw new NotSupportedException("This functionality will be provided in a later version."); - } - } -} -// diff --git a/snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs b/snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs deleted file mode 100644 index 992fcdbfa2b..00000000000 --- a/snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -namespace Utilities -{ - public class StringLibrary - { - public static Version Version { get; } = new Version("2.0"); - - public static String GetEndOfLineCharacter() - { - return Environment.Newline; - } - } -} -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/BadState1.cs b/snippets/csharp/System/NotSupportedException/Overview/BadState1.cs deleted file mode 100644 index 431ad2b35c5..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/BadState1.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.IO; -using System.Text; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - Encoding enc = Encoding.Unicode; - String value = "This is a string to persist."; - Byte[] bytes = enc.GetBytes(value); - - FileStream fs = new FileStream(@".\TestFile.dat", - FileMode.Open, - FileAccess.Read); - Task t = fs.WriteAsync(enc.GetPreamble(), 0, enc.GetPreamble().Length); - Task t2 = t.ContinueWith( (a) => fs.WriteAsync(bytes, 0, bytes.Length) ); - await t2; - fs.Close(); - } -} -// The example displays the following output: -// Unhandled Exception: System.NotSupportedException: Stream does not support writing. -// at System.IO.Stream.BeginWriteInternal(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state -// , Boolean serializeAsynchronously) -// at System.IO.FileStream.BeginWrite(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback userCallback, Object sta -// teObject) -// at System.IO.Stream.<>c.b__53_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, -// Object state) -// at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func`5 beginMet -// hod, Func`3 endMethod) -// at System.IO.Stream.BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count) -// at System.IO.FileStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) -// at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count) -// at Example.Main() -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/BadState2.cs b/snippets/csharp/System/NotSupportedException/Overview/BadState2.cs deleted file mode 100644 index 094060f5f23..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/BadState2.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; -using System.IO; -using System.Text; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - Encoding enc = Encoding.Unicode; - String value = "This is a string to persist."; - Byte[] bytes = enc.GetBytes(value); - - FileStream fs = new FileStream(@".\TestFile.dat", - FileMode.Create, - FileAccess.Write); - Task t = fs.WriteAsync(enc.GetPreamble(), 0, enc.GetPreamble().Length); - Task t2 = t.ContinueWith( (a) => fs.WriteAsync(bytes, 0, bytes.Length) ); - await t2; - fs.Close(); - } -} -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs b/snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs deleted file mode 100644 index 68abcea9a04..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -using System; -using System.IO; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - String name = @".\TestFile.dat"; - var fs = new FileStream(name, - FileMode.Create, - FileAccess.Write); - Console.WriteLine("Filename: {0}, Encoding: {1}", - name, await FileUtilities.GetEncodingType(fs)); - } -} - -public class FileUtilities -{ - public enum EncodingType - { None = 0, Unknown = -1, Utf8 = 1, Utf16 = 2, Utf32 = 3 } - - public async static Task GetEncodingType(FileStream fs) - { - Byte[] bytes = new Byte[4]; - int bytesRead = await fs.ReadAsync(bytes, 0, 4); - if (bytesRead < 2) - return EncodingType.None; - - if (bytesRead >= 3 & (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)) - return EncodingType.Utf8; - - if (bytesRead == 4) { - var value = BitConverter.ToUInt32(bytes, 0); - if (value == 0x0000FEFF | value == 0xFEFF0000) - return EncodingType.Utf32; - } - - var value16 = BitConverter.ToUInt16(bytes, 0); - if (value16 == (ushort)0xFEFF | value16 == (ushort)0xFFFE) - return EncodingType.Utf16; - - return EncodingType.Unknown; - } -} -// The example displays the following output: -// Unhandled Exception: System.NotSupportedException: Stream does not support reading. -// at System.IO.FileStream.BeginRead(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback callback, Object state) -// at System.IO.Stream.<>c.b__46_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state) -// at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance, TArgs](TInstance thisRef, TArgs args, Func`5 beginMethod, Func`3 endMethod) -// at System.IO.Stream.BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count) -// at System.IO.FileStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) -// at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count) -// at FileUtilities.GetEncodingType(FileStream fs) in C:\Work\docs\program.cs:line 26 -// at Example.Main() in C:\Work\docs\program.cs:line 13 -// at Example.
() -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs b/snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs deleted file mode 100644 index 5b65caace07..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.IO; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - String name = @".\TestFile.dat"; - var fs = new FileStream(name, - FileMode.Create, - FileAccess.Write); - Console.WriteLine("Filename: {0}, Encoding: {1}", - name, await FileUtilities.GetEncodingType(fs)); - } -} - -public class FileUtilities -{ - public enum EncodingType - { None = 0, Unknown = -1, Utf8 = 1, Utf16 = 2, Utf32 = 3 } - - // - public static async Task GetEncodingType(FileStream fs) - { - if (!fs.CanRead) - return EncodingType.Unknown; - - Byte[] bytes = new Byte[4]; - int bytesRead = await fs.ReadAsync(bytes, 0, 4); - if (bytesRead < 2) - return EncodingType.None; - - if (bytesRead >= 3 & (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)) - return EncodingType.Utf8; - - if (bytesRead == 4) { - var value = BitConverter.ToUInt32(bytes, 0); - if (value == 0x0000FEFF | value == 0xFEFF0000) - return EncodingType.Utf32; - } - - var value16 = BitConverter.ToUInt16(bytes, 0); - if (value16 == (ushort)0xFEFF | value16 == (ushort)0xFFFE) - return EncodingType.Utf16; - - return EncodingType.Unknown; - } -} -// The example displays the following output: -// Filename: .\TestFile.dat, Encoding: Unknown -// diff --git a/snippets/csharp/System/PredicateT/Overview/source.cs b/snippets/csharp/System/PredicateT/Overview/source.cs deleted file mode 100644 index 02b663f607c..00000000000 --- a/snippets/csharp/System/PredicateT/Overview/source.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; -using System.Drawing; - -public class Example -{ - public static void Main() - { - // Create an array of five Point structures. - Point[] points = { new Point(100, 200), - new Point(150, 250), new Point(250, 375), - new Point(275, 395), new Point(295, 450) }; - - // To find the first Point structure for which X times Y - // is greater than 100000, pass the array and a delegate - // that represents the ProductGT10 method to the static - // Find method of the Array class. - Point first = Array.Find(points, ProductGT10); - - // Note that you do not need to create the delegate - // explicitly, or to specify the type parameter of the - // generic method, because the C# compiler has enough - // context to determine that information for you. - - // Display the first structure found. - Console.WriteLine("Found: X = {0}, Y = {1}", first.X, first.Y); - } - - // This method implements the test condition for the Find - // method. - private static bool ProductGT10(Point p) - { - if (p.X * p.Y > 100000) - { - return true; - } - else - { - return false; - } - } -} - -/* This code example produces the following output: - -Found: X = 275, Y = 395 - */ -// diff --git a/snippets/csharp/System/SByte/Parse/parse.cs b/snippets/csharp/System/SByte/Parse/parse.cs deleted file mode 100644 index eaf195c37cf..00000000000 --- a/snippets/csharp/System/SByte/Parse/parse.cs +++ /dev/null @@ -1,149 +0,0 @@ -// -// Example of the SByte.Parse( ) methods. -using System; -using System.Globalization; - -class SByteParseDemo -{ - static void SByteParse( NumberStyles styles, - IFormatProvider provider ) - { - string[ ] sbyteFormats = { - " 99 ", " +123 ", " (123) ", - " -123 ", " 1_2_3", " 7E " }; - - // Parse each string in the sbyteFormats array, using - // NumberStyles and IFormatProvider, if specified. - foreach( string sbyteString in sbyteFormats ) - { - SByte sbyteNumber; - - // Display the first part of the output line. - Console.Write( " Parse of {0,-12}", - String.Format( "\"{0}\"", sbyteString ) ); - - try - { - // Use the appropriate SByte.Parse overload, based - // on the parameters that are specified. - if( provider == null ) - if( styles < 0 ) - sbyteNumber = SByte.Parse( sbyteString ); - else - sbyteNumber = - SByte.Parse( sbyteString, styles ); - else if( styles < 0 ) - sbyteNumber = - SByte.Parse( sbyteString, provider ); - else - sbyteNumber = SByte.Parse( - sbyteString, styles, provider ); - - // Display the resulting value if Parse succeeded. - Console.WriteLine( "succeeded: {0}", - sbyteNumber ); - } - catch( Exception ex ) - { - // Display the exception message if Parse failed. - Console.WriteLine( "failed: {0}", ex.Message ); - } - } - } - - static void RunParseDemo( ) - { - // Do not use IFormatProvider or NumberStyles. - Console.WriteLine( - "\nNumberStyles and IFormatProvider are not used:" ); - SByteParse( (NumberStyles)(-1), null ); - - // Use NumberStyles.HexNumber; do not use IFormatProvider. - Console.WriteLine( "\nNumberStyles.HexNumber " + - "is used; IFormatProvider is not used:" ); - SByteParse( NumberStyles.HexNumber, null ); - - // Get the NumberFormatInfo object from the invariant - // culture, and enable parentheses to indicate negative. - CultureInfo culture = new CultureInfo( "" ); - NumberFormatInfo numFormat = culture.NumberFormat; - numFormat.NumberNegativePattern = 0; - - // Change the digit group separator to '_' and the digit - // group size to 1. - numFormat.NumberGroupSeparator = "_"; - numFormat.NumberGroupSizes = new int[ ] { 1 }; - - // Use the NumberFormatInfo object as the IFormatProvider. - Console.WriteLine( "\nA NumberStyles value is not used, " + - "but the IFormatProvider sets the group \nseparator = " + - "'_', group size = 1, and negative pattern = ( ):" ); - SByteParse( (NumberStyles)(-1), numFormat ); - - // Use NumberStyles.Number and NumberStyles.AllowParentheses. - Console.WriteLine( - "\nNumberStyles.Number, NumberStyles.AllowParentheses, " + - "and the same \nIFormatProvider are used:" ); - SByteParse( NumberStyles.Number | - NumberStyles.AllowParentheses, numFormat ); - } - - static void Main( ) - { - Console.WriteLine( "This example of\n" + - " SByte.Parse( String ),\n" + - " SByte.Parse( String, NumberStyles ),\n" + - " SByte.Parse( String, IFormatProvider ), and\n" + - " SByte.Parse( String, NumberStyles, IFormatProvider )" + - "\ngenerates the following output when parsing " + - "string representations\nof SByte values with each " + - "of these forms of SByte.Parse( )." ); - - RunParseDemo( ); - } -} - -/* -This example of - SByte.Parse( String ), - SByte.Parse( String, NumberStyles ), - SByte.Parse( String, IFormatProvider ), and - SByte.Parse( String, NumberStyles, IFormatProvider ) -generates the following output when parsing string representations -of SByte values with each of these forms of SByte.Parse( ). - -NumberStyles and IFormatProvider are not used: - Parse of " 99 " succeeded: 99 - Parse of " +123 " succeeded: 123 - Parse of " (123) " failed: Input string was not in a correct format. - Parse of " -123 " succeeded: -123 - Parse of " 1_2_3" failed: Input string was not in a correct format. - Parse of " 7E " failed: Input string was not in a correct format. - -NumberStyles.HexNumber is used; IFormatProvider is not used: - Parse of " 99 " succeeded: -103 - Parse of " +123 " failed: Input string was not in a correct format. - Parse of " (123) " failed: Input string was not in a correct format. - Parse of " -123 " failed: Input string was not in a correct format. - Parse of " 1_2_3" failed: Input string was not in a correct format. - Parse of " 7E " succeeded: 126 - -A NumberStyles value is not used, but the IFormatProvider sets the group -separator = '_', group size = 1, and negative pattern = ( ): - Parse of " 99 " succeeded: 99 - Parse of " +123 " succeeded: 123 - Parse of " (123) " failed: Input string was not in a correct format. - Parse of " -123 " succeeded: -123 - Parse of " 1_2_3" failed: Input string was not in a correct format. - Parse of " 7E " failed: Input string was not in a correct format. - -NumberStyles.Number, NumberStyles.AllowParentheses, and the same -IFormatProvider are used: - Parse of " 99 " succeeded: 99 - Parse of " +123 " succeeded: 123 - Parse of " (123) " succeeded: -123 - Parse of " -123 " succeeded: -123 - Parse of " 1_2_3" succeeded: 123 - Parse of " 7E " failed: Input string was not in a correct format. -*/ -// diff --git a/snippets/csharp/System/SByte/Parse/parseex4.cs b/snippets/csharp/System/SByte/Parse/parseex4.cs deleted file mode 100644 index 69f2a38dc24..00000000000 --- a/snippets/csharp/System/SByte/Parse/parseex4.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string[] cultureNames = { "en-US", "fr-FR" }; - NumberStyles[] styles= { NumberStyles.Integer, - NumberStyles.Integer | NumberStyles.AllowDecimalPoint }; - string[] values = { "-17", "-17.0", "-17,0", "+103.00", "+103,00" }; - - // Parse strings using each culture - foreach (string cultureName in cultureNames) - { - CultureInfo ci = new CultureInfo(cultureName); - Console.WriteLine("Parsing strings using the {0} culture", - ci.DisplayName); - // Use each style. - foreach (NumberStyles style in styles) - { - Console.WriteLine(" Style: {0}", style.ToString()); - // Parse each numeric string. - foreach (string value in values) - { - try { - Console.WriteLine(" Converted '{0}' to {1}.", value, - SByte.Parse(value, style, ci)); - } - catch (FormatException) { - Console.WriteLine(" Unable to parse '{0}'.", value); - } - catch (OverflowException) { - Console.WriteLine(" '{0}' is out of range of the SByte type.", - value); - } - } - } - } - } -} -// The example displays the following output: -// Parsing strings using the English (United States) culture -// Style: Integer -// Converted '-17' to -17. -// Unable to parse '-17.0'. -// Unable to parse '-17,0'. -// Unable to parse '+103.00'. -// Unable to parse '+103,00'. -// Style: Integer, AllowDecimalPoint -// Converted '-17' to -17. -// Converted '-17.0' to -17. -// Unable to parse '-17,0'. -// Converted '+103.00' to 103. -// Unable to parse '+103,00'. -// Parsing strings using the French (France) culture -// Style: Integer -// Converted '-17' to -17. -// Unable to parse '-17.0'. -// Unable to parse '-17,0'. -// Unable to parse '+103.00'. -// Unable to parse '+103,00'. -// Style: Integer, AllowDecimalPoint -// Converted '-17' to -17. -// Unable to parse '-17.0'. -// Converted '-17,0' to -17. -// Unable to parse '+103.00'. -// Converted '+103,00' to 103. -// diff --git a/snippets/csharp/System/SByte/ToString/tostring.cs b/snippets/csharp/System/SByte/ToString/tostring.cs deleted file mode 100644 index 8c934302856..00000000000 --- a/snippets/csharp/System/SByte/ToString/tostring.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -// Example for the SByte.ToString( ) methods. -using System; -using System.Globalization; - -public class SByteToStringDemo -{ - static void RunToStringDemo( ) - { - SByte smallValue = -99; - SByte largeValue = 123; - - // Format the SByte values without and with format strings. - Console.WriteLine( "\nIFormatProvider is not used:" ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "No format string:", smallValue.ToString( ), - largeValue.ToString( ) ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "'X2' format string:", smallValue.ToString( "X2" ), - largeValue.ToString( "X2" ) ); - - // Get the NumberFormatInfo object from the - // invariant culture. - CultureInfo culture = new CultureInfo( "" ); - NumberFormatInfo numInfo = culture.NumberFormat; - - // Set decimal digits to 0. Set the negative pattern to ( ). - numInfo.NumberDecimalDigits = 0; - numInfo.NumberNegativePattern = 0; - - // Use the NumberFormatInfo object for an IFormatProvider. - Console.WriteLine( "\nA NumberFormatInfo " + - "object with negative pattern = ( ) and \nno " + - "decimal digits is used for the IFormatProvider:" ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "No format string:", smallValue.ToString( numInfo ), - largeValue.ToString( numInfo ) ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "'N' format string:", - smallValue.ToString( "N", numInfo ), - largeValue.ToString( "N", numInfo ) ); - } - - static void Main( ) - { - Console.WriteLine( - "This example of\n SByte.ToString( ),\n" + - " SByte.ToString( string ),\n" + - " SByte.ToString( IFormatProvider ), and\n" + - " SByte.ToString( string, IFormatProvider )\n" + - "generates the following output when formatting " + - "SByte values \nwith combinations of format " + - "strings and IFormatProvider." ); - - RunToStringDemo( ); - } -} - -/* -This example of - SByte.ToString( ), - SByte.ToString( string ), - SByte.ToString( IFormatProvider ), and - SByte.ToString( string, IFormatProvider ) -generates the following output when formatting SByte values -with combinations of format strings and IFormatProvider. - -IFormatProvider is not used: - No format string: -99 123 - 'X2' format string: 9D 7B - -A NumberFormatInfo object with negative pattern = ( ) and -no decimal digits is used for the IFormatProvider: - No format string: -99 123 - 'N' format string: (99) 123 -*/ -// diff --git a/snippets/csharp/System/Single/Overview/PrecisionList5a.cs b/snippets/csharp/System/Single/Overview/PrecisionList5a.cs deleted file mode 100644 index d4d1300def6..00000000000 --- a/snippets/csharp/System/Single/Overview/PrecisionList5a.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - sw.Write("{0:G9}{1}", values[ctr], ctr < values.Length - 1 ? "|" : "" ); - - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 = 2.882883 -// 0.3333333 = 0.3333333 -// 3.141593 = 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/comparison1.cs b/snippets/csharp/System/Single/Overview/comparison1.cs deleted file mode 100644 index d7ba9b768c6..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison1.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = .3333333f; - float value2 = 1.0f/3; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.3333333 = 0.333333343: False -// diff --git a/snippets/csharp/System/Single/Overview/comparison2.cs b/snippets/csharp/System/Single/Overview/comparison2.cs deleted file mode 100644 index ea7269c7d7f..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = 10.201438f; - value1 = (float) Math.Sqrt((float) Math.Pow(value1, 2)); - float value2 = (float) Math.Pow((float) value1 * 3.51f, 2); - value2 = ((float) Math.Sqrt(value2)) / 3.51f; - Console.WriteLine("{0} = {1}: {2}\n", - value1, value2, value1.Equals(value2)); - Console.WriteLine("{0:G9} = {1:G9}", value1, value2); - } -} -// The example displays the following output: -// 10.20144 = 10.20144: False -// -// 10.201438 = 10.2014389 -// diff --git a/snippets/csharp/System/Single/Overview/comparison3.cs b/snippets/csharp/System/Single/Overview/comparison3.cs deleted file mode 100644 index d520a83a65a..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison3.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = .3333333f; - float value2 = 1.0f/3; - int precision = 7; - value1 = (float) Math.Round(value1, precision); - value2 = (float) Math.Round(value2, precision); - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.3333333 = 0.3333333: True -// diff --git a/snippets/csharp/System/Single/Overview/comparison4.cs b/snippets/csharp/System/Single/Overview/comparison4.cs deleted file mode 100644 index a4fb50ea529..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison4.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float one1 = .1f * 10; - float one2 = 0f; - for (int ctr = 1; ctr <= 10; ctr++) - one2 += .1f; - - Console.WriteLine("{0:R} = {1:R}: {2}", one1, one2, one1.Equals(one2)); - Console.WriteLine("{0:R} is approximately equal to {1:R}: {2}", - one1, one2, - IsApproximatelyEqual(one1, one2, .000001f)); - } - - static bool IsApproximatelyEqual(float value1, float value2, float epsilon) - { - // If they are equal anyway, just return True. - if (value1.Equals(value2)) - return true; - - // Handle NaN, Infinity. - if (Double.IsInfinity(value1) | Double.IsNaN(value1)) - return value1.Equals(value2); - else if (Double.IsInfinity(value2) | Double.IsNaN(value2)) - return value1.Equals(value2); - - // Handle zero to avoid division by zero - double divisor = Math.Max(value1, value2); - if (divisor.Equals(0)) - divisor = Math.Min(value1, value2); - - return Math.Abs(value1 - value2)/divisor <= epsilon; - } -} -// The example displays the following output: -// 1 = 1.00000012: False -// 1 is approximately equal to 1.00000012: True -// diff --git a/snippets/csharp/System/Single/Overview/convert1.cs b/snippets/csharp/System/Single/Overview/convert1.cs deleted file mode 100644 index 1feb509fe08..00000000000 --- a/snippets/csharp/System/Single/Overview/convert1.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - dynamic[] values = { Byte.MinValue, Byte.MaxValue, Decimal.MinValue, - Decimal.MaxValue, Double.MinValue, Double.MaxValue, - Int16.MinValue, Int16.MaxValue, Int32.MinValue, - Int32.MaxValue, Int64.MinValue, Int64.MaxValue, - SByte.MinValue, SByte.MaxValue, UInt16.MinValue, - UInt16.MaxValue, UInt32.MinValue, UInt32.MaxValue, - UInt64.MinValue, UInt64.MaxValue }; - float sngValue; - foreach (var value in values) { - if (value.GetType() == typeof(Decimal) || - value.GetType() == typeof(Double)) - sngValue = (float) value; - else - sngValue = value; - Console.WriteLine("{0} ({1}) --> {2:R} ({3})", - value, value.GetType().Name, - sngValue, sngValue.GetType().Name); - } - } -} -// The example displays the following output: -// 0 (Byte) --> 0 (Single) -// 255 (Byte) --> 255 (Single) -// -79228162514264337593543950335 (Decimal) --> -7.92281625E+28 (Single) -// 79228162514264337593543950335 (Decimal) --> 7.92281625E+28 (Single) -// -1.79769313486232E+308 (Double) --> -Infinity (Single) -// 1.79769313486232E+308 (Double) --> Infinity (Single) -// -32768 (Int16) --> -32768 (Single) -// 32767 (Int16) --> 32767 (Single) -// -2147483648 (Int32) --> -2.14748365E+09 (Single) -// 2147483647 (Int32) --> 2.14748365E+09 (Single) -// -9223372036854775808 (Int64) --> -9.223372E+18 (Single) -// 9223372036854775807 (Int64) --> 9.223372E+18 (Single) -// -128 (SByte) --> -128 (Single) -// 127 (SByte) --> 127 (Single) -// 0 (UInt16) --> 0 (Single) -// 65535 (UInt16) --> 65535 (Single) -// 0 (UInt32) --> 0 (Single) -// 4294967295 (UInt32) --> 4.2949673E+09 (Single) -// 0 (UInt64) --> 0 (Single) -// 18446744073709551615 (UInt64) --> 1.84467441E+19 (Single) -// diff --git a/snippets/csharp/System/Single/Overview/convert2.cs b/snippets/csharp/System/Single/Overview/convert2.cs deleted file mode 100644 index 491165a52d4..00000000000 --- a/snippets/csharp/System/Single/Overview/convert2.cs +++ /dev/null @@ -1,143 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float[] values = { Single.MinValue, -67890.1234f, -12345.6789f, - 12345.6789f, 67890.1234f, Single.MaxValue, - Single.NaN, Single.PositiveInfinity, - Single.NegativeInfinity }; - checked { - foreach (var value in values) { - try { - Int64 lValue = (long) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - lValue, lValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Int64.", value); - } - try { - UInt64 ulValue = (ulong) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - ulValue, ulValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to UInt64.", value); - } - try { - Decimal dValue = (decimal) value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - dValue, dValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Decimal.", value); - } - - Double dblValue = value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - dblValue, dblValue.GetType().Name); - Console.WriteLine(); - } - } - } -} -// The example displays the following output for conversions performed -// in a checked context: -// Unable to convert -3.402823E+38 to Int64. -// Unable to convert -3.402823E+38 to UInt64. -// Unable to convert -3.402823E+38 to Decimal. -// -3.402823E+38 (Single) --> -3.40282346638529E+38 (Double) -// -// -67890.13 (Single) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// Unable to convert -67890.13 to UInt64. -// -67890.13 (Single) --> -67890.12 (Decimal) -// -67890.13 (Single) --> -67890.125 (Double) -// -// -12345.68 (Single) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// Unable to convert -12345.68 to UInt64. -// -12345.68 (Single) --> -12345.68 (Decimal) -// -12345.68 (Single) --> -12345.6787109375 (Double) -// -// 12345.68 (Single) --> 12345 (0x0000000000003039) (Int64) -// 12345.68 (Single) --> 12345 (0x0000000000003039) (UInt64) -// 12345.68 (Single) --> 12345.68 (Decimal) -// 12345.68 (Single) --> 12345.6787109375 (Double) -// -// 67890.13 (Single) --> 67890 (0x0000000000010932) (Int64) -// 67890.13 (Single) --> 67890 (0x0000000000010932) (UInt64) -// 67890.13 (Single) --> 67890.12 (Decimal) -// 67890.13 (Single) --> 67890.125 (Double) -// -// Unable to convert 3.402823E+38 to Int64. -// Unable to convert 3.402823E+38 to UInt64. -// Unable to convert 3.402823E+38 to Decimal. -// 3.402823E+38 (Single) --> 3.40282346638529E+38 (Double) -// -// Unable to convert NaN to Int64. -// Unable to convert NaN to UInt64. -// Unable to convert NaN to Decimal. -// NaN (Single) --> NaN (Double) -// -// Unable to convert Infinity to Int64. -// Unable to convert Infinity to UInt64. -// Unable to convert Infinity to Decimal. -// Infinity (Single) --> Infinity (Double) -// -// Unable to convert -Infinity to Int64. -// Unable to convert -Infinity to UInt64. -// Unable to convert -Infinity to Decimal. -// -Infinity (Single) --> -Infinity (Double) -// The example displays the following output for conversions performed -// in an unchecked context: -// -3.402823E+38 (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -3.402823E+38 (Single) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -3.402823E+38 to Decimal. -// -3.402823E+38 (Single) --> -3.40282346638529E+38 (Double) -// -// -67890.13 (Single) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// -67890.13 (Single) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64) -// -67890.13 (Single) --> -67890.12 (Decimal) -// -67890.13 (Single) --> -67890.125 (Double) -// -// -12345.68 (Single) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// -12345.68 (Single) --> 18446744073709539271 (0xFFFFFFFFFFFFCFC7) (UInt64) -// -12345.68 (Single) --> -12345.68 (Decimal) -// -12345.68 (Single) --> -12345.6787109375 (Double) -// -// 12345.68 (Single) --> 12345 (0x0000000000003039) (Int64) -// 12345.68 (Single) --> 12345 (0x0000000000003039) (UInt64) -// 12345.68 (Single) --> 12345.68 (Decimal) -// 12345.68 (Single) --> 12345.6787109375 (Double) -// -// 67890.13 (Single) --> 67890 (0x0000000000010932) (Int64) -// 67890.13 (Single) --> 67890 (0x0000000000010932) (UInt64) -// 67890.13 (Single) --> 67890.12 (Decimal) -// 67890.13 (Single) --> 67890.125 (Double) -// -// 3.402823E+38 (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// 3.402823E+38 (Single) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert 3.402823E+38 to Decimal. -// 3.402823E+38 (Single) --> 3.40282346638529E+38 (Double) -// -// NaN (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// NaN (Single) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert NaN to Decimal. -// NaN (Single) --> NaN (Double) -// -// Infinity (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// Infinity (Single) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert Infinity to Decimal. -// Infinity (Single) --> Infinity (Double) -// -// -Infinity (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -Infinity (Single) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -Infinity to Decimal. -// -Infinity (Single) --> -Infinity (Double) -// diff --git a/snippets/csharp/System/Single/Overview/exceptional1.cs b/snippets/csharp/System/Single/Overview/exceptional1.cs deleted file mode 100644 index 1bdda06c237..00000000000 --- a/snippets/csharp/System/Single/Overview/exceptional1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = 1.163287e-36f; - float value2 = 9.164234e-25f; - float result = value1 * value2; - Console.WriteLine("{0} * {1} = {2}", value1, value2, result); - Console.WriteLine("{0} = 0: {1}", result, result.Equals(0.0f)); - } -} -// The example displays the following output: -// 1.163287E-36 * 9.164234E-25 = 0 -// 0 = 0: True -// diff --git a/snippets/csharp/System/Single/Overview/exceptional2.cs b/snippets/csharp/System/Single/Overview/exceptional2.cs deleted file mode 100644 index 9b6f111f9c2..00000000000 --- a/snippets/csharp/System/Single/Overview/exceptional2.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = 3.065e35f; - float value2 = 6.9375e32f; - float result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Single.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}\n", - Single.IsNegativeInfinity(result)); - - value1 = -value1; - result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Single.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}", - Single.IsNegativeInfinity(result)); - } -} - -// The example displays the following output: -// PositiveInfinity: True -// NegativeInfinity: False -// -// PositiveInfinity: False -// NegativeInfinity: True -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist1.cs b/snippets/csharp/System/Single/Overview/precisionlist1.cs deleted file mode 100644 index 013abcb6980..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist1.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 1/3.0; - Single sValue2 = 1/3.0f; - Double value2 = (Double) sValue2; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, - value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.33333333333333331 = 0.3333333432674408: False -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist3.cs b/snippets/csharp/System/Single/Overview/precisionlist3.cs deleted file mode 100644 index 916bbc9bfe3..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist3.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Single[] values = { 10.01f, 2.88f, 2.88f, 2.88f, 9.0f }; - Single result = 27.65f; - Single total = 0f; - foreach (var value in values) - total += value; - - if (total.Equals(result)) - Console.WriteLine("The sum of the values equals the total."); - else - Console.WriteLine("The sum of the values ({0}) does not equal the total ({1}).", - total, result); - } -} -// The example displays the following output: -// The sum of the values (27.65) does not equal the total (27.65). -// -// If the index items in the Console.WriteLine statement are changed to {0:R}, -// the example displays the following output: -// The sum of the values (27.6500015) does not equal the total (27.65). -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist4.cs b/snippets/csharp/System/Single/Overview/precisionlist4.cs deleted file mode 100644 index 8b5076f17c3..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist4.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 <> 2.882883 -// 0.3333333 <> 0.3333333 -// 3.141593 <> 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist4a.cs b/snippets/csharp/System/Single/Overview/precisionlist4a.cs deleted file mode 100644 index 377c3d644c9..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist4a.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 <> 2.882883 -// 0.3333333 <> 0.3333333 -// 3.141593 <> 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist5.cs b/snippets/csharp/System/Single/Overview/precisionlist5.cs deleted file mode 100644 index 714592c5e12..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist5.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - sw.Write("{0:R}{1}", values[ctr], ctr < values.Length - 1 ? "|" : "" ); - - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 = 2.882883 -// 0.3333333 = 0.3333333 -// 3.141593 = 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/representation1.cs b/snippets/csharp/System/Single/Overview/representation1.cs deleted file mode 100644 index c661ce90c7e..00000000000 --- a/snippets/csharp/System/Single/Overview/representation1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Single value = .2f; - Single result1 = value * 10f; - Single result2 = 0f; - for (int ctr = 1; ctr <= 10; ctr++) - result2 += value; - - Console.WriteLine(".2 * 10: {0:R}", result1); - Console.WriteLine(".2 Added 10 times: {0:R}", result2); - } -} -// The example displays the following output: -// .2 * 10: 2 -// .2 Added 10 times: 2.00000024 -// diff --git a/snippets/csharp/System/Single/Overview/representation2.cs b/snippets/csharp/System/Single/Overview/representation2.cs deleted file mode 100644 index 94a4ad65cf8..00000000000 --- a/snippets/csharp/System/Single/Overview/representation2.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Single value = 123.456f; - Single additional = Single.Epsilon * 1e15f; - Console.WriteLine($"{value} + {additional} = {value + additional}"); - } -} -// The example displays the following output: -// 123.456 + 1.401298E-30 = 123.456 -// diff --git a/snippets/csharp/System/Single/Parse/parse.cs b/snippets/csharp/System/Single/Parse/parse.cs deleted file mode 100644 index b919ed8fde4..00000000000 --- a/snippets/csharp/System/Single/Parse/parse.cs +++ /dev/null @@ -1,156 +0,0 @@ -// -// Example of the Single.Parse( ) methods. -using System; -using System.Globalization; - -class SingleParseDemo -{ - // Get the exception type name; remove the namespace prefix. - static string GetExceptionType( Exception ex ) - { - string exceptionType = ex.GetType( ).ToString( ); - return exceptionType.Substring( - exceptionType.LastIndexOf( '.' )+1 ); - } - - // Parse each string in the singleFormats array, using - // NumberStyles and IFormatProvider, if specified. - static void SingleParse( NumberStyles styles, - IFormatProvider provider ) - { - string[ ] singleFormats = { - " 987.654E-2", " 987,654E-2", "(98765,43210)", - "9,876,543.210", "9.876.543,210", "98_76_54_32,19" }; - - foreach( string singleString in singleFormats ) - { - float singleNumber; - - // Display the first part of the output line. - Console.Write( " Parse of {0,-20}", - String.Format( "\"{0}\"", singleString ) ); - - try - { - // Use the appropriate Single.Parse overload, based - // on the parameters that are specified. - if( provider == null ) - { - if( styles < 0 ) - singleNumber = Single.Parse( singleString ); - else - singleNumber = - Single.Parse( singleString, styles ); - } - else if( styles < 0 ) - singleNumber = - Single.Parse( singleString, provider ); - else - singleNumber = - Single.Parse( singleString, styles, provider ); - - // Display the resulting value if Parse succeeded. - Console.WriteLine( "success: {0}", singleNumber ); - } - catch( Exception ex ) - { - // Display the exception type if Parse failed. - Console.WriteLine( "failed: {0}", - GetExceptionType( ex ) ); - } - } - } - - public static void Main( ) - { - Console.WriteLine( "This example of\n" + - " Single.Parse( String ),\n" + - " Single.Parse( String, NumberStyles ),\n" + - " Single.Parse( String, IFormatProvider ), and\n" + - " Single.Parse( String, NumberStyles, " + - "IFormatProvider )\ngenerates the " + - "following output when run in the [{0}] culture.", - CultureInfo.CurrentCulture.Name ); - Console.WriteLine( "Several string representations " + - "of Single values are parsed." ); - - // Do not use IFormatProvider or NumberStyles. - Console.WriteLine( "\nNumberStyles and IFormatProvider " + - "are not used; current culture is [{0}]:", - CultureInfo.CurrentCulture.Name ); - SingleParse( ( (NumberStyles)( -1 ) ), null ); - - // Use the NumberStyle for Currency. - Console.WriteLine( "\nNumberStyles.Currency " + - "is used; IFormatProvider is not used:" ); - SingleParse( NumberStyles.Currency, null ); - - // Create a CultureInfo object for another culture. Use - // [Dutch - The Netherlands] unless the current culture - // is Dutch language. In that case use [English - U.S.]. - string cultureName = - CultureInfo.CurrentCulture.Name.Substring( 0, 2 ) == "nl" ? - "en-US" : "nl-NL"; - CultureInfo culture = new CultureInfo( cultureName ); - - Console.WriteLine( "\nNumberStyles is not used; " + - "[{0}] culture IFormatProvider is used:", - culture.Name ); - SingleParse( ( (NumberStyles)( -1 ) ), culture ); - - // Get the NumberFormatInfo object from CultureInfo, and - // then change the digit group size to 2 and the digit - // separator to '_'. - NumberFormatInfo numInfo = culture.NumberFormat; - numInfo.NumberGroupSizes = new int[ ] { 2 }; - numInfo.NumberGroupSeparator = "_"; - - // Use the NumberFormatInfo object as the IFormatProvider. - Console.WriteLine( "\nNumberStyles.Currency is used, " + - "group size = 2, separator = \"_\":" ); - SingleParse( NumberStyles.Currency, numInfo ); - } -} - -/* -This example of - Single.Parse( String ), - Single.Parse( String, NumberStyles ), - Single.Parse( String, IFormatProvider ), and - Single.Parse( String, NumberStyles, IFormatProvider ) -generates the following output when run in the [en-US] culture. -Several string representations of Single values are parsed. - -NumberStyles and IFormatProvider are not used; current culture is [en-US]: - Parse of " 987.654E-2" success: 9.87654 - Parse of " 987,654E-2" success: 9876.54 - Parse of "(98765,43210)" failed: FormatException - Parse of "9,876,543.210" success: 9876543 - Parse of "9.876.543,210" failed: FormatException - Parse of "98_76_54_32,19" failed: FormatException - -NumberStyles.Currency is used; IFormatProvider is not used: - Parse of " 987.654E-2" failed: FormatException - Parse of " 987,654E-2" failed: FormatException - Parse of "(98765,43210)" success: -9.876543E+09 - Parse of "9,876,543.210" success: 9876543 - Parse of "9.876.543,210" failed: FormatException - Parse of "98_76_54_32,19" failed: FormatException - -NumberStyles is not used; [nl-NL] culture IFormatProvider is used: - Parse of " 987.654E-2" success: 9876.54 - Parse of " 987,654E-2" success: 9.87654 - Parse of "(98765,43210)" failed: FormatException - Parse of "9,876,543.210" failed: FormatException - Parse of "9.876.543,210" success: 9876543 - Parse of "98_76_54_32,19" failed: FormatException - -NumberStyles.Currency is used, group size = 2, separator = "_": - Parse of " 987.654E-2" failed: FormatException - Parse of " 987,654E-2" failed: FormatException - Parse of "(98765,43210)" success: -98765.43 - Parse of "9,876,543.210" failed: FormatException - Parse of "9.876.543,210" success: 9876543 - Parse of "98_76_54_32,19" success: 9.876543E+07 -*/ -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable1.cs b/snippets/csharp/System/String/IndexOf/ignorable1.cs deleted file mode 100644 index 44549f12460..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable1.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD")); - Console.WriteLine(s2.IndexOf("\u00AD")); - - // Find the index of the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn")); - Console.WriteLine(s2.IndexOf("\u00ADn")); - - // Find the index of the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm")); - Console.WriteLine(s2.IndexOf("\u00ADm")); - } -} -// The example displays the following output if run under -// .NET 4 or later: -// 0 -// 0 -// 1 -// 1 -// 4 -// 3 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable10.cs b/snippets/csharp/System/String/IndexOf/ignorable10.cs deleted file mode 100644 index a0f7341c51b..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable10.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, s1.Length - position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, s1.Length - position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, s1.Length - position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, s2.Length - position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable12.cs b/snippets/csharp/System/String/IndexOf/ignorable12.cs deleted file mode 100644 index 1a69627a260..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable12.cs +++ /dev/null @@ -1,124 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, - s1.Length - position, StringComparison.CurrentCulture)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, - s2.Length - position, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, - s1.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, - s2.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, - s1.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, - s2.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, - s1.Length - position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, - s2.Length - position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, - s1.Length - position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, - s2.Length - position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, - s1.Length - position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, - s2.Length - position, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable5.cs b/snippets/csharp/System/String/IndexOf/ignorable5.cs deleted file mode 100644 index 7cd507e85d4..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable5.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - Console.WriteLine("Culture-sensitive comparison:"); - // Use culture-sensitive comparison to find the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.CurrentCulture)); - - Console.WriteLine("Ordinal comparison:"); - // Use ordinal comparison to find the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.Ordinal)); - - // Use ordinal comparison to find the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.Ordinal)); - - // Use ordinal comparison to find the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparison: -// 0 -// 0 -// 1 -// 1 -// 4 -// 3 -// Ordinal comparison: -// 3 -// -1 -// -1 -// -1 -// 3 -// -1 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable6.cs b/snippets/csharp/System/String/IndexOf/ignorable6.cs deleted file mode 100644 index 2f96426aa85..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable6.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable9.cs b/snippets/csharp/System/String/IndexOf/ignorable9.cs deleted file mode 100644 index 33ce8550f14..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable9.cs +++ /dev/null @@ -1,113 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable1.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable1.cs deleted file mode 100644 index 036f569571a..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable1.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the last soft hyphen. - Console.WriteLine(s1.LastIndexOf("\u00AD")); - Console.WriteLine(s2.LastIndexOf("\u00AD")); - - // Find the index of the last soft hyphen followed by "n". - Console.WriteLine(s1.LastIndexOf("\u00ADn")); - Console.WriteLine(s2.LastIndexOf("\u00ADn")); - - // Find the index of the last soft hyphen followed by "m". - Console.WriteLine(s1.LastIndexOf("\u00ADm")); - Console.WriteLine(s2.LastIndexOf("\u00ADm")); - } -} -// The example displays the following output: -// 6 -// 5 -// 1 -// 1 -// 4 -// 3 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable10.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable10.cs deleted file mode 100644 index 41431515a47..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable10.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, position + 1)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, position + 1)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, position + 1)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, position + 1)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, position + 1)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, position + 1)); - } -} -// The example displays the following output: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable12.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable12.cs deleted file mode 100644 index f2ba187d07b..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable12.cs +++ /dev/null @@ -1,124 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, - position + 1, StringComparison.CurrentCulture)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, - position + 1, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, - position + 1, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, - position + 1, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// -// Ordinal comparisons: -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable5.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable5.cs deleted file mode 100644 index cbbfc8b7ae6..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable5.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - Console.WriteLine("Culture-sensitive comparison:"); - // Use culture-sensitive comparison to find the last soft hyphen. - Console.WriteLine(s1.LastIndexOf("\u00AD", StringComparison.CurrentCulture)); - Console.WriteLine(s2.LastIndexOf("\u00AD", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the last soft hyphen followed by "n". - Console.WriteLine(s1.LastIndexOf("\u00ADn", StringComparison.CurrentCulture)); - Console.WriteLine(s2.LastIndexOf("\u00ADn", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the last soft hyphen followed by "m". - Console.WriteLine(s1.LastIndexOf("\u00ADm", StringComparison.CurrentCulture)); - Console.WriteLine(s2.LastIndexOf("\u00ADm", StringComparison.CurrentCulture)); - - Console.WriteLine("Ordinal comparison:"); - // Use ordinal comparison to find the last soft hyphen. - Console.WriteLine(s1.LastIndexOf("\u00AD", StringComparison.Ordinal)); - Console.WriteLine(s2.LastIndexOf("\u00AD", StringComparison.Ordinal)); - - // Use ordinal comparison to find the last soft hyphen followed by "n". - Console.WriteLine(s1.LastIndexOf("\u00ADn", StringComparison.Ordinal)); - Console.WriteLine(s2.LastIndexOf("\u00ADn", StringComparison.Ordinal)); - - // Use ordinal comparison to find the last soft hyphen followed by "m". - Console.WriteLine(s1.LastIndexOf("\u00ADm", StringComparison.Ordinal)); - Console.WriteLine(s2.LastIndexOf("\u00ADm", StringComparison.Ordinal)); - } -} -// The example displays the following output: -// 6 -// 5 -// 1 -// 1 -// 4 -// 3 -// Ordinal comparison: -// 3 -// -1 -// -1 -// -1 -// 3 -// -1 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable6.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable6.cs deleted file mode 100644 index 782797e58b0..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable6.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position)); - } -} -// The example displays the following output: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable9.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable9.cs deleted file mode 100644 index 9d973f97023..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable9.cs +++ /dev/null @@ -1,113 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// -// Ordinal comparisons: -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// -1 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// diff --git a/snippets/csharp/System/TimeSpan/Overview/instantiate1.cs b/snippets/csharp/System/TimeSpan/Overview/instantiate1.cs deleted file mode 100644 index a2b58defd48..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/instantiate1.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - Implicit(); - Console.WriteLine(); - Explicit(); - Console.WriteLine(); - TimeSpanOperation(); - Console.WriteLine(); - Parse(); - Console.WriteLine(); - } - - private static void Implicit() - { - // - TimeSpan interval = new TimeSpan(); - Console.WriteLine(interval.Equals(TimeSpan.Zero)); // Displays "True". - // - } - - private static void Explicit() - { - // - TimeSpan interval = new TimeSpan(2, 14, 18); - Console.WriteLine(interval.ToString()); - - // Displays "02:14:18". - // - } - - private static void TimeSpanOperation() - { - // - DateTime departure = new DateTime(2010, 6, 12, 18, 32, 0); - DateTime arrival = new DateTime(2010, 6, 13, 22, 47, 0); - TimeSpan travelTime = arrival - departure; - Console.WriteLine("{0} - {1} = {2}", arrival, departure, travelTime); - - // The example displays the following output: - // 6/13/2010 10:47:00 PM - 6/12/2010 6:32:00 PM = 1.04:15:00 - // - } - - private static void Parse() - { - // - string[] values = { "12", "31.", "5.8:32:16", "12:12:15.95", ".12"}; - foreach (string value in values) - { - try { - TimeSpan ts = TimeSpan.Parse(value); - Console.WriteLine("'{0}' --> {1}", value, ts); - } - catch (FormatException) { - Console.WriteLine("Unable to parse '{0}'", value); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is outside the range of a TimeSpan.", value); - } - } - - // The example displays the following output: - // '12' --> 12.00:00:00 - // Unable to parse '31.' - // '5.8:32:16' --> 5.08:32:16 - // '12:12:15.95' --> 12:12:15.9500000 - // Unable to parse '.12' - // - } -} diff --git a/snippets/csharp/System/TimeSpan/Overview/legacycode1.cs b/snippets/csharp/System/TimeSpan/Overview/legacycode1.cs deleted file mode 100644 index f41ded0b18b..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/legacycode1.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - ShowFormattingCode(); - // Output from .NET Framework 3.5 and earlier versions: - // 12:30:45 - // Output from .NET Framework 4: - // Invalid Format - - Console.WriteLine("---"); - - ShowParsingCode(); - // Output: - // 000000006 --> 6.00:00:00 - - void ShowFormattingCode() - { - TimeSpan interval = new TimeSpan(12, 30, 45); - string output; - try { - output = String.Format("{0:r}", interval); - } - catch (FormatException) { - output = "Invalid Format"; - } - Console.WriteLine(output); - } - - void ShowParsingCode() - { - string value = "000000006"; - try { - TimeSpan interval = TimeSpan.Parse(value); - Console.WriteLine("{0} --> {1}", value, interval); - } - catch (FormatException) { - Console.WriteLine("{0}: Bad Format", value); - } - catch (OverflowException) { - Console.WriteLine("{0}: Overflow", value); - } - } - // - } -} diff --git a/snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs b/snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs deleted file mode 100644 index 70c6359fe96..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - AppDomainSetup appSetup = new AppDomainSetup(); - appSetup.SetCompatibilitySwitches( new string[] { "NetFx40_TimeSpanLegacyFormatMode" } ); - AppDomain legacyDomain = AppDomain.CreateDomain("legacyDomain", - null, appSetup); - legacyDomain.ExecuteAssembly("ShowTimeSpan.exe"); - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/TimeSpan/Overview/showtimespan.cs b/snippets/csharp/System/TimeSpan/Overview/showtimespan.cs deleted file mode 100644 index f134c4f0573..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/showtimespan.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - TimeSpan interval = DateTime.Now - DateTime.Now.Date; - string msg = String.Format("Elapsed Time Today: {0:d} hours.", - interval); - Console.WriteLine(msg); - } -} -// The example displays the following output: -// Elapsed Time Today: 01:40:52.2524662 hours. -// \ No newline at end of file diff --git a/snippets/csharp/System/TimeSpan/Overview/zero1.cs b/snippets/csharp/System/TimeSpan/Overview/zero1.cs deleted file mode 100644 index 02e32a707bb..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/zero1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - Random rnd = new Random(); - - TimeSpan timeSpent = TimeSpan.Zero; - - timeSpent += GetTimeBeforeLunch(); - timeSpent += GetTimeAfterLunch(); - - Console.WriteLine("Total time: {0}", timeSpent); - - TimeSpan GetTimeBeforeLunch() - { - return new TimeSpan(rnd.Next(3, 6), 0, 0); - } - - TimeSpan GetTimeAfterLunch() - { - return new TimeSpan(rnd.Next(3, 6), 0, 0); - } - - // The example displays output like the following: - // Total time: 08:00:00 - // - } -} diff --git a/snippets/csharp/System/TimeSpan/ToString/ToString2.cs b/snippets/csharp/System/TimeSpan/ToString/ToString2.cs deleted file mode 100644 index 8df19c7df4d..00000000000 --- a/snippets/csharp/System/TimeSpan/ToString/ToString2.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -using System; - -public class ToString -{ - public static void Main() - { - TimeSpan span; - - // Initialize a time span to zero. - span = TimeSpan.Zero; - Console.WriteLine(FormatTimeSpan(span, true)); - - // Initialize a time span to 14 days. - span = new TimeSpan(-14, 0, 0, 0, 0); - Console.WriteLine(FormatTimeSpan(span, true)); - - // Initialize a time span to 1:02:03. - span = new TimeSpan(1, 2, 3); - Console.WriteLine(FormatTimeSpan(span, false)); - - // Initialize a time span to 250 milliseconds. - span = new TimeSpan(0, 0, 0, 0, 250); - Console.WriteLine(FormatTimeSpan(span, true)); - - // Initialize a time span to 99 days, 23 hours, 59 minutes, and 59.9999999 seconds. - span = new TimeSpan(99, 23, 59, 59, 999); - Console.WriteLine(FormatTimeSpan(span, false)); - - // Initialize a timespan to 25 milliseconds. - span = new TimeSpan(0, 0, 0, 0, 25); - Console.WriteLine(FormatTimeSpan(span, false)); - } - - private static string FormatTimeSpan(TimeSpan span, bool showSign) - { - string sign = String.Empty; - if (showSign && (span > TimeSpan.Zero)) - sign = "+"; - - return sign + span.Days.ToString("00") + "." + - span.Hours.ToString("00") + ":" + - span.Minutes.ToString("00") + ":" + - span.Seconds.ToString("00") + "." + - span.Milliseconds.ToString("000"); - } -} -// This example displays the following output: -// 00.00:00:00.000 -// -14.00:00:00.000 -// 00.01:02:03.000 -// +00.00:00:00.250 -// 99.23:59:59.999 -// 00.00:00:00.025 -// diff --git a/snippets/csharp/System/Type/FullName/remarks.cs b/snippets/csharp/System/Type/FullName/remarks.cs deleted file mode 100644 index 30aaf98c27b..00000000000 --- a/snippets/csharp/System/Type/FullName/remarks.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -// -public class Base { } -public class Derived : Base { } -// - -class ProgStubClass -{ - public static void Main() {} -} \ No newline at end of file diff --git a/snippets/csharp/System/Type/GetType/yourassembly.cs b/snippets/csharp/System/Type/GetType/yourassembly.cs deleted file mode 100644 index d0eeb5002d9..00000000000 --- a/snippets/csharp/System/Type/GetType/yourassembly.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; -using System.Reflection; -[assembly:AssemblyVersion("1.0.0.0")] -namespace YourNamespace -{ - public class YourType {} -} \ No newline at end of file diff --git a/snippets/csharp/System/Type/Overview/Equals1.cs b/snippets/csharp/System/Type/Overview/Equals1.cs deleted file mode 100644 index 9a6219c45a9..00000000000 --- a/snippets/csharp/System/Type/Overview/Equals1.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - long number1 = 1635429; - int number2 = 16203; - double number3 = 1639.41; - long number4 = 193685412; - - // Get the type of number1. - Type t = number1.GetType(); - - // Compare types of all objects with number1. - Console.WriteLine("Type of number1 and number2 are equal: {0}", - Object.ReferenceEquals(t, number2.GetType())); - Console.WriteLine("Type of number1 and number3 are equal: {0}", - Object.ReferenceEquals(t, number3.GetType())); - Console.WriteLine("Type of number1 and number4 are equal: {0}", - Object.ReferenceEquals(t, number4.GetType())); - - // The example displays the following output: - // Type of number1 and number2 are equal: False - // Type of number1 and number3 are equal: False - // Type of number1 and number4 are equal: True - // - } -} diff --git a/snippets/csharp/System/Type/Overview/GetType1.cs b/snippets/csharp/System/Type/Overview/GetType1.cs deleted file mode 100644 index 54feeda6386..00000000000 --- a/snippets/csharp/System/Type/Overview/GetType1.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - object[] values = { "word", true, 120, 136.34, 'a' }; - foreach (var value in values) - Console.WriteLine("{0} - type {1}", value, - value.GetType().Name); - - // The example displays the following output: - // word - type String - // True - type Boolean - // 120 - type Int32 - // 136.34 - type Double - // a - type Char - // - } -} diff --git a/snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs b/snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs deleted file mode 100644 index b2c1d09a6fb..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Person p = new Person("John", "Doe"); - Console.WriteLine(p); - } -} - -public class Person -{ - static InfoModule infoModule; - - String fName; - String mName; - String lName; - - static Person() - { - infoModule = new InfoModule(DateTime.UtcNow); - } - - public Person(String fName, String lName) - { - this.fName = fName; - this.lName = lName; - infoModule.Increment(); - } - - public override String ToString() - { - return String.Format("{0} {1}", fName, lName); - } -} -// The example displays the following output if missing1a.dll is renamed or removed: -// Unhandled Exception: System.TypeInitializationException: -// The type initializer for 'Person' threw an exception. ---> -// System.IO.FileNotFoundException: Could not load file or assembly -// 'Missing1a, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' -// or one of its dependencies. The system cannot find the file specified. -// at Person..cctor() -// --- End of inner exception stack trace --- -// at Person..ctor(String fName, String lName) -// at Example.Main() -// diff --git a/snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs b/snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs deleted file mode 100644 index 56903779fba..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; - -public class InfoModule -{ - private DateTime firstUse; - private int ctr = 0; - - public InfoModule(DateTime dat) - { - firstUse = dat; - } - - public int Increment() - { - return ++ctr; - } - - public DateTime GetInitializationTime() - { - return firstUse; - } -} -// diff --git a/snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs b/snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs deleted file mode 100644 index ce73d8fa914..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - AppDomain domain = AppDomain.CurrentDomain; - // Set a timeout interval of -2 seconds. - domain.SetData("REGEX_DEFAULT_MATCH_TIMEOUT", TimeSpan.FromSeconds(-2)); - - Regex rgx = new Regex("[aeiouy]"); - Console.WriteLine("Regular expression pattern: {0}", rgx.ToString()); - Console.WriteLine("Timeout interval for this regex: {0} seconds", - rgx.MatchTimeout.TotalSeconds); - } -} -// The example displays the following output: -// Unhandled Exception: System.TypeInitializationException: -// The type initializer for 'System.Text.RegularExpressions.Regex' threw an exception. ---> -// System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. -// Parameter name: AppDomain data 'REGEX_DEFAULT_MATCH_TIMEOUT' contains an invalid value or -// object for specifying a default matching timeout for System.Text.RegularExpressions.Regex. -// at System.Text.RegularExpressions.Regex.InitDefaultMatchTimeout() -// at System.Text.RegularExpressions.Regex..cctor() -// --- End of inner exception stack trace --- -// at System.Text.RegularExpressions.Regex..ctor(String pattern) -// at Example.Main() -// diff --git a/snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs b/snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs deleted file mode 100644 index f8b8e1b478a..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; - -public class Example -{ - private static TestClass test = new TestClass(3); - - public static void Main() - { - Example ex = new Example(); - Console.WriteLine(test.Value); - } -} - -public class TestClass -{ - public readonly int Value; - - public TestClass(int value) - { - if (value < 0 || value > 1) throw new ArgumentOutOfRangeException(); - Value = value; - } -} -// The example displays the following output: -// Unhandled Exception: System.TypeInitializationException: -// The type initializer for 'Example' threw an exception. ---> -// System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. -// at TestClass..ctor(Int32 value) -// at Example..cctor() -// --- End of inner exception stack trace --- -// at Example.Main() -// diff --git a/snippets/csharp/System/UInt16/Parse/parseex1.cs b/snippets/csharp/System/UInt16/Parse/parseex1.cs deleted file mode 100644 index a18bb39d180..00000000000 --- a/snippets/csharp/System/UInt16/Parse/parseex1.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -using System; - -public class Temperature -{ - internal ushort n_value; - internal string s_value; - - // Parses a string in the form [ws][sign]digits['F|'C][ws] - public static Temperature Parse(string s) - { - Temperature temp = new Temperature(); - - if (s == null) - throw new ArgumentNullException("s"); - - s = s.TrimEnd(); - temp.s_value = s; - if (s.EndsWith("'F") | s.EndsWith("'C")) - { - temp.Value = UInt16.Parse(s.Remove(s.LastIndexOf("'"), 2) ); - } - else - { - try { - temp.Value = UInt16.Parse(s); - } - catch (FormatException e) { - throw new FormatException(String.Format("{0} is an invalid temperature.", s), e); - } - catch (OverflowException e) { - throw new OverflowException(String.Format("{0} is out of range.", s), e); - } - } - - return temp; - } - - public ushort Value - { - get { return n_value; } - set { this.n_value = value; } - } -} -// - -// -public class Example -{ - public static void Main() - { - string[] values = { "32'F", "32'C", "16", "-0", "-12", "", null }; - foreach (string value in values) - { - try { - Temperature tmp = Temperature.Parse(value); - Console.WriteLine(tmp.Value); - } - catch (FormatException) { - Console.WriteLine("'{0}': Invalid Format", value.Trim()); - } - catch (OverflowException) { - Console.WriteLine("{0}: Overflow", value.Trim()); - } - catch (ArgumentNullException e) { - Console.WriteLine("The {0} parameter is null.", e.ParamName); - } - } - } -} -// The example displays the following output: -// 32 -// 32 -// 16 -// 0 -// -12: Overflow -// '': Invalid Format -// The s parameter is null. -// diff --git a/snippets/csharp/System/UInt16/TryParse/tryparse1.cs b/snippets/csharp/System/UInt16/TryParse/tryparse1.cs deleted file mode 100644 index f8110f998c2..00000000000 --- a/snippets/csharp/System/UInt16/TryParse/tryparse1.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - string[] numericStrings = { "1293.8", "+1671.7", "28347.", - " 33113 ", "(0)", "-0", "+12936", - "18-", "9870", "31,024", " 3127 ", - "70000" }; - ushort number; - foreach (string numericString in numericStrings) - { - if (UInt16.TryParse(numericString, out number)) - Console.WriteLine("Converted '{0}' to {1}.", numericString, number); - else - Console.WriteLine("Cannot convert '{0}' to a UInt16.", numericString); - } - // The example displays the following output: - // Cannot convert '1293.8' to a UInt16. - // Cannot convert '+1671.7' to a UInt16. - // Cannot convert '28347.' to a UInt16. - // Converted ' 33113 ' to 33113. - // Cannot convert '(0)' to a UInt16. - // Converted '-0' to 0. - // Converted '+12936' to 12936. - // Cannot convert '18-' to a UInt16. - // Converted '9870' to 9870. - // Cannot convert '31,024' to a UInt16. - // Converted ' 3127 ' to 3127. - // Cannot convert '70000' to a UInt16. - // - } -} diff --git a/snippets/csharp/System/Version/Overview/GettingVersions1.cs b/snippets/csharp/System/Version/Overview/GettingVersions1.cs deleted file mode 100644 index c9cdee4c9b3..00000000000 --- a/snippets/csharp/System/Version/Overview/GettingVersions1.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Reflection; - -[assembly: CLSCompliant(true)] -public class Class1 -{ - public static void Main() - { - Example1 ex1 = new Example1(); - - GetOsVersion(); - Console.WriteLine(); - GetClrVersion(); - Console.WriteLine(); - GetSpecificAssemblyVersion(); - Console.WriteLine(); - ex1.GetExecutingAssemblyVersion(); - Console.WriteLine(); - GetApplicationVersion(); - } - - private static void GetOsVersion() - { - // - // Get the operating system version. - OperatingSystem os = Environment.OSVersion; - Version ver = os.Version; - Console.WriteLine("Operating System: {0} ({1})", os.VersionString, ver.ToString()); - // - } - - private static void GetClrVersion() - { - // - // Get the common language runtime version. - Version ver = Environment.Version; - Console.WriteLine("CLR Version {0}", ver.ToString()); - // - } - - private static void GetSpecificAssemblyVersion() - { - // Get the version of a specific assembly. - string filename = @".\StringLibrary.dll"; - Assembly assem = Assembly.ReflectionOnlyLoadFrom(filename); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } - - private static void GetApplicationVersion() - { - // Get the version of the executing assembly (that is, this assembly). - Assembly assem = Assembly.GetEntryAssembly(); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("Application {0}, Version {1}", assemName.Name, ver.ToString()); - } -} - -public class Example1 -{ - public static void GetExecutingAssemblyVersion() - { - // Get the version of the current application. - Assembly assem = typeof(Example1).Assembly; - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } -} \ No newline at end of file diff --git a/snippets/csharp/System/Version/Overview/clickonce.cs b/snippets/csharp/System/Version/Overview/clickonce.cs deleted file mode 100644 index e05774aa507..00000000000 --- a/snippets/csharp/System/Version/Overview/clickonce.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -using System; -using System.Deployment.Application; - -public class Example -{ - public static void Main() - { - Version ver = ApplicationDeployment.CurrentDeployment.CurrentVersion; - Console.WriteLine("ClickOnce Publish Version: {0}", ver); - } -} -// diff --git a/snippets/csharp/System/Version/Overview/comparisons1.cs b/snippets/csharp/System/Version/Overview/comparisons1.cs deleted file mode 100644 index 40c0aab873e..00000000000 --- a/snippets/csharp/System/Version/Overview/comparisons1.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CompareSimple(); - } - - private static void CompareSimple() - { - // - Version v1 = new Version(2, 0); - Version v2 = new Version("2.1"); - Console.Write("Version {0} is ", v1); - switch(v1.CompareTo(v2)) - { - case 0: - Console.Write("the same as"); - break; - case 1: - Console.Write("later than"); - break; - case -1: - Console.Write("earlier than"); - break; - } - Console.WriteLine(" Version {0}.", v2); - // The example displays the following output: - // Version 2.0 is earlier than Version 2.1. - // - } -} diff --git a/snippets/csharp/System/Version/Overview/comparisons2.cs b/snippets/csharp/System/Version/Overview/comparisons2.cs deleted file mode 100644 index 15310b9ca95..00000000000 --- a/snippets/csharp/System/Version/Overview/comparisons2.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -enum VersionTime {Earlier = -1, Same = 0, Later = 1 }; - -public class Example -{ - public static void Main() - { - Version v1 = new Version(1, 1); - Version v1a = new Version("1.1.0"); - ShowRelationship(v1, v1a); - - Version v1b = new Version(1, 1, 0, 0); - ShowRelationship(v1b, v1a); - } - - private static void ShowRelationship(Version v1, Version v2) - { - Console.WriteLine("Relationship of {0} to {1}: {2}", - v1, v2, (VersionTime) v1.CompareTo(v2)); - } -} -// The example displays the following output: -// Relationship of 1.1 to 1.1.0: Earlier -// Relationship of 1.1.0.0 to 1.1.0: Later -// diff --git a/snippets/csharp/System/Version/Overview/currentapp.cs b/snippets/csharp/System/Version/Overview/currentapp.cs deleted file mode 100644 index 58fc2f22360..00000000000 --- a/snippets/csharp/System/Version/Overview/currentapp.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; -using System.Reflection; - -public class Example -{ - public static void Main() - { - // Get the version of the executing assembly (that is, this assembly). - Assembly assem = Assembly.GetEntryAssembly(); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("Application {0}, Version {1}", assemName.Name, ver.ToString()); - } -} -// diff --git a/snippets/csharp/System/Version/Overview/currentassem.cs b/snippets/csharp/System/Version/Overview/currentassem.cs deleted file mode 100644 index e6e5968ebb0..00000000000 --- a/snippets/csharp/System/Version/Overview/currentassem.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; -using System.Reflection; - -public class Example -{ - public static void Main() - { - // Get the version of the current assembly. - Assembly assem = typeof(Example).Assembly; - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } -} -// diff --git a/snippets/csharp/System/Version/Overview/specificassem.cs b/snippets/csharp/System/Version/Overview/specificassem.cs deleted file mode 100644 index 9a9ac7b8491..00000000000 --- a/snippets/csharp/System/Version/Overview/specificassem.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; -using System.Reflection; - -public class Example -{ - public static void Main() - { - // Get the version of a specific assembly. - string filename = @".\StringLibrary.dll"; - Assembly assem = Assembly.ReflectionOnlyLoadFrom(filename); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } -} -// From 08cc288f511d2ec399f862e9a00f8bb67d1138f8 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:04:31 +0200 Subject: [PATCH 3/8] remove extra para tag --- xml/System/TimeZone.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System/TimeZone.xml b/xml/System/TimeZone.xml index 55e1d8cbf57..6c0ba7d35c7 100644 --- a/xml/System/TimeZone.xml +++ b/xml/System/TimeZone.xml @@ -593,7 +593,7 @@ ]]> - Although it is not required, in most cases derived classes running under .NET Framework version 2.0 or later should override the default implementation of this method. The behavior of the default implementation depends on the property of the parameter. If its value is , this method returns unchanged. If its value is either or , this method assumes is UTC and converts it to the local system time without calling the method. + Although it is not required, in most cases derived classes should override the default implementation of this method. The behavior of the default implementation depends on the property of the parameter. If its value is , this method returns unchanged. If its value is either or , this method assumes is UTC and converts it to the local system time without calling the method. From a2393544e11fd5887cd6abf7e070bc68867a66d6 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:27:22 +0200 Subject: [PATCH 4/8] reinstate 1 snippet file --- .../ZipFile/CreateFromDirectory/program3.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs diff --git a/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs b/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs new file mode 100644 index 00000000000..f866647919c --- /dev/null +++ b/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs @@ -0,0 +1,19 @@ +// +using System; +using System.IO; +using System.IO.Compression; + +namespace ConsoleApplication +{ + class Program + { + static void Main(string[] args) + { + string startPath = @"c:\example\start"; + string zipPath = @"c:\example\result.zip"; + + ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true); + } + } +} +// \ No newline at end of file From e4de503f623ba5c2d52481a800842332d2e25399 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:58:01 +0200 Subject: [PATCH 5/8] delete makefiles --- .../CodeCompileUnit/Overview/makefile | 7 ------- .../DefineUnmanagedResource/makefile | 10 --------- .../DefineUnmanagedResource/makefile1 | 10 --------- .../Overview/makefile | 14 ------------- .../AssemblyName/Flags/makefile | 10 --------- .../IpcClientChannel/.ctor/makefile | 12 ----------- .../Overview/makefile | 10 --------- .../IsRemotelyActivatedClientType/makefile | 11 ---------- .../IsRemotelyActivatedClientType/makefile1 | 11 ---------- .../IsWellKnownClientType/makefile | 11 ---------- .../IsWellKnownClientType/makefile1 | 11 ---------- .../Overview/makefile | 9 -------- .../WorkflowHostingEndpoint/Overview/makefile | 4 ---- .../System/IAsyncResult/Overview/makefile | 21 ------------------- snippets/csharp/System/IntPtr/Add/makefile | 4 ---- .../csharp/System/IntPtr/Subtract/makefile | 4 ---- .../csharp/System/IntPtr/op_Addition/makefile | 8 ------- snippets/csharp/System/String/.ctor/makefile | 4 ---- .../System/Type/HasElementType/makefile | 2 -- 19 files changed, 173 deletions(-) delete mode 100644 snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile delete mode 100644 snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile delete mode 100644 snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 delete mode 100644 snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile delete mode 100644 snippets/csharp/System.Reflection/AssemblyName/Flags/makefile delete mode 100644 snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile delete mode 100644 snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile delete mode 100644 snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 delete mode 100644 snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile delete mode 100644 snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile delete mode 100644 snippets/csharp/System/IAsyncResult/Overview/makefile delete mode 100644 snippets/csharp/System/IntPtr/Add/makefile delete mode 100644 snippets/csharp/System/IntPtr/Subtract/makefile delete mode 100644 snippets/csharp/System/IntPtr/op_Addition/makefile delete mode 100644 snippets/csharp/System/String/.ctor/makefile delete mode 100644 snippets/csharp/System/Type/HasElementType/makefile diff --git a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile b/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile deleted file mode 100644 index c9949278a80..00000000000 --- a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: source.dll source2.dll - -source.dll : source.cs - csc source.cs /r:Microsoft.jscript.dll - -source2.dll : source2.cs - csc source2.cs diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile deleted file mode 100644 index 581717571b4..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all : assemblybuilder_defineunmanagedresource.exe EmittedTest2.exe - -assemblybuilder_defineunmanagedresource.exe : assemblybuilder_defineunmanagedresource.cs - csc assemblybuilder_defineunmanagedresource.cs - -MyEmitTestAssembly.dll : assemblybuilder_defineunmanagedresource.exe - assemblybuilder_defineunmanagedresource.exe - -EmittedTest2.exe : MyEmitTestAssembly.dll EmittedTest2.cs - csc /r:MyEmitTestAssembly.dll EmittedTest2.cs \ No newline at end of file diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 deleted file mode 100644 index 42a8f53f84d..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 +++ /dev/null @@ -1,10 +0,0 @@ -all : assemblybuilder_defineunmanagedresource2.exe EmittedTest3.exe - -assemblybuilder_defineunmanagedresource2.exe : assemblybuilder_defineunmanagedresource2.cs - csc assemblybuilder_defineunmanagedresource2.cs - -MyEmitTestAssembly.dll : assemblybuilder_defineunmanagedresource2.exe - assemblybuilder_defineunmanagedresource2.exe - -EmittedTest3.exe : MyEmitTestAssembly.dll EmittedTest3.cs - csc /r:MyEmitTestAssembly.dll EmittedTest3.cs \ No newline at end of file diff --git a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile b/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile deleted file mode 100644 index 095c5d3c69a..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile +++ /dev/null @@ -1,14 +0,0 @@ -all: source.dll source2.dll - -source.dll: TestPublicKey.snk source.cs - csc /t:library source.cs - -TestPublicKey.snk: - sn -k TestPublicKey.snk - -source2.dll: myKey.snk source2.cs - csc /t:library source2.cs - -myKey.snk: - sn -k myKey.snk - diff --git a/snippets/csharp/System.Reflection/AssemblyName/Flags/makefile b/snippets/csharp/System.Reflection/AssemblyName/Flags/makefile deleted file mode 100644 index 1afe090101e..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyName/Flags/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: assemblyname_keypair.exe KeyFileAttrib.exe - -assemblyname_keypair.exe: assemblyname_keypair.cs - csc /target:exe assemblyname_keypair.cs - -KeyFileAttrib.exe: keyfile.snk KeyFileAttrib.cs - csc /target:exe KeyFileAttrib.cs - -keyfile.snk: - sn -k keyfile.snk \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile b/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile deleted file mode 100644 index d5f2addf79e..00000000000 --- a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: common.dll client.dll client2.dll server.dll - -common.dll: common.cs - csc /t:library common.cs - -server.dll: server.cs common.dll - CS>csc /t:library server.cs /r:common.dll - -client.dll: client.cs common.dll - csc /t:library server.cs /r:common.dll -client2.dll: client2.cs common.dll - csc /t:library client2.cs /r:common.dll \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile b/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile deleted file mode 100644 index 5b86eeda7f0..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: ActivatedServiceTypeEntry_ObjectType_Server.exe ActivatedServiceTypeEntry_ObjectType_Client.exe - -ActivatedServiceTypeEntry_ObjectType_Server.exe: ActivatedServiceTypeEntry_ObjectType_Server.cs ActivatedServiceTypeEntry_ObjectType_Share.dll - csc ActivatedServiceTypeEntry_ObjectType_Server.cs /r:ActivatedServiceTypeEntry_ObjectType_Share.dll - -ActivatedServiceTypeEntry_ObjectType_Client.exe: ActivatedServiceTypeEntry_ObjectType_Client.cs ActivatedServiceTypeEntry_ObjectType_Share.dll - csc ActivatedServiceTypeEntry_ObjectType_Client.cs /r:ActivatedServiceTypeEntry_ObjectType_Share.dll - -ActivatedServiceTypeEntry_ObjectType_Share.dll: ActivatedServiceTypeEntry_ObjectType_Share.cs - csc /t:library ActivatedServiceTypeEntry_ObjectType_Share.cs diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile deleted file mode 100644 index 4d13cb1ef9a..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsRemotelyActivatedClientType1_server.exe RemotingConfiguration_IsRemotelyActivatedClientType1_client.exe RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll - -RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll : RemotingConfiguration_IsRemotelyActivatedClientType1_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsRemotelyActivatedClientType1_shared.cs - -RemotingConfiguration_IsRemotelyActivatedClientType1_server.exe : RemotingConfiguration_IsRemotelyActivatedClientType1_server.cs RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll RemotingConfiguration_IsRemotelyActivatedClientType1_server.cs - -RemotingConfiguration_IsRemotelyActivatedClientType1_client.exe : RemotingConfiguration_IsRemotelyActivatedClientType1_client.cs RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll RemotingConfiguration_IsRemotelyActivatedClientType1_client.cs - diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 deleted file mode 100644 index b2cf2345b9a..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsRemotelyActivatedClienttype2_server.exe RemotingConfiguration_IsRemotelyActivatedClienttype2_client.exe RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll - -RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll : RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.cs - -RemotingConfiguration_IsRemotelyActivatedClienttype2_server.exe : RemotingConfiguration_IsRemotelyActivatedClienttype2_server.cs RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll RemotingConfiguration_IsRemotelyActivatedClienttype2_server.cs - -RemotingConfiguration_IsRemotelyActivatedClienttype2_client.exe : RemotingConfiguration_IsRemotelyActivatedClienttype2_client.cs RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll RemotingConfiguration_IsRemotelyActivatedClienttype2_client.cs - diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile deleted file mode 100644 index 05a666573bb..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsWellKnownClientType1_server.exe RemotingConfiguration_IsWellKnownClientType1_client.exe RemotingConfiguration_IsWellKnownClientType1_shared.dll - -RemotingConfiguration_IsWellKnownClientType1_shared.dll : RemotingConfiguration_IsWellKnownClientType1_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsWellKnownClientType1_shared.cs - -RemotingConfiguration_IsWellKnownClientType1_server.exe : RemotingConfiguration_IsWellKnownClientType1_server.cs RemotingConfiguration_IsWellKnownClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType1_shared.dll RemotingConfiguration_IsWellKnownClientType1_server.cs - -RemotingConfiguration_IsWellKnownClientType1_client.exe : RemotingConfiguration_IsWellKnownClientType1_client.cs RemotingConfiguration_IsWellKnownClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType1_shared.dll RemotingConfiguration_IsWellKnownClientType1_client.cs - diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 deleted file mode 100644 index fa6e448de00..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsWellKnownClientType2_server.exe RemotingConfiguration_IsWellKnownClientType2_client.exe RemotingConfiguration_IsWellKnownClientType2_shared.dll - -RemotingConfiguration_IsWellKnownClientType2_shared.dll : RemotingConfiguration_IsWellKnownClientType2_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsWellKnownClientType2_shared.cs - -RemotingConfiguration_IsWellKnownClientType2_server.exe : RemotingConfiguration_IsWellKnownClientType2_server.cs RemotingConfiguration_IsWellKnownClientType2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType2_shared.dll RemotingConfiguration_IsWellKnownClientType2_server.cs - -RemotingConfiguration_IsWellKnownClientType2_client.exe : RemotingConfiguration_IsWellKnownClientType2_client.cs RemotingConfiguration_IsWellKnownClientType2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType2_shared.dll RemotingConfiguration_IsWellKnownClientType2_client.cs - diff --git a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile b/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile deleted file mode 100644 index 09a286afe5d..00000000000 --- a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: NameIdPermission.dll NameIdPermissionAttribute.dll - -NameIdPermission.dll : nameidpermission.cs - csc /t:library nameidpermission.cs - -NameIdPermissionAttribute.dll : nameidpermissionattribute.cs - csc /t:library nameidpermissionattribute.cs /r:NameIdPermission.dll - - diff --git a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile b/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile deleted file mode 100644 index ffc017aa3aa..00000000000 --- a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: CreationEndpoint.exe - -CreationEndpoint.exe: CreationEndpoint.cs CreationEndpointElement.cs Program.cs - csc /t:exe *.cs /r:System.ServiceModel.dll /r:System.ServiceModel.Activities.dll /r:System.Activities.dll \ No newline at end of file diff --git a/snippets/csharp/System/IAsyncResult/Overview/makefile b/snippets/csharp/System/IAsyncResult/Overview/makefile deleted file mode 100644 index 6ebfe1d3c97..00000000000 --- a/snippets/csharp/System/IAsyncResult/Overview/makefile +++ /dev/null @@ -1,21 +0,0 @@ -all: testMethod.dll EndInvoke.exe WaitHandle.exe polling.exe Callback.exe - -testMethod.dll: testmethod.cs - csc /t:library testmethod.cs - - -EndInvoke.exe: endinvoke.cs testMethod.dll - csc /out:endinvoke.exe endinvoke.cs /r:testmethod.dll - - -WaitHandle.exe: waithandle.cs testMethod.dll - csc /out:waithandle.exe waithandle.cs /r:testmethod.dll - -polling.exe: polling.cs testmethod.dll - csc /out:polling.exe polling.cs /r:testmethod.dll - -Callback.exe: Callback.cs testmethod.dll - csc /out:Callback.exe Callback.cs /r:testmethod.dll -clean: - del *.dll - del *.exe \ No newline at end of file diff --git a/snippets/csharp/System/IntPtr/Add/makefile b/snippets/csharp/System/IntPtr/Add/makefile deleted file mode 100644 index ce25ec64d61..00000000000 --- a/snippets/csharp/System/IntPtr/Add/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: Add1.exe - -Add1.exe: Add1.cs - csc /unsafe Add1.cs diff --git a/snippets/csharp/System/IntPtr/Subtract/makefile b/snippets/csharp/System/IntPtr/Subtract/makefile deleted file mode 100644 index d61faa2e849..00000000000 --- a/snippets/csharp/System/IntPtr/Subtract/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: Add1.exe - -Subtract1.exe: Subtract1.cs - csc /unsafe Subtract1.cs diff --git a/snippets/csharp/System/IntPtr/op_Addition/makefile b/snippets/csharp/System/IntPtr/op_Addition/makefile deleted file mode 100644 index 7cff7967e8a..00000000000 --- a/snippets/csharp/System/IntPtr/op_Addition/makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: Addition1.exe op_Subtraction1.exe - -Addition1.exe: Addition1.cs - csc /unsafe Addition1.cs - -op_Subtraction1.exe: op_Subtraction1.cs - csc /unsafe op_Subtraction1.cs - diff --git a/snippets/csharp/System/String/.ctor/makefile b/snippets/csharp/System/String/.ctor/makefile deleted file mode 100644 index f19149e6a0d..00000000000 --- a/snippets/csharp/System/String/.ctor/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all : source.dll - -source.dll : source.cs - csc /t:library /unsafe source.cs \ No newline at end of file diff --git a/snippets/csharp/System/Type/HasElementType/makefile b/snippets/csharp/System/Type/HasElementType/makefile deleted file mode 100644 index 62fd8db0d22..00000000000 --- a/snippets/csharp/System/Type/HasElementType/makefile +++ /dev/null @@ -1,2 +0,0 @@ -type_haselementtype.exe: - csc /unsafe type_haselementtype.cs \ No newline at end of file From 725d29d676cf01ca3eb66e744e8e22f5f643b271 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:15:54 +0200 Subject: [PATCH 6/8] delete VB snippet files --- .../VB/source.vb | 23 --- .../VB/source.vb | 19 -- .../VB/source.vb | 19 -- .../VB/source.vb | 20 -- .../VB/source.vb | 22 --- .../VB/source.vb | 29 --- .../VB/mysample.vb | 30 --- .../VB/mysample.vb | 19 -- .../VB/source.vb | 18 -- .../VB/source.vb | 21 -- .../VB/mysample.vb | 24 --- .../VB/source.vb | 40 ---- .../VB/source.vb | 31 --- .../VB/source.vb | 24 --- .../VB/source.vb | 24 --- .../VB/source.vb | 22 --- .../VB/source.vb | 22 --- .../VB/source.vb | 27 --- .../VB/source.vb | 20 -- .../VB/source.vb | 28 --- .../VB/source.vb | 31 --- .../VB/source.vb | 29 --- .../VB/source.vb | 28 --- .../VB/source.vb | 54 ----- .../VB/source.vb | 32 --- .../ImprovedInteropSnippets/VB/codefile1.vb | 17 -- .../VB/program.vb | 58 ------ .../VB/resourcepermissionbase.vb | 129 ------------ .../SandboxingAPIs/VB/program.vb | 35 ---- .../UnmanagedMarshalObsolete/vb/source.vb | 66 ------- .../classic Delegate Example/VB/source.vb | 59 ------ .../VB/source.vb | 32 --- .../VB/source.vb | 42 ---- .../VB/source.vb | 35 ---- .../VB/source.vb | 19 -- .../VB/source.vb | 24 --- .../VB/source.vb | 32 --- .../vb/split10.vb | 30 --- .../vb/split3.vb | 31 --- .../vb/split7.vb | 36 ---- .../system.TimeZone.Class/VB/tzclass.vb | 73 ------- .../VB/TimeZone_ToLocalTime.vb | 78 -------- .../vb/program3.vb | 15 -- .../VB/source.vb | 45 ----- .../VB/source.vb | 28 --- .../VB/source.vb | 41 ---- .../VB/source.vb | 39 ---- .../VB/source.vb | 28 --- .../VB/source.vb | 47 ----- .../VB/source.vb | 32 --- .../VB/source.vb | 23 --- .../VB/source.vb | 29 --- .../VB/source.vb | 40 ---- .../VB/source.vb | 47 ----- .../VB/source.vb | 24 --- .../VB/source.vb | 53 ----- .../VB/source.vb | 53 ----- .../VB/source.vb | 71 ------- .../VB/source.vb | 50 ----- .../VB/source.vb | 67 ------- .../VB/source.vb | 27 --- .../VB/source.vb | 31 --- .../VB/dataset_trans.vb | 42 ---- .../VB/getrow.vb | 30 --- .../XmlDataDocument.Load/VB/loadrdr.vb | 29 --- .../VB/schemaevent.vb | 30 --- .../VB/schemacolladd.vb | 45 ----- .../XmlSchemaCollection.Basic/VB/aa.vb | 31 --- .../VB/valid_xsd2.vb | 52 ----- .../VB/readdefattr.vb | 30 --- .../VB/schematype.vb | 39 ---- .../VB/vrdr_resolver.vb | 48 ----- .../XslTRansform.Transform7/VB/trans_snip4.vb | 25 --- .../XslTransform.Load2/VB/trans2.vb | 37 ---- .../XslTransform.Load3/VB/trans3.vb | 36 ---- .../XslTransform.Load4/VB/trans_ev.vb | 30 --- .../XslTransform.Load5/VB/trans_noev.vb | 31 --- .../XslTransform.Transform4/VB/trans_snip3.vb | 38 ---- .../XslTransform.Transform6/VB/transstring.vb | 44 ----- .../xsltransform.transform3/VB/trans_snip2.vb | 20 -- .../VB/source.vb | 27 --- .../VB/source.vb | 13 -- ...dateclient_socketpermission_constructor.vb | 154 --------------- .../VB/dateclient_socketpermission_toxml.vb | 185 ------------------ .../VB/dnspermission_constructor.vb | 56 ------ .../VB/dnspermission_copy.vb | 59 ------ .../VB/dnspermission_fromxml.vb | 80 -------- .../VB/dnspermission_issubsetof.vb | 71 ------- .../VB/dnspermission_isunrestricted.vb | 57 ------ .../SocketPermissionExample/VB/source.vb | 107 ---------- .../VB/source.vb | 43 ---- .../webpermissionattribute_acceptconnect.vb | 41 ---- .../VB/source.vb | 49 ----- .../VB/source.vb | 42 ---- .../VB/source.vb | 49 ----- .../VB/source.vb | 43 ---- .../VB/webpermission_acceptconnectlist.vb | 89 --------- .../VB/webpermission_constructor4.vb | 69 ------- .../VB/webpermission_copy.vb | 84 -------- .../VB/webpermission_fromtoxml.vb | 70 ------- .../VB/webpermission_intersect.vb | 93 --------- .../VB/webpermission_issubset.vb | 95 --------- .../WebPermission_IsSubset2/VB/source.vb | 44 ----- .../WebPermission_Regex/VB/regex.vb | 47 ----- .../VB/webpermission_union.vb | 79 -------- .../VB/webrequest_begingetresponse.vb | 128 ------------ .../VB/dnspermission_union_intersect.vb | 77 -------- 107 files changed, 4830 deletions(-) delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split10.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split3.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split7.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.ToLocalTime/VB/TimeZone_ToLocalTime.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.BaseURI Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.GetAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.HasValue Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToFirstAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.CreateNavigator/VB/dataset_trans.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/VB/getrow.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.Cctor/VB/valid_xsd2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.IsDefault/VB/readdefattr.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.SchemaType/VB/schematype.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.XmlResolver/VB/vrdr_resolver.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTransform.Load2/VB/trans2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTransform.Load5/VB/trans_noev.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform6/VB/transstring.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Accept/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/VB/webpermissionattribute_acceptconnect.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Connect/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_AcceptConnectList/VB/webpermission_acceptconnectlist.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Constructor4/VB/webpermission_constructor4.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Copy/VB/webpermission_copy.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_FromToXml/VB/webpermission_fromtoxml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Intersect/VB/webpermission_intersect.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset/VB/webpermission_issubset.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset2/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Regex/VB/regex.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Union/VB/webpermission_union.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetResponse/VB/webrequest_begingetresponse.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb deleted file mode 100644 index c0c899a403c..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb +++ /dev/null @@ -1,23 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleCommand _ - (ByVal queryString As String, ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - command.Connection.Open() - command.ExecuteReader() - command.Cancel() - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb deleted file mode 100644 index 71cc4a0603e..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb +++ /dev/null @@ -1,19 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim command As New OracleCommand() - command.CommandText = "SELECT * FROM Emp ORDER BY EmpNo" - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb deleted file mode 100644 index 71cc4a0603e..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb +++ /dev/null @@ -1,19 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim command As New OracleCommand() - command.CommandText = "SELECT * FROM Emp ORDER BY EmpNo" - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb deleted file mode 100644 index 52d1f71324a..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb +++ /dev/null @@ -1,20 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim queryString As String = _ - "SELECT * FROM Emp ORDER BY EmpNo" - Dim command As New OracleCommand(queryString) - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb deleted file mode 100644 index 316fc9d1c5d..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb +++ /dev/null @@ -1,22 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleCommand(ByVal myExecuteQuery As String, _ - ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(myExecuteQuery, connection) - command.Connection.Open() - command.ExecuteNonQuery() - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb deleted file mode 100644 index cdc86049b48..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb +++ /dev/null @@ -1,29 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateMyOracleDataReader(ByVal queryString As String, _ - ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - connection.Open() - Dim reader As OracleDataReader = command.ExecuteReader() - Try - While reader.Read() - Console.WriteLine(reader.GetValue(0)) - End While - Finally - reader.Close() - End Try - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb deleted file mode 100644 index 8cdcd768f67..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb +++ /dev/null @@ -1,30 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateMyOracleDataReader(ByVal queryString As String, _ - ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - connection.Open() - - 'Implicitly closes the connection because - ' CommandBehavior.CloseConnectionwas specified. - Dim reader As OracleDataReader = _ - command.ExecuteReader(CommandBehavior.CloseConnection) - While reader.Read() - Console.WriteLine(reader.GetValue(0)) - End While - reader.Close() - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb deleted file mode 100644 index ce391bc5c65..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb +++ /dev/null @@ -1,19 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid -' -Public Sub CreateOracleCommand(myScalarQuery As String, connection As OracleConnection) - Dim command As New OracleCommand(myScalarQuery, connection) - command.Connection.Open() - command.ExecuteScalar() - connection.Close() -End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb deleted file mode 100644 index 747d8c46c74..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb +++ /dev/null @@ -1,18 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim command As New OracleCommand() - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb deleted file mode 100644 index 1cfa929c2c4..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb +++ /dev/null @@ -1,21 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim connection As New OracleConnection _ - ("Data Source=Oracle8i;Integrated Security=yes") - Dim queryString As String = _ - "SELECT * FROM Emp ORDER BY EmpNo" - Dim command As New OracleCommand(queryString, connection) - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb deleted file mode 100644 index 9974a10dae6..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb +++ /dev/null @@ -1,24 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleCommand(ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - connection.Open() - Dim transaction As OracleTransaction = connection.BeginTransaction() - Dim queryString As String = _ - "SELECT * FROM Emp ORDER BY EmpNo" - Dim command As New OracleCommand(queryString, connection, transaction) - command.CommandType = CommandType.Text - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb deleted file mode 100644 index 6e0598529f5..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb +++ /dev/null @@ -1,40 +0,0 @@ -Imports System.Data -Imports System.Data.OracleClient - -Module Module1 - - Sub Main() - ' Need to create actual connection code here. - 'Call CreateOracleCommand() - End Sub - - ' - Public Sub CreateOracleCommand(ByVal connection As OracleConnection, _ - ByVal queryString As String, ByVal prmArray() As OracleParameter) - - Dim command As New OracleCommand(queryString, connection) - command.CommandText = _ - "SELECT * FROM Emp WHERE Job = :pJob AND Sal = :pSal" - - Dim j As Integer - For j = 0 To prmArray.Length - 1 - command.Parameters.Add(prmArray(j)) - Next j - - Dim message As String = "" - Dim i As Integer - For i = 0 To command.Parameters.Count - 1 - message += command.Parameters(i).ToString() + ControlChars.Cr - Next i - - Console.WriteLine(message) - - Dim reader As OracleDataReader = command.ExecuteReader - While reader.Read - Console.WriteLine(reader.GetValue(0)) - End While - - End Sub - ' - -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb deleted file mode 100644 index 0571a03b985..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb +++ /dev/null @@ -1,31 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub ReadMyData(ByVal connectionString As String) - Dim queryString As String = "SELECT EmpNo, DeptNo FROM Scott.Emp" - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - connection.Open() - Dim reader As OracleDataReader = command.ExecuteReader() - Try - While reader.Read() - Console.WriteLine(reader.GetInt32(0) & ", " _ - & reader.GetInt32(1)) - End While - Finally - ' always call Close when done reading. - reader.Close() - End Try - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb deleted file mode 100644 index 255df495a87..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleConnection() - Dim connectionString As String = _ - "Data Source=Oracle8i;Integrated Security=yes" - - Using connection As New OracleConnection(connectionString) - connection.Open() - Console.WriteLine("ServerVersion: " + connection.ServerVersion _ - + ControlChars.NewLine + "DataSource: " + connection.DataSource) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb deleted file mode 100644 index 255df495a87..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleConnection() - Dim connectionString As String = _ - "Data Source=Oracle8i;Integrated Security=yes" - - Using connection As New OracleConnection(connectionString) - connection.Open() - Console.WriteLine("ServerVersion: " + connection.ServerVersion _ - + ControlChars.NewLine + "DataSource: " + connection.DataSource) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb deleted file mode 100644 index b2a04f57aa6..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb +++ /dev/null @@ -1,22 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleConnection() - Dim connectionString As String = "Data Source=Oracle8i;Integrated Security=yes" - Using connection As New OracleConnection(connectionString) - connection.Open() - Console.WriteLine("ServerVersion: " & connection.ServerVersion _ - + ControlChars.NewLine + "State: " & connection.State) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb deleted file mode 100644 index 26b50c79bf3..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb +++ /dev/null @@ -1,22 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub createOracleConnection() - Using connection As New OracleConnection() - connection.ConnectionString = _ - "Data Source=Oracle8i;Integrated Security=yes" - connection.Open() - Console.WriteLine("Connection State: " & connection.State) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb deleted file mode 100644 index e76dcabc966..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb +++ /dev/null @@ -1,27 +0,0 @@ -Imports System.Data -Imports System.Data.OracleClient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub InsertRow(ByVal connectionString As String) - Dim queryString As String = _ - "INSERT INTO Dept (DeptNo, Dname, Loc) values (50, 'TECHNOLOGY', 'DENVER')" - - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString) - command.Connection = connection - Try - connection.Open() - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - End Using - End Sub - ' - -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb deleted file mode 100644 index 9124fc7d8cf..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb +++ /dev/null @@ -1,20 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Common -Module Module1 - ' - Sub Main() - Dim builder As New DbConnectionStringBuilder - builder.ConnectionString = _ - "Provider=MSDataShape.1;Persist Security Info=False;" & _ - "Data Provider=MSDAORA;Data Source=orac;" & _ - "user id=username;password=*******" - - For Each value As String In builder.Values - Console.WriteLine(value) - Next - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb deleted file mode 100644 index 98351880d86..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb +++ /dev/null @@ -1,28 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before running this example. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder - builder.DataSource = "OracleSample" - builder.IntegratedSecurity = True - Console.WriteLine("Initial connection string: " & builder.ConnectionString) - - Console.WriteLine("Before call to Clear, count = " & builder.Count) - builder.Clear() - Console.WriteLine("After call to Clear, count = " & builder.Count) - Console.WriteLine("Cleared connection string: " & builder.ConnectionString) - Console.WriteLine() - - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb deleted file mode 100644 index 478604effee..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb +++ /dev/null @@ -1,31 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before running this example. -Imports System.Data.OracleClient - -Module Module1 - - Sub Main() - Dim builder As _ - New OracleConnectionStringBuilder( _ - "Server=OracleDemo;Integrated Security=True") - - ' Display the connection string, which should now - ' contains the "Data Source" key, as opposed to the - ' supplied "Server". - Console.WriteLine(builder.ConnectionString) - - ' Retrieve the DataSource property. - Console.WriteLine("DataSource = " & builder.DataSource) - - Console.WriteLine("Press any key to continue.") - Console.ReadLine() - End Sub - -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb deleted file mode 100644 index e16b9d4b909..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb +++ /dev/null @@ -1,29 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before you can run this sample. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder - builder.Item("Data Source") = "OracleDemo" - ' Item is the default property, so - ' you need not include it in the reference. - builder("integrated security") = True - builder.Item("Unicode") = True - - ' Overwrite the existing value for the Data Source value. - builder.Item("Data Source") = "NewOracleDemo" - - Console.WriteLine(builder.ConnectionString) - Console.WriteLine() - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb deleted file mode 100644 index 52c1b448dab..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb +++ /dev/null @@ -1,28 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may have to set a reference to the System.Data.OracleClient -' assembly before running this example. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder - builder.DataSource = "OracleSample" - builder.IntegratedSecurity = True - - ' Loop through the collection of keys, displaying - ' the key and value for each item. - For Each key As String In builder.Keys - Console.WriteLine("{0}={1}", key, builder(key)) - Next - - Console.WriteLine() - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb deleted file mode 100644 index 4f5fd578b4b..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb +++ /dev/null @@ -1,54 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before you can run this sample. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder() - builder.ConnectionString = GetConnectionString() - - ' Call TryGetValue method for multiple - ' key names. Note that these keys are converted - ' to well-known synonynms for data retrieval. - DisplayValue(builder, "Data Source") - DisplayValue(builder, "trusted_connection") - DisplayValue(builder, "InvalidKey") - DisplayValue(builder, Nothing) - - Console.WriteLine("Press any key to continue.") - Console.ReadLine() - End Sub - - Private Sub DisplayValue( _ - ByVal builder As OracleConnectionStringBuilder, ByVal key As String) - Dim value As Object = Nothing - - ' Although TryGetValue handles missing keys just fine, - ' it doesn't handle passing in a null (Nothing in Visual Basic) - ' key. This example traps for that particular error, but - ' bubbles any other unknown exceptions back out to the - ' caller. - Try - If builder.TryGetValue(key, value) Then - Console.WriteLine("{0}='{1}' ", key, value) - Else - Console.WriteLine("Unable to retrieve value for '{0}'", key) - End If - Catch ex As ArgumentNullException - Console.WriteLine("Unable to retrieve value for null key.") - End Try - End Sub - - Private Function GetConnectionString() As String - ' To avoid storing the connection string in your code, - ' you can retrieve it from a configuration file. - Return "Server=OracleDemo;Integrated Security=True" - End Function -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb deleted file mode 100644 index efa9915363f..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly in order to run this example. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As _ - New OracleConnectionStringBuilder(GetConnectionString()) - - ' Loop through each of the values, displaying the contents. - For Each value As Object In builder.Values - Console.WriteLine(value) - Next - - Console.WriteLine("Press any key to continue.") - Console.ReadLine() - End Sub - - Private Function GetConnectionString() As String - ' To avoid storing the connection string in your code, - ' you can retrieve it from a configuration file. - Return "Data Source=OracleSample;Integrated Security=true;" & _ - "Persist Security Info=True; Max Pool Size=100; Min Pool Size=1" - End Function -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb b/snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb deleted file mode 100644 index 2c031943135..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb +++ /dev/null @@ -1,17 +0,0 @@ -'System.Runtime.InteropServices.IDispatchImplAttribute -'System.Runtime.InteropServices.IDispatchImplType -' -Imports System.Runtime.InteropServices -' by default all classes in this assembly will use COM implementaion - - -Module MyNamespace - ' But this class will use runtime implementaion - _ - Public Class c - ' - End Class - -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb b/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb deleted file mode 100644 index d1590e56adb..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb +++ /dev/null @@ -1,58 +0,0 @@ -'Types:System.Security.Permissions.IsolatedStorageContainment (enum) -'Types:System.Security.Permissions.IsolatedStoragePermissionAttribute -'Types:System.Security.Permissions.SecurityAction -' -Option Strict On -Imports System.Security.Permissions -Imports System.IO.IsolatedStorage -Imports System.IO - - -' Notify the CLR to only grant IsolatedStorageFilePermission to called methods. -' This restricts the called methods to working only with storage files that are isolated -' by user and assembly. - _ -Public NotInheritable Class App - - Shared Sub Main() - WriteIsolatedStorage() - End Sub - Shared Sub WriteIsolatedStorage() - ' Attempt to create a storage file that is isolated by user and assembly. - ' IsolatedStorageFilePermission granted to the attribute at the top of this file - ' allows CLR to load this assembly and execution of this statement. - Dim s As New IsolatedStorageFileStream("AssemblyData", FileMode.Create, IsolatedStorageFile.GetUserStoreForAssembly()) - Try - - ' Write some data out to the isolated file. - Dim sw As New StreamWriter(s) - Try - sw.Write("This is some test data.") - Finally - sw.Dispose() - End Try - Finally - s.Dispose() - End Try - - ' Attempt to open the file that was previously created. - Dim t As New IsolatedStorageFileStream("AssemblyData", FileMode.Open, IsolatedStorageFile.GetUserStoreForAssembly()) - Try - ' Read the data from the file and display it. - Dim sr As New StreamReader(t) - Try - Console.WriteLine(sr.ReadLine()) - Finally - sr.Dispose() - End Try - Finally - t.Dispose() - End Try - - End Sub -End Class - -' This code produces the following output. -' -' Some test data. -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb b/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb deleted file mode 100644 index 0da0a8f2800..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb +++ /dev/null @@ -1,129 +0,0 @@ -' -Imports System.Security.Permissions -Imports System.Collections - - Public Class MailslotPermission - Inherits ResourcePermissionBase - - Private innerCollection As ArrayList - - - Public Sub New() - SetNames() - End Sub - - - Public Sub New(ByVal state As PermissionState) - MyBase.New(state) - SetNames() - End Sub - - - ' - Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String) - SetNames() - Me.AddPermissionAccess(New MailslotPermissionEntry(permissionAccess, name, machineName1)) - End Sub - - - Public Sub New(ByVal permissionAccessEntries() As MailslotPermissionEntry) - SetNames() - If permissionAccessEntries Is Nothing Then - Throw New ArgumentNullException("permissionAccessEntries") - End If - Dim index As Integer - - While index < permissionAccessEntries.Length - Me.AddPermissionAccess(permissionAccessEntries(index)) - End While - End Sub - ' - - Public ReadOnly Property PermissionEntries() As ArrayList - Get - If Me.innerCollection Is Nothing Then - Me.innerCollection = New ArrayList() - End If - Me.innerCollection.InsertRange(0, MyBase.GetPermissionEntries()) - - Return Me.innerCollection - End Get - End Property - - - Friend Overloads Sub AddPermissionAccess(ByVal entry As MailslotPermissionEntry) - MyBase.AddPermissionAccess(entry.GetBaseEntry()) - End Sub - - - Friend Shadows Sub Clear() - MyBase.Clear() - End Sub - - - Friend Overloads Sub RemovePermissionAccess(ByVal entry As MailslotPermissionEntry) - MyBase.RemovePermissionAccess(entry.GetBaseEntry()) - End Sub - - - Private Sub SetNames() - Me.PermissionAccessType = GetType(MailslotPermissionAccess) - Me.TagNames = New String() {"Name", "Machine"} - End Sub -End Class - - Public Enum MailslotPermissionAccess - None = 0 - Send = 2 - Receive = 4 Or Send -End Enum 'MailslotPermissionAccess - - Public Class MailslotPermissionEntry - Private nameVar As String - Private machineNameVar As String - Private permissionAccessVar As MailslotPermissionAccess - - - Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String) - Me.permissionAccessVar = permissionAccess - Me.nameVar = name - Me.machineNameVar = machineName1 - End Sub - - - Friend Sub New(ByVal baseEntry As ResourcePermissionBaseEntry) - Me.permissionAccessVar = CType(baseEntry.PermissionAccess, MailslotPermissionAccess) - Me.nameVar = baseEntry.PermissionAccessPath(0) - Me.machineNameVar = baseEntry.PermissionAccessPath(1) - End Sub - - - Public ReadOnly Property Name() As String - Get - Return Me.nameVar - End Get - End Property - - - Public ReadOnly Property MachineName() As String - Get - Return Me.machineNameVar - End Get - End Property - - - Public ReadOnly Property PermissionAccess() As MailslotPermissionAccess - Get - Return Me.permissionAccessVar - End Get - End Property - - - Friend Function GetBaseEntry() As ResourcePermissionBaseEntry - Dim baseEntry As New ResourcePermissionBaseEntry(CInt(Me.PermissionAccess), New String() {Me.Name, Me.MachineName}) - Return baseEntry - End Function 'GetBaseEntry - - -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb b/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb deleted file mode 100644 index 17320d0faa6..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb +++ /dev/null @@ -1,35 +0,0 @@ - ' -Imports System.Collections -Imports System.Diagnostics -Imports System.Security -Imports System.Security.Permissions -Imports System.Security.Policy -Imports System.Reflection -Imports System.IO - - - -Class Program - - Shared Sub Main(ByVal args() As String) - ' Create the permission set to grant to other assemblies. - ' In this case we are granting the permissions found in the LocalIntranet zone. - Dim e As New Evidence() - e.AddHostEvidence(New Zone(SecurityZone.Intranet)) - Dim pset As PermissionSet = SecurityManager.GetStandardSandbox(e) - - Dim ads As New AppDomainSetup() - ' Identify the folder to use for the sandbox. - ads.ApplicationBase = "C:\Sandbox" - ' Copy the application to be executed to the sandbox. - Directory.CreateDirectory("C:\Sandbox") - File.Copy("..\..\..\HelloWorld\bin\debug\HelloWorld.exe", "C:\sandbox\HelloWorld.exe", True) - - ' Create the sandboxed domain. - Dim sandbox As AppDomain = AppDomain.CreateDomain("Sandboxed Domain", e, ads, pset, Nothing) - sandbox.ExecuteAssemblyByName("HelloWorld") - - End Sub -End Class - -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb b/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb deleted file mode 100644 index 482c300503a..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb +++ /dev/null @@ -1,66 +0,0 @@ -' -Imports System.Reflection -Imports System.Reflection.Emit -Imports System.Runtime.InteropServices - -Public Class Example - - Public Shared Sub Main() - - Dim myDomain As AppDomain = AppDomain.CurrentDomain - Dim myAsmName As New AssemblyName("EmitMarshalAs") - - Dim myAssembly As AssemblyBuilder = _ - myDomain.DefineDynamicAssembly(myAsmName, _ - AssemblyBuilderAccess.RunAndSave) - - Dim myModule As ModuleBuilder = _ - myAssembly.DefineDynamicModule(myAsmName.Name, _ - myAsmName.Name & ".dll") - - Dim myType As TypeBuilder = _ - myModule.DefineType("Sample", TypeAttributes.Public) - - Dim myMethod As MethodBuilder = _ - myType.DefineMethod("Test", MethodAttributes.Public, _ - Nothing, new Type() { GetType(String) }) - - - ' Get a parameter builder for the parameter that needs the - ' attribute, using the HasFieldMarshal attribute. In this - ' example, the parameter is at position 0 and has the name - ' "arg". - Dim pb As ParameterBuilder = _ - myMethod.DefineParameter(0, _ - ParameterAttributes.HasFieldMarshal, "arg") - - ' Get the MarshalAsAttribute constructor that takes an - ' argument of type UnmanagedType. - ' - Dim ciParameters() As Type = { GetType(UnmanagedType) } - Dim ci As ConstructorInfo = _ - GetType(MarshalAsAttribute).GetConstructor(ciParameters) - - ' Create a CustomAttributeBuilder representing the attribute, - ' specifying the necessary unmanaged type. In this case, - ' UnmanagedType.BStr is specified. - ' - Dim ciArguments() As Object = { UnmanagedType.BStr } - Dim cabuilder As New CustomAttributeBuilder(ci, ciArguments) - - ' Apply the attribute to the parameter. - ' - pb.SetCustomAttribute(cabuilder) - - - ' Emit a dummy method body. - Dim il As ILGenerator = myMethod.GetILGenerator() - il.Emit(OpCodes.Ret) - - myType.CreateType() - myAssembly.Save(myAsmName.Name & ".dll") - - End Sub - -End Class -' diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb deleted file mode 100644 index 79a4422d272..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb +++ /dev/null @@ -1,59 +0,0 @@ -' -Public Class SamplesDelegate - - ' Declares a delegate for a method that takes in an int and returns a String. - Delegate Function myMethodDelegate(myInt As Integer) As [String] - - ' Defines some methods to which the delegate can point. - Public Class mySampleClass - - ' Defines an instance method. - Public Function myStringMethod(myInt As Integer) As [String] - If myInt > 0 Then - Return "positive" - End If - If myInt < 0 Then - Return "negative" - End If - Return "zero" - End Function 'myStringMethod - - ' Defines a static method. - Public Shared Function mySignMethod(myInt As Integer) As [String] - If myInt > 0 Then - Return "+" - End If - If myInt < 0 Then - Return "-" - End If - Return "" - End Function 'mySignMethod - End Class - - Public Shared Sub Main() - - ' Creates one delegate for each method. For the instance method, an - ' instance (mySC) must be supplied. For the Shared method, the - ' method name is qualified by the class name. - Dim mySC As New mySampleClass() - Dim myD1 As New myMethodDelegate(AddressOf mySC.myStringMethod) - Dim myD2 As New myMethodDelegate(AddressOf mySampleClass.mySignMethod) - - ' Invokes the delegates. - Console.WriteLine("{0} is {1}; use the sign ""{2}"".", 5, myD1(5), myD2(5)) - Console.WriteLine("{0} is {1}; use the sign ""{2}"".", - 3, myD1(- 3), myD2(- 3)) - Console.WriteLine("{0} is {1}; use the sign ""{2}"".", 0, myD1(0), myD2(0)) - - End Sub - -End Class - - -'This code produces the following output: -' -'5 is positive; use the sign "+". -'-3 is negative; use the sign "-". -'0 is zero; use the sign "". - - -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb deleted file mode 100644 index 9c1e98fe574..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -Imports System.Security.Permissions - -' - -'In Visual Basic, you must specify that you are using the assembly scope when making a request. -' - -Namespace Snippet2 - -' - Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace - -Namespace Snippet3 - -' -' -Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb deleted file mode 100644 index 3f31e11761a..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb +++ /dev/null @@ -1,42 +0,0 @@ - -Imports System.Security -Imports System.Security.Permissions - - - -Class Program - - Shared Sub Main(ByVal args() As String) - ' - Dim f As New FileIOPermission(PermissionState.None) - f.AllLocalFiles = FileIOPermissionAccess.Read - Try - f.Demand() - Catch s As SecurityException - Console.WriteLine(s.Message) - End Try - - ' - ' - Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, "C:\test_r") - f2.AddPathList(FileIOPermissionAccess.Write Or FileIOPermissionAccess.Read, "C:\example\out.txt") - Try - f2.Demand() - Catch s As SecurityException - Console.WriteLine(s.Message) - End Try - ' - Console.Read() - - ' - Dim f3 As New FileIOPermission(PermissionState.None) - f3.AllFiles = FileIOPermissionAccess.Read - Try - f3.Demand() - Catch s As SecurityException - Console.WriteLine(s.Message) - End Try - ' - - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb deleted file mode 100644 index 594bbf45ce1..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System.Security.Permissions - -Namespace Snippet1 - -' - Public Class SampleClass -' - End Class -End Namespace - -Namespace Snippet2 - -' - Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace - -Namespace Snippet3 - -' -' - Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb deleted file mode 100644 index a4157e37046..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb +++ /dev/null @@ -1,19 +0,0 @@ -' -Imports System.Threading -Imports System.Security.Permissions -Imports System.Security.Principal - - - -Class SecurityPrincipalDemo - - - Public Shared Sub Main() - AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) - Dim principalPerm As New PrincipalPermission(Nothing, "Administrators") - principalPerm.Demand() - Console.WriteLine("Demand succeeded.") - - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb deleted file mode 100644 index d0247922b9c..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -Imports System.Security -Imports System.Security.Policy -Imports System.Security.Permissions -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected textBox1 As TextBox - - Public Sub Method() -' - 'Define users and roles. - Dim ppBob As New PrincipalPermission("Bob", "Manager") - Dim ppLouise As New PrincipalPermission("Louise", "Supervisor") - Dim ppGreg As New PrincipalPermission("Greg", "Employee") - - 'Define groups of users. - Dim pp1 As PrincipalPermission = _ - CType(ppBob.Union(ppLouise), PrincipalPermission) - Dim pp2 As PrincipalPermission = _ - CType(ppGreg.Union(pp1), PrincipalPermission) -' - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb deleted file mode 100644 index 47c4beb16a6..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -' -Imports System.Threading -Imports System.Security.Permissions -Imports System.Security.Principal - - - -Class SecurityPrincipalDemo - - Public Shared Sub Main() - Try - ' PrincipalPolicy must be set to WindowsPrincipal to check roles. - AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) - ' Check using the PrincipalPermissionAttribute - CheckAdministrator() - ' Check using PrincipalPermission class. - Dim principalPerm As New PrincipalPermission(Nothing, "Administrators") - principalPerm.Demand() - Console.WriteLine("Demand succeeded.") - Catch e As Exception - Console.WriteLine(e.Message) - End Try - - End Sub - - _ - Shared Sub CheckAdministrator() - Console.WriteLine("User is an administrator") - - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split10.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split10.vb deleted file mode 100644 index 574814befef..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split10.vb +++ /dev/null @@ -1,30 +0,0 @@ -' Visual Basic .NET Document -Option Strict On - -' -Imports System.Text.RegularExpressions - -Module Example - Public Sub Main() - Dim input As String = "07/14/2007" - Dim pattern As String = "(-)|(/)" - For Each result As String In Regex.Split(input, pattern) - Console.WriteLine("'{0}'", result) - Next - End Sub -End Module -' In .NET 1.0 and 1.1, the method returns an array of -' 3 elements, as follows: -' '07' -' '14' -' '2007' -' -' In .NET 2.0 and later, the method returns an array of -' 5 elements, as follows: -' '07' -' '/' -' '14' -' '/' -' '2007' -' - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split3.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split3.vb deleted file mode 100644 index 6c7cd1aa293..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split3.vb +++ /dev/null @@ -1,31 +0,0 @@ -' Visual Basic .NET Document -Option Strict On - -' -Imports System.Text.RegularExpressions - -Module Example - Public Sub Main() - Dim input As String = "07/14/2007" - Dim pattern As String = "(-)|(/)" - Dim regex As Regex = New Regex(pattern) - For Each result As String In regex.Split(input) - Console.WriteLine("'{0}'", result) - Next - End Sub -End Module -' In .NET 1.0 and 1.1, the method returns an array of -' 3 elements, as follows: -' '07' -' '14' -' '2007' -' -' In .NET 2.0 and later, the method returns an array of -' 5 elements, as follows: -' '07' -' '/' -' '14' -' '/' -' '2007' -' - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split7.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split7.vb deleted file mode 100644 index 99c75bbd6cc..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Regex.Split/vb/split7.vb +++ /dev/null @@ -1,36 +0,0 @@ -' Visual Basic .NET Document -Option Strict On - -' -Imports System.Text.RegularExpressions - -Module Example - Public Sub Main() - Dim pattern As String = "(-)|([|])" ' possible delimiters found in string - Dim input As String = "apple|apricot|plum|pear|pomegranate|pineapple|peach" - - Dim regex As Regex = New Regex(pattern) - ' Split on delimiters from 15th character on - Dim substrings() As String = regex.Split(input, 4, 15) - For Each match As String In substrings - Console.WriteLine("'{0}'", match) - Next - End Sub -End Module -' In .NET 2.0, the method returns an array of -' 7 elements, as follows: -' apple|apricot|plum' -' '|' -' 'pear' -' '|' -' 'pomegranate' -' '|' -' 'pineapple|peach' -' In .NET 1.0 and 1.1, the method returns an array of -' 4 elements, as follows: -' 'apple|apricot|plum' -' 'pear' -' 'pomegranate' -' 'pineapple|peach' -' - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb deleted file mode 100644 index 194e4c7376a..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb +++ /dev/null @@ -1,73 +0,0 @@ -' -' Example of selected TimeZone class elements. -Imports System.Globalization - -Module TimeZoneDemo - - Sub Main( ) - - Const dataFmt As String = "{0,-30}{1}" - Const timeFmt As String = "{0,-30}{1:yyyy-MM-dd HH:mm}" - - Console.WriteLine( "This example of selected " & _ - "TimeZone class elements generates the following " & _ - vbCrLf & "output, which varies depending on the " & _ - "time zone in which it is run." & vbCrLf ) - - ' Get the local time zone and the current local time and year. - Dim localZone As TimeZone = TimeZone.CurrentTimeZone - Dim currentDate As DateTime = DateTime.Now - Dim currentYear As Integer = currentDate.Year - - ' Display the names for standard time and daylight saving - ' time for the local time zone. - Console.WriteLine( dataFmt, "Standard time name:", _ - localZone.StandardName ) - Console.WriteLine( dataFmt, "Daylight saving time name:", _ - localZone.DaylightName ) - - ' Display the current date and time and show if they occur - ' in daylight saving time. - Console.WriteLine( vbCrLf & timeFmt, _ - "Current date and time:", currentDate ) - Console.WriteLine( dataFmt, "Daylight saving time?", _ - localZone.IsDaylightSavingTime( currentDate ) ) - - ' Get the current Coordinated Universal Time (UTC) and UTC - ' offset. - Dim currentUTC As DateTime = _ - localZone.ToUniversalTime( currentDate ) - Dim currentOffset As TimeSpan = _ - localZone.GetUtcOffset( currentDate ) - - Console.WriteLine( timeFmt, "Coordinated Universal Time:", _ - currentUTC ) - Console.WriteLine( dataFmt, "UTC offset:", currentOffset ) - - ' Get the DaylightTime object for the current year. - Dim daylight As DaylightTime = _ - localZone.GetDaylightChanges( currentYear ) - - ' Display the daylight saving time range for the current year. - Console.WriteLine( vbCrLf & _ - "Daylight saving time for year {0}:", currentYear ) - Console.WriteLine( "{0:yyyy-MM-dd HH:mm} to " & _ - "{1:yyyy-MM-dd HH:mm}, delta: {2}", _ - daylight.Start, daylight.End, daylight.Delta ) - End Sub -End Module - -'This example of selected TimeZone class elements generates the following -'output, which varies depending on the time zone in which it is run. -' -'Standard time name: Pacific Standard Time -'Daylight saving time name: Pacific Daylight Time -' -'Current date and time: 2006-01-06 16:47 -'Daylight saving time? False -'Coordinated Universal Time: 2006-01-07 00:47 -'UTC offset: -08:00:00 -' -'Daylight saving time for year 2006: -'2006-04-02 02:00 to 2006-10-29 02:00, delta: 01:00:00 -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.ToLocalTime/VB/TimeZone_ToLocalTime.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.ToLocalTime/VB/TimeZone_ToLocalTime.vb deleted file mode 100644 index 8398a57f724..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.ToLocalTime/VB/TimeZone_ToLocalTime.vb +++ /dev/null @@ -1,78 +0,0 @@ -' Visual Basic .NET Document -Option Strict On - -Imports System.Globalization - -Public Module modEntryPoint - Public Sub Main() - - Dim tz As New TimeZoneEx - - ' Select a PDT date/time - Dim dt1 As New Date(2006, 09, 14, 6, 32, 45, DateTimeKind.Utc) - Console.WriteLine("{0} UTC is equivalent to {1} local time.", _ - dt1, tz.ToLocalTime(dt1)) - - ' Select a PST date/time - Dim dt2 As New Date(2006, 12, 9, 11, 12, 45, DateTimeKind.Utc) - Console.WriteLine("{0} UTC is equivalent to {1} local time.", _ - dt2, tz.ToLocalTime(dt2)) - Console.WriteLIne("DateTime offset is {0}:{1}", tz.GetUtcOffset(Date.Now).Hours, tz.GetUtcOffset(Date.Now).Minutes) - - ' Select a local time - Dim localTime1 As New Date(Date.Now.Ticks, DateTimeKind.Local) - Console.WriteLine("{0} is equivalent to {1} UTC time.", _ - localTime1, tz.ToUniversalTime(localTime1)) - End Sub -End Module - -Public Class TimeZoneEx : Inherits TimeZone - Private internalTimeZone As TimeZone - - Public Sub New() - MyBase.New() - internalTimeZone = TimeZone.CurrentTimeZone - End Sub - - Public Overrides ReadOnly Property DaylightName() As String - Get - Return internalTimeZone.DaylightName - End Get - End Property - - Public Overrides ReadOnly Property StandardName() As STring - Get - Return internalTimeZone.StandardName - End Get - End Property - - Public Overrides Function GetDaylightChanges(year as Integer) As DaylightTime - Return internalTimeZone.GetDaylightChanges(year) - End Function - - Public Overrides Function GetUtcOffset(time As DateTime) As TimeSpan - If time.Kind = DateTimeKind.Utc Then - Return New TimeSpan(0, 0, 0) - Else - Return New TimeSpan(14, 0, 0) - End If - End Function - - ' - Public Overrides Function ToLocalTime(time As Date) As Date - If time.Kind = DateTimeKind.Local Then - Return time - ElseIf time.Kind = DateTimeKind.Utc Then - Dim returnTime As New Date(time.Ticks, DateTimeKind.Local) - returnTime += me.GetUtcOffset(returnTime) - if internalTimeZone.IsDaylightSavingTime(returnTime) Then - returnTime -= New TimeSpan(1, 0, 0) - End If - Return returnTime - Else - Throw New ArgumentException("The source time zone cannot be determined.") - End If - End Function - ' -End Class - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb deleted file mode 100644 index 43b68f6991c..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb +++ /dev/null @@ -1,15 +0,0 @@ -' -Imports System.IO -Imports System.IO.Compression - -Module Module1 - - Sub Main() - Dim startPath As String = "c:\example\start" - Dim zipPath As String = "c:\example\result.zip" - - ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, True) - End Sub - -End Module -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb deleted file mode 100644 index 56c91f469b2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb +++ /dev/null @@ -1,45 +0,0 @@ -' - -Imports System.Xml -Imports System.Data -Imports System.Data.SqlClient - -public class Sample - - public shared sub Main() - - Dim dsNorthwind as DataSet = new DataSet() - - 'Create the connection string. - Dim sConnect as String - sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind" - - 'Create a connection object to connect to the northwind db. - Dim nwconnect as SqlConnection - nwconnect = new SqlConnection(sConnect) - - 'Create a command string to select all the customers in the WA region. - Dim sCommand as String = "Select * from Customers where Region='WA'" - - 'Create an Adapter to load the DataSet. - Dim myDataAdapter as SqlDataAdapter - myDataAdapter = new SqlDataAdapter(sCommand, nwconnect) - - 'Fill the DataSet with the selected records. - myDataAdapter.Fill(dsNorthwind, "Customers") - - 'Load the document with the DataSet. - Dim doc as XmlDataDocument = new XmlDataDocument(dsNorthwind) - - 'Create a shallow clone of the XmlDataDocument. Note that although - 'none of the child nodes were copied over, the cloned node does - 'have the schema information. - Dim clone as XmlDataDocument - clone = CType (doc.CloneNode(false), XmlDataDocument) - Console.WriteLine("Child count: {0}", clone.ChildNodes.Count) - Console.WriteLine(clone.DataSet.GetXmlSchema()) - - end sub -end class -' - diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/VB/source.vb deleted file mode 100644 index b596bb671ac..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/VB/source.vb +++ /dev/null @@ -1,28 +0,0 @@ -' -imports System.Data -imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create an XmlDataDocument. - Dim doc as XmlDataDocument = new XmlDataDocument() - - 'Load the schema. - doc.DataSet.ReadXmlSchema("store.xsd") - - 'Load the XML data. - doc.Load("2books.xml") - - 'Change the price on the first book using the DataSet methods. - Dim books as DataTable = doc.DataSet.Tables.Item("book") - books.Rows.Item(0).Item("price") = "12.95" - - Console.WriteLine("Display the modified XML data...") - doc.Save(Console.Out) - - end sub -end class - ' - diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/VB/source.vb deleted file mode 100644 index f526ead23af..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/VB/source.vb +++ /dev/null @@ -1,41 +0,0 @@ -' -Imports System.Xml -Imports System.Data -Imports System.Data.SqlClient - -public class Sample - - public shared sub Main() - - Dim dsNorthwind as DataSet = new DataSet() - - 'Create the connection string. - Dim sConnect as String - sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind" - - 'Create a connection object to connect to the northwind db. - Dim nwconnect as SqlConnection - nwconnect = new SqlConnection(sConnect) - - 'Create a command string to select all the customers in the WA region. - Dim sCommand as String = "Select * from Customers where Region='WA'" - - 'Create an Adapter to load the DataSet. - Dim myDataAdapter as SqlDataAdapter - myDataAdapter = new SqlDataAdapter(sCommand, nwconnect) - - 'Fill the DataSet with the selected records. - myDataAdapter.Fill(dsNorthwind, "Customers") - - 'Load the document with the DataSet. - Dim doc as XmlDataDocument = new XmlDataDocument(dsNorthwind) - - 'Create an element representing the first customer record. - Dim row as DataRow = doc.DataSet.Tables.Item(0).Rows.Item(0) - Dim elem as XmlElement = doc.GetElementFromRow(row) - Console.WriteLine(elem.OuterXml) - - end sub -end class -' - diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/VB/source.vb deleted file mode 100644 index 78fad3c9230..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/VB/source.vb +++ /dev/null @@ -1,39 +0,0 @@ -' -Imports System.Xml -Imports System.Data -Imports System.Data.SqlClient - -public class Sample - - public shared sub Main() - - Dim dsNorthwind as DataSet = new DataSet() - - 'Create the connection string. - Dim sConnect as String - sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind" - - 'Create a connection object to connect to the northwind db. - Dim nwconnect as SqlConnection - nwconnect = new SqlConnection(sConnect) - - 'Create a command string to select all the customers in the WA region. - Dim sCommand as String = "Select * from Customers where Region='WA'" - - 'Create an Adapter to load the DataSet. - Dim myDataAdapter as SqlDataAdapter - myDataAdapter = new SqlDataAdapter(sCommand, nwconnect) - - 'Fill the DataSet with the selected records. - myDataAdapter.Fill(dsNorthwind, "Customers") - - 'Load the document with the DataSet. - Dim doc as XmlDataDocument = new XmlDataDocument(dsNorthwind) - - 'Display the XmlDataDocument. - doc.Save(Console.Out) - - end sub -end class - ' - diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb deleted file mode 100644 index 5d27718f4f2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb +++ /dev/null @@ -1,28 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Serialization -Imports System.Xml.Xsl -Imports System.Xml.XPath -Imports System.Xml.Schema - - - -Public Class Class1 - - - Public Shared Sub Main() - - Dim xsc As XmlSchemaCollection - ' - If xsc.Contains("urn:bookstore-schema") Then - Dim schema As XmlSchema = xsc("urn:bookstore-schema") - Dim sw As New StringWriter() - Dim xmlWriter As New XmlTextWriter(sw) - xmlWriter.Formatting = Formatting.Indented - xmlWriter.Indentation = 2 - schema.Write(xmlWriter) - Console.WriteLine(sw.ToString()) - End If - ' - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb deleted file mode 100644 index b729f89c162..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.AttributeCount Example/VB/source.vb +++ /dev/null @@ -1,47 +0,0 @@ -' -Option Strict -Option Explicit - -Imports System.IO -Imports System.Xml - -Public Class Sample - - Public Shared Sub Main() - Dim reader As XmlValidatingReader = Nothing - - Try - 'Create the string to parse. - Dim xmlFrag As String = " " - - 'Create the XmlNamespaceManager. - Dim nt As New NameTable() - Dim nsmgr As New XmlNamespaceManager(nt) - - 'Create the XmlParserContext. - Dim context As New XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None) - - 'Create the XmlValidatingReader . - reader = New XmlValidatingReader(xmlFrag, XmlNodeType.Element, context) - - 'Read the attributes on the root element. - reader.MoveToContent() - If reader.HasAttributes Then - Dim i As Integer - For i = 0 To reader.AttributeCount - 1 - reader.MoveToAttribute(i) - Console.WriteLine("{0} = {1}", reader.Name, reader.Value) - Next i - 'Move the reader back to the node that owns the attribute. - reader.MoveToElement() - End If - - - Finally - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub -End Class -' diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.BaseURI Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.BaseURI Example/VB/source.vb deleted file mode 100644 index d548bff094d..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.BaseURI Example/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -' -Option Strict -Option Explicit - -Imports System.IO -Imports System.Xml - -Public Class Sample - - Public Shared Sub Main() - Dim reader As XmlValidatingReader = Nothing - Dim txtreader As XmlTextReader = Nothing - - Try - 'Create the validating reader. - txtreader = New XmlTextReader("http://localhost/uri.xml") - reader = New XmlValidatingReader(txtreader) - reader.ValidationType = ValidationType.None - - 'Parse the file and display the base URI for each node. - While reader.Read() - Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI) - End While - - Finally - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.GetAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.GetAttribute Example/VB/source.vb deleted file mode 100644 index f2029df3cd5..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.GetAttribute Example/VB/source.vb +++ /dev/null @@ -1,23 +0,0 @@ -' -Imports System.IO -Imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create the validating reader. - Dim txtreader as XmlTextReader = new XmlTextReader("attrs.xml") - Dim reader as XmlValidatingReader = new XmlValidatingReader(txtreader) - - 'Read the ISBN attribute. - reader.MoveToContent() - Dim isbn as string = reader.GetAttribute("ISBN") - Console.WriteLine("The ISBN value: " + isbn) - - 'Close the reader. - reader.Close() - - End sub -End class -' diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.HasValue Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.HasValue Example/VB/source.vb deleted file mode 100644 index 61f93dc5ab1..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.HasValue Example/VB/source.vb +++ /dev/null @@ -1,29 +0,0 @@ -' -Imports System.IO -Imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create the validating reader. - Dim txtreader as XmlTextReader = new XmlTextReader("book1.xml") - txtreader.WhitespaceHandling = WhitespaceHandling.None - Dim reader as XmlValidatingReader = new XmlValidatingReader(txtreader) - reader.ValidationType = ValidationType.None - - 'Parse the file and each node and its value. - while (reader.Read()) - if (reader.HasValue) then - Console.WriteLine("({0}) {1}={2}", reader.NodeType, reader.Name, reader.Value) - else - Console.WriteLine("({0}) {1}", reader.NodeType, reader.Name) - end if - end while - - 'Close the reader. - reader.Close() - - end sub -end class -' diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/VB/source.vb deleted file mode 100644 index 40cd9fbb0bc..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.IsEmptyElement Example/VB/source.vb +++ /dev/null @@ -1,40 +0,0 @@ -' -Imports System.IO -Imports System.Xml - -Public Class Sample - - Public Shared Sub Main() - Dim txtreader As XmlTextReader = Nothing - Dim reader As XmlValidatingReader = Nothing - - Try - 'Implement the readers. - txtreader = New XmlTextReader("elems.xml") - reader = New XmlValidatingReader(txtreader) - - 'Parse the XML and display the text content of each of the elements. - While reader.Read() - If reader.IsStartElement() Then - If reader.IsEmptyElement Then - Console.WriteLine("<{0}/>", reader.Name) - Else - Console.Write("<{0}> ", reader.Name) - reader.Read() 'Read the start tag. - If (reader.IsStartElement()) 'Handle nested elements. - Console.WriteLine() - Console.Write("<{0}>", reader.Name) - End If - Console.WriteLine(reader.ReadString()) 'Read the text content of the element. - End If - End If - End While - - Finally - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToAttribute Example/VB/source.vb deleted file mode 100644 index 977810bd904..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToAttribute Example/VB/source.vb +++ /dev/null @@ -1,47 +0,0 @@ -' -Option Strict -Option Explicit - -Imports System.IO -Imports System.Xml - -Public Class Sample - - Public Shared Sub Main() - Dim reader As XmlValidatingReader = Nothing - - Try - 'Create the XML fragment to be parsed. - Dim xmlFrag As String = "" - - 'Create the XmlParserContext. - Dim context As XmlParserContext - Dim subset As String = "" - context = New XmlParserContext(Nothing, Nothing, "book", Nothing, Nothing, subset, "", "", XmlSpace.None) - - 'Create the reader and set it to not expand general entities. - reader = New XmlValidatingReader(xmlFrag, XmlNodeType.Element, context) - reader.ValidationType = ValidationType.None - reader.EntityHandling = EntityHandling.ExpandCharEntities - - 'Read the misc attribute. Because EntityHandling is set to - 'ExpandCharEntities, the attribute is parsed into multiple text - 'and entity reference nodes. - reader.MoveToContent() - reader.MoveToAttribute("misc") - While reader.ReadAttributeValue() - If reader.NodeType = XmlNodeType.EntityReference Then - 'To expand the entity, call ResolveEntity. - Console.WriteLine("{0} {1}", reader.NodeType, reader.Name) - Else - Console.WriteLine("{0} {1}", reader.NodeType, reader.Value) - End If - End While - Finally - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub -End Class -' diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToFirstAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToFirstAttribute Example/VB/source.vb deleted file mode 100644 index b3fdfce93d6..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.MoveToFirstAttribute Example/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -' -Imports System.IO -Imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create the validating reader. - Dim txtreader as XmlTextReader = new XmlTextReader("attrs.xml") - Dim reader as XmlValidatingReader = new XmlValidatingReader(txtreader) - - 'Read the genre attribute. - reader.MoveToContent() - reader.MoveToFirstAttribute() - Dim genre As String = reader.Value - Console.WriteLine("The genre value: " & genre) - - 'Close the reader. - reader.Close() - - End sub -End class -' diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb deleted file mode 100644 index 1edecafb3b7..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Name Example/VB/source.vb +++ /dev/null @@ -1,53 +0,0 @@ -' -Imports System.IO -Imports System.Xml - -Public Class Sample - Private Const filename As String = "items.xml" - - Public Shared Sub Main() - Dim txtreader As XmlTextReader = Nothing - Dim reader As XmlValidatingReader = Nothing - - Try - 'Load the reader with the data file and ignore all white space nodes. - txtreader = New XmlTextReader(filename) - txtreader.WhitespaceHandling = WhitespaceHandling.None - - 'Implement the validating reader over the text reader. - reader = New XmlValidatingReader(txtreader) - reader.ValidationType = ValidationType.None - - 'Parse the file and display each of the nodes. - While reader.Read() - Select Case reader.NodeType - Case XmlNodeType.Element - Console.Write("<{0}>", reader.Name) - Case XmlNodeType.Text - Console.Write(reader.Value) - Case XmlNodeType.CDATA - Console.Write("", reader.Value) - Case XmlNodeType.ProcessingInstruction - Console.Write("", reader.Name, reader.Value) - Case XmlNodeType.Comment - Console.Write("", reader.Value) - Case XmlNodeType.XmlDeclaration - Console.Write("") - Case XmlNodeType.Document - Case XmlNodeType.DocumentType - Console.Write("", reader.Name) - End Select - End While - - Finally - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/VB/source.vb deleted file mode 100644 index 1ee59f16a8d..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ResolveEntity Example/VB/source.vb +++ /dev/null @@ -1,53 +0,0 @@ -' -Option Strict -Option Explicit - -Imports System.IO -Imports System.Xml - -Public Class Sample - - Public Shared Sub Main() - Dim reader As XmlValidatingReader = Nothing - Dim txtreader As XmlTextReader = Nothing - - Try - 'Create and load the XmlTextReader with the XML file. - txtreader = New XmlTextReader("book1.xml") - txtreader.WhitespaceHandling = WhitespaceHandling.None - - 'Create the XmlValidatingReader over the XmlTextReader. - 'Set the reader to not expand general entities. - reader = New XmlValidatingReader(txtreader) - reader.ValidationType = ValidationType.None - reader.EntityHandling = EntityHandling.ExpandCharEntities - - reader.MoveToContent() 'Move to the root element. - reader.Read() 'Move to title start tag. - reader.Skip() 'Skip the title element. - 'Read the misc start tag. The reader is now positioned on - 'the entity reference node. - reader.ReadStartElement() - - 'Because EntityHandling is set to ExpandCharEntities, you must call - 'ResolveEntity to expand the entity. The entity replacement text is - 'then parsed and returned as a child node. - Console.WriteLine("Expand the entity...") - reader.ResolveEntity() - - Console.WriteLine("The entity replacement text is returned as a text node.") - reader.Read() - Console.WriteLine("NodeType: {0} Value: {1}", reader.NodeType, reader.Value) - - Console.WriteLine("An EndEntity node closes the entity reference scope.") - reader.Read() - Console.WriteLine("NodeType: {0} Name: {1}", reader.NodeType, reader.Name) - - Finally - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/VB/source.vb deleted file mode 100644 index e221ffc751e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.Schemas Example/VB/source.vb +++ /dev/null @@ -1,71 +0,0 @@ -' -Option Strict -Option Explicit - -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -Public Class SchemaCollectionSample - Private doc1 As String = "booksSchema.xml" - Private doc2 As String = "booksSchemaFail.xml" - Private doc3 As String = "newbooks.xml" - Private schema As String = "books.xsd" - Private schema1 As String = "schema1.xdr" - - Private reader As XmlTextReader = Nothing - Private vreader As XmlValidatingReader = Nothing - Private m_success As Boolean = True - - Public Sub New() - - 'Load the schema collection - Dim xsc As New XmlSchemaCollection() - xsc.Add("urn:bookstore-schema", schema) 'XSD schema - xsc.Add("urn:newbooks-schema", schema1) 'XDR schema - - 'Validate the files using schemas stored in the collection. - Validate(doc1, xsc) 'Should pass. - Validate(doc2, xsc) 'Should fail. - Validate(doc3, xsc) 'Should fail. - - End Sub - - Public Shared Sub Main() - Dim validation As New SchemaCollectionSample() - End Sub - - Private Sub Validate(filename As String, xsc As XmlSchemaCollection) - - m_success = True - Console.WriteLine() - Console.WriteLine("Validating XML file {0}...", filename.ToString()) - reader = New XmlTextReader(filename) - - 'Create a validating reader. - vreader = New XmlValidatingReader(reader) - - 'Use the schemas stored in the schema collection. - vreader.Schemas.Add(xsc) - - 'Set the validation event handler. - AddHandler vreader.ValidationEventHandler, AddressOf ValidationCallBack - 'Read and validate the XML data. - While vreader.Read() - End While - Console.WriteLine("Validation finished. Validation {0}", IIf(m_success, "successful", "failed")) - Console.WriteLine() - - 'Close the reader. - vreader.Close() - - End Sub - - - Private Sub ValidationCallBack(sender As Object, args As ValidationEventArgs) - m_success = False - - Console.Write((ControlChars.CrLf & ControlChars.Tab & "Validation error: " & args.Message)) - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/VB/source.vb deleted file mode 100644 index 924e2365576..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationEventHandler Example/VB/source.vb +++ /dev/null @@ -1,50 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -Public Class Sample - - Private txtreader As XmlTextReader = Nothing - Private reader As XmlValidatingReader = Nothing - Private m_success As Boolean = True - - Public Sub New() - 'Validate file against the XSD schema. - 'The validation should fail. - Validate("notValidXSD.xml") - End Sub - - Public Shared Sub Main() - Dim validation As New Sample() - End Sub - - Private Sub Validate(filename As String) - Try - Console.WriteLine("Validating XML file " & filename.ToString()) - txtreader = New XmlTextReader(filename) - reader = New XmlValidatingReader(txtreader) - - ' Set the validation event handler - AddHandler reader.ValidationEventHandler, AddressOf Me.ValidationEventHandle - - ' Read XML data - While reader.Read() - End While - Console.WriteLine("Validation finished. Validation {0}", IIf(m_success, "successful", "failed")) - - Finally - 'Close the reader. - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub - - 'Display the validation error. - Private Sub ValidationEventHandle(sender As Object, args As ValidationEventArgs) - m_success = False - Console.WriteLine(ControlChars.CrLf & ControlChars.Tab & "Validation error: " & args.Message) - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/VB/source.vb deleted file mode 100644 index ff720ec845b..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlValidatingReader.ValidationType Example/VB/source.vb +++ /dev/null @@ -1,67 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -Public Class Sample - Private doc1 As String = "notValid.xml" - Private doc2 As String = "cdDTD.xml" - Private doc3 As String = "book1.xml" - - Private txtreader As XmlTextReader = Nothing - Private reader As XmlValidatingReader = Nothing - Private m_success As Boolean = True - - Public Sub New() - 'Parse the files and validate when requested. - Validate(doc1, ValidationType.XDR) 'Validation should fail. - Validate(doc2, ValidationType.DTD) 'Validation should fail. - Validate(doc3, ValidationType.None) 'No validation performed. - End Sub - - Public Shared Sub Main() - Dim validation As New Sample() - End Sub - - Private Sub Validate(filename As String, vt As ValidationType) - Try - 'Implement the readers. Set the ValidationType. - txtreader = New XmlTextReader(filename) - reader = New XmlValidatingReader(txtreader) - reader.ValidationType = vt - - 'If the reader is set to validate, set the event handler. - If vt = ValidationType.None Then - Console.WriteLine(ControlChars.Cr & "Parsing XML file " & filename.ToString()) - Else - Console.WriteLine(ControlChars.Cr & "Validating XML file " & filename.ToString()) - m_success = True - 'Set the validation event handler. - AddHandler reader.ValidationEventHandler, AddressOf ValidationCallBack - End If - - ' Read XML data - While reader.Read() - End While - If vt = ValidationType.None Then - Console.WriteLine("Finished parsing file.") - Else - Console.WriteLine("Validation finished. Validation {0}", IIf(m_success, "successful", "failed")) - End If - - Finally - 'Close the reader. - If Not (reader Is Nothing) Then - reader.Close() - End If - End Try - End Sub - - 'Display the validation errors. - Private Sub ValidationCallBack(sender As Object, args As ValidationEventArgs) - m_success = False - - Console.Write(ControlChars.CrLf & ControlChars.Tab & "Validation error: " & args.Message) - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform Example/VB/source.vb deleted file mode 100644 index 4ead9d1c3ba..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform Example/VB/source.vb +++ /dev/null @@ -1,27 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Serialization -Imports System.Xml.Xsl -Imports System.Xml.XPath - -Public Class Class1 - - Public Sub Method1() - ' - 'Create a new XslTransform object. - Dim xslt As New XslTransform() - - 'Load the stylesheet. - xslt.Load(CType("http://server/favorite.xsl", String)) - - 'Create a new XPathDocument and load the XML data to be transformed. - Dim mydata As New XPathDocument("inputdata.xml") - - 'Create an XmlTextWriter which outputs to the console. - Dim writer As New XmlTextWriter(Console.Out) - - 'Transform the data and send the output to the console. - xslt.Transform(mydata, Nothing, writer, Nothing) - ' - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb deleted file mode 100644 index 5cc2450c360..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb +++ /dev/null @@ -1,31 +0,0 @@ -' -Option Strict -Option Explicit - -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl -Imports System.Xml.XPath - -Public Class Sample - Private Shared filename1 As String = "books.xml" - Private Shared stylesheet1 As String = "output.xsl" - - - Public Shared Sub Main() - 'Load the stylesheet. - Dim xslt As New XslTransform() - xslt.Load(stylesheet1) - - 'Load the file to transform. - Dim doc As New XPathDocument(filename1) - - 'Create an XmlTextWriter which outputs to the console. - Dim writer As New XmlTextWriter(Console.Out) - - 'Transform the file and send the output to the console. - xslt.Transform(doc, Nothing, writer, Nothing) - writer.Close() - End Sub -End Class -' diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.CreateNavigator/VB/dataset_trans.vb b/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.CreateNavigator/VB/dataset_trans.vb deleted file mode 100644 index 4e323598cf2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.CreateNavigator/VB/dataset_trans.vb +++ /dev/null @@ -1,42 +0,0 @@ -' -Imports System.IO -Imports System.Data -Imports System.Data.SqlClient -Imports System.Xml -Imports System.Xml.XPath -Imports System.Xml.Xsl - -public class Sample - - public shared sub Main() - - ' Create a DataSet and load it with customer data. - Dim dsNorthwind as DataSet = new DataSet() - Dim sConnect as String - sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind" - Dim nwconnect as SqlConnection - nwconnect = new SqlConnection(sConnect) - Dim sCommand as String = "Select * from Customers where Region='WA'" - Dim myDataAdapter as SqlDataAdapter - myDataAdapter = new SqlDataAdapter(sCommand, nwconnect) - myDataAdapter.Fill(dsNorthwind,"Customers") - - ' Load the DataSet into an XmlDataDocument. - Dim doc as XmlDataDocument = new XmlDataDocument(dsNorthwind) - - ' Create the XslTransform object and load the stylesheet. - Dim xsl as XslTransform = new XslTransform() - xsl.Load("customers.xsl") - - ' Create an XPathNavigator to use in the transform. - Dim nav as XPathNavigator = doc.CreateNavigator() - - ' Create a FileStream object. - Dim fs as FileStream = new FileStream("cust.html", FileMode.Create) - - ' Transform the data. - xsl.Transform(nav, nothing, fs, nothing) - - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/VB/getrow.vb b/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/VB/getrow.vb deleted file mode 100644 index da67d4b245e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/VB/getrow.vb +++ /dev/null @@ -1,30 +0,0 @@ -' -Imports System.Data -Imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create an XmlDataDocument. - Dim doc as XmlDataDocument = new XmlDataDocument() - - 'Load the schema. - doc.DataSet.ReadXmlSchema("store.xsd") - - 'Load the XML data. - doc.Load("2books.xml") - - 'Change the price on the first book. - Dim book as XmlElement - book = CType(doc.DocumentElement.FirstChild, XmlElement) - Dim row as DataRow - row = doc.GetRowFromElement(book) - row.Item("price") = "12.95" - - Console.WriteLine("Display the modified XML data...") - Console.WriteLine(doc.DocumentElement.OuterXml) - - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb b/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb deleted file mode 100644 index 818518387dd..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb +++ /dev/null @@ -1,29 +0,0 @@ -' -Imports System.Data -Imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create an XmlDataDocument. - Dim doc as XmlDataDocument = new XmlDataDocument() - - 'Load the schema. - doc.DataSet.ReadXmlSchema("store.xsd") - - 'Load the XML data. - Dim reader as XmlTextReader = new XmlTextReader("2books.xml") - reader.MoveToContent() 'Moves the reader to the root node. - doc.Load(reader) - - 'Change the price on the first book imports the DataSet methods. - Dim books as DataTable = doc.DataSet.Tables.Item("book") - books.Rows.Item(0).Item("price") = "12.95" - - Console.WriteLine("Display the modified XML data...") - doc.Save(Console.Out) - - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb b/snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb deleted file mode 100644 index 529898203a2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb +++ /dev/null @@ -1,30 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -public class Sample - - public shared sub Main () - - 'Create the schema collection. - Dim xsc as XmlSchemaCollection = new XmlSchemaCollection() - - 'Set an event handler to manage invalid schemas. - AddHandler xsc.ValidationEventHandler, AddressOf ValidationCallBack - - 'Add the schema to the collection. - xsc.Add(nothing, "invalid.xsd") - - end sub - - 'Display the schema error information. - Private shared sub ValidationCallBack (sender as object, args as ValidationEventArgs) - Console.WriteLine("Invalid XSD schema: " + args.Exception.Message) - end sub - -end class -' - - - diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb b/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb deleted file mode 100644 index 23e8e4b383f..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb +++ /dev/null @@ -1,45 +0,0 @@ -Imports System.Xml -Imports System.Xml.Schema - -Namespace Microsoft.Samples.Xml.Schema - - Public NotInheritable Class Sample - - Private Sub New() - - End Sub - - Public Shared Sub Main() - - ' - Dim sc As XmlSchemaCollection = New XmlSchemaCollection() - AddHandler sc.ValidationEventHandler, AddressOf ValidationCallBack - - ' Create a resolver with the necessary credentials. - Dim resolver As XmlUrlResolver = New XmlUrlResolver() - resolver.Credentials = System.Net.CredentialCache.DefaultCredentials - - ' Add the new schema to the collection. - sc.Add("", New XmlTextReader("sample.xsd"), resolver) - ' - - If (sc.Count > 0) Then - Dim tr As XmlTextReader = New XmlTextReader("notValidXSD.xml") - Dim rdr As XmlValidatingReader = New XmlValidatingReader(tr) - - rdr.ValidationType = ValidationType.Schema - rdr.Schemas.Add(sc) - AddHandler rdr.ValidationEventHandler, AddressOf ValidationCallBack - While (rdr.Read()) - End While - End If - - End Sub - - Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal e As ValidationEventArgs) - Console.WriteLine("XSD Error: {0}", e.Message) - End Sub - - End Class - -End Namespace \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb b/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb deleted file mode 100644 index 9094679f9c2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb +++ /dev/null @@ -1,31 +0,0 @@ -' -Imports System.Xml -Imports System.Xml.Schema -Imports System.IO - -public class ValidXSD - - public shared sub Main() - Dim sc as XmlSchemaCollection = new XmlSchemaCollection() - AddHandler sc.ValidationEventHandler, AddressOf ValidationCallBack - sc.Add(nothing, "books.xsd") - - if(sc.Count > 0) - Dim tr as XmlTextReader = new XmlTextReader("notValidXSD.xml") - Dim rdr as XmlValidatingReader = new XmlValidatingReader(tr) - - rdr.ValidationType = ValidationType.Schema - rdr.Schemas.Add(sc) - AddHandler rdr.ValidationEventHandler, AddressOf ValidationCallBack - while (rdr.Read()) - end while - end if - - end sub - - private shared sub ValidationCallBack(sender as object, e as ValidationEventArgs) - Console.WriteLine("XSD Error: {0}", e.Message) - end sub - -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.Cctor/VB/valid_xsd2.vb b/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.Cctor/VB/valid_xsd2.vb deleted file mode 100644 index 0a55086c86d..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.Cctor/VB/valid_xsd2.vb +++ /dev/null @@ -1,52 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -public class Sample - - private m_success as Boolean = true - - public sub New () - 'Validate the document using an external XSD schema. Validation should fail. - Validate("notValidXSD.xml") - - 'Validate the document using an inline XSD. Validation should succeed. - Validate("inlineXSD.xml") - end sub - - public shared sub Main () - - Dim validation as Sample = new Sample() - end sub - - private sub Validate(filename as String) - - m_success = true - Console.WriteLine() - Console.WriteLine("******") - Console.WriteLine("Validating XML file " + filename.ToString()) - Dim txtreader as XmlTextReader = new XmlTextReader (filename) - Dim reader as XmlValidatingReader = new XmlValidatingReader (txtreader) - - ' Set the validation event handler - AddHandler reader.ValidationEventHandler, AddressOf ValidationCallBack - - ' Read XML data - while (reader.Read()) - end while - Console.WriteLine ("Validation finished. Validation {0}", IIf(m_success, "successful!", "failed.")) - - 'Close the reader. - reader.Close() - end sub - - 'Display the validation error. - Private sub ValidationCallBack (sender as object, args as ValidationEventArgs) - - m_success = false - Console.WriteLine() - Console.WriteLine(" Validation error: " + args.Message ) - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.IsDefault/VB/readdefattr.vb b/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.IsDefault/VB/readdefattr.vb deleted file mode 100644 index f280cc226c9..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.IsDefault/VB/readdefattr.vb +++ /dev/null @@ -1,30 +0,0 @@ -' -Imports System.IO -Imports System.Xml - -public class Sample - - public shared sub Main() - - 'Create the reader. - Dim txtreader as XmlTextReader = new XmlTextReader("book4.xml") - Dim reader as XmlValidatingReader = new XmlValidatingReader(txtreader) - - reader.MoveToContent() - - 'Display each of the attribute nodes, including default attributes. - while (reader.MoveToNextAttribute()) - if (reader.IsDefault) - Console.Write("(default attribute) ") - end if - Console.WriteLine("{0} = {1}", reader.Name, reader.Value) - end while - - 'Close the reader. - reader.Close() - - end sub -end class -' - - diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.SchemaType/VB/schematype.vb b/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.SchemaType/VB/schematype.vb deleted file mode 100644 index 80cf7365ac1..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.SchemaType/VB/schematype.vb +++ /dev/null @@ -1,39 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -public class Sample - - public shared sub Main() - - Dim tr as XmlTextReader = new XmlTextReader("booksSchema.xml") - Dim vr as XmlValidatingReader = new XmlValidatingReader(tr) - - vr.Schemas.Add(nothing, "books.xsd") - vr.ValidationType = ValidationType.Schema - AddHandler vr.ValidationEventHandler, AddressOf ValidationCallBack - - while(vr.Read()) - - if(vr.NodeType = XmlNodeType.Element) - - if (vr.SchemaType.ToString() = "System.Xml.Schema.XmlSchemaComplexType") - Dim sct as XmlSchemaComplexType = CType(vr.SchemaType,XmlSchemaComplexType) - Console.WriteLine("{0}({1})", vr.Name, sct.Name) - else - Dim value as object = vr.ReadTypedValue() - Console.WriteLine("{0}({1}):{2}", vr.Name, value.GetType().Name, value) - end if - end if - end while - end sub - - private shared sub ValidationCallBack (sender as object, args as ValidationEventArgs) - - Console.WriteLine("***Validation error") - Console.WriteLine("Severity:{0}", args.Severity) - Console.WriteLine("Message :{0}", args.Message) - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.XmlResolver/VB/vrdr_resolver.vb b/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.XmlResolver/VB/vrdr_resolver.vb deleted file mode 100644 index a71cfd4b8b4..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XmlValidatingReader.XmlResolver/VB/vrdr_resolver.vb +++ /dev/null @@ -1,48 +0,0 @@ - -Imports System.IO -Imports System.Xml -Imports System.Net - -public class Sample - - public shared sub Main(args as String()) - - dim UserName as string = args(0) - dim SecurelyStoredPassword as string = args(1) - dim Domain as string = args(2) - -' - ' Create the reader. - Dim txtreader as XmlTextReader = new XmlTextReader("book5.xml") - Dim reader as XmlValidatingReader = new XmlValidatingReader(txtreader) - txtreader.WhitespaceHandling = WhitespaceHandling.None - - ' Set the credentials necessary to access the DTD file stored on the network. - Dim resolver as XmlUrlResolver = new XmlUrlResolver() - resolver.Credentials = System.Net.CredentialCache.DefaultCredentials - reader.XmlResolver = resolver - - ' Display each of the element nodes. - while (reader.Read()) - select case reader.NodeType - case XmlNodeType.Element: - Console.Write("<{0}>", reader.Name) - case XmlNodeType.Text: - Console.Write(reader.Value) - case XmlNodeType.DocumentType: - Console.Write("", reader.Name) - end select - end while - ' - 'Close the reader. - reader.Close() - - end sub -end class - - - diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb b/snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb deleted file mode 100644 index 67c6fb880ca..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb +++ /dev/null @@ -1,25 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl - -public class Sample - - public shared sub Main() - -' - -' Create a resolver with default credentials. -Dim resolver as XmlUrlResolver = new XmlUrlResolver() -resolver.Credentials = System.Net.CredentialCache.DefaultCredentials - -' Create the XslTransform object. -Dim xslt as XslTransform = new XslTransform() - -' Load the stylesheet. -xslt.Load("http://myServer/data/authors.xsl", resolver) - -' Transform the file. -xslt.Transform("books.xml", "titles.xml", resolver) -' - end sub -end class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load2/VB/trans2.vb b/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load2/VB/trans2.vb deleted file mode 100644 index fd85de2b8d2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load2/VB/trans2.vb +++ /dev/null @@ -1,37 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.XPath -Imports System.Xml.Xsl -Imports System.Net - -public class Sample - - private shared filename as String = "books.xml" - private shared stylesheet as String = "sort.xsl" - - public shared sub Main() - - 'Create the XslTransform. - Dim xslt as XslTransform = new XslTransform() - - 'Create a resolver and set the credentials to use. - Dim resolver as XmlUrlResolver = new XmlUrlResolver() - resolver.Credentials = CredentialCache.DefaultCredentials - - 'Load the stylesheet. - xslt.Load(stylesheet, resolver) - - 'Load the XML data file. - Dim doc as XPathDocument = new XPathDocument(filename) - - 'Create the XmlTextWriter to output to the console. - Dim writer as XmlTextWriter = new XmlTextWriter(Console.Out) - - 'Transform the file. - xslt.Transform(doc, nothing, writer, nothing) - writer.Close() - - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb b/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb deleted file mode 100644 index 32d6ae9391e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb +++ /dev/null @@ -1,36 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl -Imports System.Xml.XPath - -public class Sample - - private const filename as String = "books.xml" - private const stylesheet as String = "titles.xsl" - - public shared sub Main() - - 'Create the reader to load the stylesheet. - 'Move the reader to the xsl:stylesheet node. - Dim reader as XmlTextReader = new XmlTextReader(stylesheet) - reader.Read() - reader.Read() - - 'Create the XslTransform object and load the stylesheet. - Dim xslt as XslTransform = new XslTransform() - xslt.Load(reader) - - 'Load the file to transform. - Dim doc as XPathDocument = new XPathDocument(filename) - - 'Create an XmlTextWriter which outputs to the console. - Dim writer as XmlTextWriter = new XmlTextWriter(Console.Out) - - 'Transform the file and send the output to the console. - xslt.Transform(doc, nothing, writer) - writer.Close() - - end sub -end class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb b/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb deleted file mode 100644 index 295c080852a..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb +++ /dev/null @@ -1,30 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl - - public class Sample - - public shared sub Main () - - - Dim reader as new XmlTextReader("c:\tmp\output.xsl") - TransformFile(reader, "http://localhost/data") - - end sub - - ' Perform an XSLT transformation where xsltReader is an XmlReader containing - ' a stylesheet and secureURI is a trusted URI that can be used to create Evidence. -' - - public shared sub TransformFile (xsltReader as XmlReader, secureURL as String) - - ' Load the stylesheet using a default XmlUrlResolver and Evidence - ' created using the trusted URL. - Dim xslt as XslTransform = new XslTransform() - xslt.Load(xsltReader, new XmlUrlResolver(), XmlSecureResolver.CreateEvidenceForUrl(secureURL)) - - ' Transform the file. - xslt.Transform("books.xml", "books.html", new XmlUrlResolver()) - end sub -' -end class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load5/VB/trans_noev.vb b/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load5/VB/trans_noev.vb deleted file mode 100644 index e4f22610692..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load5/VB/trans_noev.vb +++ /dev/null @@ -1,31 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl -Imports System.Xml.XPath - - public class Sample - - public shared sub Main () - - - Dim doc as new XmlDocument() - doc.Load("c:\tmp\output.xsl") - TransformFile(doc.CreateNavigator()) - - end sub - - ' Perform an XSLT transformation where xsltNav is an XPathNavigator containing - ' a stylesheet from an untrusted source. -' - - public shared sub TransformFile (xsltNav as XPathNavigator) - - ' Load the stylesheet. - Dim xslt as XslTransform = new XslTransform() - xslt.Load(xsltNav, nothing, nothing) - - ' Transform the file. - xslt.Transform("books.xml", "books.html", nothing) - end sub -' -end class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb b/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb deleted file mode 100644 index 29c97b0386e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb +++ /dev/null @@ -1,38 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl -Imports System.Xml.XPath - -public class Sample - - public shared sub Main(args as String()) - - dim UserName as string = args(0) - dim SecurelyStoredPassword as string = args(1) - dim Domain as string = args(2) - -' -' Create the XslTransform object. -Dim xslt as XslTransform = new XslTransform() - -' Load the stylesheet. -xslt.Load("titles.xsl") - -' Create a resolver and specify the necessary credentials. -Dim resolver as XmlUrlResolver = new XmlUrlResolver() -Dim myCred as System.Net.NetworkCredential -myCred = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain) -resolver.Credentials = myCred - -' Transform thefile using the resolver. The resolver is used -' to process the XSLT document() function. -Dim doc as XPathDocument = new XPathDocument("books.xml") -Dim reader as XmlReader = xslt.Transform(doc, nothing, resolver) - -' Load the reader into a new document for more processing. -Dim xmldoc as XmlDocument = new XmlDocument() -xmldoc.Load(reader) -' - Console.WriteLine(xmldoc.OuterXml) - end sub -end class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform6/VB/transstring.vb b/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform6/VB/transstring.vb deleted file mode 100644 index d824c9e9a6e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform6/VB/transstring.vb +++ /dev/null @@ -1,44 +0,0 @@ -' -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl -Imports System.Xml.XPath - -public class Sample - - public shared sub Main() - - ' Create a string containing the XSLT stylesheet. - Dim xsltString as String - xsltString = "" & _ - " " & _ - " " & _ - " " & _ - " Book Titles" & _ - " " & _ - " " & _ - " " & _ - " " & _ - " " & _ - " " & _ - " " & _ - "

" & _ - "
" & _ - "
" - - ' Create the XslTransform object. - Dim xslt as XslTransform = new XslTransform() - - ' Load the stylesheet. - Dim rdr as StringReader = new StringReader(xsltString) - xslt.Load(new XPathDocument(rdr), nothing, nothing) - - ' Transform the file and output an HTML string. - Dim HTMLoutput as string - Dim writer as StringWriter = new StringWriter() - xslt.Transform(new XPathDocument("books.xml"), nothing, writer, nothing) - HTMLoutput = writer.ToString() - - end sub -end class -'
\ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb b/snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb deleted file mode 100644 index 57465affa7f..00000000000 --- a/snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb +++ /dev/null @@ -1,20 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Xsl - -public class Sample - - public shared sub Main() - -' - 'Create the XslTransform object. - Dim xslt as XslTransform = new XslTransform() - - 'Load the stylesheet. - xslt.Load("output.xsl") - - 'Transform the file. - xslt.Transform("books.xml", "books.html") -' - end sub -end class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/VB/source.vb deleted file mode 100644 index 52635d324e7..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/VB/source.vb +++ /dev/null @@ -1,27 +0,0 @@ - -Imports System.Security -Imports System.Security.Permissions -Imports System.Net - -' -' Uses the DnsPermissionAttribute to restrict access only to those who have permission. - _ -Public Class MyClass1 - - Public Shared Function GetIPAddress() As IPAddress - Dim ipAddress As IPAddress = Dns.Resolve("localhost").AddressList(0) - Return ipAddress - End Function 'GetIPAddress - - Public Shared Sub Main() - Try - ' Grants Access. - Console.WriteLine(("Access granted" + ControlChars.NewLine + " The local host IP Address is :" + MyClass1.GetIPAddress().ToString())) - ' Denies Access. - Catch securityException As SecurityException - Console.WriteLine("Access denied") - Console.WriteLine(securityException.ToString()) - End Try - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb deleted file mode 100644 index 78db09405da..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb +++ /dev/null @@ -1,13 +0,0 @@ -Imports System.Net - - - -Public Class Class1 - - Public Sub Method1() - ' - Dim proxyURI As New Uri("http://webproxy:80") - GlobalProxySelection.Select = New WebProxy(proxyURI) - ' - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb b/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb deleted file mode 100644 index 4febcd3580d..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/VB/dateclient_socketpermission_constructor.vb +++ /dev/null @@ -1,154 +0,0 @@ - ' -' This program demonstrates the 'SocketPermission(PermissionState)', -' 'SocketPermission(NetworkAccess, TransportType, string, int) constructors, -' 'FromXml', 'Intersect', 'AddPermission' methods and 'AllPorts' field -' of 'SocketPermission' class. -' -' This program provides a class called 'DateClient' that functions as a client -' for a 'DateServer'. A 'DateServer' is a server that provides the current date on -' the server in response to a request from a client. The 'DateClient' class -' provides a method called 'GetDate' which returns the current date on the server. -' The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -' instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -' instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -' TransportType, string, int)' constructor. A third 'SocketPermission' object is -' formed from the intersection of the above two 'SocketPermission' objects with the -' use of the 'Intersect' method of 'SocketPermission' class. This 'SocketPermission' -' object is used by the 'GetDate' method to verify the permissions of the calling -' method. If the calling method has the requisite permissions the 'GetDate' method -' connects to the 'DateServer' and returns the current date that the 'DateServer' -' sends. If any exception occurs the 'GetDate' method returns an empty string. -' -' Note: This program requires 'DateServer_SocketPermission' program executing. -' - -Imports System.Net -Imports System.Net.Sockets -Imports System.Text -Imports System.Collections -Imports System.Security -Imports System.Security.Permissions - -Public Class DateClient - - Private serverSocket As Socket - Private asciiEncoding As Encoding - Private serverAddress As IPAddress - - Private serverPort As Integer - - - 'The constructor takes the address and port of the remote server. - Public Sub New(ipAddress As IPAddress, port As Integer) - serverAddress = ipAddress - serverPort = port - serverSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) - asciiEncoding = Encoding.ASCII - End Sub - - - Public Function GetDate() As [String] -' -' -' -' -' -' - - Dim socketPermission1 As New SocketPermission(PermissionState.Unrestricted) - - 'Create a 'SocketPermission' object for two ip addresses. - Dim socketPermission2 As New SocketPermission(PermissionState.None) - Dim securityElement1 As SecurityElement = socketPermission2.ToXml() - ''SocketPermission' object for 'Connect' permission - Dim securityElement2 As New SecurityElement("ConnectAccess") - 'Format to specify ip address are ## - 'First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' - ' ports for the ip-address. - Dim securityElement3 As New SecurityElement("URI", "192.168.144.238#-1#3") - 'Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - Dim securityElement4 As New SecurityElement("URI", "192.168.144.240#-1#3") - securityElement2.AddChild(securityElement3) - securityElement2.AddChild(securityElement4) - securityElement1.AddChild(securityElement2) - - - 'Obtain a 'SocketPermission' object using 'FromXml' method. - socketPermission2.FromXml(securityElement1) - - Console.WriteLine(ControlChars.Cr + "Displays the result of FromXml method : " + ControlChars.Cr) - Console.WriteLine(socketPermission2.ToString()) - - 'Create another 'SocketPermission' object with two ip addresses. - 'First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - Dim socketPermission3 As New SocketPermission(NetworkAccess.Connect, TransportType.All, "192.168.144.238", SocketPermission.AllPorts) - - 'Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3.AddPermission(NetworkAccess.Connect, TransportType.All, "192.168.144.239", SocketPermission.AllPorts) - - Console.WriteLine("Displays the result of AddPermission method : " + ControlChars.Cr) - Console.WriteLine(socketPermission3.ToString()) - - 'Find the intersection between two 'SocketPermission' objects. - socketPermission1 = CType(socketPermission2.Intersect(socketPermission3), SocketPermission) - - Console.WriteLine("Displays the result of Intersect method :" + ControlChars.Cr + " ") - Console.WriteLine(socketPermission1.ToString()) - 'Demand that the calling method have the requsite socket permission. - socketPermission1.Demand() -' -' -' -' -' -' - 'Get the current date from the remote date server. - Try - Dim bytesReceived As Integer - Dim getByte(100) As Byte - serverSocket.Connect(New IPEndPoint(serverAddress, serverPort)) - bytesReceived = serverSocket.Receive(getByte, getByte.Length, 0) - Return asciiEncoding.GetString(getByte, 0, bytesReceived) - Catch e As Exception - Console.WriteLine(ControlChars.Cr + "Exception raised : {0}", e.Message) - Return "" - End Try - End Function 'GetDate -End Class - - -'This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' object. -Public Class UserDateClient - - 'Entry point which delegates to C-style main Private Function - Public Overloads Shared Sub Main() - Main(System.Environment.GetCommandLineArgs()) - End Sub - - - Overloads Public Shared Sub Main(args() As [String]) - If args.Length <> 3 Then - PrintUsage() - Return - End If - Try - Dim myDateClient As New DateClient(IPAddress.Parse(args(1)), Int32.Parse(args(2))) - Dim currentDate As [String] = myDateClient.GetDate() - Console.WriteLine("The current date and time is : ") - Console.WriteLine("{0}", currentDate) - 'This exception is thrown by the called method in the context of improper permissions. - Catch e As SecurityException - Console.WriteLine(ControlChars.Cr + "SecurityException raised : {0}", e.Message) - Catch e As Exception - Console.WriteLine(ControlChars.Cr + "Exception raised : {0}", e.Message) - End Try - End Sub - - - Private Shared Sub PrintUsage() - Console.WriteLine("Usage : DateClient_SocketPermission_Constructor") - Console.WriteLine(ControlChars.Tab + "DateClient_SocketPermission_Constructor " + ChrW(60) + "ipaddress" + ChrW(62) + " " + ChrW(60) + "port" + ChrW(62)) - Console.WriteLine(ControlChars.Tab + "The ipaddress argument is the ip address of the Date server.") - Console.WriteLine(ControlChars.Tab + "The port argument is the port of the Date server.") - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb b/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb deleted file mode 100644 index 0924419985b..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/VB/dateclient_socketpermission_toxml.vb +++ /dev/null @@ -1,185 +0,0 @@ - ' -' This program demonstrates the 'ToXml' and 'IsUnrestricted' method and 'ConnectList' property of -' 'SocketPermission' class. -' -' This program provides a class called 'DateClient' that functions as a client -' for a 'DateServer'. A 'DateServer' is a server that provides the current date on -' the server in response to a request from a client. The 'DateClient' class -' provides a method called 'GetDate' which returns the current date on the server. -' The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -' instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -' instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -' TransportType, string, int)' constructor. A third 'SocketPermission' object is -' formed from the union of the above two 'SocketPermission' objects with the use of the -' 'Union' method of 'SocketPermission' class. This 'SocketPermission' object is used by -' the 'GetDate' method to verify the permissions of the calling method. If the calling -' method has the requisite permissions the 'GetDate' method connects to the 'DateServer' -' and returns the current date that the 'DateServer' sends. If any exception occurs -' the 'GetDate' method returns an empty string. -' -' Note: This program requires 'DateServer_SocketPermission' program executing. -' - -Imports System.Net -Imports System.Net.Sockets -Imports System.Text -Imports System.Collections -Imports System.Security -Imports System.Security.Permissions - -Public Class DateClient - - Private serverSocket As Socket - Private asciiEncoding As Encoding - Private serverAddress As IPAddress - - Private serverPort As Integer - - - 'The constructor takes the address and port of the remote server. - Public Sub New(serverIpAddress As IPAddress, port As Integer) - serverAddress = serverIpAddress - serverPort = port - serverSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) - asciiEncoding = Encoding.ASCII - End Sub - - - 'Print a security element and all its children, in a depth-first manner. - Private Sub PrintSecurityElement(securityElementObj As SecurityElement, depth As Integer) - - Console.WriteLine("Depth : {0}", depth) - Console.WriteLine("Tag : {0}", securityElementObj.Tag) - Console.WriteLine("Text : {0}", securityElementObj.Text) - If Not (securityElementObj.Children Is Nothing) Then - Console.WriteLine("Children : {0}", securityElementObj.Children.Count) - End If - If Not (securityElementObj.Attributes Is Nothing) Then - Dim attributeEnumerator As IEnumerator = securityElementObj.Attributes.GetEnumerator() - While attributeEnumerator.MoveNext() - Console.WriteLine("Attribute - ""{0}"" , Value - ""{1}""", CType(attributeEnumerator, IDictionaryEnumerator).Key, CType(attributeEnumerator, IDictionaryEnumerator).Value) - End While - End If - - Console.WriteLine("") - - If Not (securityElementObj.Children Is Nothing) Then - depth += 1 - Dim i As Integer - For i = 0 To securityElementObj.Children.Count - 1 - PrintSecurityElement(CType(securityElementObj.Children(i), SecurityElement), depth) - Next i - End If - End Sub - - Public Function GetDate() As [String] -' -' -' - - Dim socketPermission1 As New SocketPermission(PermissionState.Unrestricted) - - 'Create a 'SocketPermission' object for two ip addresses. - Dim socketPermission2 As New SocketPermission(PermissionState.None) - Dim securityElement4 As SecurityElement = socketPermission2.ToXml() - ''SocketPermission' object for 'Connect' permission - Dim securityElement1 As New SecurityElement("ConnectAccess") - 'Format to specify ip address are ## - 'First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - Dim securityElement2 As New SecurityElement("URI", "192.168.144.238#-1#3") - 'Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - Dim securityElement3 As New SecurityElement("URI", "192.168.144.240#-1#3") - securityElement1.AddChild(securityElement2) - securityElement1.AddChild(securityElement3) - securityElement4.AddChild(securityElement1) - - 'Obtain a 'SocketPermission' object using 'FromXml' method. - socketPermission2.FromXml(securityElement4) - - 'Create another 'SocketPermission' object with two ip addresses. - 'First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - Dim socketPermission3 As New SocketPermission(NetworkAccess.Connect, TransportType.All, "192.168.144.238", SocketPermission.AllPorts) - - 'Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3.AddPermission(NetworkAccess.Connect, TransportType.All, "192.168.144.239", SocketPermission.AllPorts) - - Console.WriteLine(ControlChars.Cr + "Checks the Socket permissions using IsUnrestricted method : ") - If socketPermission1.IsUnrestricted() Then - Console.WriteLine("Socket permission is unrestricted") - Else - Console.WriteLine("Socket permission is restricted") - End If - Console.WriteLine() - - Console.WriteLine("Display result of ConnectList property : " + ControlChars.Cr) - Dim enumerator As IEnumerator = socketPermission3.ConnectList - While enumerator.MoveNext() - Console.WriteLine("The hostname is : {0}", CType(enumerator.Current, EndpointPermission).Hostname) - Console.WriteLine("The port is : {0}", CType(enumerator.Current, EndpointPermission).Port) - Console.WriteLine("The Transport type is : {0}", CType(enumerator.Current, EndpointPermission).Transport) - End While - - Console.WriteLine("") - - Console.WriteLine("Display Security Elements :" + ControlChars.Cr + " ") - PrintSecurityElement(socketPermission2.ToXml(), 0) - - 'Get a 'SocketPermission' object which is a union of two other 'SocketPermission' objects. - socketPermission1 = CType(socketPermission3.Union(socketPermission2), SocketPermission) - - 'Demand that the calling method have the socket permission. - socketPermission1.Demand() -' -' -' - - 'Get the current date from the remote date server. - Try - Dim bytesReceived As Integer - Dim getByte(100) As Byte - serverSocket.Connect(New IPEndPoint(serverAddress, serverPort)) - bytesReceived = serverSocket.Receive(getByte, getByte.Length, 0) - Return asciiEncoding.GetString(getByte, 0, bytesReceived) - Catch e As Exception - Console.WriteLine(ControlChars.Cr + "Exception raised : {0}", e.Message) - Return "" - End Try - End Function 'GetDate -End Class - - -'This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' object. -Public Class UserDateClient - - 'Entry point which delegates to C-style main Private Function - Public Overloads Shared Sub Main() - Main(System.Environment.GetCommandLineArgs()) - End Sub - - - Overloads Public Shared Sub Main(args() As [String]) - If args.Length <> 3 Then - PrintUsage() - Return - End If - Try - Dim myDateClient As New DateClient(IPAddress.Parse(args(1)), Int32.Parse(args(2))) - Dim currentDate As [String] = myDateClient.GetDate() - Console.WriteLine("The current date and time is : ") - Console.WriteLine("{0}", currentDate) - 'This exception is thrown by the called method in the context of improper permissions. - Catch e As SecurityException - Console.WriteLine(ControlChars.Cr + "SecurityException raised : {0}", e.Message) - Catch e As Exception - Console.WriteLine(ControlChars.Cr + "Exception raised : {0}", e.Message) - End Try - End Sub - - - Private Shared Sub PrintUsage() - Console.WriteLine("Usage : DateClient_SocketPermission_ToXml") - Console.WriteLine(ControlChars.Tab + "DateClient_SocketPermission_ToXml " + ChrW(60) + "ipaddress" + ChrW(62) + " " + ChrW(60) + "port" + ChrW(62)) - Console.WriteLine(ControlChars.Tab + "The ipaddress argument is the ip address of the Date server.") - Console.WriteLine(ControlChars.Tab + "The port argument is the port of the Date server.") - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb b/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb deleted file mode 100644 index 8b8f66684d1..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb +++ /dev/null @@ -1,56 +0,0 @@ - ' -' This program demonstrates the 'Constructor' of 'DnsPermission' class. -' It creates an instance of 'DnsPermission' class and checks for permission.Then it -' creates a 'SecurityElement' object and prints it's attributes which hold the XML -' encoding of 'DnsPermission' instance . -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - -Class DnsPermissionExample - - - Public Shared Sub Main() - Try - Dim dnsPermissionExampleObj As New DnsPermissionExample() - dnsPermissionExampleObj.useDns() - Catch e As SecurityException - Console.WriteLine("SecurityException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As Exception - Console.WriteLine("Exception caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - -' - Public Sub useDns() - ' Create a DnsPermission instance. - Dim permission As New DnsPermission(PermissionState.Unrestricted) - - ' Check for permission. - permission.Demand() - ' Create a SecurityElement object to hold XML encoding of the DnsPermission instance. - Dim securityElementObj As SecurityElement = permission.ToXml() - Console.WriteLine("Tag, Attributes and Values of 'DnsPermission' instance :") - Console.WriteLine((ControlChars.Cr + ControlChars.Tab + "Tag :" + securityElementObj.Tag)) - ' Print the attributes and values. - PrintKeysAndValues(securityElementObj.Attributes) - End Sub - - Private Sub PrintKeysAndValues(myList As Hashtable) - ' Get the enumerator that can iterate through the hash table. - Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator() - Console.WriteLine(ControlChars.Cr + ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub -' -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb b/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb deleted file mode 100644 index 9bd102138f0..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb +++ /dev/null @@ -1,59 +0,0 @@ - ' -' This program demonstrates the 'Copy' method of 'DnsPermission' class. -' It creates an identical copy of 'DnsPermission' instance. -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - -Class DnsPermissionExample - - - Public Shared Sub Main() - Try - Dim dnsPermissionExampleObj As New DnsPermissionExample() - dnsPermissionExampleObj.UseDns() - Catch e As SecurityException - Console.WriteLine("SecurityException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As Exception - Console.WriteLine("Exception caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - - -' - Public Sub UseDns() - ' Create a DnsPermission instance. - Dim myPermission As New DnsPermission(PermissionState.Unrestricted) - ' Check for permission. - myPermission.Demand() - ' Create an identical copy of the above DnsPermission object. - Dim myPermissionCopy As DnsPermission = CType(myPermission.Copy(), DnsPermission) - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :") - ' Print the attributes and values. - PrintKeysAndValues(myPermission.ToXml().Attributes) - Console.WriteLine("Attribute and values of copied instance :") - PrintKeysAndValues(myPermissionCopy.ToXml().Attributes) - End Sub - - - Private Sub PrintKeysAndValues(myHashtable As Hashtable) - ' Get the enumerator that can iterate through he hash table. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub - -' - -End Class - diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb b/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb deleted file mode 100644 index 960c29e07c4..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb +++ /dev/null @@ -1,80 +0,0 @@ - ' -' This program demonstrates the 'FromXml' method of 'DnsPermission' class. -' It creates an instance of 'DnsPermission' class and prints the XML encoding of that instance.Then it -' creates a 'SecurityElement' object and adds the attributes corresponding to the above 'DnsPermission' -' object. A new 'DnsPermission' instance is reconstructed from the 'SecurityElement' instance by calling -' 'FromXml' method and it's XML encoding is printed. -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - -Class DnsPermissionExample - - - Public Shared Sub Main() - Dim dnsPermissionExampleObj As New DnsPermissionExample() - dnsPermissionExampleObj.ConstructDnsPermission() - End Sub - -' - Public Sub ConstructDnsPermission() - Try - ' Create a DnsPermission instance. - Dim permission As New DnsPermission(PermissionState.None) - ' Create a SecurityElement instance by calling the ToXml method on the - ' DnsPermission instance and print its attributes, - ' which hold the XML encoding of the DnsPermission instance. - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :") - PrintKeysAndValues(permission.ToXml().Attributes) - - ' Create a SecurityElement instacnce . - Dim securityElementObj As New SecurityElement("IPermission") - ' Add attributes and values of the SecurityElement instance corresponding to - ' the permission instance. - securityElementObj.AddAttribute("version", "1") - securityElementObj.AddAttribute("Unrestricted", "true") - securityElementObj.AddAttribute("class", "System.Net.DnsPermission") - - ' Reconstruct a DnsPermission instance from an XML encoding. - Dim permission1 As New DnsPermission(PermissionState.None) - permission1.FromXml(securityElementObj) - - ' Print the attributes and values of the constructed DnsPermission object. - Console.WriteLine("After reconstruction Attributes and Values of new DnsPermission instance :") - PrintKeysAndValues(permission1.ToXml().Attributes) - Catch e As NullReferenceException - Console.WriteLine("NullReferenceException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As SecurityException - Console.WriteLine("SecurityException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As ArgumentNullException - Console.WriteLine("ArgumentNullException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As Exception - Console.WriteLine("Exception caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - - - Private Sub PrintKeysAndValues(myList As Hashtable) - ' Get the enumerator that can iterate through the hash table. - Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub - -' - -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb b/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb deleted file mode 100644 index bb0bb42de78..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb +++ /dev/null @@ -1,71 +0,0 @@ - ' -' This program demonstrates the 'IsSubsetOf' method of 'DnsPermission' class. -' 'IsSubsetOf' method returns true, if the current DnsPermission instance allows no -' more access to DNS servers than does the specified 'DnsPermission' instance. -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - -Class DnsPermissionExample - - ' private variables - Private permission As DnsPermission - - - Public Shared Sub Main() - Try - Dim dnsPermissionExampleObj As New DnsPermissionExample() - dnsPermissionExampleObj.useDns() - Catch e As SecurityException - Console.WriteLine("SecurityException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As Exception - Console.WriteLine("Exception caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - -' - Public Sub useDns() - ' Create a DnsPermission instance. - permission = New DnsPermission(PermissionState.Unrestricted) - Dim dnsPermission1 As New DnsPermission(PermissionState.None) - ' Check for permission. - permission.Demand() - dnsPermission1.Demand() - ' Print the attributes and values. - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :") - PrintKeysAndValues(permission.ToXml().Attributes) - Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :") - PrintKeysAndValues(dnsPermission1.ToXml().Attributes) - Subset(dnsPermission1) - End Sub - - - Private Sub Subset(Permission1 As DnsPermission) - If permission.IsSubsetOf(Permission1) Then - Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance.") - Else - Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance.") - End If - End Sub - - Private Sub PrintKeysAndValues(myList As Hashtable) - ' Get the enumerator that can iterate through the hash table. - Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub - -' - -End Class - diff --git a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb b/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb deleted file mode 100644 index b15d0e27433..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb +++ /dev/null @@ -1,57 +0,0 @@ - ' -' This program demonstrates the 'IsUnrestricted' method of 'DnsPermission' class. -' It checks the overall permission state of the object and it will return true if the -' 'DnsPermission' instance was created with unrestricted permission state otherwise false. -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - -Class DnsPermissionExample - - - Public Shared Sub Main() - Try - Dim dnsPermissionExampleObj As New DnsPermissionExample() - dnsPermissionExampleObj.useDns() - Catch e As SecurityException - Console.WriteLine("SecurityException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As Exception - Console.WriteLine("Exception caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - -' - Public Sub useDns() - ' Create a DnsPermission instance. - Dim permission As New DnsPermission(PermissionState.Unrestricted) - ' Check for permission. - permission.Demand() - Console.WriteLine("Attributes and Values of DnsPermission instance :") - ' Print the attributes and values. - PrintKeysAndValues(permission.ToXml().Attributes) - ' Check the permission state. - If permission.IsUnrestricted() Then - Console.WriteLine("Overall permissions : Unrestricted") - Else - Console.WriteLine("Overall permissions : Restricted") - End If - End Sub - - Private Sub PrintKeysAndValues(myList As Hashtable) - ' Get the enumerator that can iterate through the hash table. - Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb deleted file mode 100644 index 7d1219ef0ef..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/SocketPermissionExample/VB/source.vb +++ /dev/null @@ -1,107 +0,0 @@ - -Imports System.Text -Imports System.IO -Imports System.Net -Imports System.Net.Sockets -Imports System.Threading -Imports System.Security.Permissions -Imports System.Collections - -Public Class MySocketPermissionExample - - - Public Shared Sub MySocketPermission() - ' - ' - ' Creates a SocketPermission restricting access to and from all URIs. - Dim mySocketPermission1 As New SocketPermission(PermissionState.None) - - ' The socket to which this permission will apply will allow connections from www.contoso.com. - mySocketPermission1.AddPermission(NetworkAccess.Accept, TransportType.Tcp, "www.contoso.com", 11000) - - ' Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com. - Dim mySocketPermission2 As New SocketPermission(NetworkAccess.Connect, TransportType.Tcp, "www.southridgevideo.com", 11002) - - ' Creates a SocketPermission from the union of two SocketPermissions. - Dim mySocketPermissionUnion As SocketPermission = CType(mySocketPermission1.Union(mySocketPermission2), SocketPermission) - - ' Checks to see if the union was successfully created by using the IsSubsetOf method. - If mySocketPermission1.IsSubsetOf(mySocketPermissionUnion) And mySocketPermission2.IsSubsetOf(mySocketPermissionUnion) Then - Console.WriteLine("This union contains permissions from both mySocketPermission1 and mySocketPermission2") - - ' Prints the allowable accept URIs to the console. - Console.WriteLine("This union accepts connections on :") - - Dim myEnumerator As IEnumerator = mySocketPermissionUnion.AcceptList - While myEnumerator.MoveNext() - Console.WriteLine(CType(myEnumerator.Current, EndpointPermission).ToString()) - End While - - Console.WriteLine("This union establishes connections on : ") - - ' Prints the allowable connect URIs to the console. - Console.WriteLine("This union permits connections to :") - - myEnumerator = mySocketPermissionUnion.ConnectList - While myEnumerator.MoveNext() - Console.WriteLine(CType(myEnumerator.Current, EndpointPermission).ToString()) - End While - End If - ' - ' - ' Creates a SocketPermission from the intersect of two SocketPermissions. - Dim mySocketPermissionIntersect As SocketPermission = CType(mySocketPermission1.Intersect(mySocketPermissionUnion), SocketPermission) - - ' mySocketPermissionIntersect should now contain the permissions of mySocketPermission1. - If mySocketPermission1.IsSubsetOf(mySocketPermissionIntersect) Then - Console.WriteLine("This is expected") - End If - ' mySocketPermissionIntersect should not contain the permissios of mySocketPermission2. - If mySocketPermission2.IsSubsetOf(mySocketPermissionIntersect) Then - Console.WriteLine("This should not print") - End If - - ' - ' - ' Creates a copy of the intersect SocketPermission. - Dim mySocketPermissionIntersectCopy As SocketPermission = CType(mySocketPermissionIntersect.Copy(), SocketPermission) - - If mySocketPermissionIntersectCopy.Equals(mySocketPermissionIntersect) Then - Console.WriteLine("Copy successfull") - End If - ' - ' Converts a SocketPermission to XML format and then immediately converts it back to a SocketPermission. - mySocketPermission1.FromXml(mySocketPermission1.ToXml()) - - - ' Checks to see if permission for this socket resource is unrestricted. If it is, then there is no need to - ' demand that permissions be enforced. - If mySocketPermissionUnion.IsUnrestricted() Then - - 'Do nothing. There are no restrictions. - Else - ' Enforces the permissions found in mySocketPermissionUnion on any Socket Resources used below this statement. - mySocketPermissionUnion.Demand() - End If - - Dim myIpHostEntry As IPHostEntry = Dns.Resolve("www.contoso.com") - Dim myLocalEndPoint As New IPEndPoint(myIpHostEntry.AddressList(0), 11000) - - Dim s As New Socket(myLocalEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp) - Try - s.Connect(myLocalEndPoint) - Catch e As Exception - Console.WriteLine(("Exception Thrown: " + e.ToString())) - End Try - - ' Perform all socket operations in here. - s.Close() - End Sub - ' - - Public Shared Sub Main() - MySocketPermissionExample.MySocketPermission() - End Sub -End Class - - diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Accept/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Accept/VB/source.vb deleted file mode 100644 index fc3ab01c260..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Accept/VB/source.vb +++ /dev/null @@ -1,43 +0,0 @@ - ' System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - -' Demonstrate how to use the WebPermissionAttribute Accept property. - - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.IO - -Public Class WebPermissionAttribute_AcceptConnect - ' - - ' Deny access to a specific resource by setting the Accept property. - - _ - Public Shared Sub CheckAcceptPermission(uriToCheck As String) - Dim permissionToCheck As New WebPermission() - permissionToCheck.AddPermission(NetworkAccess.Accept, uriToCheck) - permissionToCheck.Demand() - End Sub - - - Public Shared Sub demoDenySite() - ' Pass the security check when accessing allowed resources. - CheckAcceptPermission("http://www.contoso.com/Public.htm") - Console.WriteLine("Public page has passed Accept permission check") - Try - 'Throw a SecurityException when trying to access not allowed resources. - CheckAcceptPermission("http://www.contoso.com/Private.htm") - Console.WriteLine("This line will not be printed") - Catch e As SecurityException - Console.WriteLine(("Exception trying to access private resource:" + e.Message)) - End Try - End Sub - ' - - - Shared Sub Main() - demoDenySite() - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/VB/webpermissionattribute_acceptconnect.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/VB/webpermissionattribute_acceptconnect.vb deleted file mode 100644 index 72cbde4b92f..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/VB/webpermissionattribute_acceptconnect.vb +++ /dev/null @@ -1,41 +0,0 @@ -' System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - -' Demonstrate how to use the WebPermissionAttribute to specify an allowable ConnectPattern. - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.IO - -Public Class WebPermissionAttribute_AcceptConnect - -' -' - - ' Deny access to a specific resource by setting the ConnectPattern property. - Public Sub Connect() - - ' Create a Connection. - Dim myWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest) - Console.WriteLine("This line should never be printed") - -' -' - - End Sub - - - Shared Sub Main() - - Try - - Dim myWebAttrib As New WebPermissionAttribute_AcceptConnect() - myWebAttrib.Connect() - - Catch e As SecurityException - Console.WriteLine(("Security Exception raised : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception raised : " + e.Message)) - End Try - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/VB/source.vb deleted file mode 100644 index 218deaccb93..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/VB/source.vb +++ /dev/null @@ -1,49 +0,0 @@ - ' System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; -'This program demonstrates the 'Connect' and 'Accept' properties of the class 'WebPermissionAttribute'. -'The program uses declarative security for calling the code in 'Connect' method. -'By using the 'Accept' and 'Connect' properties of 'WebPermissionAttribute' accept and connect access -'has been given to the uri www.contoso.com. - - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.IO -Imports System.Text.RegularExpressions - - -Public Class WebPermissionAttribute_AcceptConnect - - ' - _ - Public Shared Sub CheckAcceptPermission(uriToCheck As String) - Dim re As New Regex("http://www\.contoso\.com/Public/.*") - Dim con As New WebPermission(NetworkAccess.Connect, re) - con.Assert() - Dim permissionToCheck As New WebPermission() - permissionToCheck.AddPermission(NetworkAccess.Accept, uriToCheck) - permissionToCheck.Demand() - End Sub - - - Public Shared Sub demoDenySite() - 'Passes a security check. - CheckAcceptPermission("http://www.contoso.com/Public/page.htm") - Console.WriteLine("Public page has passed Accept permission check") - - Try - 'Throws a SecurityException. - CheckAcceptPermission("http://www.contoso.com/Private/page.htm") - Console.WriteLine("This line will not be printed") - Catch e As SecurityException - Console.WriteLine(("Expected exception" + e.Message)) - End Try - End Sub - - - ' - Shared Sub Main() - demoDenySite() - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Connect/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Connect/VB/source.vb deleted file mode 100644 index f9c9eca9ac0..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Connect/VB/source.vb +++ /dev/null @@ -1,42 +0,0 @@ - ' System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Connect; - -'Demonstrate how to use the WebPermissionAttribute Connect property. - - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.IO - -Public Class WebPermissionAttribute_Connect - ' - - ' Set the WebPermissionAttribute Connect property. - _ - Public Shared Sub CheckConnectPermission(uriToCheck As String) - Dim permissionToCheck As New WebPermission() - permissionToCheck.AddPermission(NetworkAccess.Connect, uriToCheck) - permissionToCheck.Demand() - End Sub - - - Public Shared Sub demoDenySite() - 'Pass the security check. - CheckConnectPermission("http://www.contoso.com/Public.htm") - Console.WriteLine("Public page has passed Connect permission check") - Try - 'Throw a SecurityException. - CheckConnectPermission("http://www.contoso.com/Private.htm") - Console.WriteLine("This line will not be printed") - Catch e As SecurityException - Console.WriteLine(("Expected exception" + e.Message)) - End Try - End Sub - ' - - - Shared Sub Main() - demoDenySite() - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/VB/source.vb deleted file mode 100644 index 56bf7aac4e9..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/VB/source.vb +++ /dev/null @@ -1,49 +0,0 @@ - ' System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Connect; - - ' Demonstrate how to use the WebPermissionAttribute ConnectPattern property. - - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.IO -Imports System.Text.RegularExpressions - - -Public Class WebPermissionAttribute_Connect - - ' - - ' Set the WebPermissionAttribute ConnectPattern property. - _ - Public Shared Sub CheckConnectPermission(uriToCheck As String) - Dim re As New Regex("http://www\.contoso\.com/Public/.*") - Dim con As New WebPermission(NetworkAccess.Connect, re) - con.Assert() - Dim permissionToCheck As New WebPermission() - permissionToCheck.AddPermission(NetworkAccess.Connect, uriToCheck) - permissionToCheck.Demand() - End Sub - - - Public Shared Sub demoDenySite() - 'Pass the security check. - CheckConnectPermission("http://www.contoso.com/Public/page.htm") - Console.WriteLine("Public page has passed Connect permission check") - - Try - 'Throw a SecurityException. - CheckConnectPermission("http://www.contoso.com/Private/page.htm") - Console.WriteLine("This line will not be printed") - Catch e As SecurityException - Console.WriteLine(("Expected exception" + e.Message)) - End Try - End Sub - - - ' - Shared Sub Main() - demoDenySite() - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/VB/source.vb deleted file mode 100644 index eb71f4e6975..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/VB/source.vb +++ /dev/null @@ -1,43 +0,0 @@ - ' System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.IO - -Public Class WebPermissionAttribute_AcceptConnect - -' - - ' Set the declarative security for the URI. - _ - Public Sub Connect() - ' Throw an exception. - Try - Dim myWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest) - Catch e As Exception - Console.WriteLine(("Exception : " + e.ToString())) - End Try - End Sub - -' - - - - - Shared Sub Main() - - Try - - Dim myWebAttrib As New WebPermissionAttribute_AcceptConnect() - myWebAttrib.Connect() - - Catch e As SecurityException - Console.WriteLine(("Security Exception raised : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception raised : " + e.Message)) - End Try - End Sub - -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_AcceptConnectList/VB/webpermission_acceptconnectlist.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_AcceptConnectList/VB/webpermission_acceptconnectlist.vb deleted file mode 100644 index ceb137ef39e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_AcceptConnectList/VB/webpermission_acceptconnectlist.vb +++ /dev/null @@ -1,89 +0,0 @@ -' System.Net.WebPermission.ConnectList;System.Net.WebPermission.AcceptList; -' This program demonstrates the use of the ConnectList and AcceptList WebPermission -' class prerties. -' It first creates a WebPermission object with Permissionstate set to None and then -' sets the Connect and Accept access right to some predefined URLs. -' The using the AcceptList and ConnectList properties it displays the URLs that have -' the Accept and Connect permission set, respectively. - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - - _ - -Class WebPermission_AcceptConnectList - - Shared Sub Main() - Try - Dim myWebPermission_AcceptConnectList As New WebPermission_AcceptConnectList() - myWebPermission_AcceptConnectList.DisplayAcceptConnect() - Catch e As SecurityException - Console.WriteLine(("SecurityException : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception : " + e.Message)) - End Try - End Sub - - - Public Sub DisplayAcceptConnect() - ' Create a 'WebPermission' object with permission state set to 'None'. - Dim myWebPermission1 As New WebPermission(PermissionState.None) - - ' Allow 'Connect' access right to first set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.contoso.com") - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.adventure-works.com") - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.alpineskihouse.com") - - ' Allow 'Accept' access right to second set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Accept, "http://www.contoso.com") - myWebPermission1.AddPermission(NetworkAccess.Accept, "http://www.adventure-works.com") - myWebPermission1.AddPermission(NetworkAccess.Accept, "http://www.alpineskihouse.com") - - ' Check whether all callers higher in the call stack have been granted the permission or not. - myWebPermission1.Demand() - - Console.WriteLine("The Attributes,Values and Children of the 'WebPermission' object are :" + ControlChars.Cr) - ' Display the Attributes,Values and Children of the XML encoded instance. - PrintKeysAndValues(myWebPermission1.ToXml().Attributes, myWebPermission1.ToXml().Children) - -' - ' Gets all URIs with Connect permission. - Dim myEnum As IEnumerator = myWebPermission1.ConnectList - Console.WriteLine(ControlChars.Cr + "The URIs with Connect permission are :" + ControlChars.Cr) - While myEnum.MoveNext() - Console.WriteLine((ControlChars.Tab + "The URI is : " + myEnum.Current)) - End While -' - -' - ' Get all URI's with Accept permission. - Dim myEnum1 As IEnumerator = myWebPermission1.AcceptList - Console.WriteLine(ControlChars.Cr + ControlChars.Cr + "The URIs with Accept permission are :" + ControlChars.Cr) - While myEnum1.MoveNext() - Console.WriteLine((ControlChars.Tab + "The URI is : " + myEnum1.Current)) - End While - ' - - End Sub - - - Private Sub PrintKeysAndValues(myHashtable As Hashtable, myList As IEnumerable) - ' Get the enumerator that can iterate through Hashtabel. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-Attribute-" + ControlChars.Tab + "-Value-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - - Dim myEnumerator1 As IEnumerator = myList.GetEnumerator() - Console.WriteLine("The Children are : " + ControlChars.Cr) - While myEnumerator1.MoveNext() - Console.Write(myEnumerator1.Current) - End While - End Sub - -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Constructor4/VB/webpermission_constructor4.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Constructor4/VB/webpermission_constructor4.vb deleted file mode 100644 index 29ab1119e3d..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Constructor4/VB/webpermission_constructor4.vb +++ /dev/null @@ -1,69 +0,0 @@ -' System.Net.WebPermission.WebPermission(NetworkAccess,Regex); - -' This program demonstrates the 'WebPermission(NetworkAccess,Regex)' constructor of 'WebPermission' class. -' First a 'Regex' object is created that will accept all the urls which is having the hostfragment of -' 'www.microsoft.com'.Then a 'WebPermission' object created by passing the 'NetworkAccess' permission and -' 'Regex' object as parameters. It checks the 'WebPermission' for all the url's having the host fragment -' as 'www.microsoft.com'. -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Text.RegularExpressions -Imports System.Collections - -Class WebPermission_regexConstructor - - - Shared Sub Main() - Try - - Dim myWebPermissionRegex As New WebPermission_regexConstructor() - myWebPermissionRegex.CreateRegexConstructor() - - Catch e As SecurityException - Console.WriteLine(("SecurityException raised: " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception raised: " + e.Message)) - End Try - End Sub - - - Public Sub CreateRegexConstructor() - -' - ' Creates an instance of 'Regex' that accepts all URL's containing the host fragment 'www.contoso.com'. - Dim myRegex As New Regex("http://www\.contoso\.com/.*") - - ' Creates a 'WebPermission' that gives the permissions to all the hosts containing same host fragment. - Dim myWebPermission As New WebPermission(NetworkAccess.Connect, myRegex) - - ' Checks all callers higher in the call stack have been granted the permission. - myWebPermission.Demand() - -' - Console.WriteLine("Attribute and Values of WebPermission are : " + ControlChars.Cr) - ' Display the Attributes,Values and Children of the XML encoded copied instance. - PrintKeysAndValues(myWebPermission.ToXml().Attributes, myWebPermission.ToXml().Children) - - - End Sub - - - Private Sub PrintKeysAndValues(myHashtable As Hashtable, myList As IEnumerable) - ' Get the enumerator that can iterate through Hashtabel. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-ATTRIBUTES-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - - Dim myEnumerator1 As IEnumerator = myList.GetEnumerator() - Console.WriteLine(ControlChars.Cr + "The Children are : ") - While myEnumerator1.MoveNext() - Console.Write(ControlChars.Tab + "{0}", myEnumerator1.Current) - End While - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Copy/VB/webpermission_copy.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Copy/VB/webpermission_copy.vb deleted file mode 100644 index 6ccf0d3cd5e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Copy/VB/webpermission_copy.vb +++ /dev/null @@ -1,84 +0,0 @@ - ' System.Net.WebPermission.WebPermission(PermissionState);System.Net.WebPermission.Copy; - -' This program demonstrates the WebPermission(PermissionState) constructor and -' Copy method of the WebPermission class . -' It creates a WebPermission instance with Permissionstate set to None and -' sets the access right to one pair of URLs. -' Then it uses the Copy method to create another instance of WebPermission class -' Finally, the attributes , values and childrens of both the XML encoded instances -' are displayed. -' - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - - _ - -Class CopyWebPermission - - - Shared Sub Main() - Try - Dim myCopyWebPermission As New CopyWebPermission() - myCopyWebPermission.CreateCopy() - Catch e As SecurityException - Console.WriteLine(("SecurityException : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception : " + e.Message)) - End Try - End Sub - - - Public Sub CreateCopy() - -' - ' Create a WebPermission instance. - Dim myWebPermission1 As New WebPermission(PermissionState.None) - - ' Allow access to the first set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.microsoft.com/default.htm") - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.msn.com") - - ' Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission1.Demand() - -' - -' - ' Create another WebPermission instance that is the copy of the above WebPermission instance. - Dim myWebPermission2 As WebPermission = CType(myWebPermission1.Copy(), WebPermission) - - ' Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission2.Demand() - -' - Console.WriteLine("The Attributes and Values are :" + ControlChars.Cr) - ' Display the Attributes,Values and Children of the XML encoded instance. - PrintKeysAndValues(myWebPermission1.ToXml().Attributes, myWebPermission1.ToXml().Children) - - Console.WriteLine(ControlChars.Cr + "Copied Instance Attributes and Values are :" + ControlChars.Cr) - ' Display the Attributes,Values and Children of the XML encoded copied instance. - PrintKeysAndValues(myWebPermission2.ToXml().Attributes, myWebPermission2.ToXml().Children) - End Sub - - - Private Sub PrintKeysAndValues(myHashtable As Hashtable, myList As IEnumerable) - - ' Gets the enumerator that can iterate through Hashtable. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - - Dim myEnumerator1 As IEnumerator = myList.GetEnumerator() - Console.WriteLine("The Children are : ") - While myEnumerator1.MoveNext() - Console.Write(ControlChars.Tab + "{0}", myEnumerator1.Current) - End While - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_FromToXml/VB/webpermission_fromtoxml.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_FromToXml/VB/webpermission_fromtoxml.vb deleted file mode 100644 index 88f180014cb..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_FromToXml/VB/webpermission_fromtoxml.vb +++ /dev/null @@ -1,70 +0,0 @@ -' System.Net.WebPermission.ToXml;System.Net.WebPermission.FromXml; -' -' This program shows the use of the ToXml and FromXml methods of the WebPermission class. -' It creates a WebPermission instance with the Permissionstate set to None and -' displays the attributes and the values of the XML encoded instance . -' Then a SecurityElement instance is created and it's attributes are set. -' Finally, using the FromXml method the WebPermission instance is reconstructed from -' the above SecurityElement instance and the attributes are displayed. -' - - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - - _ - -Class WebPermission_FromToXml - - - Shared Sub Main() - Try - Dim myWebPermission_FromToXml As New WebPermission_FromToXml() - myWebPermission_FromToXml.CallXml() - Catch e As SecurityException - Console.WriteLine(("SecurityException : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception : " + e.Message)) - End Try - End Sub - - - Public Sub CallXml() - -' - ' Create a WebPermission without permission on the protected resource. - Dim myWebPermission1 As New WebPermission(PermissionState.None) - - ' Create a SecurityElement by calling the ToXml method on the WebPermission - ' instance and display its attributes (which hold the XML encoding of - ' the WebPermission). - Console.WriteLine("Attributes and Values of the WebPermission are :") - myWebPermission1.ToXml().ToString() - - ' Create another WebPermission with no permission on the protected resource. - Dim myWebPermission2 As New WebPermission(PermissionState.None) - - 'Converts the new WebPermission from XML using myWebPermission1. - myWebPermission2.FromXml(myWebPermission1.ToXml()) - -' - - Console.WriteLine("The Attributes and Values of 'WebPermission' instance after reconstruction are: " + ControlChars.Cr) - ' Display the Attributes and values of the XML encoded instances. - PrintKeysAndValues(myWebPermission2.ToXml().Attributes) - End Sub - - - Private Sub PrintKeysAndValues(myHashtable As Hashtable) - ' Get the enumerator to iterate through Hashtable. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Intersect/VB/webpermission_intersect.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Intersect/VB/webpermission_intersect.vb deleted file mode 100644 index 5cd2dd45fb2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Intersect/VB/webpermission_intersect.vb +++ /dev/null @@ -1,93 +0,0 @@ -' System.Net.WebPermission.WebPermission(); -' System.Net.WebPermission.AddPermission(NetworkAccess,stringuri); -' System.Net.WebPermission.Intersect; -' -' This program shows the use of the WebPermission() constructor, the AddPermission, -' and Intersect' methods of the WebPermission' class. -' It first creates two WebPermission objects with no arguments, with each of them -' setting the access rights to one pair of URLs. -' Then it displays the attributes , values and childrens of the XML encoded instances. -' Finally, it creates a third WebPermission object using the logical intersection of the -' first two objects. It does so by using the Intersect method. -' It then displays the attributes , values and childrens of the related XML encoded -' instances. -' - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - - _ - -Class WebPermissionIntersect - - Shared Sub Main(Args() As [String]) - Try - Dim myWebPermissionIntersect As New WebPermissionIntersect() - myWebPermissionIntersect.CreateIntersect() - Catch e As SecurityException - Console.WriteLine(("SecurityException : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception : " + e.Message)) - End Try - End Sub - - - Public Sub CreateIntersect() - ' - ' Create two WebPermission instances. - Dim myWebPermission1 As New WebPermission() - Dim myWebPermission2 As New WebPermission() - - ' - ' Allow access to the first set of resources. - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.contoso.com/default.htm") - myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.adventure-works.com/default.htm") - - ' Check whether if the callers higher in the call stack have been granted - ' access permissions. - myWebPermission1.Demand() - - ' - ' Allow access right to the second set of resources. - myWebPermission2.AddPermission(NetworkAccess.Connect, "http://www.alpineskihouse.com/default.htm") - myWebPermission2.AddPermission(NetworkAccess.Connect, "http://www.baldwinmuseumofscience.com/default.htm") - myWebPermission2.Demand() - - ' - ' Display the attributes , values and childrens of the XML encoded instances. - Console.WriteLine("Attributes and values of first 'WebPermission' instance are :") - PrintKeysAndValues(myWebPermission1.ToXml().Attributes, myWebPermission2.ToXml().Children) - - Console.WriteLine(ControlChars.Cr + "Attributes and values of second 'WebPermission' instance are : ") - PrintKeysAndValues(myWebPermission2.ToXml().Attributes, myWebPermission2.ToXml().Children) - - ' - ' Create a third WebPermission instance via the logical intersection of the previous - ' two WebPermission instances. - Dim myWebPermission3 As WebPermission = CType(myWebPermission1.Intersect(myWebPermission2), WebPermission) - - Console.WriteLine(ControlChars.Cr + "Attributes and Values of the WebPermission instance after the Intersect are:" + ControlChars.Cr) - Console.WriteLine(myWebPermission3.ToXml().ToString()) - End Sub - - ' - - Private Sub PrintKeysAndValues(myHashtable As Hashtable, myList As IEnumerable) - ' Get the enumerator that can iterate through Hashtable. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - - Dim myEnumerator1 As IEnumerator = myList.GetEnumerator() - Console.WriteLine("The Children are : ") - While myEnumerator1.MoveNext() - Console.Write(ControlChars.Tab + "{0}", myEnumerator1.Current) - End While - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset/VB/webpermission_issubset.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset/VB/webpermission_issubset.vb deleted file mode 100644 index d759effd572..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset/VB/webpermission_issubset.vb +++ /dev/null @@ -1,95 +0,0 @@ - ' System.Net.WebPermission.AddPermission(NetworkAccess, regex); -' System.Net.WebPermission.IsSubsetOf; -'* -' This program shows how to use the AddPermission(NetworkAccess, regex) and -' IsSubset methods of WebPermission class. -' It creates two WebPermission instances with the Connect access rights for the -' specified URIs. -' For he first WebPermission instance, a Connect access right is given to the -' URLs with the host fragment www.microsoft.com. This is done by using -' the AddPermission(NetworkAccess, regex) method. -' Then, a third WebPermission instance is created with the Connect access right to -' the URLs of the first and second WebPermission instances. -' Finally, the attributes, values and children of that instance are displayed. -' - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections -Imports System.Text.RegularExpressions - - _ - -Class WebPermissionIsSubset - - - Shared Sub Main(Args() As [String]) - Try - Dim myWebPermissionIsSubset As New WebPermissionIsSubset() - myWebPermissionIsSubset.CheckSubset() - - Catch e As SecurityException - Console.WriteLine(("SecurityException : " + e.Message)) - - Catch e As Exception - Console.WriteLine(("Exception : " + e.Message)) - End Try - End Sub - - - Public Sub CheckSubset() -' - ' Create a WebPermission. - Dim myWebPermission1 As New WebPermission() - - ' Allow Connect access to the specified URLs. - myWebPermission1.AddPermission(NetworkAccess.Connect, New Regex("http://www\.contoso\.com/.*", RegexOptions.Compiled Or RegexOptions.IgnoreCase Or RegexOptions.Singleline)) - - myWebPermission1.Demand() - -' - ' Create another WebPermission with the specified URL. - Dim myWebPermission2 As New WebPermission(NetworkAccess.Connect, "http://www.contoso.com") - ' Check whether all callers higher in the call stack have been granted the permission. - myWebPermission2.Demand() - -' - Dim myWebPermission3 As WebPermission = Nothing - ' Check which permissions have the Connect access to more number of URLs. - If myWebPermission2.IsSubsetOf(myWebPermission1) Then - Console.WriteLine(ControlChars.Cr + " WebPermission2 is the Subset of WebPermission1" + ControlChars.Cr) - myWebPermission3 = myWebPermission1 - Else - If myWebPermission1.IsSubsetOf(myWebPermission2) Then - Console.WriteLine(ControlChars.Cr + " WebPermission1 is the Subset of WebPermission2") - myWebPermission3 = myWebPermission2 - Else - ' Create the third permission. - myWebPermission3 = CType(myWebPermission1.Union(myWebPermission2), WebPermission) - End If - End If -' - ' Prints the attributes , values and childrens of XML encoded instances. - Console.WriteLine(ControlChars.Cr + "Attributes and Values of third WebPermission instance are : ") - PrintKeysAndValues(myWebPermission3.ToXml().Attributes, myWebPermission3.ToXml().Children) - End Sub - - - Private Sub PrintKeysAndValues(myHashtable As Hashtable, myList As IEnumerable) - ' Get the enumerator that can iterate through Hashtable. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - - Dim myEnumerator1 As IEnumerator = myList.GetEnumerator() - Console.WriteLine("The Children are : ") - While myEnumerator1.MoveNext() - Console.Write(ControlChars.Tab + "{0}", myEnumerator1.Current) - End While - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset2/VB/source.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset2/VB/source.vb deleted file mode 100644 index 7bdfbe44fba..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_IsSubset2/VB/source.vb +++ /dev/null @@ -1,44 +0,0 @@ - ' System.Net.WebPermission.AddPermission(NetworkAccess, regex);System.Net.WebPermission.IsSubsetOf; -' -' This program shows the use of the AddPermission(NetworkAccess, regex) and -' IsSubset methods of the WebPermission class. -' It creates two WebPermission instances with the Connect access rights for the specified -' URIs. The second URI being a subset of the first one. -' Then the IsSubsetOf method is called to verify that the second URI is indeed a subset -' of the firts one. The result of the call to the IsSubsetOf is then displayed. -' - - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections -Imports System.Text.RegularExpressions - - _ - -Public Class Sample - - - Public Shared Sub myIsSubsetExample() -' - ' Create the target permission. - Dim targetPermission As New WebPermission() - targetPermission.AddPermission(NetworkAccess.Connect, New Regex("www\.contoso\.com/Public/.*")) - - ' Create the permission for a URI matching target. - Dim connectPermission As New WebPermission() - connectPermission.AddPermission(NetworkAccess.Connect, "www.contoso.com/Public/default.htm") - - 'The following statement prints true. - Console.WriteLine(("Is the second URI a subset of the first one?: " & connectPermission.IsSubsetOf(targetPermission))) - End Sub - -' - - Public Shared Sub Main() - ' Verify that the second URI is a subset of the first one. - myIsSubsetExample() - End Sub - -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Regex/VB/regex.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Regex/VB/regex.vb deleted file mode 100644 index 7b742a2172f..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Regex/VB/regex.vb +++ /dev/null @@ -1,47 +0,0 @@ -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Text.RegularExpressions -Imports System.Collections - -Class MyWebPermissionExample - - - Public Shared Sub MySample() - -' - ' Create a Regex that accepts all the URLs contianing the host fragment www.contoso.com. - Dim myRegex As New Regex("http://www\.contoso\.com/.*") - - ' Create a WebPermission that gives permission to all the hosts containing same host fragment. - Dim myWebPermission As New WebPermission(NetworkAccess.Connect, myRegex) - ' Add connect privileges for a www.adventure-works.com. - myWebPermission.AddPermission(NetworkAccess.Connect, "http://www.adventure-works.com") - ' Add accept privileges for www.alpineskihouse.com. - myWebPermission.AddPermission(NetworkAccess.Accept, "http://www.alpineskihouse.com/") - ' Check whether all callers higher in the call stack have been granted the permission. - myWebPermission.Demand() - - ' Get all the URIs with Connect permission. - Dim myConnectEnum As IEnumerator = myWebPermission.ConnectList - Console.WriteLine(ControlChars.NewLine + "The 'URIs' with 'Connect' permission are :" + ControlChars.NewLine) - While myConnectEnum.MoveNext() - Console.WriteLine((ControlChars.Tab + myConnectEnum.Current.ToString())) - End While - - ' Get all the URIs with Accept permission. - Dim myAcceptEnum As IEnumerator = myWebPermission.AcceptList - Console.WriteLine(ControlChars.NewLine + ControlChars.NewLine + "The 'URIs' with 'Accept' permission is :" + ControlChars.NewLine) - - While myAcceptEnum.MoveNext() - Console.WriteLine((ControlChars.Tab + myAcceptEnum.Current)) - End While -' - - End Sub - - Public Shared Sub Main() - MySample() - End Sub - -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Union/VB/webpermission_union.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Union/VB/webpermission_union.vb deleted file mode 100644 index e86f4438b1d..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebPermission_Union/VB/webpermission_union.vb +++ /dev/null @@ -1,79 +0,0 @@ -' System.Net.WebPermission.WebPermission(NetworkAccess, uriString);System.Net.WebPermission.Union; -'* -' This program shows the use of the WebPermission(NetworkAccess access,string uriString) -' constructor and Union method of the WebPermission' class. -' It creates two instance of the WebPermission class with the specified access -' rights to the predefined URIs. -' It displays the attributes , values and childrens of those XML encoded instances. -' Then, using the Union method, it creates a third WebPermission instance -' via a logical union of the first two. -' Finally, it displays the attributes , values and childrens of those XML encoded -' instances. - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - - _ - -Class WebPermissionUnion - - - Shared Sub Main() - Try - Dim myWebPermissionUnion As New WebPermissionUnion() - myWebPermissionUnion.CreateUnion() - Catch e As SecurityException - Console.WriteLine(("SecurityException : " + e.Message)) - Catch e As Exception - Console.WriteLine(("Exception : " + e.Message)) - End Try - End Sub - - - Public Sub CreateUnion() - ' - ' Create a WebPermission.instance. - Dim myWebPermission1 As New WebPermission(NetworkAccess.Connect, "http://www.contoso.com/default.htm") - myWebPermission1.Demand() - - ' - ' Create another WebPermission instance. - Dim myWebPermission2 As New WebPermission(NetworkAccess.Connect, "http://www.adventure-works.com") - myWebPermission2.Demand() - - ' Print the attributes, values and childrens of the XML encoded instances. - Console.WriteLine("Attributes and values of the first WebPermission are : ") - PrintKeysAndValues(myWebPermission1.ToXml().Attributes, myWebPermission1.ToXml().Children) - - Console.WriteLine(ControlChars.Cr + "Attributes and values of the second WebPermission are : ") - PrintKeysAndValues(myWebPermission2.ToXml().Attributes, myWebPermission2.ToXml().Children) - - ' - ' Create another WebPermission that is the Union of previous two WebPermission - ' instances. - Dim myWebPermission3 As WebPermission = CType(myWebPermission1.Union(myWebPermission2), WebPermission) - Console.WriteLine(ControlChars.Cr + "Attributes and values of the WebPermission after the Union are : ") - ' Display the attributes,values and children. - Console.WriteLine(myWebPermission3.ToXml().ToString()) - End Sub - - ' - - Private Sub PrintKeysAndValues(myHashtable As Hashtable, myList As IEnumerable) - ' Get the enumerator that can iterate through Hashtable. - Dim myEnumerator As IDictionaryEnumerator = myHashtable.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - - Dim myEnumerator1 As IEnumerator = myList.GetEnumerator() - Console.WriteLine("The Children are : ") - While myEnumerator1.MoveNext() - Console.Write(ControlChars.Tab + "{0}", myEnumerator1.Current) - End While - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetResponse/VB/webrequest_begingetresponse.vb b/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetResponse/VB/webrequest_begingetresponse.vb deleted file mode 100644 index 6c9e168f56e..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetResponse/VB/webrequest_begingetresponse.vb +++ /dev/null @@ -1,128 +0,0 @@ -' System.Net.WebRequest.BeginGetResponse System.Net.WebRequest.EndGetResponse -' This program demonstrates 'BeginGetResponse' and 'EndGetResponse' methods of 'WebRequest' Class. -' A new 'WebRequest' object is created to the mentioned Uri.An Asynchronous call is started for response -' from the Uri using 'BeginGetResponse' method of 'WebRequest' class. The asynchronous response is ended -' by 'EndGetResponse' method of the 'WebRequest' class. The contents of the HTML page of the requested -' Uri are displayed to the console. -' - -' -' - -Imports System.Net -Imports System.IO -Imports System.Text -Imports System.Threading - -Public Class RequestState - ' This class stores the state of the request - Private Shared BUFFER_SIZE As Integer = 1024 - Public requestData As StringBuilder - Public bufferRead() As Byte - Public request As WebRequest - Public response As WebResponse - Public responseStream As Stream - - Public Sub New() - bufferRead = New Byte(BUFFER_SIZE) {} - requestData = New StringBuilder("") - request = Nothing - responseStream = Nothing - End Sub -End Class - -Class WebRequest_BeginGetResponse - Public Shared allDone As New ManualResetEvent(False) - Private Shared BUFFER_SIZE As Integer = 1024 - - Shared Sub Main() - Try - - - ' Create a new webrequest to the mentioned URL. - Dim myWebRequest As WebRequest = WebRequest.Create("http://www.contoso.com") - 'Please, set the proxy to a correct value. - Dim proxy As New WebProxy("itgproxy:80") - proxy.Credentials = New NetworkCredential("srikun", "simrin123") - myWebRequest.Proxy = proxy - ' Create a new instance of the RequestState. - Dim myRequestState As New RequestState() - ' The 'WebRequest' object is associated to the 'RequestState' object. - myRequestState.request = myWebRequest - ' Start the Asynchronous call for response. - Dim asyncResult As IAsyncResult = CType(myWebRequest.BeginGetResponse(AddressOf RespCallback, myRequestState), IAsyncResult) - allDone.WaitOne() - ' Release the WebResponse resource. - myRequestState.response.Close() - Console.Read() - Catch e As WebException - Console.WriteLine("WebException raised!") - Console.WriteLine(ControlChars.Cr + "{0}", e.Message) - Console.WriteLine(ControlChars.Cr + "{0}", e.Status) - Catch e As Exception - Console.WriteLine("Exception raised!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - - Private Shared Sub RespCallback(asynchronousResult As IAsyncResult) - Try - ' Set the State of request to asynchronous. - Dim myRequestState As RequestState = CType(asynchronousResult.AsyncState, RequestState) - Dim myWebRequest1 As WebRequest = myRequestState.request - ' End the Asynchronous response. - myRequestState.response = myWebRequest1.EndGetResponse(asynchronousResult) - ' Read the response into a 'Stream' object. - Dim responseStream As Stream = myRequestState.response.GetResponseStream() - myRequestState.responseStream = responseStream - ' Begin the reading of the contents of the HTML page and print it to the console. - Dim asynchronousResultRead As IAsyncResult = responseStream.BeginRead(myRequestState.bufferRead, 0, BUFFER_SIZE, AddressOf ReadCallBack, myRequestState) - Catch e As WebException - Console.WriteLine("WebException raised!") - Console.WriteLine(ControlChars.Cr + "{0}", e.Message) - Console.WriteLine(ControlChars.Cr + "{0}", e.Status) - Catch e As Exception - Console.WriteLine("Exception raised!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub - Private Shared Sub ReadCallBack(asyncResult As IAsyncResult) - Try - ' Result state is set to AsyncState. - Dim myRequestState As RequestState = CType(asyncResult.AsyncState, RequestState) - Dim responseStream As Stream = myRequestState.responseStream - Dim read As Integer = responseStream.EndRead(asyncResult) - ' Read the contents of the HTML page and then print to the console. - If read > 0 Then - myRequestState.requestData.Append(Encoding.ASCII.GetString(myRequestState.bufferRead, 0, read)) - Dim asynchronousResult As IAsyncResult = responseStream.BeginRead(myRequestState.bufferRead, 0, BUFFER_SIZE, AddressOf ReadCallBack, myRequestState) - Else - Console.WriteLine(ControlChars.Cr + "The HTML page Contents are: ") - If myRequestState.requestData.Length > 1 Then - Dim sringContent As String - sringContent = myRequestState.requestData.ToString() - Console.WriteLine(sringContent) - End If - Console.WriteLine(ControlChars.Cr + "Press 'Enter' key to continue........") - responseStream.Close() - allDone.Set() - End If - Catch e As WebException - Console.WriteLine("WebException raised!") - Console.WriteLine(ControlChars.Cr + "{0}", e.Message) - Console.WriteLine(ControlChars.Cr + "{0}", e.Status) - Catch e As Exception - Console.WriteLine("Exception raised!") - Console.WriteLine("Source :{0} ", e.Source) - Console.WriteLine("Message :{0} ", e.Message) - End Try - End Sub - -End Class - -' -' - - diff --git a/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb b/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb deleted file mode 100644 index 84ea88dea97..00000000000 --- a/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb +++ /dev/null @@ -1,77 +0,0 @@ - ' -' This program demonstrates the 'Intersect' and 'Union' methods of 'DnsPermission' class. -' It creates a 'DnsPermission' instance that is the Union/Intersection of current permission -' instance and specified permission instance. -' - -Imports System.Net -Imports System.Security -Imports System.Security.Permissions -Imports System.Collections - -Class DnsPermissionExample - - ' private variables - Private dnsPermission1 As DnsPermission - Private dnsPermission2 As DnsPermission - - - Public Shared Sub Main() - Try - Dim dnsPermissionExampleObj As New DnsPermissionExample() - dnsPermissionExampleObj.useDns() - Catch e As SecurityException - Console.WriteLine("SecurityException caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - Catch e As Exception - Console.WriteLine("Exception caught!!!") - Console.WriteLine(("Source : " + e.Source)) - Console.WriteLine(("Message : " + e.Message)) - End Try - End Sub -' - Private Sub MyUnion() - ' Create a DnsPermission instance which is the union of the current DnsPermission instance and the specified DnsPermission instance. - Dim permission As DnsPermission = CType(dnsPermission1.Union(dnsPermission2), DnsPermission) - ' Print the attributes and values of the union instance of DnsPermission. - PrintKeysAndValues(permission.ToXml().Attributes) - End Sub -' - Public Sub useDns() - ' Create a DnsPermission instance. - dnsPermission1 = New DnsPermission(PermissionState.Unrestricted) - dnsPermission2 = New DnsPermission(PermissionState.None) - ' Check for permission. - dnsPermission1.Demand() - dnsPermission2.Demand() - Console.WriteLine("Attributes and Values of first DnsPermission instance :") - PrintKeysAndValues(dnsPermission1.ToXml().Attributes) - Console.WriteLine("Attributes and Values of second DnsPermission instance :") - PrintKeysAndValues(dnsPermission2.ToXml().Attributes) - Console.WriteLine("Union of both instances : ") - MyUnion() - Console.WriteLine("Intersection of both instances : ") - MyIntersection() - End Sub - - Private Sub PrintKeysAndValues(myList As Hashtable) - ' Get the enumerator that can iterate through the hash table. - Dim myEnumerator As IDictionaryEnumerator = myList.GetEnumerator() - Console.WriteLine(ControlChars.Tab + "-KEY-" + ControlChars.Tab + "-VALUE-") - While myEnumerator.MoveNext() - Console.WriteLine(ControlChars.Tab + "{0}:" + ControlChars.Tab + "{1}", myEnumerator.Key, myEnumerator.Value) - End While - Console.WriteLine() - End Sub -' - - Private Sub MyIntersection() - ' Create a DnsPermission instance that is the intersection of the current - ' DnsPermission instance and the specified DnsPermission instance. - Dim permission As DnsPermission = CType(dnsPermission1.Intersect(dnsPermission2), DnsPermission) - ' Print the attributes and values of the intersection instance of DnsPermission. - PrintKeysAndValues(permission.ToXml().Attributes) - End Sub -' -End Class From 26604235986a615a8f8a596d7ba10ca19a305278 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Fri, 27 Jun 2025 12:57:23 +0200 Subject: [PATCH 7/8] delete final orphans --- .../visualbasic/System.DateTime/Calendar.vb | 110 -- .../System.DateTime/DateTimeComparisons.vb | 58 - .../System.DateTime/DateWithTimeZone.vb | 32 - .../System.DateTime/Instantiation.vb | 61 - .../visualbasic/System.DateTime/Parsing.vb | 166 --- .../System.DateTime/Persistence.vb | 296 ----- .../visualbasic/System.DateTime/Program.vb | 11 - .../visualbasic/System.DateTime/Resolution.vb | 50 - .../System.DateTime/StringFormat.vb | 50 - .../SystemDateTimeReference.vbproj | 8 - .../VB/Project.vbproj | 12 - .../VB/source.vb | 33 - .../VB/App_Code/TypeResolver.vb | 38 - .../VB/fileinfomembers.vb | 260 ---- .../VB/project.vbproj | 9 - .../vb/Application.Designer.vb | 38 - .../vb/Application.myapp | 11 - .../vb/Form1.Designer.vb | 62 - .../vb/Form1.resx | 120 -- .../vb/Form1.vb | 31 - .../vb/WFCrossThreadVB.vbproj | 140 --- .../vb/app.config | 23 - .../vb/snippets.5000.json | 3 - .../vb/Form1.Designer.vb | 62 - .../vb/Form1.resx | 120 -- .../vb/Form1.vb | 42 - .../vb/WFCrossThreadSolutionVB.vbproj | 139 --- .../vb/app.config | 23 - .../vb/snippets.5000.json | 3 - .../vb/Application.xaml | 9 - .../vb/Application.xaml.vb | 6 - .../vb/MainWindow.xaml | 14 - .../vb/MainWindow.xaml.vb | 29 - .../vb/WPFCrossThreadVB.vbproj | 108 -- .../vb/app.config | 23 - .../vb/snippets.5000.json | 3 - .../vb/Application.xaml | 9 - .../vb/Application.xaml.vb | 6 - .../vb/MainWindow.xaml | 14 - .../vb/MainWindowDispatcher.xaml.vb | 36 - .../vb/WPFCrossThreadDispatcherVB.vbproj | 108 -- .../vb/app.config | 23 - .../vb/snippets.5000.json | 3 - .../vb/customexception.vbproj | 118 -- .../system.exception.class/vb/example.vb | 48 - .../vb/notprimeexception.vb | 38 - .../vb/primenumbergenerator.vb | 62 - .../system.exception.class/vb/rethrow1.vb | 75 -- .../system.exception.class/vb/rethrow3.vb | 88 -- .../system.exception.class/vb/usageerrors1.vb | 35 - .../system.exception.class/vb/usageerrors2.vb | 39 - .../vb/IDisposableSnippets.vbproj | 7 - .../system.idisposable/vb/base1.vb | 34 - .../system.idisposable/vb/base2.vb | 34 - .../system.idisposable/vb/calling1.vb | 52 - .../system.idisposable/vb/calling2.vb | 56 - .../system.idisposable/vb/derived1.vb | 59 - .../system.idisposable/vb/derived2.vb | 62 - .../vb/App.xaml | 8 - .../vb/App.xaml.vb | 82 -- .../vb/ApplicationInsights.config | 3 - .../vb/MainPage.xaml | 15 - .../vb/MainPage.xaml.vb | 43 - .../vb/Package.appxmanifest | 49 - .../vb/UWPCrossThreadSolutionVB.vbproj | 195 --- .../vb/project.json | 19 - .../vb/Project.vbproj | 10 - .../vb/regex_example1.vb | 63 - .../xmlprocessingapp/vb/booksdata.xml | 36 - .../xmlprocessingapp/vb/booksdata.xsd | 23 - .../xmlprocessingapp/vb/constants.vb | 17 - .../xmlprocessingapp/vb/downarrow.png | Bin 2081 -> 0 bytes .../xmlprocessingapp/vb/form1.designer.vb | 1043 ----------------- .../xmlprocessingapp/vb/form1.resx | 279 ----- .../xmlprocessingapp/vb/form1.vb | 715 ----------- .../vb/my project/application.designer.vb | 38 - .../vb/my project/application.myapp | 11 - .../vb/my project/assemblyinfo.vb | 34 - .../vb/my project/resources.designer.vb | 62 - .../vb/my project/resources.resx | 117 -- .../vb/my project/settings.designer.vb | 73 -- .../vb/my project/settings.settings | 7 - .../xmlprocessingapp/vb/refreshtree.png | Bin 1970 -> 0 bytes .../xmlprocessingapp/vb/save.png | Bin 2081 -> 0 bytes .../xmlprocessingapp/vb/snippets.5000.json | 3 - .../xmlprocessingapp/vb/uparrow.png | Bin 1923 -> 0 bytes .../xmlprocessingapp/vb/xmlhelpermethods.vb | 559 --------- .../vb/xmlprocessingappvb.vbproj | 140 --- .../tpl_synccontext/vb/App.config | 6 - .../tpl_synccontext/vb/Application.xaml | 9 - .../tpl_synccontext/vb/Application.xaml.vb | 6 - .../tpl_synccontext/vb/MainWindow.xaml | 14 - .../tpl_synccontext/vb/MainWindow.xaml.vb | 147 --- .../tpl_synccontext/vb/WPF_VB1.vbproj | 139 --- .../tpl_synccontext/vb/snippets.5000.json | 3 - .../VB/source.vb | 51 - .../VB/source.vb | 27 - .../VB/source.vb | 22 - .../visualbasic/myapp.xaml | 9 - .../securitypermissionssnippets.vbproj | 55 - .../visualbasic/snippets.5000.json | 3 - .../visualbasic/window1.xaml | 10 - .../visualbasic/window1.xaml.vb | 169 --- .../visualbasic/myapp.xaml | 9 - .../visualbasic/snippets.5000.json | 3 - .../webbrowserpermissionssnippets.vbproj | 54 - .../visualbasic/window1.xaml | 10 - .../visualbasic/window1.xaml.vb | 78 -- 108 files changed, 7677 deletions(-) delete mode 100644 snippets/visualbasic/System.DateTime/Calendar.vb delete mode 100644 snippets/visualbasic/System.DateTime/DateTimeComparisons.vb delete mode 100644 snippets/visualbasic/System.DateTime/DateWithTimeZone.vb delete mode 100644 snippets/visualbasic/System.DateTime/Instantiation.vb delete mode 100644 snippets/visualbasic/System.DateTime/Parsing.vb delete mode 100644 snippets/visualbasic/System.DateTime/Persistence.vb delete mode 100644 snippets/visualbasic/System.DateTime/Program.vb delete mode 100644 snippets/visualbasic/System.DateTime/Resolution.vb delete mode 100644 snippets/visualbasic/System.DateTime/StringFormat.vb delete mode 100644 snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/WPFCrossThreadVB.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/app.config delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/Application.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/Application.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/MainWindow.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/MainWindowDispatcher.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/WPFCrossThreadDispatcherVB.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/app.config delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf2/vb/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/customexception.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/example.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/notprimeexception.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/primenumbergenerator.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/rethrow1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/rethrow3.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/usageerrors1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/usageerrors2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/IDisposableSnippets.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/base1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/base2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/calling1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/calling2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/derived1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.idisposable/vb/derived2.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/App.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/App.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/ApplicationInsights.config delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/MainPage.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/MainPage.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/Package.appxmanifest delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/UWPCrossThreadSolutionVB.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.invalidoperationexception.threading.uwp/vb/project.json delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.regex.class/vb/Project.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.regex.class/vb/regex_example1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/booksdata.xml delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/booksdata.xsd delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/constants.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/downarrow.png delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/form1.designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/form1.resx delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/form1.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/application.designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/application.myapp delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/assemblyinfo.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/resources.designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/resources.resx delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/settings.designer.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/my project/settings.settings delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/refreshtree.png delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/save.png delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/uparrow.png delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/xmlhelpermethods.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Data/xmlprocessingapp/vb/xmlprocessingappvb.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/App.config delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/Application.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/Application.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/MainWindow.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/MainWindow.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/WPF_VB1.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_Misc/tpl_synccontext/vb/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurable Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurableAttribute Example/VB/source.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/myapp.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/securitypermissionssnippets.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/myapp.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/snippets.5000.json delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/webbrowserpermissionssnippets.vbproj delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml delete mode 100644 snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb diff --git a/snippets/visualbasic/System.DateTime/Calendar.vb b/snippets/visualbasic/System.DateTime/Calendar.vb deleted file mode 100644 index 23346c6863c..00000000000 --- a/snippets/visualbasic/System.DateTime/Calendar.vb +++ /dev/null @@ -1,110 +0,0 @@ -Imports System.Globalization - -Module CalendarSamples - Public Sub Snippets() - ThaiBuddhistEra() - ThaiBuddhistEraParse() - InstantiateCalendar() - CalendarFields() - CalculateWeeks() - End Sub - - Private Sub ThaiBuddhistEra() - ' - Dim thTH As New CultureInfo("th-TH") - Dim value As New DateTime(2016, 5, 28) - - Console.WriteLine(value.ToString(thTH)) - - thTH.DateTimeFormat.Calendar = New GregorianCalendar() - Console.WriteLine(value.ToString(thTH)) - ' The example displays the following output: - ' 28/5/2559 0:00:00 - ' 28/5/2016 0:00:00 - ' - End Sub - - ' - Private Sub ThaiBuddhistEraParse() - Dim thTH As New CultureInfo("th-TH") - Dim value As DateTime = DateTime.Parse("28/5/2559", thTH) - Console.WriteLine(value.ToString(thTH)) - - thTH.DateTimeFormat.Calendar = New GregorianCalendar() - Console.WriteLine(value.ToString(thTH)) - ' The example displays the following output: - ' 28/5/2559 0:00:00 - ' 28/5/2016 0:00:00 - End Sub - ' - - Private Sub InstantiateCalendar() - ' - Dim thTH As New CultureInfo("th-TH") - Dim dat As New DateTime(2559, 5, 28, thTH.DateTimeFormat.Calendar) - Console.WriteLine($"Thai Buddhist Era date: {dat.ToString("d", thTH)}") - Console.WriteLine($"Gregorian date: {dat:d}") - ' The example displays the following output: - ' Thai Buddhist Era Date: 28/5/2559 - ' Gregorian Date: 28/05/2016 - ' - End Sub - - Private Sub CalendarFields() - ' - Dim thTH As New CultureInfo("th-TH") - Dim cal As Calendar = thTH.DateTimeFormat.Calendar - Dim dat As New DateTime(2559, 5, 28, cal) - Console.WriteLine("Using the Thai Buddhist Era calendar:") - Console.WriteLine($"Date: {dat.ToString("d", thTH)}") - Console.WriteLine($"Year: {cal.GetYear(dat)}") - Console.WriteLine($"Leap year: {cal.IsLeapYear(cal.GetYear(dat))}") - Console.WriteLine() - - Console.WriteLine("Using the Gregorian calendar:") - Console.WriteLine($"Date: {dat:d}") - Console.WriteLine($"Year: {dat.Year}") - Console.WriteLine($"Leap year: {DateTime.IsLeapYear(dat.Year)}") - ' The example displays the following output: - ' Using the Thai Buddhist Era calendar - ' Date : 28/5/2559 - ' Year: 2559 - ' Leap year : True - ' - ' Using the Gregorian calendar - ' Date : 28/05/2016 - ' Year: 2016 - ' Leap year : True - ' - End Sub - - Private Sub CalculateWeeks() - ' - Dim thTH As New CultureInfo("th-TH") - Dim thCalendar As Calendar = thTH.DateTimeFormat.Calendar - Dim dat As New DateTime(1395, 8, 18, thCalendar) - Console.WriteLine("Using the Thai Buddhist Era calendar:") - Console.WriteLine($"Date: {dat.ToString("d", thTH)}") - Console.WriteLine($"Day of Week: {thCalendar.GetDayOfWeek(dat)}") - Console.WriteLine($"Week of year: {thCalendar.GetWeekOfYear(dat, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)}") - Console.WriteLine() - - Dim greg As Calendar = New GregorianCalendar() - Console.WriteLine("Using the Gregorian calendar:") - Console.WriteLine($"Date: {dat:d}") - Console.WriteLine($"Day of Week: {dat.DayOfWeek}") - Console.WriteLine($"Week of year: {greg.GetWeekOfYear(dat, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)}") - ' The example displays the following output: - ' Using the Thai Buddhist Era calendar - ' Date : 18/8/1395 - ' Day of Week: Sunday - ' Week of year: 34 - ' - ' Using the Gregorian calendar - ' Date : 18/08/0852 - ' Day of Week: Sunday - ' Week of year: 34 - ' - End Sub -End Module - diff --git a/snippets/visualbasic/System.DateTime/DateTimeComparisons.vb b/snippets/visualbasic/System.DateTime/DateTimeComparisons.vb deleted file mode 100644 index aee488bf948..00000000000 --- a/snippets/visualbasic/System.DateTime/DateTimeComparisons.vb +++ /dev/null @@ -1,58 +0,0 @@ -Class DateTimeComparisons - Public Shared Sub Snippets() - TestRoughlyEquals() - End Sub - - ' - Public Shared Function RoughlyEquals(time As DateTime, timeWithWindow As DateTime, - windowInSeconds As Integer, - frequencyInSeconds As Integer) As Boolean - Dim delta As Long = (timeWithWindow.Subtract(time)).TotalSeconds _ - Mod frequencyInSeconds - - If delta > windowInSeconds Then - delta = frequencyInSeconds - delta - End If - - Return Math.Abs(delta) < windowInSeconds - End Function - - Public Shared Sub TestRoughlyEquals() - Dim window As Integer = 10 - Dim freq As Integer = 60 * 60 * 2 ' 2 hours; - Dim d1 As DateTime = DateTime.Now - - Dim d2 As DateTime = d1.AddSeconds(2 * window) - Dim d3 As DateTime = d1.AddSeconds(-2 * window) - Dim d4 As DateTime = d1.AddSeconds(window / 2) - Dim d5 As DateTime = d1.AddSeconds(-window / 2) - - Dim d6 As DateTime = d1.AddHours(2).AddSeconds(2 * window) - Dim d7 As DateTime = d1.AddHours(2).AddSeconds(-2 * window) - Dim d8 As DateTime = d1.AddHours(2).AddSeconds(window / 2) - Dim d9 As DateTime = d1.AddHours(2).AddSeconds(-window / 2) - - Console.WriteLine($"d1 ({d1}) ~= d1 ({d1}): {RoughlyEquals(d1, d1, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d2 ({d2}): {RoughlyEquals(d1, d2, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d3 ({d3}): {RoughlyEquals(d1, d3, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d4 ({d4}): {RoughlyEquals(d1, d4, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d5 ({d5}): {RoughlyEquals(d1, d5, window, freq)}") - - Console.WriteLine($"d1 ({d1}) ~= d6 ({d6}): {RoughlyEquals(d1, d6, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d7 ({d7}): {RoughlyEquals(d1, d7, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d8 ({d8}): {RoughlyEquals(d1, d8, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d9 ({d9}): {RoughlyEquals(d1, d9, window, freq)}") - End Sub - ' The example displays output similar to the following: - ' d1 (1/28/2010 9:01:26 PM) ~= d1 (1/28/2010 9:01:26 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d2 (1/28/2010 9:01:46 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d3 (1/28/2010 9:01:06 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d4 (1/28/2010 9:01:31 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d5 (1/28/2010 9:01:21 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d6 (1/28/2010 11:01:46 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d7 (1/28/2010 11:01:06 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d8 (1/28/2010 11:01:31 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d9 (1/28/2010 11:01:21 PM): True - ' - -End Class diff --git a/snippets/visualbasic/System.DateTime/DateWithTimeZone.vb b/snippets/visualbasic/System.DateTime/DateWithTimeZone.vb deleted file mode 100644 index 8c38aaaced5..00000000000 --- a/snippets/visualbasic/System.DateTime/DateWithTimeZone.vb +++ /dev/null @@ -1,32 +0,0 @@ -' -Namespace DateTimeExtensions - Public Structure DateWithTimeZone - Private tz As TimeZoneInfo - Private dt As DateTime - - Public Sub New(dateValue As DateTime, timeZone As TimeZoneInfo) - dt = dateValue - tz = If(timeZone, TimeZoneInfo.Local) - End Sub - - Public Property TimeZone As TimeZoneInfo - Get - Return tz - End Get - Set - tz = Value - End Set - End Property - - Public Property DateTime As Date - Get - Return dt - End Get - Set - dt = Value - End Set - End Property - End Structure -End Namespace -' - diff --git a/snippets/visualbasic/System.DateTime/Instantiation.vb b/snippets/visualbasic/System.DateTime/Instantiation.vb deleted file mode 100644 index b4612342cd9..00000000000 --- a/snippets/visualbasic/System.DateTime/Instantiation.vb +++ /dev/null @@ -1,61 +0,0 @@ -Module Instantiation - - Public Sub Snippets() - InstantiateWithConstructor() - InstantiateWithCompilerSyntax() - InstantiateWithReturnValue() - InstantiateFromString() - InstantiateUsingDftCtor() - End Sub - - Private Sub InstantiateWithConstructor() - ' - Dim date1 As New Date(2008, 5, 1, 8, 30, 52) - ' - End Sub - - Private Sub InstantiateWithCompilerSyntax() - ' - Dim date1 As Date = #5/1/2008 8:30:52AM# - ' - End Sub - - Private Sub InstantiateWithReturnValue() - ' - Dim date1 As Date = Date.Now - Dim date2 As Date = Date.UtcNow - Dim date3 As Date = Date.Today - ' - End Sub - - Private Sub InstantiateFromString() - ' - Dim dateString As String = "5/1/2008 8:30:52 AM" - Dim date1 As Date = Date.Parse(dateString, - System.Globalization.CultureInfo.InvariantCulture) - Dim iso8601String As String = "20080501T08:30:52Z" - Dim dateISO8602 As Date = DateTime.ParseExact(iso8601String, "yyyyMMddTHH:mm:ssZ", - System.Globalization.CultureInfo.InvariantCulture) - Console.WriteLine(dateISO8602) - - ' - Console.WriteLine(date1) - End Sub - - Private Sub InstantiateUsingDftCtor() - ' - Dim dat1 As DateTime - ' The following method call displays 1/1/0001 12:00:00 AM. - Console.WriteLine(dat1.ToString(System.Globalization.CultureInfo.InvariantCulture)) - ' The following method call displays True. - Console.WriteLine(dat1.Equals(Date.MinValue)) - - Dim dat2 As New DateTime() - ' The following method call displays 1/1/0001 12:00:00 AM. - Console.WriteLine(dat2.ToString(System.Globalization.CultureInfo.InvariantCulture)) - ' The following method call displays True. - Console.WriteLine(dat2.Equals(Date.MinValue)) - ' - End Sub - -End Module diff --git a/snippets/visualbasic/System.DateTime/Parsing.vb b/snippets/visualbasic/System.DateTime/Parsing.vb deleted file mode 100644 index 4cfe6eecb6c..00000000000 --- a/snippets/visualbasic/System.DateTime/Parsing.vb +++ /dev/null @@ -1,166 +0,0 @@ -Imports System.Globalization -Imports System.Threading - -Module Parsing - Public Sub Snippets() - ParseStandardFormats() - End Sub - - Private Sub ParseStandardFormats() - ' - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - - Dim date1 As New DateTime(2013, 6, 1, 12, 32, 30) - Dim badFormats As New List(Of String) - - Console.WriteLine($"{"Date String",-37} {"Date",-19}") - Console.WriteLine() - For Each dateString As String In date1.GetDateTimeFormats() - Dim parsedDate As DateTime - If DateTime.TryParse(dateString, parsedDate) Then - Console.WriteLine($"{dateString,-37} {DateTime.Parse(dateString),-19:g}") - Else - badFormats.Add(dateString) - End If - Next - - ' Display strings that could not be parsed. - If badFormats.Count > 0 Then - Console.WriteLine() - Console.WriteLine("Strings that could not be parsed: ") - For Each badFormat In badFormats - Console.WriteLine($" {badFormat}") - Next - End If - ' The example displays the following output: - ' Date String Date - ' - ' 01/06/2013 01/06/2013 00:00:00 - ' 01/06/13 01/06/2013 00:00:00 - ' 1/6/13 01/06/2013 00:00:00 - ' 1.6.13 01/06/2013 00:00:00 - ' 2013-06-01 01/06/2013 00:00:00 - ' 01 June 2013 01/06/2013 00:00:00 - ' 1 June 2013 01/06/2013 00:00:00 - ' 01 June 2013 12:32 01/06/2013 12:32:00 - ' 01 June 2013 12:32 01/06/2013 12:32:00 - ' 01 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 01 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 1 June 2013 12:32 01/06/2013 12:32:00 - ' 1 June 2013 12:32 01/06/2013 12:32:00 - ' 1 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 1 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 01 June 2013 12:32:30 01/06/2013 12:32:30 - ' 01 June 2013 12:32:30 01/06/2013 12:32:30 - ' 01 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/2013 12:32 01/06/2013 12:32:00 - ' 01/06/2013 12:32 01/06/2013 12:32:00 - ' 01/06/2013 12:32 PM 01/06/2013 12:32:00 - ' 01/06/2013 12:32 PM 01/06/2013 12:32:00 - ' 01/06/13 12:32 01/06/2013 12:32:00 - ' 01/06/13 12:32 01/06/2013 12:32:00 - ' 01/06/13 12:32 PM 01/06/2013 12:32:00 - ' 01/06/13 12:32 PM 01/06/2013 12:32:00 - ' 1/6/13 12:32 01/06/2013 12:32:00 - ' 1/6/13 12:32 01/06/2013 12:32:00 - ' 1/6/13 12:32 PM 01/06/2013 12:32:00 - ' 1/6/13 12:32 PM 01/06/2013 12:32:00 - ' 1.6.13 12:32 01/06/2013 12:32:00 - ' 1.6.13 12:32 01/06/2013 12:32:00 - ' 1.6.13 12:32 PM 01/06/2013 12:32:00 - ' 1.6.13 12:32 PM 01/06/2013 12:32:00 - ' 2013-06-01 12:32 01/06/2013 12:32:00 - ' 2013-06-01 12:32 01/06/2013 12:32:00 - ' 2013-06-01 12:32 PM 01/06/2013 12:32:00 - ' 2013-06-01 12:32 PM 01/06/2013 12:32:00 - ' 01/06/2013 12:32:30 01/06/2013 12:32:30 - ' 01/06/2013 12:32:30 01/06/2013 12:32:30 - ' 01/06/2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 PM 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 PM 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 PM 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 PM 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 PM 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 PM 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 PM 01/06/2013 12:32:30 - ' 01 June 01/06/2013 00:00:00 - ' 01 June 01/06/2013 00:00:00 - ' 2013-06-01T12:32:30.0000000 01/06/2013 12:32:30 - ' 2013-06-01T12:32:30.0000000 01/06/2013 12:32:30 - ' Sat, 01 Jun 2013 12:32:30 GMT 01/06/2013 05:32:30 - ' Sat, 01 Jun 2013 12:32:30 GMT 01/06/2013 05:32:30 - ' 2013-06-01T12:32:30 01/06/2013 12:32:30 - ' 12:32 22/04/2013 12:32:00 - ' 12:32 22/04/2013 12:32:00 - ' 12:32 PM 22/04/2013 12:32:00 - ' 12:32 PM 22/04/2013 12:32:00 - ' 12:32:30 22/04/2013 12:32:30 - ' 12:32:30 22/04/2013 12:32:30 - ' 12:32:30 PM 22/04/2013 12:32:30 - ' 12:32:30 PM 22/04/2013 12:32:30 - ' 2013-06-01 12:32:30Z 01/06/2013 05:32:30 - ' 01 June 2013 19:32:30 01/06/2013 19:32:30 - ' 01 June 2013 19:32:30 01/06/2013 19:32:30 - ' 01 June 2013 07:32:30 PM 01/06/2013 19:32:30 - ' 01 June 2013 7:32:30 PM 01/06/2013 19:32:30 - ' 1 June 2013 19:32:30 01/06/2013 19:32:30 - ' 1 June 2013 19:32:30 01/06/2013 19:32:30 - ' 1 June 2013 07:32:30 PM 01/06/2013 19:32:30 - ' 1 June 2013 7:32:30 PM 01/06/2013 19:32:30 - ' June 2013 01/06/2013 00:00:00 - ' June 2013 01/06/2013 00:00:00 - ' - End Sub - - Private Sub ParseCustomFormats() - ' - Dim formats() As String = {"yyyyMMdd", "HHmmss"} - Dim dateStrings() As String = {"20130816", "20131608", - " 20130816 ", "115216", - "521116", " 115216 "} - Dim parsedDate As DateTime - - For Each dateString As String In dateStrings - If DateTime.TryParseExact(dateString, formats, Nothing, - DateTimeStyles.AllowWhiteSpaces Or - DateTimeStyles.AdjustToUniversal, - parsedDate) Then - Console.WriteLine($"{dateString} --> {parsedDate:g}") - Else - Console.WriteLine($"Cannot convert {dateString}") - End If - Next - ' The example displays the following output: - ' 20130816 --> 8/16/2013 12:00 AM - ' Cannot convert 20131608 - ' 20130816 --> 8/16/2013 12:00 AM - ' 115216 --> 4/22/2013 11:52 AM - ' Cannot convert 521116 - ' 115216 --> 4/22/2013 11:52 AM - ' - End Sub - - Private Sub ParseISO8601() - ' - Dim iso8601String As String = "20080501T08:30:52Z" - Dim dateISO8602 As DateTime = DateTime.ParseExact(iso8601String, "yyyyMMddTHH:mm:ssZ", CultureInfo.InvariantCulture) - Console.WriteLine($"{iso8601String} --> {dateISO8602:g}") - ' - - End Sub -End Module diff --git a/snippets/visualbasic/System.DateTime/Persistence.vb b/snippets/visualbasic/System.DateTime/Persistence.vb deleted file mode 100644 index 02ea45a9a25..00000000000 --- a/snippets/visualbasic/System.DateTime/Persistence.vb +++ /dev/null @@ -1,296 +0,0 @@ -Imports System.Globalization -Imports System.IO -Imports System.Runtime.Serialization -Imports System.Runtime.Serialization.Formatters.Binary -Imports System.Threading -Imports System.Xml.Serialization -Imports SystemDateTimeReference.DateTimeExtensions - -Module Persistence - Private Const filenameTxt As String = ".\BadDates.txt" - Sub Snippets() - File.Delete(filenameTxt) - PersistAsLocalStrings() - File.Delete(filenameTxt) - PersistAsInvariantStrings() - File.Delete(filenameTxt) - File.Delete(filenameInts) - PersistAsIntegers() - File.Delete(filenameInts) - - File.Delete(filenameXml) - PersistAsXml() - File.Delete(filenameXml) - - File.Delete(filenameBin) - End Sub - - ' - Public Sub PersistAsLocalStrings() - SaveDatesAsStrings() - RestoreDatesAsStrings() - End Sub - - Private Sub SaveDatesAsStrings() - Dim dates As Date() = {#6/14/2014 6:32AM#, #7/10/2014 11:49PM#, - #1/10/2015 1:16AM#, #12/20/2014 9:45PM#, - #6/2/2014 3:14PM#} - Dim output As String = Nothing - - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For ctr As Integer = 0 To dates.Length - 1 - Console.WriteLine(dates(ctr).ToString("f")) - output += dates(ctr).ToString() + If(ctr <> dates.Length - 1, "|", "") - Next - Dim sw As New StreamWriter(filenameTxt) - sw.Write(output) - sw.Close() - Console.WriteLine("Saved dates...") - End Sub - - Private Sub RestoreDatesAsStrings() - TimeZoneInfo.ClearCachedData() - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - Dim sr As New StreamReader(filenameTxt) - Dim inputValues As String() = sr.ReadToEnd().Split({"|"c}, StringSplitOptions.RemoveEmptyEntries) - sr.Close() - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For Each inputValue In inputValues - Dim dateValue As Date - If DateTime.TryParse(inputValue, dateValue) Then - Console.WriteLine($"'{inputValue}' --> {dateValue:f}") - Else - Console.WriteLine($"Cannot parse '{inputValue}'") - End If - Next - Console.WriteLine("Restored dates...") - End Sub - ' When saved on an en-US system, the example displays the following output: - ' Current Time Zone: (UTC-08:00) Pacific Time (US & Canada) - ' The dates on an en-US system: - ' Saturday, June 14, 2014 6:32 AM - ' Thursday, July 10, 2014 11:49 PM - ' Saturday, January 10, 2015 1:16 AM - ' Saturday, December 20, 2014 9:45 PM - ' Monday, June 02, 2014 3:14 PM - ' Saved dates... - ' - ' When restored on an en-GB system, the example displays the following output: - ' Current Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London - ' The dates on an en-GB system: - ' Cannot parse '6/14/2014 6:32:00 AM' - ' '7/10/2014 11:49:00 PM' --> 07 October 2014 23:49 - ' '1/10/2015 1:16:00 AM' --> 01 October 2015 01:16 - ' Cannot parse '12/20/2014 9:45:00 PM' - ' '6/2/2014 3:14:00 PM' --> 06 February 2014 15:14 - ' Restored dates... - ' - - ' - Public Sub PersistAsInvariantStrings() - SaveDatesAsInvariantStrings() - RestoreDatesAsInvariantStrings() - End Sub - - Private Sub SaveDatesAsInvariantStrings() - Dim dates As Date() = {#6/14/2014 6:32AM#, #7/10/2014 11:49PM#, - #1/10/2015 1:16AM#, #12/20/2014 9:45PM#, - #6/2/2014 3:14PM#} - Dim output As String = Nothing - - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For ctr As Integer = 0 To dates.Length - 1 - Console.WriteLine(dates(ctr).ToString("f")) - output += dates(ctr).ToUniversalTime().ToString("O", CultureInfo.InvariantCulture) + - If(ctr <> dates.Length - 1, "|", "") - Next - Dim sw As New StreamWriter(filenameTxt) - sw.Write(output) - sw.Close() - Console.WriteLine("Saved dates...") - End Sub - - Private Sub RestoreDatesAsInvariantStrings() - TimeZoneInfo.ClearCachedData() - Console.WriteLine("Current Time Zone: {0}", - TimeZoneInfo.Local.DisplayName) - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - Dim sr As New StreamReader(filenameTxt) - Dim inputValues As String() = sr.ReadToEnd().Split({"|"c}, StringSplitOptions.RemoveEmptyEntries) - sr.Close() - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For Each inputValue In inputValues - Dim dateValue As Date - If DateTime.TryParseExact(inputValue, "O", CultureInfo.InvariantCulture, - DateTimeStyles.RoundtripKind, dateValue) Then - Console.WriteLine($"'{inputValue}' --> {dateValue.ToLocalTime():f}") - Else - Console.WriteLine($"Cannot parse '{inputValue}'") - End If - Next - Console.WriteLine("Restored dates...") - End Sub - ' When saved on an en-US system, the example displays the following output: - ' Current Time Zone: (UTC-08:00) Pacific Time (US & Canada) - ' The dates on an en-US system: - ' Saturday, June 14, 2014 6:32 AM - ' Thursday, July 10, 2014 11:49 PM - ' Saturday, January 10, 2015 1:16 AM - ' Saturday, December 20, 2014 9:45 PM - ' Monday, June 02, 2014 3:14 PM - ' Saved dates... - ' - ' When restored on an en-GB system, the example displays the following output: - ' Current Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London - ' The dates on an en-GB system: - ' '2014-06-14T13:32:00.0000000Z' --> 14 June 2014 14:32 - ' '2014-07-11T06:49:00.0000000Z' --> 11 July 2014 07:49 - ' '2015-01-10T09:16:00.0000000Z' --> 10 January 2015 09:16 - ' '2014-12-21T05:45:00.0000000Z' --> 21 December 2014 05:45 - ' '2014-06-02T22:14:00.0000000Z' --> 02 June 2014 23:14 - ' Restored dates... - ' - - Private Const filenameInts As String = ".\IntDates.bin" - - ' - Public Sub PersistAsIntegers() - SaveDatesAsIntegers() - RestoreDatesAsIntegers() - End Sub - - Private Sub SaveDatesAsIntegers() - Dim dates As Date() = {#6/14/2014 6:32AM#, #7/10/2014 11:49PM#, - #1/10/2015 1:16AM#, #12/20/2014 9:45PM#, - #6/2/2014 3:14PM#} - - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - Dim ticks(dates.Length - 1) As Long - For ctr As Integer = 0 To dates.Length - 1 - Console.WriteLine(dates(ctr).ToString("f")) - ticks(ctr) = dates(ctr).ToUniversalTime().Ticks - Next - Dim fs As New FileStream(filenameInts, FileMode.Create) - Dim bw As New BinaryWriter(fs) - bw.Write(ticks.Length) - For Each tick In ticks - bw.Write(tick) - Next - bw.Close() - Console.WriteLine("Saved dates...") - End Sub - - Private Sub RestoreDatesAsIntegers() - TimeZoneInfo.ClearCachedData() - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - Dim fs As New FileStream(filenameInts, FileMode.Open) - Dim br As New BinaryReader(fs) - Dim items As Integer - Dim dates As DateTime() - - Try - items = br.ReadInt32() - ReDim dates(items - 1) - - For ctr As Integer = 0 To items - 1 - Dim ticks As Long = br.ReadInt64() - dates(ctr) = New DateTime(ticks).ToLocalTime() - Next - Catch e As EndOfStreamException - Console.WriteLine("File corruption detected. Unable to restore data...") - Exit Sub - Catch e As IOException - Console.WriteLine("Unspecified I/O error. Unable to restore data...") - Exit Sub - Catch e As OutOfMemoryException 'Thrown in array initialization. - Console.WriteLine("File corruption detected. Unable to restore data...") - Exit Sub - Finally - br.Close() - End Try - - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For Each value In dates - Console.WriteLine(value.ToString("f")) - Next - Console.WriteLine("Restored dates...") - End Sub - ' When saved on an en-US system, the example displays the following output: - ' Current Time Zone: (UTC-08:00) Pacific Time (US & Canada) - ' The dates on an en-US system: - ' Saturday, June 14, 2014 6:32 AM - ' Thursday, July 10, 2014 11:49 PM - ' Saturday, January 10, 2015 1:16 AM - ' Saturday, December 20, 2014 9:45 PM - ' Monday, June 02, 2014 3:14 PM - ' Saved dates... - ' - ' When restored on an en-GB system, the example displays the following output: - ' Current Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London - ' The dates on an en-GB system: - ' 14 June 2014 14:32 - ' 11 July 2014 07:49 - ' 10 January 2015 09:16 - ' 21 December 2014 05:45 - ' 02 June 2014 23:14 - ' Restored dates... - ' - - Private Const filenameXml As String = ".\LeapYears.xml" - - ' - Public Sub PersistAsXml() - ' Serialize the data. - Dim leapYears As New List(Of DateTime)() - For year As Integer = 2000 To 2100 Step 4 - If Date.IsLeapYear(year) Then - leapYears.Add(New Date(year, 2, 29)) - End If - Next - Dim dateArray As DateTime() = leapYears.ToArray() - - Dim serializer As New XmlSerializer(dateArray.GetType()) - Dim sw As TextWriter = New StreamWriter(filenameXml) - - Try - serializer.Serialize(sw, dateArray) - Catch e As InvalidOperationException - Console.WriteLine(e.InnerException.Message) - Finally - If sw IsNot Nothing Then sw.Close() - End Try - - ' Deserialize the data. - Dim deserializedDates As Date() - Using fs As New FileStream(filenameXml, FileMode.Open) - deserializedDates = CType(serializer.Deserialize(fs), Date()) - End Using - - ' Display the dates. - Console.WriteLine($"Leap year days from 2000-2100 on an {Thread.CurrentThread.CurrentCulture.Name} system:") - Dim nItems As Integer - For Each dat In deserializedDates - Console.Write($" {dat:d} ") - nItems += 1 - If nItems Mod 5 = 0 Then Console.WriteLine() - Next - End Sub - ' The example displays the following output: - ' Leap year days from 2000-2100 on an en-GB system: - ' 29/02/2000 29/02/2004 29/02/2008 29/02/2012 29/02/2016 - ' 29/02/2020 29/02/2024 29/02/2028 29/02/2032 29/02/2036 - ' 29/02/2040 29/02/2044 29/02/2048 29/02/2052 29/02/2056 - ' 29/02/2060 29/02/2064 29/02/2068 29/02/2072 29/02/2076 - ' 29/02/2080 29/02/2084 29/02/2088 29/02/2092 29/02/2096 - ' - - Private Const filenameBin As String = ".\Dates.bin" - - Private Const filename As String = ".\Schedule.bin" - -End Module diff --git a/snippets/visualbasic/System.DateTime/Program.vb b/snippets/visualbasic/System.DateTime/Program.vb deleted file mode 100644 index 33cd33cade6..00000000000 --- a/snippets/visualbasic/System.DateTime/Program.vb +++ /dev/null @@ -1,11 +0,0 @@ -Module Program - Sub Main(args As String()) - Instantiation.Snippets() - StringFormat.Snippets() - Parsing.Snippets() - Resolution.Snippets() - CalendarSamples.Snippets() - Persistence.Snippets() - DateTimeComparisons.Snippets() - End Sub -End Module diff --git a/snippets/visualbasic/System.DateTime/Resolution.vb b/snippets/visualbasic/System.DateTime/Resolution.vb deleted file mode 100644 index a317d56fe09..00000000000 --- a/snippets/visualbasic/System.DateTime/Resolution.vb +++ /dev/null @@ -1,50 +0,0 @@ -Imports System.Threading - -Module Resolution - - Public Sub Snippets() - DemonstrateResolution() - End Sub - - Private Sub DemonstrateResolution() - ' - Dim output As String = "" - For ctr As Integer = 0 To 20 - output += Date.Now.Millisecond.ToString() + vbCrLf - ' Introduce a delay loop. - For delay As Integer = 0 To 1000 - Next - - If ctr = 10 Then - output += "Thread.Sleep called..." + vbCrLf - Thread.Sleep(5) - End If - Next - Console.WriteLine(output) - ' The example displays output like the following: - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' Thread.Sleep called... - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' - - End Sub -End Module diff --git a/snippets/visualbasic/System.DateTime/StringFormat.vb b/snippets/visualbasic/System.DateTime/StringFormat.vb deleted file mode 100644 index 9d488e4f41f..00000000000 --- a/snippets/visualbasic/System.DateTime/StringFormat.vb +++ /dev/null @@ -1,50 +0,0 @@ -Module StringFormat - Public Sub Snippets() - ShowDefaultToString() - ShowCultureSpecificToString() - ShowDefaultFullDateAndTime() - ShowCultureSpecificFullDateAndTime() - ShowIsoDateTime() - End Sub - - Private Sub ShowDefaultToString() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString()) - ' For en-US culture, displays 3/1/2008 7:00:00 AM - ' - End Sub - - Private Sub ShowCultureSpecificToString() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR"))) - ' Displays 01/03/2008 07:00:00 - ' - End Sub - - Private Sub ShowDefaultFullDateAndTime() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString("F")) - ' Displays Saturday, March 01, 2008 7:00:00 AM - ' - End Sub - - Private Sub ShowCultureSpecificFullDateAndTime() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString("F", New System.Globalization.CultureInfo("fr-FR"))) - ' Displays samedi 1 mars 2008 07:00:00 - ' - End Sub - - Private Sub ShowIsoDateTime() - ' - Dim date1 As DateTime = New DateTime(2008, 3, 1, 7, 0, 0, DateTimeKind.Utc) - Console.WriteLine(date1.ToString("yyyy-MM-ddTHH:mm:sszzz", System.Globalization.CultureInfo.InvariantCulture)) - ' Displays 2008-03-01T07:00:00+00:00 - ' - End Sub - -End Module diff --git a/snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj b/snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj deleted file mode 100644 index 41f1d5ad4b2..00000000000 --- a/snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - net6.0 - - - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj deleted file mode 100644 index 1564968cb6e..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Library - net4.8 - - - - - - - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb deleted file mode 100644 index 78dcf2592bf..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb +++ /dev/null @@ -1,33 +0,0 @@ -Option Explicit -Option Strict On - -Imports System.Data.OracleClient - -Module Module1 - ' - Sub Main() - Dim builder As _ - New OracleConnectionStringBuilder(GetConnectionString()) - Console.WriteLine("Connection string = " & builder.ConnectionString) - - ' Keys you have provided return true. - Console.WriteLine(builder.ContainsKey("Integrated Security")) - - ' Keys that are valid but have not been set return true. - Console.WriteLine(builder.ContainsKey("Unicode")) - - ' Keys that don't exist return false. - Console.WriteLine(builder.ContainsKey("MyKey")) - - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub - - Private Function GetConnectionString() As String - ' To avoid storing the connection string in your code, - ' you can retrieve it from a configuration file. - Return "Server=OracleDemo;Integrated Security=True" - End Function - ' -End Module - diff --git a/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb b/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb deleted file mode 100644 index 758485d89d2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb +++ /dev/null @@ -1,38 +0,0 @@ -Imports System.Collections.Generic -Imports System.Security.Permissions -Imports System.Text -Imports System.Web - -Namespace System.Web.Script.Serialization.TypeResolver.VB - - ' - Public Class CustomTypeResolver - Inherits JavaScriptTypeResolver - - Public Overrides Function ResolveType(ByVal id As String) As Type - Return Type.GetType(id) - End Function - - Public Overrides Function ResolveTypeId(ByVal type As Type) As String - If type Is Nothing Then - Throw New ArgumentNullException("type") - End If - - Return type.Name - End Function - End Class - ' - - Public Class ColorType - Public rgb() As String = {"00", "00", "FF"} - Public defaultColor As FavoriteColors = FavoriteColors.Blue - End Class - - Public Enum FavoriteColors - Black - White - Blue - Red - End Enum - -End Namespace \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb deleted file mode 100644 index cc71c398bca..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb +++ /dev/null @@ -1,260 +0,0 @@ -' -Imports System.IO -Imports System.Runtime.Serialization.Formatters.Binary - -' - -Public Class FileInfoSnippets - Public Sub Attributes() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - Console.WriteLine("{0} has attributes of {1}", fileName, fileInfo.Attributes) - ' Toggle the archive flag of the file. - Dim archiveFlag As Boolean = CBool(fileInfo.Attributes And FileAttributes.Archive) - If archiveFlag Then - fileInfo.Attributes = fileInfo.Attributes And Not FileAttributes.Archive - Else - fileInfo.Attributes = fileInfo.Attributes Or FileAttributes.Archive - End If - Console.WriteLine("{0} has attributes of {1}", fileName, fileInfo.Attributes) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat has attributes of Normal - ' C:\autoexec.bat has attributes of Archive - ' - Console.WriteLine() - End Sub - Public Sub CreationTime() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} was created at {1}", fileName, fileInfo.CreationTime) - - ' Add two hours to the creation time. - fileInfo.CreationTime.Add(TimeSpan.FromHours(2.0)) - - Console.WriteLine("{0} is now created at {1}", fileName, fileInfo.CreationTime) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat was created at 8/17/2004 5:30:13 PM - ' C:\autoexec.bat is now created at 8/17/2004 7:30:13 PM - ' - Console.WriteLine() - End Sub - - Public Sub DirectoryName() - ' - Dim fileName As String = "C:\TMP\log.txt" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} has a directoryName of {1}", fileName, fileInfo.DirectoryName) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\TMP\log.txt has a directory name of C:\TMP - ' - Console.WriteLine() - End Sub - - - Public Sub Directory() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - Dim dirInfo As DirectoryInfo = fileInfo.Directory - - Console.WriteLine("{0} is in a directory of {1} files.", fileName, dirInfo.GetFiles().Length) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat is in a directory of 24 files. - ' - Console.WriteLine() - End Sub - - Public Sub ExtensionAndName() - ' - Dim dirName As String = "C:\" - Dim dirInfo As New DirectoryInfo(dirName) - - Console.WriteLine("{0} contains the following system files:", dirName) - Dim fileInfo As FileInfo - For Each fileInfo In dirInfo.GetFiles() - If fileInfo.Extension.ToLower().Equals(".sys") Then - Console.WriteLine(fileInfo.Name) - End If - Next fileInfo - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\ contains the following system files: - ' CONFIG.SYS - ' IO.SYS - ' MSDOS.SYS - ' pagefile.sys - ' - Console.WriteLine() - End Sub - - Public Sub LastAccessTime() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} was last accessed at {1}", fileName, fileInfo.LastAccessTime) - - ' Set the access time back two hours. - fileInfo.LastAccessTime.Subtract(TimeSpan.FromHours(2.0)) - - Console.WriteLine("{0} now was last accessed at {1}", fileName, fileInfo.LastAccessTime) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat was last accessed at 8/17/2004 1:30:13 PM - ' C:\autoexec.bat now was last accessed at 8/17/2004 11:30:13 AM - ' - Console.WriteLine() - End Sub - - Public Sub LastWriteTime() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} was last written to at {1}", fileName, fileInfo.LastWriteTime) - - ' Set the last write time back two hours. - fileInfo.LastWriteTime.Subtract(TimeSpan.FromHours(2.0)) - - Console.WriteLine("{0} now was last written to at {1}", fileName, fileInfo.LastWriteTime) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat was last written to at 8/17/2004 1:30:13 PM - ' C:\autoexec.bat now was last written to at 8/17/2004 11:30:13 AM - ' - Console.WriteLine() - End Sub - - Public Sub Length() - ' - Dim dirName As String = "C:\" - Dim dirInfo As New DirectoryInfo(dirName) - - Console.WriteLine("{0} contains the following files:", dirName) - Console.WriteLine("Size Filename") - Dim fileInfo As FileInfo - For Each fileInfo In dirInfo.GetFiles() - Try - Console.WriteLine("{0}" + ChrW(9) + " {1}", fileInfo.Length, fileInfo.Name) - Catch e As IOException - Console.WriteLine(ChrW(9) + " {0}: {1}", fileInfo.Name, e.Message) - End Try - Next fileInfo - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\ contains the following files: - ' Size Filename - ' 0 AUTOEXEC.BAT - ' 211 boot.ini - ' 0 CONFIG.SYS - ' 885 InoSetRTThread.log - ' 0 IO.SYS - ' 0 MSDOS.SYS - ' 47564 NTDETECT.COM - ' 250032 ntldr - ' 1610612736 pagefile.sys - ' 1479 PatchInfo.txt - ' 102 Platform.ini - ' 548 RISGX280.log - ' 196568 UpdatePatch.log - ' - Console.WriteLine() - End Sub - - Public Sub AppendTextAndOpenText() - ' - Dim fileName As String = Path.GetTempFileName() - Dim fileInfo As New FileInfo(fileName) - Console.WriteLine("File '{0}' created of size {1} bytes", fileName, fileInfo.Length) - - ' Append some text to the file. - Dim s As StreamWriter = fileInfo.AppendText() - s.WriteLine("The text in the file") - s.Close() - - fileInfo.Refresh() - Console.WriteLine("File '{0}' now has size {1} bytes", fileName, fileInfo.Length) - - ' Read the text file. - Dim r As StreamReader = fileInfo.OpenText() - Dim textLine As String = r.ReadLine() - Console.WriteLine(textLine) - r.Close() - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' File 'C:\DOCUME~1\cliffc\LOCALS~1\Temp\tmp12C.tmp' created of size 0 bytes - ' File 'C:\DOCUME~1\cliffc\LOCALS~1\Temp\tmp12C.tmp' now has size 22 bytes - ' The text in the file - ' - Console.WriteLine() - End Sub - - Public Sub CreateText() - ' - Dim fileInfo As New FileInfo("myFile") - - ' Create the file and output some text to it. - Dim s As StreamWriter = fileInfo.CreateText() - s.WriteLine("Output to the file") - s.Close() - - fileInfo.Refresh() - Console.WriteLine("File '{0}' now has size {1} bytes", fileInfo.Name, fileInfo.Length) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' File 'myFile' now has size 20 bytes - ' - Console.WriteLine() - End Sub - - Public Shared Sub Main() - Console.WriteLine() - Dim fileInfoSnippets As New FileInfoSnippets() - fileInfoSnippets.Attributes() - fileInfoSnippets.CreationTime() - fileInfoSnippets.DirectoryName() - fileInfoSnippets.Directory() - fileInfoSnippets.ExtensionAndName() - fileInfoSnippets.LastAccessTime() - fileInfoSnippets.LastWriteTime() - fileInfoSnippets.Length() - fileInfoSnippets.AppendTextAndOpenText() - fileInfoSnippets.CreateText() - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj b/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj deleted file mode 100644 index 4b1cf7e4bb1..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - exe - net7.0 - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb deleted file mode 100644 index 7fa5f7c2430..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb +++ /dev/null @@ -1,38 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - 'NOTE: This file is auto-generated; do not modify it directly. To make changes, - ' or if you encounter build errors in this file, go to the Project Designer - ' (go to Project Properties or double-click the My Project node in - ' Solution Explorer), and make changes on the Application tab. - ' - Partial Friend Class MyApplication - - _ - Public Sub New() - MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - Me.IsSingleInstance = false - Me.EnableVisualStyles = true - Me.SaveMySettingsOnExit = true - Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses - End Sub - - _ - Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.WFCrossThreadVB.Form1 - End Sub - End Class -End Namespace diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp deleted file mode 100644 index 1243847fd9b..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp +++ /dev/null @@ -1,11 +0,0 @@ - - - true - Form1 - false - 0 - true - 0 - 0 - true - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb deleted file mode 100644 index 6f270bef899..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ - _ -Partial Class Form1 - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - _ - Private Sub InitializeComponent() - Me.threadExampleBtn = New System.Windows.Forms.Button() - Me.textBox1 = New System.Windows.Forms.TextBox() - Me.SuspendLayout() - ' - 'threadExampleBtn - ' - Me.threadExampleBtn.Location = New System.Drawing.Point(101, 184) - Me.threadExampleBtn.Name = "threadExampleBtn" - Me.threadExampleBtn.Size = New System.Drawing.Size(75, 23) - Me.threadExampleBtn.TabIndex = 0 - Me.threadExampleBtn.Text = "Button1" - Me.threadExampleBtn.UseVisualStyleBackColor = True - ' - 'textBox1 - ' - Me.textBox1.Location = New System.Drawing.Point(12, 36) - Me.textBox1.Multiline = True - Me.textBox1.Name = "textBox1" - Me.textBox1.Size = New System.Drawing.Size(260, 113) - Me.textBox1.TabIndex = 1 - ' - 'Form1 - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(284, 261) - Me.Controls.Add(Me.textBox1) - Me.Controls.Add(Me.threadExampleBtn) - Me.Name = "Form1" - Me.Text = "Form1" - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - - Friend WithEvents threadExampleBtn As Button - Friend WithEvents textBox1 As TextBox -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx deleted file mode 100644 index 1af7de150c9..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb deleted file mode 100644 index 48508e05c31..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb +++ /dev/null @@ -1,31 +0,0 @@ -Imports System.Threading - -Public Class Form1 - ' - Dim lines As New List(Of String)() - Private Async Sub threadExampleBtn_Click(sender As Object, e As EventArgs) Handles threadExampleBtn.Click - textBox1.Text = String.Empty - lines.Clear() - - lines.Add("Simulating work on UI thread.") - textBox1.Lines = lines.ToArray() - DoSomeWork(20) - - lines.Add("Simulating work on non-UI thread.") - textBox1.Lines = lines.ToArray() - Await Task.Run(Sub() DoSomeWork(1000)) - - lines.Add("ThreadsExampleBtn_Click completes. ") - textBox1.Lines = lines.ToArray() - End Sub - - Private Async Sub DoSomeWork(milliseconds As Integer) - ' Simulate work. - Await Task.Delay(milliseconds) - - ' Report completion. - lines.Add(String.Format("Some work completed in {0} ms on UI thread.", milliseconds)) - textBox1.Lines = lines.ToArray() - End Sub - ' -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj deleted file mode 100644 index bcfd20b0c58..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj +++ /dev/null @@ -1,140 +0,0 @@ - - - - - Debug - AnyCPU - {0B7BE8EF-B57B-4945-862B-D341854CBF58} - WinExe - WFCrossThreadVB.My.MyApplication - WFCrossThreadVB - WFCrossThreadVB - 512 - WindowsForms - v4.8 - true - - - - AnyCPU - true - full - true - true - bin\Debug\ - WFCrossThreadVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - WFCrossThreadVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form - - - Form1.vb - Form - - - - True - Application.myapp - - - - - - Form1.vb - - - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config deleted file mode 100644 index b5cb6d50fc4..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json deleted file mode 100644 index da9ebf8da2f..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "host": "visualstudio" -} diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb deleted file mode 100644 index 20deef8b370..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ - _ -Partial Class Form1 - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - _ - Private Sub InitializeComponent() - Me.theadExampleBtn = New System.Windows.Forms.Button() - Me.textBox1 = New System.Windows.Forms.TextBox() - Me.SuspendLayout() - ' - 'theadExampleBtn - ' - Me.theadExampleBtn.Location = New System.Drawing.Point(106, 210) - Me.theadExampleBtn.Name = "theadExampleBtn" - Me.theadExampleBtn.Size = New System.Drawing.Size(75, 23) - Me.theadExampleBtn.TabIndex = 0 - Me.theadExampleBtn.Text = "Button1" - Me.theadExampleBtn.UseVisualStyleBackColor = True - ' - 'textBox1 - ' - Me.textBox1.Location = New System.Drawing.Point(31, 45) - Me.textBox1.Multiline = True - Me.textBox1.Name = "textBox1" - Me.textBox1.Size = New System.Drawing.Size(221, 139) - Me.textBox1.TabIndex = 1 - ' - 'Form1 - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(284, 261) - Me.Controls.Add(Me.textBox1) - Me.Controls.Add(Me.theadExampleBtn) - Me.Name = "Form1" - Me.Text = "Form1" - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - - Friend WithEvents theadExampleBtn As Button - Friend WithEvents textBox1 As TextBox -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx deleted file mode 100644 index 1af7de150c9..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb deleted file mode 100644 index dd001ceb45f..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb +++ /dev/null @@ -1,42 +0,0 @@ -Imports System.Collections.Generic -Imports System.Threading.Tasks - -Public Class Form1 - - Dim lines As New List(Of String)() - - Private Async Sub theadExampleBtn_Click(sender As Object, e As EventArgs) Handles theadExampleBtn.Click - textBox1.Text = String.Empty - lines.Clear() - - lines.Add("Simulating work on UI thread.") - textBox1.Lines = lines.ToArray() - DoSomeWork(20) - - lines.Add("Simulating work on non-UI thread.") - textBox1.Lines = lines.ToArray() - Await Task.Run(Sub() DoSomeWork(1000)) - - lines.Add("ThreadsExampleBtn_Click completes. ") - textBox1.Lines = lines.ToArray() - End Sub - - ' - Private Async Sub DoSomeWork(milliseconds As Integer) - ' Simulate work. - Await Task.Delay(milliseconds) - - ' Report completion. - Dim uiMarshal As Boolean = textBox1.InvokeRequired - Dim msg As String = String.Format("Some work completed in {0} ms. on {1}UI thread" + vbCrLf, - milliseconds, If(uiMarshal, String.Empty, "non-")) - lines.Add(msg) - - If uiMarshal Then - textBox1.Invoke(New Action(Sub() textBox1.Lines = lines.ToArray())) - Else - textBox1.Lines = lines.ToArray() - End If - End Sub - ' -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj deleted file mode 100644 index ee9a99e687b..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Debug - AnyCPU - {11E8460E-5231-4932-92A2-443AA943A4E4} - WinExe - WFCrossThreadSolutionVB.My.MyApplication - WFCrossThreadSolutionVB - WFCrossThreadSolutionVB - 512 - WindowsForms - v4.8 - true - - - - AnyCPU - true - full - true - true - bin\Debug\ - WFCrossThreadSolutionVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - WFCrossThreadSolutionVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form - - - Form1.vb - Form - - - - - - Form1.vb - - - - - - - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config deleted file mode 100644 index b5cb6d50fc4..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json deleted file mode 100644 index da9ebf8da2f..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "host": "visualstudio" -} diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml deleted file mode 100644 index ecb56e719b6..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb deleted file mode 100644 index 084cbe917ec..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb +++ /dev/null @@ -1,6 +0,0 @@ -Class Application - - ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException - ' can be handled in this file. - -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml deleted file mode 100644 index 008112be3f0..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - -