diff --git a/docfx.json b/docfx.json
index cceca40203e..269725313ef 100644
--- a/docfx.json
+++ b/docfx.json
@@ -88,6 +88,7 @@
"api/Microsoft.Activities**.yml": "microsoft.activities",
"api/Microsoft.Build**.yml": "microsoft.build",
"api/Microsoft.CSharp**.yml": "microsoft.csharp",
+ "api/Microsoft.Extensions**.yml": "microsoft.extensions",
"api/Microsoft.JScript**.yml": "microsoft.jscript",
"api/Microsoft.SqlServer**.yml": "microsoft.sqlserver",
"api/Microsoft.VisualBasic**.yml": "microsoft.visualbasic",
@@ -100,6 +101,7 @@
"api/System.Buffers**.yml": "system.buffers",
"api/System.CodeDom**.yml": "system.codedom",
"api/System.Collections**.yml": "system.collections",
+ "api/System.CommandLine**.yml": "system.commandline",
"api/System.ComponentModel**.yml": "system.componentmodel",
"api/System.Composition**.yml": "system.composition",
"api/System.Configuration**.yml": "system.configuration",
@@ -111,6 +113,7 @@
"api/System.Drawing**.yml": "system.drawing",
"api/System.Dynamic**.yml": "system.dynamic",
"api/System.EnterpriseServices**.yml": "system.enterpriseservices",
+ "api/System.Formats**.yml": "system.formats",
"api/System.Globalization**.yml": "system.globalization",
"api/System.IdentityModel**.yml": "system.identitymodel",
"api/System.IO**.yml": "system.io",
@@ -139,6 +142,7 @@
"api/System.Xaml**.yml": "system.xaml",
"api/System.Xml**.yml": "system.xml",
"api/UIAutomationClientsideProviders**.yml": "uiautomationclientsideproviders",
+ "api/Windows.UI**.yml": "windows.ui",
"api/XamlGeneratedNamespace**.yml": "xamlgeneratednamespace"
},
"langs": {
diff --git a/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp b/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp
deleted file mode 100644
index d20aed62b38..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Permissions;
-using namespace System::IO;
-using namespace System::Security::Cryptography::X509Certificates;
-
-//Reads a file.
-array^ ReadFile( String^ fileName )
-{
- FileStream^ f = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read );
- int size = (int)f->Length;
- array^data = gcnew array(size);
- size = f->Read( data, 0, size );
- f->Close();
- return data;
-}
-
-[SecurityPermissionAttribute(SecurityAction::LinkDemand, Unrestricted = true)]
-int main()
-{
- array^args = Environment::GetCommandLineArgs();
-
- //Test for correct number of arguments.
- if ( args->Length < 2 )
- {
- Console::WriteLine( "Usage: CertInfo " );
- return -1;
- }
-
- try
- {
- System::Security::Cryptography::X509Certificates::X509Certificate2 ^ x509 =
- gcnew System::Security::Cryptography::X509Certificates::X509Certificate2;
-
- //Create X509Certificate2 object from .cer file.
- array^rawData = ReadFile( args[ 1 ] );
-
- x509->Import(rawData);
-
- //Print to console information contained in the certificate.
- Console::WriteLine( "{0}Subject: {1}{0}", Environment::NewLine, x509->Subject );
- Console::WriteLine( "{0}Issuer: {1}{0}", Environment::NewLine, x509->Issuer );
- Console::WriteLine( "{0}Version: {1}{0}", Environment::NewLine, x509->Version );
- Console::WriteLine( "{0}Valid Date: {1}{0}", Environment::NewLine, x509->NotBefore );
- Console::WriteLine( "{0}Expiry Date: {1}{0}", Environment::NewLine, x509->NotAfter );
- Console::WriteLine( "{0}Thumbprint: {1}{0}", Environment::NewLine, x509->Thumbprint );
- Console::WriteLine( "{0}Serial Number: {1}{0}", Environment::NewLine, x509->SerialNumber );
- Console::WriteLine( "{0}Friendly Name: {1}{0}", Environment::NewLine, x509->PublicKey->Oid->FriendlyName );
- Console::WriteLine( "{0}Public Key Format: {1}{0}", Environment::NewLine, x509->PublicKey->EncodedKeyValue->Format(true) );
- Console::WriteLine( "{0}Raw Data Length: {1}{0}", Environment::NewLine, x509->RawData->Length );
- Console::WriteLine( "{0}Certificate to string: {1}{0}", Environment::NewLine, x509->ToString( true ) );
- Console::WriteLine( "{0}Certificate to XML String: {1}{0}", Environment::NewLine, x509->PublicKey->Key->ToXmlString( false ) );
-
- //Add the certificate to a X509Store.
- X509Store ^ store = gcnew X509Store;
- store->Open( OpenFlags::MaxAllowed );
- store->Add( x509 );
- store->Close();
- }
- 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." );
- }
- catch ( NullReferenceException^ )
- {
- Console::WriteLine( "File must be a .cer file. Program does not have access to that type of file." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp b/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp
deleted file mode 100644
index bbe9ba49645..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Permissions;
-using namespace System::IO;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
- try
- {
- X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser );
- store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) );
- X509Certificate2Collection ^ collection = dynamic_cast(store->Certificates);
- X509Certificate2Collection ^ fcollection = dynamic_cast(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false ));
- X509Certificate2Collection ^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag::MultiSelection);
- Console::WriteLine( "Number of certificates: {0}{1}", scollection->Count, Environment::NewLine );
- System::Collections::IEnumerator^ myEnum = scollection->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- X509Certificate2 ^ x509 = safe_cast(myEnum->Current);
- array^rawdata = x509->RawData;
- Console::WriteLine( "Content Type: {0}{1}", X509Certificate2::GetCertContentType( rawdata ), Environment::NewLine );
- Console::WriteLine( "Friendly Name: {0}{1}", x509->FriendlyName, Environment::NewLine );
- Console::WriteLine( "Certificate Verified?: {0}{1}", x509->Verify(), Environment::NewLine );
- Console::WriteLine( "Simple Name: {0}{1}", x509->GetNameInfo( X509NameType::SimpleName, true ), Environment::NewLine );
- Console::WriteLine( "Signature Algorithm: {0}{1}", x509->SignatureAlgorithm->FriendlyName, Environment::NewLine );
- Console::WriteLine( "Private Key: {0}{1}", x509->PrivateKey->ToXmlString( false ), Environment::NewLine );
- Console::WriteLine( "Public Key: {0}{1}", x509->PublicKey->Key->ToXmlString( false ), Environment::NewLine );
- Console::WriteLine( "Certificate Archived?: {0}{1}", x509->Archived, Environment::NewLine );
- Console::WriteLine( "Length of Raw Data: {0}{1}", x509->RawData->Length, Environment::NewLine );
- x509->Reset();
- }
- store->Close();
- }
- catch ( CryptographicException^ )
- {
- Console::WriteLine( "Information could not be written out for this certificate." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp
deleted file mode 100644
index 262a32465c4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Xml;
-using namespace System::IO;
-
-/// This sample used the GetXml method in the CipherReference class to
-/// write the XML values for the CipherReference to the console.
-
-[STAThread]
-int main()
-{
-
- //Create a URI string.
- String^ uri = "http://www.woodgrovebank.com/document.xml";
-
- // Create a Base64 transform. The input content retrieved from the
- // URI should be Base64-decoded before other processing.
- Transform^ base64 = gcnew XmlDsigBase64Transform;
-
- //Create a transform chain and add the transform to it.
- TransformChain^ tc = gcnew TransformChain;
- tc->Add( base64 );
-
- //Create information.
- CipherReference ^ reference = gcnew CipherReference( uri,tc );
-
- // Write the CipherReference value to the console.
- Console::WriteLine( "Cipher Reference data: {0}", reference->GetXml()->OuterXml );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp b/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp
deleted file mode 100644
index 914c8f0a8fb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// Types:System.Globalization.CompareInfo
-//
-using namespace System;
-using namespace System::Text;
-using namespace System::Globalization;
-
-int main()
-{
- array^ sign = gcnew array { "<", "=", ">" };
-
- // The code below demonstrates how strings compare
- // differently for different cultures.
- String^ s1 = "Coté";
- String^ s2 = "coté";
- String^ s3 = "côte";
-
- // Set sort order of strings for French in France.
- CompareInfo^ ci = (gcnew CultureInfo("fr-FR"))->CompareInfo;
- Console::WriteLine(L"The LCID for {0} is {1}.", ci->Name, ci->LCID);
-
- // Display the result using fr-FR Compare of Coté = coté.
- Console::WriteLine(L"fr-FR Compare: {0} {2} {1}",
- s1, s2, sign[ci->Compare(s1, s2, CompareOptions::IgnoreCase) + 1]);
-
- // Display the result using fr-FR Compare of coté > côte.
- Console::WriteLine(L"fr-FR Compare: {0} {2} {1}",
- s2, s3, sign[ci->Compare(s2, s3, CompareOptions::None) + 1]);
-
- // Set sort order of strings for Japanese as spoken in Japan.
- ci = (gcnew CultureInfo("ja-JP"))->CompareInfo;
- Console::WriteLine(L"The LCID for {0} is {1}.", ci->Name, ci->LCID);
-
- // Display the result using ja-JP Compare of coté < côte.
- Console::WriteLine("ja-JP Compare: {0} {2} {1}",
- s2, s3, sign[ci->Compare(s2, s3) + 1]);
-}
-
-// This code produces the following output.
-//
-// The LCID for fr-FR is 1036.
-// fr-FR Compare: Coté = coté
-// fr-FR Compare: coté > côte
-// The LCID for ja-JP is 1041.
-// ja-JP Compare: coté < côte
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp
deleted file mode 100644
index 2c6841d495b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-// System::Diagnostics->CounterCreationDataCollection::ctor
-// System::Diagnostics->CounterCreationDataCollection->AddRange(CounterCreationDataCollection)
-/*
-The following program demonstrates 'CounterCreationDataCollection()' constructor and
-'AddRange(CounterCreationDataCollection)' method of 'CounterCreationDataCollection' class.
-A 'CounterCreationData' Object* is created and added to an instance of 'CounterCreationDataCollection'
-class. Then counters in the 'CounterCreationDataCollection' are displayed to the console.
-*/
-//
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-int main()
-{
- PerformanceCounter^ myCounter;
- try
- {
- String^ myCategoryName;
- int numberOfCounters;
- Console::Write( "Enter the number of counters : " );
- numberOfCounters = Int32::Parse( Console::ReadLine() );
- array^myCounterCreationData = gcnew array(numberOfCounters);
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- Console::Write( "Enter the counter name for {0} counter : ", i );
- myCounterCreationData[ i ] = gcnew CounterCreationData;
- myCounterCreationData[ i ]->CounterName = Console::ReadLine();
- }
- CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData );
- Console::Write( "Enter the category Name : " );
- myCategoryName = Console::ReadLine();
-
- // Check if the category already exists or not.
- if ( !PerformanceCounterCategory::Exists( myCategoryName ) )
- {
- CounterCreationDataCollection^ myNewCounterCollection = gcnew CounterCreationDataCollection;
-
- // Add the 'CounterCreationDataCollection' to 'CounterCreationDataCollection' Object*.
- myNewCounterCollection->AddRange( myCounterCollection );
- PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myNewCounterCollection );
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false );
-
- }
- Console::WriteLine( "The list of counters in CounterCollection are: " );
- for ( int i = 0; i < myNewCounterCollection->Count; i++ )
- Console::WriteLine( "Counter {0} is '{1}'", i + 1, myNewCounterCollection[ i ]->CounterName );
- }
- else
- {
- Console::WriteLine( "The category already exists" );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}.", e->Message );
- }
-}
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp
deleted file mode 100644
index 04c88582196..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-// System::Diagnostics->CounterCreationDataCollection::Contains(CounterCreationData)
-// System::Diagnostics->CounterCreationDataCollection::Remove(CounterCreationData)
-
-/*
-The following program demonstrates 'Contains' and 'Remove' methods of
-'CounterCreationDataCollection' class. An instance of 'CounterCreationDataCollection'
-is created by passing an array of 'CounterCreationData'. A particular instance of
-'CounterCreationData' is removed if it exist in the 'CounterCreationDataCollection'.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- PerformanceCounter^ myCounter;
- 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 = Int32::Parse( Console::ReadLine() );
- array^ myCounterCreationData =
- gcnew array(numberOfCounters);
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- Console::Write( "Enter the counter name for {0} counter : ", i );
- myCounterCreationData[ i ] = gcnew CounterCreationData;
- myCounterCreationData[ i ]->CounterName = Console::ReadLine();
- }
- CounterCreationDataCollection^ myCounterCollection =
- gcnew CounterCreationDataCollection;
- // Add the 'CounterCreationData[]' to 'CounterCollection'.
- myCounterCollection->AddRange( myCounterCreationData );
-
- PerformanceCounterCategory::Create( myCategoryName,
- "Sample Category", myCounterCollection );
-
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- myCounter = gcnew PerformanceCounter( myCategoryName,
- myCounterCreationData[ i ]->CounterName, "", false );
- }
- if ( myCounterCreationData->Length > 0 )
- {
- if ( myCounterCollection->Contains( myCounterCreationData[ 0 ] ) )
- {
- myCounterCollection->Remove( myCounterCreationData[ 0 ] );
- Console::WriteLine( "'{0}' counter is removed from the" +
- " CounterCreationDataCollection", myCounterCreationData[ 0 ]->CounterName );
- }
- }
- else
- {
- Console::WriteLine( "The counters does not exist" );
- }
- }
- else
- {
- Console::WriteLine( "The category already exists" );
- }
-//
-//
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}.", e->Message );
- return;
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp
deleted file mode 100644
index 5af877a5275..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// System::Diagnostics->CounterCreationDataCollection->CounterCreationDataCollection(CounterCreationData->Item[])
-
-/*
-The following program demonstrates 'CounterCreationDataCollection(CounterCreationData->Item[])'
-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
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- PerformanceCounter^ myCounter;
- 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 = Int32::Parse( Console::ReadLine() );
- array^myCounterCreationData = gcnew array(numberOfCounters);
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- Console::Write( "Enter the counter name for {0} counter : ", i );
- myCounterCreationData[ i ] = gcnew CounterCreationData;
- myCounterCreationData[ i ]->CounterName = Console::ReadLine();
-
- }
- CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData );
-
- // Create the category.
- PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myCounterCollection );
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false );
-
- }
- 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/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp
deleted file mode 100644
index d9619066739..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-// System::Diagnostics->CounterCreationDataCollection->CounterCreationDataCollection(CounterCreationDataCollection)
-/*
-The following program demonstrates 'CounterCreationDataCollection(CounterCreationDataCollection)'
-constructor of 'CounterCreationDataCollection' class.
-An instance of 'CounterCreationDataCollection' is created by passing another instance
-of 'CounterCreationDataCollection'. The counters of the 'CounterCreationDataCollection'
-are displayed to the console.
-*/
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void main()
-{
- PerformanceCounter^ myCounter;
- try
- {
-//
- String^ myCategoryName;
- int numberOfCounters;
- Console::Write( "Enter the number of counters : " );
- numberOfCounters = Int32::Parse( Console::ReadLine() );
- array^myCounterCreationData = gcnew array(numberOfCounters);
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- Console::Write( "Enter the counter name for {0} counter : ", i );
- myCounterCreationData[ i ] = gcnew CounterCreationData;
- myCounterCreationData[ i ]->CounterName = Console::ReadLine();
-
- }
- CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData );
- Console::Write( "Enter the category Name:" );
- myCategoryName = Console::ReadLine();
-
- // Check if the category already exists or not.
- if ( !PerformanceCounterCategory::Exists( myCategoryName ) )
- {
- CounterCreationDataCollection^ myNewCounterCollection = gcnew CounterCreationDataCollection( myCounterCollection );
- PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myNewCounterCollection );
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false );
-
- }
- Console::WriteLine( "The list of counters in 'CounterCollection' are : " );
- for ( int i = 0; i < myNewCounterCollection->Count; i++ )
- Console::WriteLine( "Counter {0} is '{1}'", i, myNewCounterCollection[ i ]->CounterName );
- }
- else
- {
- Console::WriteLine( "The category already exists" );
- }
-//
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}.", e->Message );
- return;
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp
deleted file mode 100644
index e4e097db2f4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-// System::Diagnostics->CounterCreationDataCollection::Insert(int, CounterCreationData)
-// System::Diagnostics->CounterCreationDataCollection::IndexOf(CounterCreationData)
-
-/*
-The following program demonstrates 'IndexOf(CounterCreationData)' and 'Insert(int, CounterCreationData)'
-methods of 'CounterCreationDataCollection' class. An instance of 'CounterCreationDataCollection'
-is created by passing an array of 'CounterCreationData' to the constructor. A counter is inserted
-into the 'CounterCreationDataCollection' at specified index. The inserted counter and
-its index are displayed to the console.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- PerformanceCounter^ myCounter;
- 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 = Int32::Parse( Console::ReadLine() );
- array^ myCounterCreationData =
- gcnew array(numberOfCounters);
-
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- Console::Write( "Enter the counter name for {0} counter ", i );
- myCounterCreationData[ i ] = gcnew CounterCreationData;
- myCounterCreationData[ i ]->CounterName = Console::ReadLine();
- }
- CounterCreationDataCollection^ myCounterCollection =
- gcnew CounterCreationDataCollection( myCounterCreationData );
- CounterCreationData^ myInsertCounterCreationData = gcnew CounterCreationData(
- "CounterInsert","",PerformanceCounterType::NumberOfItems32 );
- // Insert an instance of 'CounterCreationData' in the 'CounterCreationDataCollection'.
- myCounterCollection->Insert( myCounterCollection->Count - 1,
- myInsertCounterCreationData );
- Console::WriteLine( "'{0}' counter is inserted into 'CounterCreationDataCollection'",
- myInsertCounterCreationData->CounterName );
- // Create the category.
- PerformanceCounterCategory::Create( myCategoryName, "Sample Category",
- myCounterCollection );
-
- for ( int i = 0; i < numberOfCounters; i++ )
- {
- myCounter = gcnew PerformanceCounter( myCategoryName,
- myCounterCreationData[ i ]->CounterName, "", false );
- }
- Console::WriteLine( "The index of '{0}' counter is {1}",
- myInsertCounterCreationData->CounterName, myCounterCollection->IndexOf( myInsertCounterCreationData ) );
- }
- else
- {
- Console::WriteLine( "The category already exists" );
- }
-//
-//
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}.", e->Message );
- return;
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp b/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp
deleted file mode 100644
index 2fe2f7b3082..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// System::Diagnostics->CounterSample->CounterSample(long, long, long, long, long, long, PerformanceCounterType)
-// System::Diagnostics->CounterSample->CounterSample(long, long, long, long, long, long, PerformanceCounterType, long)
-
-/* The following program demonstrates the constructors of the 'CounterSample'
-structure. It creates an instance of performance counter, configures it
-to interact with 'Processor' category, '% Processor Time' counter and
-'0' instance, creates an instance of 'CounterSample', and displays
-the corresponding fields.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
-//
- PerformanceCounter^ myPerformanceCounter1 = gcnew PerformanceCounter(
- "Processor","% Processor Time","0" );
- CounterSample myCounterSample1( 10L, 20L, 30L, 40L, 50L, 60L,
- PerformanceCounterType::AverageCount64 );
- Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample1.CounterTimeStamp );
-
- Console::WriteLine( "BaseValue = {0}", myCounterSample1.BaseValue );
- Console::WriteLine( "RawValue = {0}", myCounterSample1.RawValue );
- Console::WriteLine( "CounterFrequency = {0}", myCounterSample1.CounterFrequency );
- Console::WriteLine( "SystemFrequency = {0}", myCounterSample1.SystemFrequency );
- Console::WriteLine( "TimeStamp = {0}", myCounterSample1.TimeStamp );
- Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample1.TimeStamp100nSec );
- Console::WriteLine( "CounterType = {0}", myCounterSample1.CounterType );
- // Hold the results of sample.
- myCounterSample1 = myPerformanceCounter1->NextSample();
- Console::WriteLine( "BaseValue = {0}", myCounterSample1.BaseValue );
- Console::WriteLine( "RawValue = {0}", myCounterSample1.RawValue );
- Console::WriteLine( "CounterFrequency = {0}", myCounterSample1.CounterFrequency );
- Console::WriteLine( "SystemFrequency = {0}", myCounterSample1.SystemFrequency );
- Console::WriteLine( "TimeStamp = {0}", myCounterSample1.TimeStamp );
- Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample1.TimeStamp100nSec );
- Console::WriteLine( "CounterType = {0}", myCounterSample1.CounterType );
-//
- Console::WriteLine( "" );
- Console::WriteLine( "" );
-//
- PerformanceCounter^ myPerformanceCounter2 =
- gcnew PerformanceCounter( "Processor","% Processor Time","0" );
- CounterSample myCounterSample2( 10L, 20L, 30L, 40L, 50L, 60L,
- PerformanceCounterType::AverageCount64,300);
- Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp );
- Console::WriteLine( "BaseValue = {0}", myCounterSample2.BaseValue );
- Console::WriteLine( "RawValue = {0}", myCounterSample2.RawValue );
- Console::WriteLine( "CounterFrequency = {0}", myCounterSample2.CounterFrequency );
- Console::WriteLine( "SystemFrequency = {0}", myCounterSample2.SystemFrequency );
- Console::WriteLine( "TimeStamp = {0}", myCounterSample2.TimeStamp );
- Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample2.TimeStamp100nSec );
- Console::WriteLine( "CounterType = {0}", myCounterSample2.CounterType );
- Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp );
- // Hold the results of sample.
- myCounterSample2 = myPerformanceCounter2->NextSample();
- Console::WriteLine( "BaseValue = {0}", myCounterSample2.BaseValue );
- Console::WriteLine( "RawValue = {0}", myCounterSample2.RawValue );
- Console::WriteLine( "CounterFrequency = {0}", myCounterSample2.CounterFrequency );
- Console::WriteLine( "SystemFrequency = {0}", myCounterSample2.SystemFrequency );
- Console::WriteLine( "TimeStamp = {0}", myCounterSample2.TimeStamp );
- Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample2.TimeStamp100nSec );
- Console::WriteLine( "CounterType = {0}", myCounterSample2.CounterType );
- Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp );
-//
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp
deleted file mode 100644
index 99c669d9f27..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-
-void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv);
-String^ DecryptTextFromFile(String^ path, array^ key, array^ iv);
-
-int main()
-{
- try
- {
- array^ key;
- array^ iv;
-
- // Create a new TripleDES object to generate a random key
- // and initialization vector (IV).
- {
- TripleDES^ tripleDes;
-
- try
- {
- tripleDes = TripleDES::Create();
- key = tripleDes->Key;
- iv = tripleDes->IV;
- }
- finally
- {
- delete tripleDes;
- }
- }
-
- // Create a string to encrypt.
- String^ original = "Here is some data to encrypt.";
- // The name/path of the file to write.
- String^ filename = "CText.enc";
-
- // Encrypt the string to a file.
- EncryptTextToFile(original, filename, key, iv);
-
- // Decrypt the file back to a string.
- String^ decrypted = DecryptTextFromFile(filename, key, iv);
-
- // Display the decrypted string to the console.
- Console::WriteLine(decrypted);
- }
- catch (Exception^ e)
- {
- Console::WriteLine(e->Message);
- }
-}
-
-void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv)
-{
- FileStream^ fStream = nullptr;
- TripleDES^ tripleDes = nullptr;
- ICryptoTransform^ encryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create or open the specified file.
- fStream = File::Open(path, FileMode::Create);
- // Create a new TripleDES object.
- tripleDes = TripleDES::Create();
- // Create a TripleDES encryptor from the key and IV
- encryptor = tripleDes->CreateEncryptor(key, iv);
- // Create a CryptoStream using the FileStream and encryptor
- cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write);
-
- // Convert the provided string to a byte array.
- array^ toEncrypt = Encoding::UTF8->GetBytes(text);
-
- // Write the byte array to the crypto stream.
- cStream->Write(toEncrypt, 0, toEncrypt->Length);
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (encryptor != nullptr)
- delete encryptor;
-
- if (tripleDes != nullptr)
- delete tripleDes;
-
- if (fStream != nullptr)
- delete fStream;
- }
-}
-
-String^ DecryptTextFromFile(String^ path, array^ key, array^ iv)
-{
- FileStream^ fStream = nullptr;
- TripleDES^ tripleDes = nullptr;
- ICryptoTransform^ decryptor = nullptr;
- CryptoStream^ cStream = nullptr;
- StreamReader^ reader = nullptr;
-
- try
- {
- // Open the specified file
- fStream = File::OpenRead(path);
- // Create a new TripleDES object.
- tripleDes = TripleDES::Create();
- // Create a TripleDES decryptor from the key and IV
- decryptor = tripleDes->CreateDecryptor(key, iv);
- // Create a CryptoStream using the FileStream and decryptor
- cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read);
- // Create a StreamReader to turn the bytes back into text
- reader = gcnew StreamReader(cStream, Encoding::UTF8);
-
- // Read back all of the text from the StreamReader, which receives
- // the decrypted bytes from the CryptoStream, which receives the
- // encrypted bytes from the FileStream.
- return reader->ReadToEnd();
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (decryptor != nullptr)
- delete decryptor;
-
- if (tripleDes != nullptr)
- delete tripleDes;
-
- if (fStream != nullptr)
- delete fStream;
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp
deleted file mode 100644
index 3f109c53866..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-
-int main()
-{
-
- //The following example demonstrates the usage of the AsnEncodedData classes.
- // Asn encoded data is read from the extensions of an X509 certificate.
- try
- {
-
- // Open the certificate store.
- X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser );
- store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) );
- X509Certificate2Collection^ collection = dynamic_cast(store->Certificates);
- X509Certificate2Collection^ fcollection = dynamic_cast(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false ));
-
- // Select one or more certificates to display extensions information.
- X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, L"Certificate Select",L"Select certificates from the following list to get extension information on that certificate",X509SelectionFlag::MultiSelection);
-
- // Create a new AsnEncodedDataCollection object.
- AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection;
- for ( int i = 0; i < scollection->Count; i++ )
- {
-
- // Display certificate information.
- Console::ForegroundColor = ConsoleColor::Red;
- Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName() );
- Console::ResetColor();
-
- // Display extensions information.
- System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- X509Extension^ extension = safe_cast(myEnum->Current);
-
- // Create an AsnEncodedData object using the extensions information.
- AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData );
- Console::ForegroundColor = ConsoleColor::Green;
- Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName );
- Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value );
- Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length, Environment::NewLine );
- Console::ResetColor();
- Console::WriteLine( asndata->Format(true) );
- Console::WriteLine( Environment::NewLine );
-
- // Add the AsnEncodedData object to the AsnEncodedDataCollection object.
- asncoll->Add( asndata );
- }
-
- Console::WriteLine( Environment::NewLine );
-
- }
- Console::ForegroundColor = ConsoleColor::Red;
- Console::WriteLine( L"Number of AsnEncodedData items in the collection: {0} {1}", asncoll->Count, Environment::NewLine );
- Console::ResetColor();
- store->Close();
-
- //Create an enumerator for moving through the collection.
- AsnEncodedDataEnumerator^ asne = asncoll->GetEnumerator();
-
- //You must execute a MoveNext() to get to the first item in the collection.
- asne->MoveNext();
-
- // Write out AsnEncodedData in the collection.
- Console::ForegroundColor = ConsoleColor::Blue;
- Console::WriteLine( L"First AsnEncodedData in the collection: {0}", asne->Current->Format(true) );
- Console::ResetColor();
- asne->MoveNext();
- Console::ForegroundColor = ConsoleColor::DarkBlue;
- Console::WriteLine( L"Second AsnEncodedData in the collection: {0}", asne->Current->Format(true) );
- Console::ResetColor();
-
- //Return index in the collection to the beginning.
- asne->Reset();
- }
- catch ( CryptographicException^ )
- {
- Console::WriteLine( L"Information could not be written out for this certificate." );
- }
-
- return 1;
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp
deleted file mode 100644
index e48f4e14aa9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-
-void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv);
-String^ DecryptTextFromFile(String^ path, array^ key, array^ iv);
-
-int main()
-{
- try
- {
- array^ key;
- array^ iv;
-
- // Create a new DES object to generate a random key
- // and initialization vector (IV).
- {
- DES^ des;
-
- try
- {
- des = DES::Create();
- key = des->Key;
- iv = des->IV;
- }
- finally
- {
- delete des;
- }
- }
-
- // Create a string to encrypt.
- String^ original = "Here is some data to encrypt.";
- // The name/path of the file to write.
- String^ filename = "CText.enc";
-
- // Encrypt the string to a file.
- EncryptTextToFile(original, filename, key, iv);
-
- // Decrypt the file back to a string.
- String^ decrypted = DecryptTextFromFile(filename, key, iv);
-
- // Display the decrypted string to the console.
- Console::WriteLine(decrypted);
- }
- catch (Exception^ e)
- {
- Console::WriteLine(e->Message);
- }
-}
-
-void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv)
-{
- FileStream^ fStream = nullptr;
- DES^ des = nullptr;
- ICryptoTransform^ encryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create or open the specified file.
- fStream = File::Open(path, FileMode::Create);
- // Create a new DES object.
- des = DES::Create();
- // Create a DES encryptor from the key and IV
- encryptor = des->CreateEncryptor(key, iv);
- // Create a CryptoStream using the FileStream and encryptor
- cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write);
-
- // Convert the provided string to a byte array.
- array^ toEncrypt = Encoding::UTF8->GetBytes(text);
-
- // Write the byte array to the crypto stream.
- cStream->Write(toEncrypt, 0, toEncrypt->Length);
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (encryptor != nullptr)
- delete encryptor;
-
- if (des != nullptr)
- delete des;
-
- if (fStream != nullptr)
- delete fStream;
- }
-}
-
-String^ DecryptTextFromFile(String^ path, array^ key, array^ iv)
-{
- FileStream^ fStream = nullptr;
- DES^ des = nullptr;
- ICryptoTransform^ decryptor = nullptr;
- CryptoStream^ cStream = nullptr;
- StreamReader^ reader = nullptr;
-
- try
- {
- // Open the specified file
- fStream = File::OpenRead(path);
- // Create a new DES object.
- des = DES::Create();
- // Create a DES decryptor from the key and IV
- decryptor = des->CreateDecryptor(key, iv);
- // Create a CryptoStream using the FileStream and decryptor
- cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read);
- // Create a StreamReader to turn the bytes back into text
- reader = gcnew StreamReader(cStream, Encoding::UTF8);
-
- // Read back all of the text from the StreamReader, which receives
- // the decrypted bytes from the CryptoStream, which receives the
- // encrypted bytes from the FileStream.
- return reader->ReadToEnd();
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (decryptor != nullptr)
- delete decryptor;
-
- if (des != nullptr)
- delete des;
-
- if (fStream != nullptr)
- delete fStream;
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp
deleted file mode 100644
index 27a8c01000f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-using namespace System::IO;
-
-array^ EncryptTextToMemory(String^ text, array^ key, array^ iv);
-String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv);
-
-int main()
-{
- try
- {
- array^ key;
- array^ iv;
-
- // Create a new DES object to generate a random key
- // and initialization vector (IV).
- {
- DES^ des;
-
- try
- {
- des = DES::Create();
- key = des->Key;
- iv = des->IV;
- }
- finally
- {
- delete des;
- }
- }
-
- // Create a string to encrypt.
- String^ original = "Here is some data to encrypt.";
-
- // Encrypt the string to an in-memory buffer.
- array^ encrypted = EncryptTextToMemory(original, key, iv);
-
- // Decrypt the buffer back to a string.
- String^ decrypted = DecryptTextFromMemory(encrypted, key, iv);
-
- // Display the decrypted string to the console.
- Console::WriteLine(decrypted);
- }
- catch (Exception^ e)
- {
- Console::WriteLine(e->Message);
- }
-}
-
-array^ EncryptTextToMemory(String^ text, array^ key, array^ iv)
-{
- MemoryStream^ mStream = nullptr;
-
- try
- {
- // Create a MemoryStream.
- mStream = gcnew MemoryStream;
-
- DES^ des = nullptr;
- ICryptoTransform^ encryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create a new DES object.
- des = DES::Create();
- // Create a DES encryptor from the key and IV
- encryptor = des->CreateEncryptor(key, iv);
- // Create a CryptoStream using the MemoryStream and encryptor
- cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write);
-
- // Convert the provided string to a byte array.
- array^ toEncrypt = Encoding::UTF8->GetBytes(text);
-
- // Write the byte array to the crypto stream.
- cStream->Write(toEncrypt, 0, toEncrypt->Length);
-
- // Disposing the CryptoStream completes the encryption and flushes the stream.
- delete cStream;
-
- // Get an array of bytes from the MemoryStream that holds the encrypted data.
- array^ ret = mStream->ToArray();
-
- // Return the encrypted buffer.
- return ret;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (encryptor != nullptr)
- delete encryptor;
-
- if (des != nullptr)
- delete des;
- }
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (mStream != nullptr)
- delete mStream;
- }
-}
-
-String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv)
-{
- MemoryStream^ mStream = nullptr;
- DES^ des = nullptr;
- ICryptoTransform^ decryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create buffer to hold the decrypted data.
- // DES-encrypted data will always be slightly bigger than the decrypted data.
- array^ decrypted = gcnew array(encrypted->Length);
- Int32 offset = 0;
-
- // Create a new MemoryStream using the provided array of encrypted data.
- mStream = gcnew MemoryStream(encrypted);
- // Create a new DES object.
- des = DES::Create();
- // Create a DES decryptor from the key and IV
- decryptor = des->CreateDecryptor(key, iv);
- // Create a CryptoStream using the MemoryStream and decryptor
- cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read);
-
- // Keep reading from the CryptoStream until it finishes (returns 0).
- Int32 read = 1;
-
- while (read > 0)
- {
- read = cStream->Read(decrypted, offset, decrypted->Length - offset);
- offset += read;
- }
-
- // Convert the buffer into a string and return it.
- return Encoding::UTF8->GetString(decrypted, 0, offset);
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (decryptor != nullptr)
- delete decryptor;
-
- if (des != nullptr)
- delete des;
-
- if (mStream != nullptr)
- delete mStream;
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp
deleted file mode 100644
index 0aeedb91f59..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-using namespace System::IO;
-void EncryptTextToFile( String^ Data, String^ FileName, array^Key, array^IV )
-{
- try
- {
-
- // Create or open the specified file.
- FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate );
-
- // Create a CryptoStream using the FileStream
- // and the passed key and initialization vector (IV).
- CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew DESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write );
-
- // Create a StreamWriter using the CryptoStream.
- StreamWriter^ sWriter = gcnew StreamWriter( cStream );
-
- // Write the data to the stream
- // to encrypt it.
- sWriter->WriteLine( Data );
-
- // Close the streams and
- // close the file.
- sWriter->Close();
- cStream->Close();
- fStream->Close();
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
- }
- catch ( UnauthorizedAccessException^ e )
- {
- Console::WriteLine( "A file error occurred: {0}", e->Message );
- }
-
-}
-
-String^ DecryptTextFromFile( String^ FileName, array^Key, array^IV )
-{
- try
- {
-
- // Create or open the specified file.
- FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate );
-
- // Create a CryptoStream using the FileStream
- // and the passed key and initialization vector (IV).
- CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew DESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read );
-
- // Create a StreamReader using the CryptoStream.
- StreamReader^ sReader = gcnew StreamReader( cStream );
-
- // Read the data from the stream
- // to decrypt it.
- String^ val = sReader->ReadLine();
-
- // Close the streams and
- // close the file.
- sReader->Close();
- cStream->Close();
- fStream->Close();
-
- // Return the string.
- return val;
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
- return nullptr;
- }
- catch ( UnauthorizedAccessException^ e )
- {
- Console::WriteLine( "A file error occurred: {0}", e->Message );
- return nullptr;
- }
-
-}
-
-int main()
-{
- try
- {
-
- // Create a new DESCryptoServiceProvider object
- // to generate a key and initialization vector (IV).
- DESCryptoServiceProvider^ DESalg = gcnew DESCryptoServiceProvider;
-
- // Create a string to encrypt.
- String^ sData = "Here is some data to encrypt.";
- String^ FileName = "CText.txt";
-
- // Encrypt text to a file using the file name, key, and IV.
- EncryptTextToFile( sData, FileName, DESalg->Key, DESalg->IV );
-
- // Decrypt the text from a file using the file name, key, and IV.
- String^ Final = DecryptTextFromFile( FileName, DESalg->Key, DESalg->IV );
-
- // Display the decrypted string to the console.
- Console::WriteLine( Final );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp
deleted file mode 100644
index 3fdcdbcd1dd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-using namespace System::IO;
-array^ EncryptTextToMemory( String^ Data, array^Key, array^IV )
-{
- try
- {
-
- // Create a MemoryStream.
- MemoryStream^ mStream = gcnew MemoryStream;
-
- // Create a CryptoStream using the MemoryStream
- // and the passed key and initialization vector (IV).
- CryptoStream^ cStream = gcnew CryptoStream( mStream,(gcnew DESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write );
-
- // Convert the passed string to a byte array.
- array^toEncrypt = (gcnew ASCIIEncoding)->GetBytes( Data );
-
- // Write the byte array to the crypto stream and flush it.
- cStream->Write( toEncrypt, 0, toEncrypt->Length );
- cStream->FlushFinalBlock();
-
- // Get an array of bytes from the
- // MemoryStream that holds the
- // encrypted data.
- array^ret = mStream->ToArray();
-
- // Close the streams.
- cStream->Close();
- mStream->Close();
-
- // Return the encrypted buffer.
- return ret;
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
- return nullptr;
- }
-
-}
-
-String^ DecryptTextFromMemory( array^Data, array^Key, array^IV )
-{
- try
- {
-
- // Create a new MemoryStream using the passed
- // array of encrypted data.
- MemoryStream^ msDecrypt = gcnew MemoryStream( Data );
-
- // Create a CryptoStream using the MemoryStream
- // and the passed key and initialization vector (IV).
- CryptoStream^ csDecrypt = gcnew CryptoStream( msDecrypt,(gcnew DESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read );
-
- // Create buffer to hold the decrypted data.
- array^fromEncrypt = gcnew array(Data->Length);
-
- // Read the decrypted data out of the crypto stream
- // and place it into the temporary buffer.
- csDecrypt->Read( fromEncrypt, 0, fromEncrypt->Length );
-
- //Convert the buffer into a string and return it.
- return (gcnew ASCIIEncoding)->GetString( fromEncrypt );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
- return nullptr;
- }
-
-}
-
-int main()
-{
- try
- {
-
- // Create a new DESCryptoServiceProvider object
- // to generate a key and initialization vector (IV).
- DESCryptoServiceProvider^ DESalg = gcnew DESCryptoServiceProvider;
-
- // Create a string to encrypt.
- String^ sData = "Here is some data to encrypt.";
-
- // Encrypt the string to an in-memory buffer.
- array^Data = EncryptTextToMemory( sData, DESalg->Key, DESalg->IV );
-
- // Decrypt the buffer back to a string.
- String^ Final = DecryptTextFromMemory( Data, DESalg->Key, DESalg->IV );
-
- // Display the decrypted string to the console.
- Console::WriteLine( Final );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp
deleted file mode 100644
index 7b3ed1ec455..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-
-public ref class DataProtectionSample
-{
-private:
-
- // Create byte array for additional entropy when using Protect method.
- static array^s_additionalEntropy = {9,8,7,6,5};
-
-public:
- static void Main()
- {
-
- // Create a simple byte array containing data to be encrypted.
- array^secret = {0,1,2,3,4,1,2,3,4};
-
- //Encrypt the data.
- array^encryptedSecret = Protect( secret );
- Console::WriteLine( "The encrypted byte array is:" );
- PrintValues( encryptedSecret );
-
- // Decrypt the data and store in a byte array.
- array^originalData = Unprotect( encryptedSecret );
- Console::WriteLine( "{0}The original data is:", Environment::NewLine );
- PrintValues( originalData );
- }
-
- static array^ Protect( array^data )
- {
- try
- {
-
- // Encrypt the data using DataProtectionScope.CurrentUser. The result can be decrypted
- // only by the same current user.
- return ProtectedData::Protect( data, s_additionalEntropy, DataProtectionScope::CurrentUser );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "Data was not encrypted. An error occurred." );
- Console::WriteLine( e );
- return nullptr;
- }
- }
-
- static array^ Unprotect( array^data )
- {
- try
- {
-
- //Decrypt the data using DataProtectionScope.CurrentUser.
- return ProtectedData::Unprotect( data, s_additionalEntropy, DataProtectionScope::CurrentUser );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "Data was not decrypted. An error occurred." );
- Console::WriteLine( e );
- return nullptr;
- }
- }
-
- static void PrintValues( array^myArr )
- {
- System::Collections::IEnumerator^ myEnum = myArr->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Byte i = safe_cast(myEnum->Current);
- Console::Write( "\t{0}", i );
- }
-
- Console::WriteLine();
- }
-};
-
-int main()
-{
- DataProtectionSample::Main();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp
deleted file mode 100644
index 8bd6a68686f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-
-int main()
-{
- //
- // Create a new CspParameters object.
- CspParameters^ cspParams = gcnew CspParameters();
-
- // Specify an exchange key.
- cspParams->KeyNumber = (int) KeyNumber::Exchange;
-
- // Initialize the RSACryptoServiceProvider
- // with the CspParameters object.
- RSACryptoServiceProvider^ RSACSP = gcnew RSACryptoServiceProvider(cspParams);
- //
-};
-
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp
deleted file mode 100644
index 3189ba48a53..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-int main()
-{
-
- // Assign values to strings.
- String^ Value1 = "1.2.840.113549.1.1.1";
- String^ Name1 = "3DES";
- String^ Value2 = "1.3.6.1.4.1.311.20.2";
- String^ InvalidName = "This name is not a valid name";
- String^ InvalidValue = "1.1.1.1.1.1.1.1";
-
- // Create new Oid objects using the specified values.
- // Note that the corresponding Value or Friendly Name property is automatically added to the object.
- Oid ^ o1 = gcnew Oid( Value1 );
- Oid ^ o2 = gcnew Oid( Name1 );
-
- // Create a new Oid object using the specified Value and Friendly Name properties.
- // Note that the two are not compared to determine if the Value is associated
- // with the Friendly Name.
- Oid ^ o3 = gcnew Oid( Value2,InvalidName );
-
- //Create a new Oid object using the specified Value. Note that if the value
- // is invalid or not known, no value is assigned to the Friendly Name property.
- Oid ^ o4 = gcnew Oid( InvalidValue );
-
- //Write out the property information of the Oid objects.
- Console::WriteLine( "Oid1: Automatically assigned Friendly Name: {0}, {1}", o1->FriendlyName, o1->Value );
- Console::WriteLine( "Oid2: Automatically assigned Value: {0}, {1}", o2->FriendlyName, o2->Value );
- Console::WriteLine( "Oid3: Name and Value not compared: {0}, {1}", o3->FriendlyName, o3->Value );
- Console::WriteLine( "Oid4: Invalid Value used: {0}, {1} {2}", o4->FriendlyName, o4->Value, Environment::NewLine );
-
- //Create an Oid collection and add several Oid objects.
- OidCollection ^ oc = gcnew OidCollection;
- oc->Add( o1 );
- oc->Add( o2 );
- oc->Add( o3 );
- Console::WriteLine( "Number of Oids in the collection: {0}", oc->Count );
- Console::WriteLine( "Is synchronized: {0} {1}", oc->IsSynchronized, Environment::NewLine );
-
- //Create an enumerator for moving through the collection.
- OidEnumerator ^ oe = oc->GetEnumerator();
-
- //You must execute a MoveNext() to get to the first item in the collection.
- oe->MoveNext();
-
- // Write out Oids in the collection.
- Console::WriteLine( "First Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value );
- oe->MoveNext();
- Console::WriteLine( "Second Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value );
-
- //Return index in the collection to the beginning.
- oe->Reset();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp
deleted file mode 100644
index 06b5a8483db..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-
-// Generates a random salt value of the specified length.
-array^ CreateRandomSalt(int length)
-{
- // Create a buffer
- array^ randomBytes;
-
- if (length >= 1)
- {
- randomBytes = gcnew array (length);
- }
- else
- {
- randomBytes = gcnew array (1);
- }
-
- // Create a new RandomNumberGenerator.
- RandomNumberGenerator^ randomNumberGenerator =
- RandomNumberGenerator::Create();
-
- // Fill the buffer with random bytes.
- randomNumberGenerator->GetBytes(randomBytes);
-
- // return the bytes.
- return randomBytes;
-}
-
-// Clears the bytes in a buffer so they can't later be read from memory.
-void ClearBytes(array^ buffer)
-{
- // Check arguments.
- if (buffer == nullptr)
- {
- throw gcnew ArgumentNullException("buffer");
- }
-
- // Set each byte in the buffer to 0.
- for (int x = 0; x <= buffer->Length - 1; x++)
- {
- buffer[x] = 0;
- }
-}
-
-int main(array^ args)
-{
-
- // Get a password from the user.
- Console::WriteLine("Enter a password to produce a key:");
-
- // Security Note: Never hard-code a password within your
- // source code. Hard-coded passwords can be retrieved
- // from a compiled assembly.
- array^ password = Encoding::Unicode->GetBytes(Console::ReadLine());
-
- array^ randomSalt = CreateRandomSalt(7);
-
- // Create a TripleDESCryptoServiceProvider object.
- TripleDESCryptoServiceProvider^ cryptoDESProvider =
- gcnew TripleDESCryptoServiceProvider();
-
- try
- {
- Console::WriteLine("Creating a key with PasswordDeriveBytes...");
-
- // Create a PasswordDeriveBytes object and then create
- // a TripleDES key from the password and salt.
- PasswordDeriveBytes^ passwordDeriveBytes = gcnew PasswordDeriveBytes
- (password->ToString(), randomSalt);
-
- //
- // Create the key and set it to the Key property
- // of the TripleDESCryptoServiceProvider object.
- // This example uses the SHA1 algorithm.
- // Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
- cryptoDESProvider->Key = passwordDeriveBytes->CryptDeriveKey
- ("TripleDES", "SHA1", 192, cryptoDESProvider->IV);
- //
- Console::WriteLine("Operation complete.");
- }
- catch (Exception^ ex)
- {
- Console::WriteLine(ex->Message);
- }
- finally
- {
- // Clear the buffers
- ClearBytes(password);
- ClearBytes(randomSalt);
-
- // Clear the key.
- cryptoDESProvider->Clear();
- }
-
- Console::ReadLine();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp
deleted file mode 100644
index c6753a5be6f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-
-void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv);
-String^ DecryptTextFromFile(String^ path, array^ key, array^ iv);
-
-int main()
-{
- try
- {
- array^ key;
- array^ iv;
-
- // Create a new RC2 object to generate a random key
- // and initialization vector (IV).
- {
- RC2^ rc2;
-
- try
- {
- rc2 = RC2::Create();
- key = rc2->Key;
- iv = rc2->IV;
- }
- finally
- {
- delete rc2;
- }
- }
-
- // Create a string to encrypt.
- String^ original = "Here is some data to encrypt.";
- // The name/path of the file to write.
- String^ filename = "CText.enc";
-
- // Encrypt the string to a file.
- EncryptTextToFile(original, filename, key, iv);
-
- // Decrypt the file back to a string.
- String^ decrypted = DecryptTextFromFile(filename, key, iv);
-
- // Display the decrypted string to the console.
- Console::WriteLine(decrypted);
- }
- catch (Exception^ e)
- {
- Console::WriteLine(e->Message);
- }
-}
-
-void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv)
-{
- FileStream^ fStream = nullptr;
- RC2^ rc2 = nullptr;
- ICryptoTransform^ encryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create or open the specified file.
- fStream = File::Open(path, FileMode::Create);
- // Create a new RC2 object.
- rc2 = RC2::Create();
- // Create an RC2 encryptor from the key and IV
- encryptor = rc2->CreateEncryptor(key, iv);
- // Create a CryptoStream using the FileStream and encryptor
- cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write);
-
- // Convert the provided string to a byte array.
- array^ toEncrypt = Encoding::UTF8->GetBytes(text);
-
- // Write the byte array to the crypto stream.
- cStream->Write(toEncrypt, 0, toEncrypt->Length);
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (encryptor != nullptr)
- delete encryptor;
-
- if (rc2 != nullptr)
- delete rc2;
-
- if (fStream != nullptr)
- delete fStream;
- }
-}
-
-String^ DecryptTextFromFile(String^ path, array^ key, array^ iv)
-{
- FileStream^ fStream = nullptr;
- RC2^ rc2 = nullptr;
- ICryptoTransform^ decryptor = nullptr;
- CryptoStream^ cStream = nullptr;
- StreamReader^ reader = nullptr;
-
- try
- {
- // Open the specified file
- fStream = File::OpenRead(path);
- // Create a new RC2 object.
- rc2 = RC2::Create();
- // Create an RC2 decryptor from the key and IV
- decryptor = rc2->CreateDecryptor(key, iv);
- // Create a CryptoStream using the FileStream and decryptor
- cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read);
- // Create a StreamReader to turn the bytes back into text
- reader = gcnew StreamReader(cStream, Encoding::UTF8);
-
- // Read back all of the text from the StreamReader, which receives
- // the decrypted bytes from the CryptoStream, which receives the
- // encrypted bytes from the FileStream.
- return reader->ReadToEnd();
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (decryptor != nullptr)
- delete decryptor;
-
- if (rc2 != nullptr)
- delete rc2;
-
- if (fStream != nullptr)
- delete fStream;
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp
deleted file mode 100644
index 3179ea1bfc1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-using namespace System::IO;
-
-array^ EncryptTextToMemory(String^ text, array^ key, array^ iv);
-String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv);
-
-int main()
-{
- try
- {
- array^ key;
- array^ iv;
-
- // Create a new RC2 object to generate a random key
- // and initialization vector (IV).
- {
- RC2^ rc2;
-
- try
- {
- rc2 = RC2::Create();
- key = rc2->Key;
- iv = rc2->IV;
- }
- finally
- {
- delete rc2;
- }
- }
-
- // Create a string to encrypt.
- String^ original = "Here is some data to encrypt.";
-
- // Encrypt the string to an in-memory buffer.
- array^ encrypted = EncryptTextToMemory(original, key, iv);
-
- // Decrypt the buffer back to a string.
- String^ decrypted = DecryptTextFromMemory(encrypted, key, iv);
-
- // Display the decrypted string to the console.
- Console::WriteLine(decrypted);
- }
- catch (Exception^ e)
- {
- Console::WriteLine(e->Message);
- }
-}
-
-array^ EncryptTextToMemory(String^ text, array^ key, array^ iv)
-{
- MemoryStream^ mStream = nullptr;
-
- try
- {
- // Create a MemoryStream.
- mStream = gcnew MemoryStream;
-
- RC2^ rc2 = nullptr;
- ICryptoTransform^ encryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create a new RC2 object.
- rc2 = RC2::Create();
- // Create an RC2 encryptor from the key and IV
- encryptor = rc2->CreateEncryptor(key, iv);
- // Create a CryptoStream using the MemoryStream and encryptor
- cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write);
-
- // Convert the provided string to a byte array.
- array^ toEncrypt = Encoding::UTF8->GetBytes(text);
-
- // Write the byte array to the crypto stream.
- cStream->Write(toEncrypt, 0, toEncrypt->Length);
-
- // Disposing the CryptoStream completes the encryption and flushes the stream.
- delete cStream;
-
- // Get an array of bytes from the MemoryStream that holds the encrypted data.
- array^ ret = mStream->ToArray();
-
- // Return the encrypted buffer.
- return ret;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (encryptor != nullptr)
- delete encryptor;
-
- if (rc2 != nullptr)
- delete rc2;
- }
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (mStream != nullptr)
- delete mStream;
- }
-}
-
-String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv)
-{
- MemoryStream^ mStream = nullptr;
- RC2^ rc2 = nullptr;
- ICryptoTransform^ decryptor = nullptr;
- CryptoStream^ cStream = nullptr;
-
- try
- {
- // Create buffer to hold the decrypted data.
- // RC2-encrypted data will always be slightly bigger than the decrypted data.
- array^ decrypted = gcnew array(encrypted->Length);
- Int32 offset = 0;
-
- // Create a new MemoryStream using the provided array of encrypted data.
- mStream = gcnew MemoryStream(encrypted);
- // Create a new RC2 object.
- rc2 = RC2::Create();
- // Create an RC2 decryptor from the key and IV
- decryptor = rc2->CreateDecryptor(key, iv);
- // Create a CryptoStream using the MemoryStream and decryptor
- cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read);
-
- // Keep reading from the CryptoStream until it finishes (returns 0).
- Int32 read = 1;
-
- while (read > 0)
- {
- read = cStream->Read(decrypted, offset, decrypted->Length - offset);
- offset += read;
- }
-
- // Convert the buffer into a string and return it.
- return Encoding::UTF8->GetString(decrypted, 0, offset);
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("A Cryptographic error occurred: {0}", e->Message);
- throw;
- }
- finally
- {
- if (cStream != nullptr)
- delete cStream;
-
- if (decryptor != nullptr)
- delete decryptor;
-
- if (rc2 != nullptr)
- delete rc2;
-
- if (mStream != nullptr)
- delete mStream;
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp
deleted file mode 100644
index 2c8834fcc20..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-
-int main()
-{
- array ^ originalBytes =
- ASCIIEncoding::ASCII->GetBytes("Here is some data.");
-
- //Create a new RC2CryptoServiceProvider.
- RC2CryptoServiceProvider^ rc2Provider =
- gcnew RC2CryptoServiceProvider();
- rc2Provider->UseSalt = true;
-
- rc2Provider->GenerateKey();
- rc2Provider->GenerateIV();
-
- //Encrypt the data.
- MemoryStream^ encryptionMemoryStream = gcnew MemoryStream();
- CryptoStream^ encryptionCryptoStream = gcnew CryptoStream(
- encryptionMemoryStream, rc2Provider->CreateEncryptor(
- rc2Provider->Key, rc2Provider->IV), CryptoStreamMode::Write);
-
- //Write all data to the crypto stream and flush it.
- encryptionCryptoStream->Write(originalBytes, 0, originalBytes->Length);
- encryptionCryptoStream->FlushFinalBlock();
-
- //Get encrypted array of bytes.
- array^ encryptedBytes = encryptionMemoryStream->ToArray();
-
- //Decrypt the previously encrypted message.
- MemoryStream^ decryptionMemoryStream =
- gcnew MemoryStream(encryptedBytes);
- CryptoStream^ decryptionCryptoStream =
- gcnew CryptoStream(decryptionMemoryStream,
- rc2Provider->CreateDecryptor(rc2Provider->Key,rc2Provider->IV),
- CryptoStreamMode::Read);
-
- array^ unencryptedBytes =
- gcnew array(originalBytes->Length);
-
- //Read the data out of the crypto stream.
- decryptionCryptoStream->Read(unencryptedBytes, 0,
- unencryptedBytes->Length);
-
- //Convert the byte array back into a string.
- String^ plainText = ASCIIEncoding::ASCII->GetString(unencryptedBytes);
-
- //Display the results.
- Console::WriteLine("Unencrypted text: {0}", plainText);
-
- Console::ReadLine();
-}
-
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp
deleted file mode 100644
index 97053716b78..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-int main()
-{
- try
- {
-
- //Create a UnicodeEncoder to convert between byte array and string.
- ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding;
- String^ dataString = "Data to Encrypt";
-
- //Create byte arrays to hold original, encrypted, and decrypted data.
- array^dataToEncrypt = ByteConverter->GetBytes( dataString );
- array^encryptedData;
- array^decryptedData;
-
- //Create a new instance of the RSACryptoServiceProvider class
- // and automatically create a new key-pair.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
-
- //Display the origianl data to the console.
- Console::WriteLine( "Original Data: {0}", dataString );
-
- //Encrypt the byte array and specify no OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- encryptedData = RSAalg->Encrypt( dataToEncrypt, false );
-
- //Display the encrypted data to the console.
- Console::WriteLine( "Encrypted Data: {0}", ByteConverter->GetString( encryptedData ) );
-
- //Pass the data to ENCRYPT and boolean flag specifying
- //no OAEP padding.
- decryptedData = RSAalg->Decrypt( encryptedData, false );
-
- //Display the decrypted plaintext to the console.
- Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) );
- }
- catch ( CryptographicException^ e )
- {
-
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp
deleted file mode 100644
index aac2730c2f0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-void RSAPersistKeyInCSP( String^ ContainerName )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider to generate
- //a new key pair. Pass the CspParameters class to persist the
- //key in the container. The PersistKeyInCsp property is true by
- //default, allowing the key to be persisted.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Indicate that the key was persisted.
- Console::WriteLine( "The RSA key was persisted in the container, \"{0}\".", ContainerName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-void RSADeleteKeyInCSP( String^ ContainerName )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider.
- //Pass the CspParameters class to use the
- //key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Explicitly set the PersistKeyInCsp property to false
- //to delete the key entry in the container.
- RSAalg->PersistKeyInCsp = false;
-
- //Call Clear to release resources and delete the key from the container.
- RSAalg->Clear();
-
- //Indicate that the key was persisted.
- Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-int main()
-{
- String^ KeyContainerName = "MyKeyContainer";
-
- //Create a new key and persist it in
- //the key container.
- RSAPersistKeyInCSP( KeyContainerName );
-
- //Delete the key from the key container.
- RSADeleteKeyInCSP( KeyContainerName );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp
deleted file mode 100644
index cea1dc68672..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-array^ HashAndSignBytes( array^DataToSign, RSAParameters Key, int Index, int Length )
-{
- try
- {
-
- // Create a new instance of RSACryptoServiceProvider using the
- // key from RSAParameters.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
- RSAalg->ImportParameters( Key );
-
- // Hash and sign the data. Pass a new instance of SHA256
- // to specify the hashing algorithm.
- return RSAalg->SignData( DataToSign, Index, Length, SHA256::Create() );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key )
-{
- try
- {
-
- // Create a new instance of RSACryptoServiceProvider using the
- // key from RSAParameters.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
- RSAalg->ImportParameters( Key );
-
- // Verify the data using the signature. Pass a new instance of SHA256
- // to specify the hashing algorithm.
- return RSAalg->VerifyData( DataToVerify, SHA256::Create(), SignedData );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return false;
- }
-
-}
-
-int main()
-{
- try
- {
-
- // Create a UnicodeEncoder to convert between byte array and string.
- ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding;
- String^ dataString = "Data to Sign";
-
- // Create byte arrays to hold original, encrypted, and decrypted data.
- array^originalData = ByteConverter->GetBytes( dataString );
- array^signedData;
- array^smallArray;
-
- // Create a new instance of the RSACryptoServiceProvider class
- // and automatically create a new key-pair.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
-
- // Export the key information to an RSAParameters object.
- // You must pass true to export the private key for signing.
- // However, you do not need to export the private key
- // for verification.
- RSAParameters Key = RSAalg->ExportParameters( true );
-
- // Hash and sign the data. Start at the fifth offset
- // only use data from the next 7 bytes.
- signedData = HashAndSignBytes( originalData, Key, 5, 7 );
-
- // The previous method only signed one segment
- // of the array. Create a new array for verification
- // that only holds the data that was actually signed.
- //
- // Initialize the array.
- smallArray = gcnew array(7);
-
- // Copy 7 bytes starting at the 5th index to
- // the new array.
- Array::Copy( originalData, 5, smallArray, 0, 7 );
-
- // Verify the data and display the result to the
- // console.
- if ( VerifySignedHash( smallArray, signedData, Key ) )
- {
- Console::WriteLine( "The data was verified." );
- }
- else
- {
- Console::WriteLine( "The data does not match the signature." );
- }
- }
- catch ( ArgumentNullException^ )
- {
- Console::WriteLine( "The data was not signed or verified" );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp
deleted file mode 100644
index aa2a389c449..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-array^ HashAndSignBytes( array^DataToSign, RSAParameters Key )
-{
- try
- {
-
- // Create a new instance of RSACryptoServiceProvider using the
- // key from RSAParameters.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
- RSAalg->ImportParameters( Key );
-
- // Hash and sign the data. Pass a new instance of SHA256
- // to specify the hashing algorithm.
- return RSAalg->SignData( DataToSign, SHA256::Create() );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key )
-{
- try
- {
-
- // Create a new instance of RSACryptoServiceProvider using the
- // key from RSAParameters.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
- RSAalg->ImportParameters( Key );
-
- // Verify the data using the signature. Pass a new instance of SHA256
- // to specify the hashing algorithm.
- return RSAalg->VerifyData( DataToVerify, SHA256::Create(), SignedData );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return false;
- }
-
-}
-
-int main()
-{
- try
- {
-
- // Create a UnicodeEncoder to convert between byte array and string.
- ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding;
- String^ dataString = "Data to Sign";
-
- // Create byte arrays to hold original, encrypted, and decrypted data.
- array^originalData = ByteConverter->GetBytes( dataString );
- array^signedData;
-
- // Create a new instance of the RSACryptoServiceProvider class
- // and automatically create a new key-pair.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
-
- // Export the key information to an RSAParameters object.
- // You must pass true to export the private key for signing.
- // However, you do not need to export the private key
- // for verification.
- RSAParameters Key = RSAalg->ExportParameters( true );
-
- // Hash and sign the data.
- signedData = HashAndSignBytes( originalData, Key );
-
- // Verify the data and display the result to the
- // console.
- if ( VerifySignedHash( originalData, signedData, Key ) )
- {
- Console::WriteLine( "The data was verified." );
- }
- else
- {
- Console::WriteLine( "The data does not match the signature." );
- }
- }
- catch ( ArgumentNullException^ )
- {
- Console::WriteLine( "The data was not signed or verified" );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp
deleted file mode 100644
index ac322898229..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-using namespace System::IO;
-array^ HashAndSignBytes( Stream^ DataStream, RSAParameters Key )
-{
- try
- {
-
- // Reset the current position in the stream to
- // the beginning of the stream (0). RSACryptoServiceProvider
- // can't verify the data unless the stream position
- // is set to the starting position of the data.
- DataStream->Position = 0;
-
- // Create a new instance of RSACryptoServiceProvider using the
- // key from RSAParameters.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
- RSAalg->ImportParameters( Key );
-
- // Hash and sign the data. Pass a new instance of SHA256
- // to specify the hashing algorithm.
- return RSAalg->SignData( DataStream, SHA256::Create() );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key )
-{
- try
- {
-
- // Create a new instance of RSACryptoServiceProvider using the
- // key from RSAParameters.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
- RSAalg->ImportParameters( Key );
-
- // Verify the data using the signature. Pass a new instance of SHA256
- // to specify the hashing algorithm.
- return RSAalg->VerifyData( DataToVerify, SHA256(), SignedData );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return false;
- }
-
-}
-
-int main()
-{
- try
- {
- ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding;
-
- // Create some bytes to be signed.
- array^dataBytes = ByteConverter->GetBytes( "Here is some data to sign!" );
-
- // Create a buffer for the memory stream.
- array^buffer = gcnew array(dataBytes->Length);
-
- // Create a MemoryStream.
- MemoryStream^ mStream = gcnew MemoryStream( buffer );
-
- // Write the bytes to the stream and flush it.
- mStream->Write( dataBytes, 0, dataBytes->Length );
- mStream->Flush();
-
- // Create a new instance of the RSACryptoServiceProvider class
- // and automatically create a new key-pair.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
-
- // Export the key information to an RSAParameters object.
- // You must pass true to export the private key for signing.
- // However, you do not need to export the private key
- // for verification.
- RSAParameters Key = RSAalg->ExportParameters( true );
-
- // Hash and sign the data.
- array^signedData = HashAndSignBytes( mStream, Key );
-
- // Verify the data and display the result to the
- // console.
- if ( VerifySignedHash( dataBytes, signedData, Key ) )
- {
- Console::WriteLine( "The data was verified." );
- }
- else
- {
- Console::WriteLine( "The data does not match the signature." );
- }
-
- // Close the MemoryStream.
- mStream->Close();
- }
- catch ( ArgumentNullException^ )
- {
- Console::WriteLine( "The data was not signed or verified" );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp
deleted file mode 100644
index 68adc843467..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-
-ref class RSAKeyStoreSample
-{
-public:
- static void Main()
- {
- // Set the static UseMachineKeyStore property to use the machine key
- // store instead of the user profile key store. All CSP instances not
- // initialized with CspParameters will use this setting.
- RSACryptoServiceProvider::UseMachineKeyStore = true;
- try
- {
- RSACryptoServiceProvider^ RSAalg;
-
- // This CSP instance will use the Machine Store as set above and is
- // initialized with no parameters.
- RSAalg = gcnew RSACryptoServiceProvider();
- ShowContainerInfo(RSAalg->CspKeyContainerInfo);
- RSAalg->PersistKeyInCsp = false;
- delete RSAalg;
-
- CspParameters^ cspParams = gcnew CspParameters();
-
- cspParams->KeyContainerName = "MyKeyContainer";
-
- // This CSP instance will use the User Store since cspParams are used.
- RSAalg = gcnew RSACryptoServiceProvider(cspParams);
- ShowContainerInfo(RSAalg->CspKeyContainerInfo);
- RSAalg->PersistKeyInCsp = false;
- delete RSAalg;
-
- cspParams->Flags |= CspProviderFlags::UseMachineKeyStore;
-
- // This CSP instance will use the Machine Store. Although cspParams are used,
- // the cspParams.Flags is set to CspProviderFlags.UseMachineKeyStore.
- RSAalg = gcnew RSACryptoServiceProvider(cspParams);
- ShowContainerInfo(RSAalg->CspKeyContainerInfo);
- RSAalg->PersistKeyInCsp = false;
- delete RSAalg;
- }
- catch (CryptographicException^ e)
- {
- Console::WriteLine("Exception: {0}", e->GetType()->FullName);
- Console::WriteLine(e->Message);
- }
- }
-
- static void ShowContainerInfo(CspKeyContainerInfo^ containerInfo)
- {
- String^ keyStore;
-
- Console::WriteLine();
- if (containerInfo->MachineKeyStore)
- {
- keyStore = "Machine Store";
- }
- else
- {
- keyStore = "User Store";
- }
- Console::WriteLine("Key Store: {0}", keyStore);
- Console::WriteLine("Key Provider: {0}", containerInfo->ProviderName);
- Console::WriteLine("Key Container: \"{0}\"", containerInfo->KeyContainerName);
- Console::WriteLine("Generated: {0}", containerInfo->RandomlyGenerated);
- Console::WriteLine("Key Nubmer: {0}", containerInfo->KeyNumber);
- Console::WriteLine("Removable Key: {0}", containerInfo->Removable);
- }
-};
-
-int main()
-{
- RSAKeyStoreSample::Main();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp
deleted file mode 100644
index b99a174d918..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-void RSAPersistKeyInCSP( String^ ContainerName )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider to generate
- //a new key pair. Pass the CspParameters class to persist the
- //key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Indicate that the key was persisted.
- Console::WriteLine( "The RSA key was persisted in the container, \"{0}\".", ContainerName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-void RSADeleteKeyInCSP( String^ ContainerName )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider.
- //Pass the CspParameters class to use the
- //key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Delete the key entry in the container.
- RSAalg->PersistKeyInCsp = false;
-
- //Call Clear to release resources and delete the key from the container.
- RSAalg->Clear();
-
- //Indicate that the key was persisted.
- Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-array^ RSAEncrypt( array^DataToEncrypt, String^ ContainerName, bool DoOAEPPadding )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider.
- //Pass the CspParameters class to use the key
- //from the key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Encrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding );
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-array^ RSADecrypt( array^DataToDecrypt, String^ ContainerName, bool DoOAEPPadding )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider.
- //Pass the CspParameters class to use the key
- //from the key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Decrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding );
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e );
- return nullptr;
- }
-
-}
-
-int main()
-{
- try
- {
- String^ KeyContainerName = "MyKeyContainer";
-
- //Create a new key and persist it in
- //the key container.
- RSAPersistKeyInCSP( KeyContainerName );
-
- //Create a UnicodeEncoder to convert between byte array and string.
- UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding;
-
- //Create byte arrays to hold original, encrypted, and decrypted data.
- array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" );
- array^encryptedData;
- array^decryptedData;
-
- //Pass the data to ENCRYPT, the name of the key container,
- //and a boolean flag specifying no OAEP padding.
- encryptedData = RSAEncrypt( dataToEncrypt, KeyContainerName, false );
-
- //Pass the data to DECRYPT, the name of the key container,
- //and a boolean flag specifying no OAEP padding.
- decryptedData = RSADecrypt( encryptedData, KeyContainerName, false );
-
- //Display the decrypted plaintext to the console.
- Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) );
- RSADeleteKeyInCSP( KeyContainerName );
- }
- catch ( ArgumentNullException^ )
- {
-
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( "Encryption failed." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp
deleted file mode 100644
index 19f120af03a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-array^ RSAEncrypt( array^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding )
-{
- try
- {
-
- //Create a new instance of RSACryptoServiceProvider.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
-
- //Import the RSA Key information. This only needs
- //toinclude the public key information.
- RSAalg->ImportParameters( RSAKeyInfo );
-
- //Encrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding );
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-array^ RSADecrypt( array^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding )
-{
- try
- {
-
- //Create a new instance of RSACryptoServiceProvider.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider;
-
- //Import the RSA Key information. This needs
- //to include the private key information.
- RSAalg->ImportParameters( RSAKeyInfo );
-
- //Decrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding );
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e );
- return nullptr;
- }
-
-}
-
-int main()
-{
- try
- {
-
- //Create a UnicodeEncoder to convert between byte array and string.
- UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding;
-
- //Create byte arrays to hold original, encrypted, and decrypted data.
- array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" );
- array^encryptedData;
- array^decryptedData;
-
- //Create a new instance of RSACryptoServiceProvider to generate
- //public and private key data. Pass an integer specifying a key-
- //length of 2048.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( 2048 );
-
- //Display the key-legth to the console.
- Console::WriteLine( "A new key pair of legth {0} was created", RSAalg->KeySize );
-
- //Pass the data to ENCRYPT, the public key information
- //(using RSACryptoServiceProvider.ExportParameters(false),
- //and a boolean flag specifying no OAEP padding.
- encryptedData = RSAEncrypt( dataToEncrypt, RSAalg->ExportParameters( false ), false );
-
- //Pass the data to DECRYPT, the private key information
- //(using RSACryptoServiceProvider.ExportParameters(true),
- //and a boolean flag specifying no OAEP padding.
- decryptedData = RSADecrypt( encryptedData, RSAalg->ExportParameters( true ), false );
-
- //Display the decrypted plaintext to the console.
- Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) );
- }
- catch ( ArgumentNullException^ )
- {
-
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( "Encryption failed." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp
deleted file mode 100644
index f1f072b4665..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-void RSAPersistKeyInCSP( String^ ContainerName )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of RSACryptoServiceProvider to generate
- //a new key pair. Pass the CspParameters class to persist the
- //key in the container. Pass an intger of 2048 to specify the
- //key-size.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( 2048,cspParams );
-
- //Indicate that the key was persisted.
- Console::WriteLine( "The RSA key with a key-size of {0} was persisted in the container, \"{1}\".", RSAalg->KeySize, ContainerName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-void RSADeleteKeyInCSP( String^ ContainerName )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of DSACryptoServiceProvider.
- //Pass the CspParameters class to use the
- //key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Delete the key entry in the container.
- RSAalg->PersistKeyInCsp = false;
-
- //Call Clear to release resources and delete the key from the container.
- RSAalg->Clear();
-
- //Indicate that the key was persisted.
- Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-array^ RSAEncrypt( array^DataToEncrypt, String^ ContainerName, bool DoOAEPPadding )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of DSACryptoServiceProvider.
- //Pass the CspParameters class to use the key
- //from the key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Encrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding );
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-array^ RSADecrypt( array^DataToDecrypt, String^ ContainerName, bool DoOAEPPadding )
-{
- try
- {
-
- // Create a new instance of CspParameters. Pass
- // 13 to specify a DSA container or 1 to specify
- // an RSA container. The default is 1.
- CspParameters^ cspParams = gcnew CspParameters;
-
- // Specify the container name using the passed variable.
- cspParams->KeyContainerName = ContainerName;
-
- //Create a new instance of DSACryptoServiceProvider.
- //Pass the CspParameters class to use the key
- //from the key in the container.
- RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams );
-
- //Decrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
- return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding );
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e );
- return nullptr;
- }
-
-}
-
-int main()
-{
- try
- {
- String^ KeyContainerName = "MyKeyContainer";
-
- //Create a new key and persist it in
- //the key container.
- RSAPersistKeyInCSP( KeyContainerName );
-
- //Create a UnicodeEncoder to convert between byte array and string.
- UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding;
-
- //Create byte arrays to hold original, encrypted, and decrypted data.
- array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" );
- array^encryptedData;
- array^decryptedData;
-
- //Pass the data to ENCRYPT, the name of the key container,
- //and a boolean flag specifying no OAEP padding.
- encryptedData = RSAEncrypt( dataToEncrypt, KeyContainerName, false );
-
- //Pass the data to DECRYPT, the name of the key container,
- //and a boolean flag specifying no OAEP padding.
- decryptedData = RSADecrypt( encryptedData, KeyContainerName, false );
-
- //Display the decrypted plaintext to the console.
- Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) );
- RSADeleteKeyInCSP( KeyContainerName );
- }
- catch ( ArgumentNullException^ )
- {
-
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( "Encryption failed." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp
deleted file mode 100644
index 87f5955ad65..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-int main()
-{
- RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider;
- try
- {
-
- // Note: In cases where a random key is generated,
- // a key container is not created until you call
- // a method that uses the key. This example calls
- // the Encrypt method before calling the
- // CspKeyContainerInfo property so that a key
- // container is created.
- // Create some data to encrypt and display it.
- String^ data = L"Here is some data to encrypt.";
- Console::WriteLine( L"Data to encrypt: {0}", data );
-
- // Convert the data to an array of bytes and
- // encrypt it.
- array^byteData = Encoding::ASCII->GetBytes( data );
- array^encData = rsa->Encrypt( byteData, false );
-
- // Display the encrypted value.
- Console::WriteLine( L"Encrypted Data: {0}", Encoding::ASCII->GetString( encData ) );
- Console::WriteLine();
- Console::WriteLine( L"CspKeyContainerInfo information:" );
- Console::WriteLine();
-
- // Create a new CspKeyContainerInfo object.
- CspKeyContainerInfo^ keyInfo = rsa->CspKeyContainerInfo;
-
- // Display the value of each property.
- Console::WriteLine( L"Accessible property: {0}", keyInfo->Accessible );
- Console::WriteLine( L"Exportable property: {0}", keyInfo->Exportable );
- Console::WriteLine( L"HardwareDevice property: {0}", keyInfo->HardwareDevice );
- Console::WriteLine( L"KeyContainerName property: {0}", keyInfo->KeyContainerName );
- Console::WriteLine( L"KeyNumber property: {0}", keyInfo->KeyNumber );
- Console::WriteLine( L"MachineKeyStore property: {0}", keyInfo->MachineKeyStore );
- Console::WriteLine( L"Protected property: {0}", keyInfo->Protected );
- Console::WriteLine( L"ProviderName property: {0}", keyInfo->ProviderName );
- Console::WriteLine( L"ProviderType property: {0}", keyInfo->ProviderType );
- Console::WriteLine( L"RandomlyGenerated property: {0}", keyInfo->RandomlyGenerated );
- Console::WriteLine( L"Removable property: {0}", keyInfo->Removable );
- Console::WriteLine( L"UniqueKeyContainerName property: {0}", keyInfo->UniqueKeyContainerName );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e );
- }
- finally
- {
-
- // Clear the key.
- rsa->Clear();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp
deleted file mode 100644
index ab2873ba3a4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-int main()
-{
-
- // To idendify the Smart Card CryptoGraphic Providers on your
- // computer, use the Microsoft Registry Editor (Regedit.exe).
- // The available Smart Card CryptoGraphic Providers are listed
- // in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider.
- // Create a new CspParameters object that identifies a
- // Smart Card CryptoGraphic Provider.
- // The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types.
- // The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider.
- CspParameters^ csp = gcnew CspParameters( 1,L"Schlumberger Cryptographic Service Provider" );
- csp->Flags = CspProviderFlags::UseDefaultKeyContainer;
-
- // Initialize an RSACryptoServiceProvider object using
- // the CspParameters object.
- RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( csp );
-
- // Create some data to sign.
- array^data = gcnew array{
- 0,1,2,3,4,5,6,7
- };
- Console::WriteLine( L"Data : {0}", BitConverter::ToString( data ) );
-
- // Sign the data using the Smart Card CryptoGraphic Provider.
- array^sig = rsa->SignData( data, L"SHA256" );
- Console::WriteLine( L"Signature : {0}", BitConverter::ToString( sig ) );
-
- // Verify the data using the Smart Card CryptoGraphic Provider.
- bool verified = rsa->VerifyData( data, L"SHA256", sig );
- Console::WriteLine( L"Verified : {0}", verified );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp
deleted file mode 100644
index 99639f7a588..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = L"test.pfx";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = gcnew X509Certificate( Certificate );
- array^certData = cert->Export( X509ContentType::Cert );
- X509Certificate^ newCert = gcnew X509Certificate( certData );
-
- // Get the value.
- String^ resultsTrue = newCert->ToString( true );
-
- // Display the value to the console.
- Console::WriteLine( resultsTrue );
-
- // Get the value.
- String^ resultsFalse = newCert->ToString( false );
-
- // Display the value to the console.
- Console::WriteLine( resultsFalse );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp
deleted file mode 100644
index c67a8cb4a04..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = L"Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = gcnew X509Certificate;
- cert->Import(Certificate);
-
- // Get the value.
- String^ resultsTrue = cert->ToString( true );
-
- // Display the value to the console.
- Console::WriteLine( resultsTrue );
-
- // Get the value.
- String^ resultsFalse = cert->ToString( false );
-
- // Display the value to the console.
- Console::WriteLine( resultsFalse );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp
deleted file mode 100644
index d2dab6fe3be..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = L"Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = gcnew X509Certificate( Certificate );
-
- // Get the value.
- String^ resultsTrue = cert->ToString( true );
-
- // Display the value to the console.
- Console::WriteLine( resultsTrue );
-
- // Get the value.
- String^ resultsFalse = cert->ToString( false );
-
- // Display the value to the console.
- Console::WriteLine( resultsFalse );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp
deleted file mode 100644
index 574abf906a3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
- try
- {
- X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser );
- store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) );
- X509Certificate2Collection^ collection = dynamic_cast(store->Certificates);
- for ( int i = 0; i < collection->Count; i++ )
- {
- System::Collections::IEnumerator^ myEnum = collection[ i ]->Extensions->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- X509Extension^ extension = safe_cast(myEnum->Current);
- Console::WriteLine( L"{0}({1})", extension->Oid->FriendlyName, extension->Oid->Value );
- if ( extension->Oid->FriendlyName == L"Key Usage" )
- {
- X509KeyUsageExtension^ ext = dynamic_cast(extension);
- Console::WriteLine( ext->KeyUsages );
- }
- if ( extension->Oid->FriendlyName == L"Basic Constraints" )
- {
- X509BasicConstraintsExtension^ ext = dynamic_cast(extension);
- Console::WriteLine( ext->CertificateAuthority );
- Console::WriteLine( ext->HasPathLengthConstraint );
- Console::WriteLine( ext->PathLengthConstraint );
- }
- if ( extension->Oid->FriendlyName == L"Subject Key Identifier" )
- {
- X509SubjectKeyIdentifierExtension^ ext = dynamic_cast(extension);
- Console::WriteLine( ext->SubjectKeyIdentifier );
- }
- if ( extension->Oid->FriendlyName == L"Enhanced Key Usage" )
- {
- X509EnhancedKeyUsageExtension^ ext = dynamic_cast(extension);
- OidCollection^ oids = ext->EnhancedKeyUsages;
- System::Collections::IEnumerator^ myEnum1 = oids->GetEnumerator();
- while ( myEnum1->MoveNext() )
- {
- Oid^ oid = safe_cast(myEnum1->Current);
- Console::WriteLine( L"{0}({1})", oid->FriendlyName, oid->Value );
- }
- }
- }
-
- }
- store->Close();
- }
- catch ( CryptographicException^ )
- {
- Console::WriteLine( L"Information could not be written out for this certificate." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp
deleted file mode 100644
index c7f4f074317..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-
-ref class TrippleDESDocumentEncryption
-{
-protected:
- XmlDocument^ docValue;
- TripleDES^ algValue;
-
-public:
- TrippleDESDocumentEncryption( XmlDocument^ Doc, TripleDES^ Key )
- {
- if ( Doc != nullptr )
- {
- docValue = Doc;
- }
- else
- {
- throw gcnew ArgumentNullException( L"Doc" );
- }
-
- if ( Key != nullptr )
- {
- algValue = Key;
- }
- else
- {
- throw gcnew ArgumentNullException( L"Key" );
- }
- }
-
-
- property XmlDocument^ Doc
- {
- XmlDocument^ get()
- {
- return docValue;
- }
-
- void set( XmlDocument^ value )
- {
- docValue = value;
- }
-
- }
-
- property TripleDES^ Alg
- {
- TripleDES^ get()
- {
- return algValue;
- }
-
- void set( TripleDES^ value )
- {
- algValue = value;
- }
-
- }
- void Clear()
- {
- if ( algValue != nullptr )
- {
- algValue->Clear();
- }
- else
- {
- throw gcnew Exception( L"No TripleDES key was found to clear." );
- }
- }
-
- void Encrypt( String^ Element )
- {
-
- // Find the element by name and create a new
- // XmlElement object.
- XmlElement^ inputElement = dynamic_cast(docValue->GetElementsByTagName( Element )->Item( 0 ));
-
- // If the element was not found, throw an exception.
- if ( inputElement == nullptr )
- {
- throw gcnew Exception( L"The element was not found." );
- }
-
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml( docValue );
-
- // Encrypt the element using the symmetric key.
- array^rgbOutput = exml->EncryptData( inputElement, algValue, false );
-
- // Create an EncryptedData object and populate it.
- EncryptedData^ ed = gcnew EncryptedData;
-
- // Specify the namespace URI for XML encryption elements.
- ed->Type = EncryptedXml::XmlEncElementUrl;
-
- // Specify the namespace URI for the TrippleDES algorithm.
- ed->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncTripleDESUrl );
-
- // Create a CipherData element.
- ed->CipherData = gcnew CipherData;
-
- // Set the CipherData element to the value of the encrypted XML element.
- ed->CipherData->CipherValue = rgbOutput;
-
- // Replace the plaintext XML elemnt with an EncryptedData element.
- EncryptedXml::ReplaceElement( inputElement, ed, false );
- }
-
- void Decrypt()
- {
-
- // XmlElement object.
- XmlElement^ encryptedElement = dynamic_cast(docValue->GetElementsByTagName( L"EncryptedData" )->Item( 0 ));
-
- // If the EncryptedData element was not found, throw an exception.
- if ( encryptedElement == nullptr )
- {
- throw gcnew Exception( L"The EncryptedData element was not found." );
- }
-
-
- // Create an EncryptedData object and populate it.
- EncryptedData^ ed = gcnew EncryptedData;
- ed->LoadXml( encryptedElement );
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml;
-
- // Decrypt the element using the symmetric key.
- array^rgbOutput = exml->DecryptData( ed, algValue );
-
- // Replace the encryptedData element with the plaintext XML elemnt.
- exml->ReplaceData( encryptedElement, rgbOutput );
- }
-
-};
-
-int main()
-{
-
- // Create an XmlDocument object.
- XmlDocument^ xmlDoc = gcnew XmlDocument;
-
- // Load an XML file into the XmlDocument object.
- try
- {
- xmlDoc->PreserveWhitespace = true;
- xmlDoc->Load( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- return 0;
- }
-
-
- // Create a new TripleDES key.
- TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider;
-
- // Create a new instance of the TrippleDESDocumentEncryption object
- // defined in this sample.
- TrippleDESDocumentEncryption^ xmlTDES = gcnew TrippleDESDocumentEncryption( xmlDoc,tDESkey );
- try
- {
-
- // Encrypt the "creditcard" element.
- xmlTDES->Encrypt( L"creditcard" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine( L"Encrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlTDES->Doc->OuterXml );
-
- // Decrypt the "creditcard" element.
- xmlTDES->Decrypt();
-
- // Display the encrypted XML to the console.
- Console::WriteLine();
- Console::WriteLine( L"Decrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlTDES->Doc->OuterXml );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear the TripleDES key.
- xmlTDES->Clear();
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp
deleted file mode 100644
index c1e61870173..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file.
-static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, array^ElementsToSign )
-{
-
- // Check the arguments.
- if ( FileName == nullptr )
- throw gcnew ArgumentNullException( L"FileName" );
-
- if ( SignedFileName == nullptr )
- throw gcnew ArgumentNullException( L"SignedFileName" );
-
- if ( Key == nullptr )
- throw gcnew ArgumentNullException( L"Key" );
-
- if ( ElementsToSign == nullptr )
- throw gcnew ArgumentNullException( L"ElementsToSign" );
-
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Loop through each passed element to sign
- // and create a reference.
- System::Collections::IEnumerator^ myEnum = ElementsToSign->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- String^ s = safe_cast(myEnum->Current);
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = s;
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
- }
-
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( dynamic_cast(doc->FirstChild) )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-static Boolean VerifyXmlFile( String^ Name )
-{
-
- // Check the arguments.
- if ( Name == nullptr )
- throw gcnew ArgumentNullException( L"Name" );
-
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-int main()
-{
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- try
- {
-
- // Specify an element to sign.
- array^elements = {L"#tag1"};
-
- // Sign an XML file and save the signature to a
- // new file.
- SignXmlFile( L"Test.xml", L"SignedExample.xml", Key, elements );
- Console::WriteLine( L"XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( L"Verifying signature..." );
- bool result = VerifyXmlFile( L"SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( L"The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( L"The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear resources associated with the
- // RSA instance.
- Key->Clear();
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp
deleted file mode 100644
index cdae3dcaebf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file.
-static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key )
-{
-
- // Check the arguments.
- if ( FileName == nullptr )
- throw gcnew ArgumentNullException( L"FileName" );
-
- if ( SignedFileName == nullptr )
- throw gcnew ArgumentNullException( L"SignedFileName" );
-
- if ( Key == nullptr )
- throw gcnew ArgumentNullException( L"Key" );
-
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Get the signature object from the SignedXml object.
- Signature^ XMLSignature = signedXml->Signature;
-
- // Create a reference to be signed. Pass ""
- // to specify that all of the current XML
- // document should be signed.
- Reference^ reference = gcnew Reference( L"" );
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the Reference object to the Signature object.
- XMLSignature->SignedInfo->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) );
-
- // Add the KeyInfo object to the Reference object.
- XMLSignature->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( dynamic_cast(doc->FirstChild) )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-static Boolean VerifyXmlFile( String^ Name )
-{
-
- // Check the arguments.
- if ( Name == nullptr )
- throw gcnew ArgumentNullException( L"Name" );
-
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-int main()
-{
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- try
- {
-
- // Sign an XML file and save the signature to a
- // new file.
- SignXmlFile( L"Test.xml", L"SignedExample.xml", Key );
- Console::WriteLine( L"XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( L"Verifying signature..." );
- bool result = VerifyXmlFile( L"SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( L"The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( L"The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear resources associated with the
- // RSA instance.
- Key->Clear();
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp
deleted file mode 100644
index 97cfce97aee..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, RSA^ Alg, String^ KeyName )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( ElementToEncrypt == nullptr )
- throw gcnew ArgumentNullException( L"ElementToEncrypt" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
-
- ////////////////////////////////////////////////
- // Find the specified element in the XmlDocument
- // object and create a new XmlElemnt object.
- ////////////////////////////////////////////////
- XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 ));
-
- // Throw an XmlException if the element was not found.
- if ( elementToEncrypt == nullptr )
- {
- throw gcnew XmlException( L"The specified element was not found" );
- }
-
-
- //////////////////////////////////////////////////
- // Create a new instance of the EncryptedXml class
- // and use it to encrypt the XmlElement with the
- // a new random symmetric key.
- //////////////////////////////////////////////////
- // Create a 256 bit Aes key.
- Aes^ sessionKey = Aes::Create();
- sessionKey->KeySize = 256;
- EncryptedXml^ eXml = gcnew EncryptedXml;
- array^encryptedElement = eXml->EncryptData( elementToEncrypt, sessionKey, false );
-
- ////////////////////////////////////////////////
- // Construct an EncryptedData object and populate
- // it with the desired encryption information.
- ////////////////////////////////////////////////
- EncryptedData^ edElement = gcnew EncryptedData;
- edElement->Type = EncryptedXml::XmlEncElementUrl;
-
- // Create an EncryptionMethod element so that the
- // receiver knows which algorithm to use for decryption.
- edElement->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncAES256Url );
-
- // Encrypt the session key and add it to an EncryptedKey element.
- EncryptedKey^ ek = gcnew EncryptedKey;
- array^encryptedKey = EncryptedXml::EncryptKey( sessionKey->Key, Alg, false );
- ek->CipherData = gcnew CipherData( encryptedKey );
- ek->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncRSA15Url );
-
- // Set the KeyInfo element to specify the
- // name of the RSA key.
- // Create a new KeyInfo element.
- edElement->KeyInfo = gcnew KeyInfo;
-
- // Create a new KeyInfoName element.
- KeyInfoName^ kin = gcnew KeyInfoName;
-
- // Specify a name for the key.
- kin->Value = KeyName;
-
- // Add the KeyInfoName element to the
- // EncryptedKey object.
- ek->KeyInfo->AddClause( kin );
-
- // Add the encrypted key to the
- // EncryptedData object.
- edElement->KeyInfo->AddClause( gcnew KeyInfoEncryptedKey( ek ) );
-
- // Add the encrypted element data to the
- // EncryptedData object.
- edElement->CipherData->CipherValue = encryptedElement;
-
- ////////////////////////////////////////////////////
- // Replace the element from the original XmlDocument
- // object with the EncryptedData element.
- ////////////////////////////////////////////////////
- EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false );
-}
-
-static void Decrypt( XmlDocument^ Doc, RSA^ Alg, String^ KeyName )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
- if ( KeyName == nullptr )
- throw gcnew ArgumentNullException( L"KeyName" );
-
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml( Doc );
-
- // Add a key-name mapping.
- // This method can only decrypt documents
- // that present the specified key name.
- exml->AddKeyNameMapping( KeyName, Alg );
-
- // Decrypt the element.
- exml->DecryptDocument();
-}
-
-int main()
-{
-
- // Create an XmlDocument object.
- XmlDocument^ xmlDoc = gcnew XmlDocument;
-
- // Load an XML file into the XmlDocument object.
- try
- {
- xmlDoc->PreserveWhitespace = true;
- xmlDoc->Load( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- return 0;
- }
-
-
- // Create a new RSA key. This key will encrypt a symmetric key,
- // which will then be imbedded in the XML document.
- RSA^ rsaKey = RSA::Create();
- try
- {
-
- // Encrypt the "creditcard" element.
- Encrypt( xmlDoc, L"creditcard", rsaKey, L"rsaKey" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine( L"Encrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
- xmlDoc->Save( L"test.xml" );
-
- // Decrypt the "creditcard" element.
- Decrypt( xmlDoc, rsaKey, L"rsaKey" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine();
- Console::WriteLine( L"Decrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
- xmlDoc->Save( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear the RSA key.
- rsaKey->Clear();
- }
-
- return 1;
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp
deleted file mode 100644
index 3856ce1b7b3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg, String^ KeyName )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( ElementToEncrypt == nullptr )
- throw gcnew ArgumentNullException( L"ElementToEncrypt" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
-
- ////////////////////////////////////////////////
- // Find the specified element in the XmlDocument
- // object and create a new XmlElemnt object.
- ////////////////////////////////////////////////
- XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 ));
-
- // Throw an XmlException if the element was not found.
- if ( elementToEncrypt == nullptr )
- {
- throw gcnew XmlException( L"The specified element was not found" );
- }
-
-
- //////////////////////////////////////////////////
- // Create a new instance of the EncryptedXml class
- // and use it to encrypt the XmlElement with the
- // symmetric key.
- //////////////////////////////////////////////////
- EncryptedXml^ eXml = gcnew EncryptedXml;
- array^encryptedElement = eXml->EncryptData( elementToEncrypt, Alg, false );
-
- ////////////////////////////////////////////////
- // Construct an EncryptedData object and populate
- // it with the desired encryption information.
- ////////////////////////////////////////////////
- EncryptedData^ edElement = gcnew EncryptedData;
- edElement->Type = EncryptedXml::XmlEncElementUrl;
-
- // Create an EncryptionMethod element so that the
- // receiver knows which algorithm to use for decryption.
- // Determine what kind of algorithm is being used and
- // supply the appropriate URL to the EncryptionMethod element.
- String^ encryptionMethod = nullptr;
- if ( dynamic_cast(Alg) )
- {
- encryptionMethod = EncryptedXml::XmlEncTripleDESUrl;
- }
- else
- if ( dynamic_cast(Alg) )
- {
- encryptionMethod = EncryptedXml::XmlEncDESUrl;
- }
- else
- if ( dynamic_cast(Alg) )
- {
- switch ( Alg->KeySize )
- {
- case 128:
- encryptionMethod = EncryptedXml::XmlEncAES128Url;
- break;
-
- case 192:
- encryptionMethod = EncryptedXml::XmlEncAES192Url;
- break;
-
- case 256:
- encryptionMethod = EncryptedXml::XmlEncAES256Url;
- break;
- }
- }
- else
- {
-
- // Throw an exception if the transform is not in the previous categories
- throw gcnew CryptographicException( L"The specified algorithm is not supported for XML Encryption." );
- }
-
-
-
- edElement->EncryptionMethod = gcnew EncryptionMethod( encryptionMethod );
-
- // Set the KeyInfo element to specify the
- // name of a key.
- // Create a new KeyInfo element.
- edElement->KeyInfo = gcnew KeyInfo;
-
- // Create a new KeyInfoName element.
- KeyInfoName^ kin = gcnew KeyInfoName;
-
- // Specify a name for the key.
- kin->Value = KeyName;
-
- // Add the KeyInfoName element.
- edElement->KeyInfo->AddClause( kin );
-
- // Add the encrypted element data to the
- // EncryptedData object.
- edElement->CipherData->CipherValue = encryptedElement;
-
- ////////////////////////////////////////////////////
- // Replace the element from the original XmlDocument
- // object with the EncryptedData element.
- ////////////////////////////////////////////////////
- EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false );
-}
-
-static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg, String^ KeyName )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
- if ( KeyName == nullptr )
- throw gcnew ArgumentNullException( L"KeyName" );
-
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml( Doc );
-
- // Add a key-name mapping.
- // This method can only decrypt documents
- // that present the specified key name.
- exml->AddKeyNameMapping( KeyName, Alg );
-
- // Decrypt the element.
- exml->DecryptDocument();
-}
-
-int main()
-{
-
- // Create an XmlDocument object.
- XmlDocument^ xmlDoc = gcnew XmlDocument;
-
- // Load an XML file into the XmlDocument object.
- try
- {
- xmlDoc->PreserveWhitespace = true;
- xmlDoc->Load( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- return 0;
- }
-
-
- // Create a new TripleDES key.
- TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider;
- try
- {
-
- // Encrypt the "creditcard" element.
- Encrypt( xmlDoc, L"creditcard", tDESkey, L"tDESKey" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine( L"Encrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
-
- // Decrypt the "creditcard" element.
- Decrypt( xmlDoc, tDESkey, L"tDESKey" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine();
- Console::WriteLine( L"Decrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear the TripleDES key.
- tDESkey->Clear();
- }
- return 1;
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp
deleted file mode 100644
index 0ed4e81288a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Security::Cryptography::X509Certificates;
-static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, X509Certificate2^ Cert )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( ElementToEncrypt == nullptr )
- throw gcnew ArgumentNullException( L"ElementToEncrypt" );
-
- if ( Cert == nullptr )
- throw gcnew ArgumentNullException( L"Cert" );
-
-
- ////////////////////////////////////////////////
- // Find the specified element in the XmlDocument
- // object and create a new XmlElemnt object.
- ////////////////////////////////////////////////
- XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 ));
-
- // Throw an XmlException if the element was not found.
- if ( elementToEncrypt == nullptr )
- {
- throw gcnew XmlException( L"The specified element was not found" );
- }
-
-
- //////////////////////////////////////////////////
- // Create a new instance of the EncryptedXml class
- // and use it to encrypt the XmlElement with the
- // X.509 Certificate.
- //////////////////////////////////////////////////
- EncryptedXml^ eXml = gcnew EncryptedXml;
-
- // Encrypt the element.
- EncryptedData^ edElement = eXml->Encrypt( elementToEncrypt, Cert );
-
- ////////////////////////////////////////////////////
- // Replace the element from the original XmlDocument
- // object with the EncryptedData element.
- ////////////////////////////////////////////////////
- EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false );
-}
-
-static void Decrypt( XmlDocument^ Doc )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml( Doc );
-
- // Decrypt the XML document.
- exml->DecryptDocument();
-}
-
-int main()
-{
-
- // Create an XmlDocument object.
- XmlDocument^ xmlDoc = gcnew XmlDocument;
-
- // Load an XML file into the XmlDocument object.
- try
- {
- xmlDoc->PreserveWhitespace = true;
- xmlDoc->Load( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- return 0;
- }
-
-
- // Create a new X509Certificate2 object by loading
- // an X.509 certificate file. To use XML encryption
- // with an X.509 certificate, use an X509Certificate2
- // object to encrypt, but use a certificate in a certificate
- // store to decrypt.
- // You can create a new test certificate file using the
- // makecert.exe tool.
- // Create an X509Certificate2 object for encryption.
- X509Certificate2^ cert = gcnew X509Certificate2( L"test.pfx" );
-
- // Put the certificate in certificate store for decryption.
- X509Store^ store = gcnew X509Store( StoreLocation::CurrentUser );
- store->Open( OpenFlags::ReadWrite );
- store->Add( cert );
- store->Close();
- try
- {
-
- // Encrypt the "creditcard" element.
- Encrypt( xmlDoc, L"creditcard", cert );
-
- // Display the encrypted XML to the console.
- Console::WriteLine( L"Encrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
-
- // Decrypt the "creditcard" element.
- Decrypt( xmlDoc );
-
- // Display the encrypted XML to the console.
- Console::WriteLine();
- Console::WriteLine( L"Decrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp
deleted file mode 100644
index c8b0ef17967..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg, String^ KeyName )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( ElementToEncrypt == nullptr )
- throw gcnew ArgumentNullException( L"ElementToEncrypt" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
-
- ////////////////////////////////////////////////
- // Find the specified element in the XmlDocument
- // object and create a new XmlElemnt object.
- ////////////////////////////////////////////////
- XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 ));
-
- // Throw an XmlException if the element was not found.
- if ( elementToEncrypt == nullptr )
- {
- throw gcnew XmlException( L"The specified element was not found" );
- }
-
-
- //////////////////////////////////////////////////
- // Create a new instance of the EncryptedXml class
- // and use it to encrypt the XmlElement with the
- // symmetric key.
- //////////////////////////////////////////////////
- EncryptedXml^ eXml = gcnew EncryptedXml;
-
- // Add the key mapping.
- eXml->AddKeyNameMapping( KeyName, Alg );
-
- // Encrypt the element.
- EncryptedData^ edElement = eXml->Encrypt( elementToEncrypt, KeyName );
-
- ////////////////////////////////////////////////////
- // Replace the element from the original XmlDocument
- // object with the EncryptedData element.
- ////////////////////////////////////////////////////
- EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false );
-}
-
-static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg, String^ KeyName )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
- if ( KeyName == nullptr )
- throw gcnew ArgumentNullException( L"KeyName" );
-
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml( Doc );
-
- // Add the key name mapping.
- exml->AddKeyNameMapping( KeyName, Alg );
-
- // Decrypt the XML document.
- exml->DecryptDocument();
-}
-
-int main()
-{
-
- // Create an XmlDocument object.
- XmlDocument^ xmlDoc = gcnew XmlDocument;
-
- // Load an XML file into the XmlDocument object.
- try
- {
- xmlDoc->PreserveWhitespace = true;
- xmlDoc->Load( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-
- // Create a new TripleDES key.
- TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider;
- try
- {
-
- // Encrypt the "creditcard" element.
- Encrypt( xmlDoc, L"creditcard", tDESkey, L"tDesKey" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine( L"Encrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
-
- // Decrypt the "creditcard" element.
- Decrypt( xmlDoc, tDESkey, L"tDesKey" );
-
- // Display the encrypted XML to the console.
- Console::WriteLine();
- Console::WriteLine( L"Decrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear the TripleDES key.
- tDESkey->Clear();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp
deleted file mode 100644
index ae795778f31..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( ElementToEncrypt == nullptr )
- throw gcnew ArgumentNullException( L"ElementToEncrypt" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
-
- ////////////////////////////////////////////////
- // Find the specified element in the XmlDocument
- // object and create a new XmlElemnt object.
- ////////////////////////////////////////////////
- XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 ));
-
- // Throw an XmlException if the element was not found.
- if ( elementToEncrypt == nullptr )
- {
- throw gcnew XmlException( L"The specified element was not found" );
- }
-
-
- //////////////////////////////////////////////////
- // Create a new instance of the EncryptedXml class
- // and use it to encrypt the XmlElement with the
- // symmetric key.
- //////////////////////////////////////////////////
- EncryptedXml^ eXml = gcnew EncryptedXml;
- array^encryptedElement = eXml->EncryptData( elementToEncrypt, Alg, false );
-
- ////////////////////////////////////////////////
- // Construct an EncryptedData object and populate
- // it with the desired encryption information.
- ////////////////////////////////////////////////
- EncryptedData^ edElement = gcnew EncryptedData;
- edElement->Type = EncryptedXml::XmlEncElementUrl;
-
- // Create an EncryptionMethod element so that the
- // receiver knows which algorithm to use for decryption.
- // Determine what kind of algorithm is being used and
- // supply the appropriate URL to the EncryptionMethod element.
- String^ encryptionMethod = nullptr;
- if ( dynamic_cast(Alg) )
- {
- encryptionMethod = EncryptedXml::XmlEncTripleDESUrl;
- }
- else
- if ( dynamic_cast(Alg) )
- {
- encryptionMethod = EncryptedXml::XmlEncDESUrl;
- }
- else
- if ( dynamic_cast(Alg) )
- {
- switch ( Alg->KeySize )
- {
- case 128:
- encryptionMethod = EncryptedXml::XmlEncAES128Url;
- break;
-
- case 192:
- encryptionMethod = EncryptedXml::XmlEncAES192Url;
- break;
-
- case 256:
- encryptionMethod = EncryptedXml::XmlEncAES256Url;
- break;
- }
- }
- else
- {
-
- // Throw an exception if the transform is not in the previous categories
- throw gcnew CryptographicException( L"The specified algorithm is not supported for XML Encryption." );
- }
-
-
-
- edElement->EncryptionMethod = gcnew EncryptionMethod( encryptionMethod );
-
- // Add the encrypted element data to the
- // EncryptedData object.
- edElement->CipherData->CipherValue = encryptedElement;
-
- ////////////////////////////////////////////////////
- // Replace the element from the original XmlDocument
- // object with the EncryptedData element.
- ////////////////////////////////////////////////////
- EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false );
-}
-
-static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg )
-{
-
- // Check the arguments.
- if ( Doc == nullptr )
- throw gcnew ArgumentNullException( L"Doc" );
-
- if ( Alg == nullptr )
- throw gcnew ArgumentNullException( L"Alg" );
-
-
- // Find the EncryptedData element in the XmlDocument.
- XmlElement^ encryptedElement = dynamic_cast(Doc->GetElementsByTagName( L"EncryptedData" )->Item( 0 ));
-
- // If the EncryptedData element was not found, throw an exception.
- if ( encryptedElement == nullptr )
- {
- throw gcnew XmlException( L"The EncryptedData element was not found." );
- }
-
-
- // Create an EncryptedData object and populate it.
- EncryptedData^ edElement = gcnew EncryptedData;
- edElement->LoadXml( encryptedElement );
-
- // Create a new EncryptedXml object.
- EncryptedXml^ exml = gcnew EncryptedXml;
-
- // Decrypt the element using the symmetric key.
- array^rgbOutput = exml->DecryptData( edElement, Alg );
-
- // Replace the encryptedData element with the plaintext XML element.
- exml->ReplaceData( encryptedElement, rgbOutput );
-}
-
-int main()
-{
-
- // Create an XmlDocument object.
- XmlDocument^ xmlDoc = gcnew XmlDocument;
-
- // Load an XML file into the XmlDocument object.
- try
- {
- xmlDoc->PreserveWhitespace = true;
- xmlDoc->Load( L"test.xml" );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- return 0;
- }
-
-
- // Create a new TripleDES key.
- TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider;
- try
- {
-
- // Encrypt the "creditcard" element.
- Encrypt( xmlDoc, L"creditcard", tDESkey );
-
- // Display the encrypted XML to the console.
- Console::WriteLine( L"Encrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
-
- // Decrypt the "creditcard" element.
- Decrypt( xmlDoc, tDESkey );
-
- // Display the encrypted XML to the console.
- Console::WriteLine();
- Console::WriteLine( L"Decrypted XML:" );
- Console::WriteLine();
- Console::WriteLine( xmlDoc->OuterXml );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
-
- // Clear the TripleDES key.
- tDESkey->Clear();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp
deleted file mode 100644
index 2d4df6a368d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file.
-static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Specify a canonicalization method.
- signedXml->SignedInfo->CanonicalizationMethod = SignedXml::XmlDsigExcC14NTransformUrl;
-
- // Set the InclusiveNamespacesPrefixList property.
- XmlDsigExcC14NTransform^ canMethod = dynamic_cast(signedXml->SignedInfo->CanonicalizationMethodObject);
- canMethod->InclusiveNamespacesPrefixList = L"Sign";
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = L"";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( dynamic_cast(doc->FirstChild) )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-static Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-// Create example data to sign.
-static void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" );
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Create a new XmlNode object.
- XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" );
-
- // Add some text to the node.
- subnode->InnerText = L"Here is some data to sign.";
-
- // Append the node to the document.
- document->DocumentElement->AppendChild( subnode );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( L"Example.xml" );
- Console::WriteLine( L"New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( L"Example.xml", L"SignedExample.xml", Key );
- Console::WriteLine( L"XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( L"Verifying signature..." );
- bool result = VerifyXmlFile( L"SignedExample.xml" );
-
- // Display the results of the signature verification to \
- // the console.
- if ( result )
- {
- Console::WriteLine( L"The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( L"The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp
deleted file mode 100644
index ce578aa7c43..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file.
-static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Specify a canonicalization method.
- signedXml->SignedInfo->CanonicalizationMethod = SignedXml::XmlDsigExcC14NWithCommentsTransformUrl;
-
- // Set the InclusiveNamespacesPrefixList property.
- XmlDsigExcC14NWithCommentsTransform^ canMethod = dynamic_cast(signedXml->SignedInfo->CanonicalizationMethodObject);
- canMethod->InclusiveNamespacesPrefixList = L"Sign";
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = L"";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( dynamic_cast(doc->FirstChild) )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-static Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-// Create example data to sign.
-static void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" );
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Create a new XmlNode object.
- XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" );
-
- // Add some text to the node.
- subnode->InnerText = L"Here is some data to sign.";
-
- // Append the node to the document.
- document->DocumentElement->AppendChild( subnode );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Create an XML file to sign.
- CreateSomeXml( L"Example.xml" );
- Console::WriteLine( L"New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- //SignXmlFile("Example.xml", "SignedExample.xml", Key);
- Console::WriteLine( L"XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( L"Verifying signature..." );
- bool result = VerifyXmlFile( L"SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( L"The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( L"The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp
deleted file mode 100644
index 6edd984e6b9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Create the XML that represents the transform.
-static XmlDsigXPathTransform^ CreateXPathTransform( String^ XPathString )
-{
-
- // Create a new XMLDocument object.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Create a new XmlElement.
- XmlElement^ xPathElem = doc->CreateElement( L"XPath" );
-
- // Set the element text to the value
- // of the XPath string.
- xPathElem->InnerText = XPathString;
-
- // Create a new XmlDsigXPathTransform object.
- XmlDsigXPathTransform^ xForm = gcnew XmlDsigXPathTransform;
-
- // Load the XPath XML from the element.
- xForm->LoadInnerXml( xPathElem->SelectNodes( L"." ) );
-
- // Return the XML that represents the transform.
- return xForm;
-}
-
-
-// Sign an XML file and save the signature in a new file.
-static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ XPathString )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = L"";
-
- // Create an XmlDsigXPathTransform object using
- // the helper method 'CreateXPathTransform' defined
- // later in this sample.
- XmlDsigXPathTransform^ XPathTransform = CreateXPathTransform( XPathString );
-
- // Add the transform to the reference.
- reference->AddTransform( XPathTransform );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-static Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-// Create example data to sign.
-static void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" );
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Create a new XmlNode object.
- XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" );
-
- // Add some text to the node.
- subnode->InnerText = L"Here is some data to sign.";
-
- // Append the node to the document.
- document->DocumentElement->AppendChild( subnode );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- try
- {
-
- // Create an XML file to sign.
- CreateSomeXml( L"Example.xml" );
- Console::WriteLine( L"New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( L"Example.xml", L"SignedExample.xml", Key, L"ancestor-or-self::TempElement" );
- Console::WriteLine( L"XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( L"Verifying signature..." );
- bool result = VerifyXmlFile( L"SignedExample.xml" );
-
- // Display the results of the signature verification to \
- // the console.
- if ( result )
- {
- Console::WriteLine( L"The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( L"The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
- Key->Clear();
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp
deleted file mode 100644
index 6693cd9c0f6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Create the XML that represents the transform.
-static XmlDsigXsltTransform^ CreateXsltTransform( String^ xsl )
-{
- XmlDocument^ doc = gcnew XmlDocument;
- doc->LoadXml( xsl );
- XmlDsigXsltTransform^ xform = gcnew XmlDsigXsltTransform;
- xform->LoadInnerXml( doc->ChildNodes );
- return xform;
-}
-
-
-// Sign an XML file and save the signature in a new file.
-static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ XSLString )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = L"";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Create an XmlDsigXPathTransform object using
- // the helper method 'CreateXPathTransform' defined
- // later in this sample.
- XmlDsigXsltTransform^ XsltTransform = CreateXsltTransform( XSLString );
-
- // Add the transform to the reference.
- reference->AddTransform( XsltTransform );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-static Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-// Create example data to sign.
-static void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" );
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Create a new XmlNode object.
- XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"ElementToTransform", L"Sign" );
-
- // Add some text to the node.
- subnode->InnerText = L"Here is some data to sign.";
-
- // Append the node to the document.
- document->DocumentElement->AppendChild( subnode );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- String^ xsl = L"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ";
- try
- {
-
- // Create an XML file to sign.
- CreateSomeXml( L"Example.xml" );
- Console::WriteLine( L"New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( L"Example.xml", L"SignedExample.xml", Key, xsl );
- Console::WriteLine( L"XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( L"Verifying signature..." );
- bool result = VerifyXmlFile( L"SignedExample.xml" );
-
- // Display the results of the signature verification to \
- // the console.
- if ( result )
- {
- Console::WriteLine( L"The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( L"The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
- finally
- {
- Key->Clear();
- }
-
- return 1;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp
deleted file mode 100644
index 4477c20eac3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-#using
-#using
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-
-//
-void CheckSignatureWithEncryptedGrant(
- String^ fileName, IRelDecryptor^ decryptor)
-{
- // Create a new XML document.
- XmlDocument^ sourceDocument = gcnew XmlDocument();
- XmlNamespaceManager^ namespaceManager =
- gcnew XmlNamespaceManager(sourceDocument->NameTable);
-
- // Format using white spaces.
- sourceDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- sourceDocument->Load(fileName);
- namespaceManager->AddNamespace("dsig",
- SignedXml::XmlDsigNamespaceUrl);
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList =
- sourceDocument->SelectNodes("//dsig:Signature", namespaceManager);
-
- for (int i = 0, count = nodeList->Count; i < count; i++)
- {
- XmlDocument^ clone = (XmlDocument^) sourceDocument->Clone();
- XmlNodeList^ signatures =
- clone->SelectNodes("//dsig:Signature", namespaceManager);
-
- // Create a new SignedXml object and pass into it the
- // XML document clone.
- SignedXml^ signedDocument = gcnew SignedXml(clone);
-
- // Load the signature node.
- signedDocument->LoadXml((XmlElement^)signatures[i]);
-
- // Set the context for license transform
- Transform^ licenseTransform = ((Reference^)signedDocument->
- SignedInfo->References[0])->TransformChain[0];
-
- if ((licenseTransform::typeid == XmlLicenseTransform::typeid)
- && (decryptor != nullptr))
- {
- // Decryptor is used to decrypt encryptedGrant
- // elements.
- ((XmlLicenseTransform^) licenseTransform)->Decryptor = decryptor;
- }
-
- // Check the signature and display the result.
- if (signedDocument->CheckSignature())
- {
- Console::WriteLine("SUCCESS: " +
- "CheckSignatureWithEncryptedGrant - issuer index #" + i);
- }
- else
- {
- Console::WriteLine("FAILURE: " +
- "CheckSignatureWithEncryptedGrant - issuer index #" + i);
- }
- }
-}
-//
-
-int main()
-{
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp
deleted file mode 100644
index e5ffc2a58d4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// CurrencyDecimalDigits property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a negative value with the default number of decimal digits (2).
- Int64 myInt = -1234;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-
- // Displays the same value with four decimal digits.
- nfi->CurrencyDecimalDigits = 4;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-}
-
-/*
-This code produces the following output.
-
-($1, 234.00)
-($1, 234.0000)
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp
deleted file mode 100644
index 9620c7b2591..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// CurrencyDecimalSeparator property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S".").
- Int64 myInt = 123456789;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-
- // Displays the same value with a blank as the separator.
- nfi->CurrencyDecimalSeparator = " ";
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-}
-
-/*
-This code produces the following output.
-
-$123, 456, 789.00
-$123, 456, 789 00
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp
deleted file mode 100644
index 0421ff605f4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// CurrencyGroupSeparator property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S", ").
- Int64 myInt = 123456789;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-
- // Displays the same value with a blank as the separator.
- nfi->CurrencyGroupSeparator = " ";
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-}
-
-/*
-This code produces the following output.
-
-$123, 456, 789.00
-$123 456 789.00
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp
deleted file mode 100644
index a06da3edcbf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// CurrencyGroupSizes property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S".").
- Int64 myInt = 123456789012345;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-
- // Displays the same value with different groupings.
- array^mySizes1 = {2,3,4};
- array^mySizes2 = {2,3,0};
- nfi->CurrencyGroupSizes = mySizes1;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
- nfi->CurrencyGroupSizes = mySizes2;
- Console::WriteLine( myInt.ToString( "C", nfi ) );
-}
-
-/*
-This code produces the following output.
-
-$123, 456, 789, 012, 345.00
-$12, 3456, 7890, 123, 45.00
-$1234567890, 123, 45.00
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp
deleted file mode 100644
index a0af052a1d7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-// The following example starts an instance of Notepad. The example
-// then retrieves and displays various properties of the associated
-// process. The example detects when the process exits, and displays
-// the process's exit code.
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-int main()
-{
-
- // Define variables to track the peak
- // memory usage of the process.
- _int64 peakPagedMem = 0,peakWorkingSet = 0,peakVirtualMem = 0;
- Process^ myProcess = nullptr;
- try
- {
-
- // Start the process.
- myProcess = Process::Start( "NotePad.exe" );
-
- // Display the process statistics until
- // the user closes the program.
- do
- {
- if ( !myProcess->HasExited )
- {
-
- // Refresh the current process property values.
- myProcess->Refresh();
- Console::WriteLine();
-
- // Display current process statistics.
- Console::WriteLine( "{0} -", myProcess );
- Console::WriteLine( "-------------------------------------" );
- Console::WriteLine( " physical memory usage: {0}", myProcess->WorkingSet64 );
- Console::WriteLine( " base priority: {0}", myProcess->BasePriority );
- Console::WriteLine( " priority class: {0}", myProcess->PriorityClass );
- Console::WriteLine( " user processor time: {0}", myProcess->UserProcessorTime );
- Console::WriteLine( " privileged processor time: {0}", myProcess->PrivilegedProcessorTime );
- Console::WriteLine( " total processor time: {0}", myProcess->TotalProcessorTime );
- Console::WriteLine(" PagedSystemMemorySize64: {0}", myProcess->PagedSystemMemorySize64);
- Console::WriteLine(" PagedMemorySize64: {0}", myProcess->PagedMemorySize64);
-
- // Update the values for the overall peak memory statistics.
- peakPagedMem = myProcess->PeakPagedMemorySize64;
- peakVirtualMem = myProcess->PeakVirtualMemorySize64;
- peakWorkingSet = myProcess->PeakWorkingSet64;
- if ( myProcess->Responding )
- {
- Console::WriteLine( "Status = Running" );
- }
- else
- {
- Console::WriteLine( "Status = Not Responding" );
- }
- }
- }
- while ( !myProcess->WaitForExit( 1000 ) );
- Console::WriteLine();
- Console::WriteLine( "Process exit code: {0}", myProcess->ExitCode );
-
- // Display peak memory statistics for the process.
- Console::WriteLine( "Peak physical memory usage of the process: {0}", peakWorkingSet );
- Console::WriteLine( "Peak paged memory usage of the process: {0}", peakPagedMem );
- Console::WriteLine( "Peak virtual memory usage of the process: {0}", peakVirtualMem );
- }
- finally
- {
- if ( myProcess != nullptr )
- {
- myProcess->Close();
- }
- }
-
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp b/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp
deleted file mode 100644
index 1ec20413156..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// System::Diagnostics->CounterCreationData
-// System::Diagnostics->CounterCreationData(String*, String*, PerformanceCounterType)
-// System::Diagnostics->CounterCreationData()
-// System::Diagnostics->CounterCreationData->CounterName
-// System::Diagnostics->CounterCreationData->CounterHelp
-// System::Diagnostics->CounterCreationData->CounterType
-
-/* The following program demonstrates 'CounterCreationData' class,
-CounterCreationData(String*, String*, PerformanceCounterType)',
-'CounterCreationData()', 'CounterName', 'CounterHelp' and
-'CounterType' members of 'System::Diagnostics->CounterCreationData'
-class. It creates the custom counters with 'CounterCreationData'
-and binds them to 'PerformanceCounterCategory' object. */
-
-//
-//
-//
-//
-//
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- CounterCreationDataCollection^ myCol = gcnew CounterCreationDataCollection;
-
- // Create two custom counter objects.
- CounterCreationData^ myCounter1 = gcnew CounterCreationData( "Counter1","First custom counter",PerformanceCounterType::CounterDelta32 );
- CounterCreationData^ myCounter2 = gcnew CounterCreationData;
-
- // Set the properties of the 'CounterCreationData' Object*.
- myCounter2->CounterName = "Counter2";
- myCounter2->CounterHelp = "Second custom counter";
- myCounter2->CounterType = PerformanceCounterType::NumberOfItemsHEX32;
-
- // Add custom counter objects to CounterCreationDataCollection.
- myCol->Add( myCounter1 );
- myCol->Add( myCounter2 );
- if ( PerformanceCounterCategory::Exists( "New Counter Category" ) )
- PerformanceCounterCategory::Delete( "New Counter Category" );
-
- // Bind the counters to a PerformanceCounterCategory.
- PerformanceCounterCategory^ myCategory = PerformanceCounterCategory::Create( "New Counter Category", "Category Help", myCol );
- Console::WriteLine( "Counter Information:" );
- Console::WriteLine( "Category Name: {0}", myCategory->CategoryName );
- for ( int i = 0; i < myCol->Count; i++ )
- {
- // Display the properties of the CounterCreationData objects.
- Console::WriteLine( "CounterName : {0}", myCol[ i ]->CounterName );
- Console::WriteLine( "CounterHelp : {0}", myCol[ i ]->CounterHelp );
- Console::WriteLine( "CounterType : {0}", myCol[ i ]->CounterType );
- }
-}
-
-//
-//
-//
-//
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp b/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp
deleted file mode 100644
index b5b6c7488d8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp
+++ /dev/null
@@ -1,398 +0,0 @@
-//Types:System.Collections.DictionaryEntry
-//Types:System.Collections.IDictionary
-//Types:System.Collections.IDictionaryEnumerator
-//
-using namespace System;
-using namespace System::Collections;
-
-//
-// This class implements a simple dictionary using an array of
-// DictionaryEntry objects (key/value pairs).
-public ref class SimpleDictionary : public IDictionary
-{
- // The array of items
-private:
- array^ items;
-private:
- int itemsInUse;
-
- // Construct the SimpleDictionary with the desired number of
- // items. The number of items cannot change for the life time of
- // this SimpleDictionary.
-public:
- SimpleDictionary(int size)
- {
- items = gcnew array(size);
- }
-
- #pragma region IDictionary Members
- //
-public:
- property virtual bool IsReadOnly
- {
- bool get()
- {
- return false;
- }
- }
- //
- //
-public:
- virtual bool Contains(Object^ key)
- {
- int index;
- return TryGetIndexOfKey(key, &index);
- }
- //
- //
-public:
- virtual property bool IsFixedSize
- {
- bool get()
- {
- return false;
- }
- }
- //
- //
-public:
- virtual void Remove(Object^ key)
- {
- if (key == nullptr)
- {
- throw gcnew ArgumentNullException("key");
- }
- // Try to find the key in the DictionaryEntry array
- int index;
- if (TryGetIndexOfKey(key, &index))
- {
- // If the key is found, slide all the items down.
- Array::Copy(items, index + 1, items, index, itemsInUse -
- index - 1);
- itemsInUse--;
- }
- else
- {
- // If the key is not in the dictionary, just return.
- return;
- }
- }
- //
- //
-public:
- virtual void Clear()
- {
- itemsInUse = 0;
- }
- //
- //
-public:
- virtual void Add(Object^ key, Object^ value)
- {
- // Add the new key/value pair even if this key already exists
- // in the dictionary.
- if (itemsInUse == items->Length)
- {
- throw gcnew InvalidOperationException
- ("The dictionary cannot hold any more items.");
- }
- items[itemsInUse++] = gcnew DictionaryEntry(key, value);
- }
- //
- //
-public:
- virtual property ICollection^ Keys
- {
- ICollection^ get()
- {
- // Return an array where each item is a key.
- array
- //
-public:
- virtual property ICollection^ Values
- {
- ICollection^ get()
- {
- // Return an array where each item is a value.
- array^ values = gcnew array(itemsInUse);
- for (int i = 0; i < itemsInUse; i++)
- {
- values[i] = items[i]->Value;
- }
- return values;
- }
- }
- //
- //
-public:
- virtual property Object^ default[Object^]
- {
- Object^ get(Object^ key)
- {
- // If this key is in the dictionary, return its value.
- int index;
- if (TryGetIndexOfKey(key, &index))
- {
- // The key was found; return its value.
- return items[index]->Value;
- }
- else
- {
- // The key was not found; return null.
- return nullptr;
- }
- }
-
- void set(Object^ key, Object^ value)
- {
- // If this key is in the dictionary, change its value.
- int index;
- if (TryGetIndexOfKey(key, &index))
- {
- // The key was found; change its value.
- items[index]->Value = value;
- }
- else
- {
- // This key is not in the dictionary; add this
- // key/value pair.
- Add(key, value);
- }
- }
- }
- //
-private:
- bool TryGetIndexOfKey(Object^ key, int* index)
- {
- for (*index = 0; *index < itemsInUse; *index++)
- {
- // If the key is found, return true (the index is also
- // returned).
- if (items[*index]->Key->Equals(key))
- {
- return true;
- }
- }
-
- // Key not found, return false (index should be ignored by
- // the caller).
- return false;
- }
-//
-//
-private:
- ref class SimpleDictionaryEnumerator : public IDictionaryEnumerator
- {
- // A copy of the SimpleDictionary object's key/value pairs.
-private:
- array^ items;
-private:
- int index;
-
-public:
- SimpleDictionaryEnumerator(SimpleDictionary^ sd)
- {
- // Make a copy of the dictionary entries currently in the
- // SimpleDictionary object.
- items = gcnew array(sd->Count);
- Array::Copy(sd->items, 0, items, 0, sd->Count);
- index = -1;
- }
-
- // Return the current item.
-public:
- virtual property Object^ Current
- {
- Object^ get()
- {
- ValidateIndex();
- return items[index];
- }
- }
-
- // Return the current dictionary entry.
-public:
- virtual property DictionaryEntry Entry
- {
- DictionaryEntry get()
- {
- return (DictionaryEntry) Current;
- }
- }
-
- // Return the key of the current item.
-public:
- virtual property Object^ Key
- {
- Object^ get()
- {
- ValidateIndex();
- return items[index]->Key;
- }
- }
-
- // Return the value of the current item.
-public:
- virtual property Object^ Value
- {
- Object^ get()
- {
- ValidateIndex();
- return items[index]->Value;
- }
- }
-
- // Advance to the next item.
-public:
- virtual bool MoveNext()
- {
- if (index < items->Length - 1)
- {
- index++;
- return true;
- }
- return false;
- }
-
- // Validate the enumeration index and throw an exception if
- // the index is out of range.
-private:
- void ValidateIndex()
- {
- if (index < 0 || index >= items->Length)
- {
- throw gcnew InvalidOperationException
- ("Enumerator is before or after the collection.");
- }
- }
-
- // Reset the index to restart the enumeration.
-public:
- virtual void Reset()
- {
- index = -1;
- }
- };
- //
-public:
- virtual IDictionaryEnumerator^ GetEnumerator()
- {
- // Construct and return an enumerator.
- return gcnew SimpleDictionaryEnumerator(this);
- }
- //
- #pragma endregion
-
- #pragma region ICollection Members
-public:
- virtual property bool IsSynchronized
- {
- bool get()
- {
- return false;
- }
- }
-
-public:
- virtual property Object^ SyncRoot
- {
- Object^ get()
- {
- throw gcnew NotImplementedException();
- }
- }
-
-public:
- virtual property int Count
- {
- int get()
- {
- return itemsInUse;
- }
- }
-
-public:
- virtual void CopyTo(Array^ array, int index)
- {
- throw gcnew NotImplementedException();
- }
- #pragma endregion
-
- #pragma region IEnumerable Members
-
- virtual IEnumerator^ IEnumerable_GetEnumerator()
- = IEnumerable::GetEnumerator
- {
- // Construct and return an enumerator.
- return ((IDictionary^)this)->GetEnumerator();
- }
- #pragma endregion
-};
-//
-
-int main()
-{
- // Create a dictionary that contains no more than three
- // entries.
- IDictionary^ d = gcnew SimpleDictionary(3);
-
- // Add three people and their ages to the dictionary.
- d->Add("Jeff", 40);
- d->Add("Kristin", 34);
- d->Add("Aidan", 1);
-
- Console::WriteLine("Number of elements in dictionary = {0}",
- d->Count);
-
- Console::WriteLine("Does dictionary contain 'Jeff'? {0}",
- d->Contains("Jeff"));
- Console::WriteLine("Jeff's age is {0}", d["Jeff"]);
-
- // Display every entry's key and value.
- for each (DictionaryEntry^ de in d)
- {
- Console::WriteLine("{0} is {1} years old.", de->Key,
- de->Value);
- }
-
- // Remove an entry that exists.
- d->Remove("Jeff");
-
- // Remove an entry that does not exist, but do not throw an
- // exception.
- d->Remove("Max");
-
- // Show the names (keys) of the people in the dictionary.
- for each (String^ s in d->Keys)
- {
- Console::WriteLine(s);
- }
-
- // Show the ages (values) of the people in the dictionary.
- for each (int age in d->Values)
- {
- Console::WriteLine(age);
- }
-}
-
-// This code produces the following output.
-//
-// Number of elements in dictionary = 3
-// Does dictionary contain 'Jeff'? True
-// Jeff's age is 40
-// Jeff is 40 years old.
-// Kristin is 34 years old.
-// Aidan is 1 years old.
-// Kristin
-// Aidan
-// 34
-// 1
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp
deleted file mode 100644
index 6d4e4af244c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-using namespace System;
-using namespace System::Collections;
-
-public ref class SimpleDictionary : DictionaryBase
-{
-};
-
-public ref class DictionaySamples
-{
-public:
- static void Main()
- {
- // Create a dictionary that contains no more than three entries.
- IDictionary^ myDictionary = gcnew SimpleDictionary();
-
- // Add three people and their ages to the dictionary.
- myDictionary->Add("Jeff", 40);
- myDictionary->Add("Kristin", 34);
- myDictionary->Add("Aidan", 1);
- // Display every entry's key and value.
- for each (DictionaryEntry de in myDictionary)
- {
- Console::WriteLine("{0} is {1} years old.", de.Key, de.Value);
- }
-
- // Remove an entry that exists.
- myDictionary->Remove("Jeff");
-
- // Remove an entry that does not exist, but do not throw an exception.
- myDictionary->Remove("Max");
-
- //
- for each (DictionaryEntry de in myDictionary)
- {
- //...
- }
- //
- }
-};
-
-int main()
-{
- DictionaySamples::Main();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp
deleted file mode 100644
index ad273901016..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Specify the directories you want to manipulate.
- DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\MyDir" );
- try
- {
-
- // Determine whether the directory exists.
- if ( di->Exists )
- {
-
- // Indicate that the directory already exists.
- Console::WriteLine( "That path exists already." );
- return 0;
- }
-
- // Try to create the directory.
- di->Create();
- Console::WriteLine( "The directory was created successfully." );
-
- // Delete the directory.
- di->Delete();
- Console::WriteLine( "The directory was deleted successfully." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp
deleted file mode 100644
index b172c01236b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Specify the directories you want to manipulate.
- DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\MyDir" );
- try
- {
-
- // Determine whether the directory exists.
- if ( di->Exists )
- {
-
- // Indicate that it already exists.
- Console::WriteLine( "That path exists already." );
- return 0;
- }
-
- // Try to create the directory.
- di->Create();
- Console::WriteLine( "The directory was created successfully." );
-
- // Delete the directory.
- di->Delete();
- Console::WriteLine( "The directory was deleted successfully." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp
deleted file mode 100644
index 8a3584321aa..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Specify the directories you want to manipulate.
- DirectoryInfo^ di1 = gcnew DirectoryInfo( "c:\\MyDir" );
- DirectoryInfo^ di2 = gcnew DirectoryInfo( "c:\\MyDir\\temp" );
- try
- {
-
- // Create the directories.
- di1->Create();
- di2->Create();
-
- // This operation will not be allowed because there are subdirectories.
- Console::WriteLine( "I am about to attempt to delete {0}.", di1->Name );
- di1->Delete();
- Console::WriteLine( "The Delete operation was successful, which was unexpected." );
- }
- catch ( Exception^ )
- {
- Console::WriteLine( "The Delete operation failed as expected." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp
deleted file mode 100644
index c0751c822f0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Specify the directories you want to manipulate.
- DirectoryInfo^ di1 = gcnew DirectoryInfo( "c:\\MyDir" );
- try
- {
-
- // Create the directories.
- di1->Create();
- di1->CreateSubdirectory( "temp" );
-
- //This operation will not be allowed because there are subdirectories.
- Console::WriteLine( "I am about to attempt to delete {0}", di1->Name );
- di1->Delete();
- Console::WriteLine( "The Delete operation was successful, which was unexpected." );
- }
- catch ( Exception^ )
- {
- Console::WriteLine( "The Delete operation failed as expected." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp
deleted file mode 100644
index 7ecd08dfd25..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" );
-
- // Get only subdirectories that contain the letter "p."
- array^dirs = di->GetDirectories( "*p*" );
- Console::WriteLine( "The number of directories containing the letter p is {0}.", dirs->Length );
- Collections::IEnumerator^ myEnum = dirs->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DirectoryInfo^ diNext = safe_cast(myEnum->Current);
- Console::WriteLine( "The number of files in {0} is {1}", diNext, diNext->GetFiles()->Length );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetCreation/CPP/dir_getcreation.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetCreation/CPP/dir_getcreation.cpp
deleted file mode 100644
index 86cac85e3fc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_GetCreation/CPP/dir_getcreation.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
-
- // Get the creation time of a well-known directory.
- DateTime dt = Directory::GetCreationTime( Environment::CurrentDirectory );
-
- // Give feedback to the user.
- if ( DateTime::Now.Subtract( dt ).TotalDays > 364 )
- {
- Console::WriteLine( "This directory is over a year old." );
- }
- else
- if ( DateTime::Now.Subtract( dt ).TotalDays > 30 )
- {
- Console::WriteLine( "This directory is over a month old." );
- }
- else
- if ( DateTime::Now.Subtract( dt ).TotalDays <= 1 )
- {
- Console::WriteLine( "This directory is less than a day old." );
- }
- else
- {
- Console::WriteLine( "This directory was created on {0}", dt );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetCurDir/CPP/dir_getcurdir.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetCurDir/CPP/dir_getcurdir.cpp
deleted file mode 100644
index 716792cead5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_GetCurDir/CPP/dir_getcurdir.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
-
- // Get the current directory.
- String^ path = Directory::GetCurrentDirectory();
- String^ target = "c:\\temp";
- Console::WriteLine( "The current directory is {0}", path );
- if ( !Directory::Exists( target ) )
- {
- Directory::CreateDirectory( target );
- }
-
- // Change the current directory.
- Environment::CurrentDirectory = target;
- if ( path->Equals( Directory::GetCurrentDirectory() ) )
- {
- Console::WriteLine( "You are in the temp directory." );
- }
- else
- {
- Console::WriteLine( "You are not in the temp directory." );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetDirs2/CPP/dir_getdirs2.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetDirs2/CPP/dir_getdirs2.cpp
deleted file mode 100644
index 0896d4ca1b5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_GetDirs2/CPP/dir_getdirs2.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
-
- // Only get subdirectories that begin with the letter "p."
- array^dirs = Directory::GetDirectories( "c:\\", "p*" );
- Console::WriteLine( "The number of directories starting with p is {0}.", dirs->Length );
- Collections::IEnumerator^ myEnum = dirs->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Console::WriteLine( myEnum->Current );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetFiles2/CPP/dir_getfiles2.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetFiles2/CPP/dir_getfiles2.cpp
deleted file mode 100644
index 95bb8528e02..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_GetFiles2/CPP/dir_getfiles2.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
-
- // Only get files that begin with the letter "c".
- array^dirs = Directory::GetFiles( "c:\\", "c*" );
- Console::WriteLine( "The number of files starting with c is {0}.", dirs->Length );
- Collections::IEnumerator^ myEnum = dirs->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Console::WriteLine( myEnum->Current );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastAccess/CPP/dir_getlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetLastAccess/CPP/dir_getlastaccess.cpp
deleted file mode 100644
index d38d877f932..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastAccess/CPP/dir_getlastaccess.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\MyDir";
- if ( !Directory::Exists( path ) )
- {
- Directory::CreateDirectory( path );
- }
- Directory::SetLastAccessTime( path, DateTime(1985,5,4) );
-
- // Get the creation time of a well-known directory.
- DateTime dt = Directory::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this directory was {0}", dt );
-
- // Update the last access time.
- Directory::SetLastAccessTime( path, DateTime::Now );
- dt = Directory::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this directory was {0}", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastWrite/CPP/dir_getlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetLastWrite/CPP/dir_getlastwrite.cpp
deleted file mode 100644
index 75e5bee709d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastWrite/CPP/dir_getlastwrite.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\MyDir";
- if ( !Directory::Exists( path ) )
- {
- Directory::CreateDirectory( path );
- }
- else
- {
-
- // Take an action which will affect the write time.
- Directory::SetLastWriteTime( path, DateTime(1985,4,3) );
- }
-
- // Get the creation time of a well-known directory.
- DateTime dt = Directory::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this directory was {0}", dt );
-
- // Update the last write time.
- Directory::SetLastWriteTime( path, DateTime::Now );
- dt = Directory::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this directory was {0}", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp
deleted file mode 100644
index 0da03649338..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\MyDir";
- if ( !Directory::Exists( path ) )
- {
- Directory::CreateDirectory( path );
- }
- Directory::SetLastAccessTime( path, DateTime(1985,5,4) );
-
- // Get the last access time of a well-known directory.
- DateTime dt = Directory::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this directory was {0}", dt );
-
- // Update the last access time.
- Directory::SetLastAccessTime( path, DateTime::Now );
- dt = Directory::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this directory was {0}", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp
deleted file mode 100644
index 45c4c45428c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-void main()
-{
- try
- {
- String^ path = "c:\\MyDir";
- if ( !Directory::Exists( path ) )
- {
- Directory::CreateDirectory( path );
- }
- else
- {
-
- // Take an action that will affect the write time.
- Directory::SetLastWriteTime( path, DateTime(1985,4,3) );
- }
-
- // Get the last write time of a well-known directory.
- DateTime dt = Directory::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this directory was {0}", dt );
-
- //Update the last write time.
- Directory::SetLastWriteTime( path, DateTime::Now );
- dt = Directory::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this directory was {0}", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp b/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp
deleted file mode 100644
index 9647674e17e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-
-// Copy a source directory to a target directory.
-void CopyDirectory( String^ SourceDirectory, String^ TargetDirectory )
-{
- DirectoryInfo^ source = gcnew DirectoryInfo( SourceDirectory );
- DirectoryInfo^ target = gcnew DirectoryInfo( TargetDirectory );
-
- //Determine whether the source directory exists.
- if ( !source->Exists )
- return;
-
- if ( !target->Exists )
- target->Create();
-
-
- //Copy files.
- array^sourceFiles = source->GetFiles();
- for ( int i = 0; i < sourceFiles->Length; ++i )
- File::Copy( sourceFiles[ i ]->FullName, String::Concat( target->FullName, "\\", sourceFiles[ i ]->Name ), true );
-
- //Copy directories.
- array^sourceDirectories = source->GetDirectories();
- for ( int j = 0; j < sourceDirectories->Length; ++j )
- CopyDirectory( sourceDirectories[ j ]->FullName, String::Concat( target->FullName, "\\", sourceDirectories[ j ]->Name ) );
-}
-
-int main()
-{
- CopyDirectory( "D:\\Tools", "D:\\NewTools" );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp b/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp
deleted file mode 100644
index 3f5ffdf0349..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// System::Diagnostics::EntryWrittenEventArgs::ctor()
-
-/*
-The following example demonstrates 'EntryWrittenEventArgs ()'
-constructor of the 'EntryWrittenEventArgs' class. It creates a custom 'EventLog'
-and writes an entry into it. Then creates an 'EntryWrittenEventArgs' Object*
-using the first entry in the custom eventlog. This Object* is used to notify a message
-*/
-
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e )
-{
- if ( !e->Entry )
- Console::WriteLine( "A new entry is written in MyNewLog." );
-}
-
-int main()
-{
- try
- {
- EventLog^ myNewLog = gcnew EventLog;
- myNewLog->Log = "MyNewLog";
- myNewLog->Source = "MySource";
-
- // Create the source if it does not exist already.
- if ( !EventLog::SourceExists( "MySource" ) )
- {
- EventLog::CreateEventSource( "MySource", "MyNewLog" );
- Console::WriteLine( "CreatingEventSource" );
- }
-
- // Write an entry to the EventLog.
- myNewLog->WriteEntry( "The Latest entry in the Event Log" );
- int myEntries = myNewLog->Entries->Count;
- EventLogEntry^ entry = myNewLog->Entries[ myEntries - 1 ];
- EntryWrittenEventArgs^ myEntryEventArgs = gcnew EntryWrittenEventArgs;
- MyOnEntry( myNewLog, myEntryEventArgs );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception Raised{0}", e->Message );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp b/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp
deleted file mode 100644
index 96f9f0f008b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-// System::Diagnostics::EntryWrittenEventArgs::ctor(EventLogEntry)
-// System::Diagnostics::EntryWrittenEventArgs::Entry
-
-/*
-The following example demonstrates the 'Entry' property and EntryWrittenEventArgs (EventLogEntry)
-constructor of the 'EntryWrittenEventArgs' class. It creates a custom 'EventLog' and writes an
-entry into it. Then creates an 'EntryWrittenEventArgs' Object* using the first entry in the custom
-eventlog. This Object* is used to notify a message
-*/
-
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-//
-void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e )
-{
- EventLogEntry^ myEventLogEntry = e->Entry;
- if ( myEventLogEntry )
- {
- Console::WriteLine( "Current message entry is: '{0}'", myEventLogEntry->Message );
- }
- else
- {
- Console::WriteLine( "The current entry is null" );
- }
-}
-//
-
-int main()
-{
- try
- {
- EventLog^ myNewLog = gcnew EventLog;
- myNewLog->Log = "MyNewLog";
- myNewLog->Source = "MySource";
-
- // Create the source if it does not exist already.
- if ( !EventLog::SourceExists( "MySource" ) )
- {
- EventLog::CreateEventSource( "MySource", "MyNewLog" );
- Console::WriteLine( "CreatingEventSource" );
- }
-
- // Write an entry to the EventLog.
- myNewLog->WriteEntry( "The Latest entry in the Event Log" );
- int myEntries = myNewLog->Entries->Count;
- EventLogEntry^ entry = myNewLog->Entries[ myEntries - 1 ];
- EntryWrittenEventArgs^ myEntryEventArgs = gcnew EntryWrittenEventArgs( entry );
- MyOnEntry( myNewLog, myEntryEventArgs );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception Raised {0}", e->Message );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp
deleted file mode 100644
index 54a15c9b13c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-// System::Diagnostics::EventLogEntryType
-// System::Diagnostics::EventLogEntryType::Error
-// System::Diagnostics::EventLogEntryType::Warning
-// System::Diagnostics::EventLogEntryType::Information
-// System::Diagnostics::EventLogEntryType::FailureAudit
-// System::Diagnostics::EventLogEntryType::SuccessAudit
-/* The following program demonstrates 'Error', 'Warning',
-'Information', 'FailureAudit' and 'SuccessAudit' members of
-'EventLogEntryType' enumerator. It creates new source with a
-specified event log, new ID, EventLogEntryType and message,
-if does not exist.
-*/
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::Runtime::Serialization;
-void main()
-{
- try
- {
- EventLog^ myEventLog;
- String^ mySource = nullptr;
- String^ myLog = nullptr;
- String^ myType = nullptr;
- String^ myMessage = "A new event is created.";
- String^ myEventID = nullptr;
- int myIntLog = 0;
- int myID = 0;
- Console::Write( "Enter source name for new event (eg: Print): " );
- mySource = Console::ReadLine();
- Console::Write( "Enter log name in which to write an event(eg: System): " );
- myLog = Console::ReadLine();
- Console::WriteLine( "" );
- Console::WriteLine( " Select type of event to write:" );
- Console::WriteLine( " 1. Error " );
- Console::WriteLine( " 2. Warning" );
- Console::WriteLine( " 3. Information" );
- Console::WriteLine( " 4. FailureAudit" );
- Console::WriteLine( " 5. SuccessAudit" );
- Console::Write( "Enter the choice(eg. 1): " );
- myType = Console::ReadLine();
- myIntLog = Convert::ToInt32( myType );
- Console::Write( "Enter ID with which to write an event(eg: 0-65535): " );
- myEventID = Console::ReadLine();
- myID = Convert::ToInt32( myEventID );
-
- //
- // Check whether source exist in event log.
- if ( !EventLog::SourceExists( mySource ) )
- {
-
- // Create a new source in a specified log on a system.
- EventLog::CreateEventSource( mySource, myLog );
- }
-
- // Create an event log instance.* myEventLog = new EventLog(myLog);
- // Initialize source property of obtained instance.
- myEventLog->Source = mySource;
- switch ( myIntLog )
- {
- case 1:
-
- // Write an 'Error' entry in specified log of event log.
- myEventLog->WriteEntry( myMessage, EventLogEntryType::Error, myID );
- break;
-
- case 2:
-
- // Write a 'Warning' entry in specified log of event log.
- myEventLog->WriteEntry( myMessage, EventLogEntryType::Warning, myID );
- break;
-
- case 3:
-
- // Write an 'Information' entry in specified log of event log.
- myEventLog->WriteEntry( myMessage, EventLogEntryType::Information, myID );
- break;
-
- case 4:
-
- // Write a 'FailureAudit' entry in specified log of event log.
- myEventLog->WriteEntry( myMessage, EventLogEntryType::FailureAudit, myID );
- break;
-
- case 5:
-
- // Write a 'SuccessAudit' entry in specified log of event log.
- myEventLog->WriteEntry( myMessage, EventLogEntryType::SuccessAudit, myID );
- break;
-
- default:
- Console::WriteLine( "Error: Failed to create an event in event log." );
- break;
- }
- Console::WriteLine( "A new event in log '{0}' with ID '{1}' is successfully written into event log.", myEventLog->Log, myID );
-
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}", e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp
deleted file mode 100644
index 6cb7dbb7107..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// System::Diagnostics::EventLogEntryCollection
-// System::Diagnostics::EventLogEntryCollection::CopyTo(EventLogEntry->Item[],int)
-
-/*
-The following example demonstrates the EventLogEntryCollection class and the
-CopyTo method of EventLogEntryCollection class. A new Source for eventlog 'MyNewLog'
-is created. A new entry is created for 'MyNewLog'. The entries of EventLog are copied
-to an Array.
-*/
-
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Diagnostics;
-int main()
-{
- try
- {
- String^ myLogName = "MyNewLog";
-
- // Check if the source exists.
- if ( !EventLog::SourceExists( "MySource" ) )
- {
- //Create source.
- EventLog::CreateEventSource( "MySource", myLogName );
- Console::WriteLine( "Creating EventSource" );
- }
- else
- myLogName = EventLog::LogNameFromSourceName( "MySource", "." );
-
- // Get the EventLog associated if the source exists.
- // Create an EventLog instance and assign its source.
- EventLog^ myEventLog2 = gcnew EventLog;
- myEventLog2->Source = "MySource";
-
- // Write an informational entry to the event log.
- myEventLog2->WriteEntry( "Successfully created a new Entry in the Log" );
- myEventLog2->Close();
-
- // Create a new EventLog Object*.
- EventLog^ myEventLog1 = gcnew EventLog;
- myEventLog1->Log = myLogName;
-
- // Obtain the Log Entries of S"MyNewLog".
- EventLogEntryCollection^ myEventLogEntryCollection = myEventLog1->Entries;
- myEventLog1->Close();
- Console::WriteLine( "The number of entries in 'MyNewLog' = {0}", myEventLogEntryCollection->Count );
-
- // Display the 'Message' property of EventLogEntry.
- for ( int i = 0; i < myEventLogEntryCollection->Count; i++ )
- {
- Console::WriteLine( "The Message of the EventLog is : {0}", myEventLogEntryCollection[ i ]->Message );
- }
-
- // Copy the EventLog entries to Array of type EventLogEntry.
- array^myEventLogEntryArray = gcnew array(myEventLogEntryCollection->Count);
- myEventLogEntryCollection->CopyTo( myEventLogEntryArray, 0 );
- IEnumerator^ myEnumerator = myEventLogEntryArray->GetEnumerator();
- while ( myEnumerator->MoveNext() )
- {
- EventLogEntry^ myEventLogEntry = safe_cast(myEnumerator->Current);
- Console::WriteLine( "The LocalTime the Event is generated is {0}", myEventLogEntry->TimeGenerated );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}", e->Message );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp
deleted file mode 100644
index 60cc220d29d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-// System::Diagnostics::EventLogEntryCollection->Count
-// System::Diagnostics::EventLogEntryCollection::Item
-
-/*
-The following example demonstrates 'Item','Count' properties of
-EventLogEntryCollection class. A new Source for eventlog 'MyNewLog' is created.
-The program checks if a Event source exists. If the source already exists, it gets
-the Log name associated with it otherwise, creates a new event source.
-A new entry is created for 'MyNewLog'.Entries of 'MyNewLog' are obtained and
-the count and the messages are displayed.
-
-*/
-
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Diagnostics;
-
-void main()
-{
- try
- {
- String^ myLogName = "MyNewLog";
-
- // Check if the source exists.
- if ( !EventLog::SourceExists( "MySource" ) )
- {
-
- //Create source.
- EventLog::CreateEventSource( "MySource", myLogName );
- Console::WriteLine( "Creating EventSource" );
- }
- else
- myLogName = EventLog::LogNameFromSourceName( "MySource", "." );
-
- // Get the EventLog associated if the source exists.
- // Create an EventLog instance and assign its source.
- EventLog^ myEventLog2 = gcnew EventLog;
- myEventLog2->Source = "MySource";
-
- //Write an entry to the event log.
- myEventLog2->WriteEntry( "Successfully created a new Entry in the Log. " );
-
- //
- //
- // Create a new EventLog object.
- EventLog^ myEventLog1 = gcnew EventLog;
- myEventLog1->Log = myLogName;
-
- // Obtain the Log Entries of the Event Log
- EventLogEntryCollection^ myEventLogEntryCollection = myEventLog1->Entries;
- Console::WriteLine( "The number of entries in 'MyNewLog' = {0}", myEventLogEntryCollection->Count );
-
- // Display the 'Message' property of EventLogEntry.
- for ( int i = 0; i < myEventLogEntryCollection->Count; i++ )
- {
- Console::WriteLine( "The Message of the EventLog is : {0}", myEventLogEntryCollection[ i ]->Message );
- }
- //
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception Caught! {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp
deleted file mode 100644
index 2c9c0d22442..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-// System::Diagnostics::EventLogEntry::EntryType
-// System::Diagnostics::EventLogEntry::Source
-
-/*
-The following example demonstrates the properties 'EntryType' and 'Source'
-of the class 'EventLogEntry'.
-A new instance of 'EventLog' class is created and is associated to existing
-System Log file of local machine. User selects the event type and the latest
-entry in the log file of that type and it's source is displayed.
-*/
-
-//
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- String^ myEventType = nullptr;
-
- // Associate the instance of 'EventLog' with local System Log.
- EventLog^ myEventLog = gcnew EventLog( "System","." );
- Console::WriteLine( "1:Error" );
- Console::WriteLine( "2:Information" );
- Console::WriteLine( "3:Warning" );
- Console::WriteLine( "Select the Event Type" );
- int myOption = Convert::ToInt32( Console::ReadLine() );
- switch ( myOption )
- {
- case 1:
- myEventType = "Error";
- break;
-
- case 2:
- myEventType = "Information";
- break;
-
- case 3:
- myEventType = "Warning";
- break;
-
- default:
- break;
- }
- EventLogEntryCollection^ myLogEntryCollection = myEventLog->Entries;
- int myCount = myLogEntryCollection->Count;
-
- // Iterate through all 'EventLogEntry' instances in 'EventLog'.
- for ( int i = myCount - 1; i > -1; i-- )
- {
- EventLogEntry^ myLogEntry = myLogEntryCollection[ i ];
-
- // Select the entry having desired EventType.
- if ( myLogEntry->EntryType.Equals( myEventType ) )
- {
- // Display Source of the event.
- Console::WriteLine( "{0} was the source of last event of type {1}", myLogEntry->Source, myLogEntry->EntryType );
- return 0;
- }
- }
-}
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp
deleted file mode 100644
index 24f99e2bd0d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// System.Diagnostics.EventLogInstaller
-
-// The following example demonstrates the EventLogInstaller class.
-// It defines the instance MyEventLogInstaller with the
-// attribute RunInstallerAttribute.
-//
-// The Log and Source properties of the new instance are set,
-// and the instance is added to the Installers collection.
-//
-// Note:
-// 1) Run this program using the following command:
-// InstallUtil.exe
-// 2) Uninstall the event log created in step 1 using the
-// following command:
-// InstallUtil.exe /u
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Configuration::Install;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-
-[RunInstaller(true)]
-ref class MyEventLogInstaller: public Installer
-{
-private:
- EventLogInstaller^ myEventLogInstaller;
-
-public:
- MyEventLogInstaller()
- {
- // Create an instance of an EventLogInstaller.
- myEventLogInstaller = gcnew EventLogInstaller;
-
- // Set the source name of the event log.
- myEventLogInstaller->Source = "NewLogSource";
-
- // Set the event log that the source writes entries to.
- myEventLogInstaller->Log = "MyNewLog";
-
- // Add myEventLogInstaller to the Installer collection.
- Installers->Add( myEventLogInstaller );
- }
-};
-//
-
-void main(){}
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp
deleted file mode 100644
index f89e23b187c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Globalization;
-using namespace System::IO;
-using namespace System::Data;
-using namespace System::Diagnostics;
-using namespace Microsoft::Win32;
-void GetNewOverflowSetting( OverflowAction * newOverflow, interior_ptr numDays );
-void DisplayEventLogProperties();
-void ChangeEventLogOverflowAction( String^ logName );
-
-/// The main entry point for the sample application.
-
-[STAThread]
-int main()
-{
- DisplayEventLogProperties();
- Console::WriteLine();
- Console::WriteLine( "Enter the name of an event log to change the" );
- Console::WriteLine( "overflow policy (or press Enter to exit): " );
- String^ input = Console::ReadLine();
- if ( !String::IsNullOrEmpty( input ) )
- {
- ChangeEventLogOverflowAction( input );
- }
-}
-
-
-// Prompt the user for the overflow policy setting.
-void GetNewOverflowSetting( OverflowAction * newOverflow, interior_ptr numDays )
-{
- Console::Write( "Enter the new overflow policy setting [" );
- Console::Write( " OverwriteOlder," );
- Console::Write( " DoNotOverwrite," );
- Console::Write( " OverwriteAsNeeded" );
- Console::WriteLine( "] : " );
- String^ input = Console::ReadLine();
- if ( !String::IsNullOrEmpty( input ) )
- {
- String^ INPUT = input->Trim()->ToUpper( CultureInfo::InvariantCulture );
- if ( INPUT->Equals( "OVERWRITEOLDER" ) )
- {
- *newOverflow = OverflowAction::OverwriteOlder;
- Console::WriteLine( "Enter the number of days to retain events: " );
- input = Console::ReadLine();
-
- if ( ( !Int32::TryParse( input, *numDays )) || ( *numDays == 0) )
- {
- Console::WriteLine( " Invalid input, defaulting to 7 days." );
- *numDays = 7;
- }
- }
- else
- if ( INPUT->Equals( "DONOTOVERWRITE" ) )
- {
- *newOverflow = OverflowAction::DoNotOverwrite;
- }
- else
- if ( INPUT->Equals( "OVERWRITEASNEEDED" ) )
- {
- *newOverflow = OverflowAction::OverwriteAsNeeded;
- }
- else
- Console::WriteLine( "Unrecognized overflow policy." );
- }
-
- Console::WriteLine();
-}
-
-
-//
-void DisplayEventLogProperties()
-{
-
- // Iterate through the current set of event log files,
- // displaying the property settings for each file.
- array^eventLogs = EventLog::GetEventLogs();
- System::Collections::IEnumerator^ myEnum = eventLogs->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- EventLog^ e = safe_cast(myEnum->Current);
- Int64 sizeKB = 0;
- Console::WriteLine();
- Console::WriteLine( "{0}:", e->LogDisplayName );
- Console::WriteLine( " Log name = \t\t {0}", e->Log );
- Console::WriteLine( " Number of event log entries = {0}", e->Entries->Count );
-
- // Determine if there is a file for this event log.
- RegistryKey ^ regEventLog = Registry::LocalMachine->OpenSubKey( String::Format( "System\\CurrentControlSet\\Services\\EventLog\\{0}", e->Log ) );
- if ( regEventLog )
- {
- Object^ temp = regEventLog->GetValue( "File" );
- if ( temp != nullptr )
- {
- Console::WriteLine( " Log file path = \t {0}", temp );
- FileInfo^ file = gcnew FileInfo( temp->ToString() );
-
- // Get the current size of the event log file.
- if ( file->Exists )
- {
- sizeKB = file->Length / 1024;
- if ( (file->Length % 1024) != 0 )
- {
- sizeKB++;
- }
- Console::WriteLine( " Current size = \t {0} kilobytes", sizeKB );
- }
- }
- else
- {
- Console::WriteLine( " Log file path = \t " );
- }
- }
-
- // Display the maximum size and overflow settings.
- sizeKB = e->MaximumKilobytes;
- Console::WriteLine( " Maximum size = \t {0} kilobytes", sizeKB );
- Console::WriteLine( " Overflow setting = \t {0}", e->OverflowAction );
- switch ( e->OverflowAction )
- {
- case OverflowAction::OverwriteOlder:
- Console::WriteLine( "\t Entries are retained a minimum of {0} days.", e->MinimumRetentionDays );
- break;
-
- case OverflowAction::DoNotOverwrite:
- Console::WriteLine( "\t Older entries are not overwritten." );
- break;
-
- case OverflowAction::OverwriteAsNeeded:
- Console::WriteLine( "\t If number of entries equals max size limit, a new event log entry overwrites the oldest entry." );
- break;
-
- default:
- break;
- }
- }
-}
-
-
-//
-//
-// Display the current event log overflow settings, and
-// prompt the user to input a new overflow setting.
-void ChangeEventLogOverflowAction( String^ logName )
-{
- if ( EventLog::Exists( logName ) )
- {
-
- // Display the current overflow setting of the
- // specified event log.
- EventLog^ inputLog = gcnew EventLog( logName );
- Console::WriteLine( " Event log {0}", inputLog->Log );
- OverflowAction logOverflow = inputLog->OverflowAction;
- Int32 numDays = inputLog->MinimumRetentionDays;
- Console::WriteLine( " Current overflow setting = {0}", logOverflow );
- if ( logOverflow == OverflowAction::OverwriteOlder )
- {
- Console::WriteLine( "\t Entries are retained a minimum of {0} days.", numDays );
- }
-
- // Prompt user for a new overflow setting.
- GetNewOverflowSetting( &logOverflow, &numDays );
-
- // Change the overflow setting on the event log.
- if ( logOverflow != inputLog->OverflowAction )
- {
- inputLog->ModifyOverflowPolicy( logOverflow, numDays );
- Console::WriteLine( "Event log overflow policy was modified successfully!" );
- }
- else
- {
- Console::WriteLine( "Event log overflow policy was not modified." );
- }
- }
- else
- {
- Console::WriteLine( "Event log {0} was not found.", logName );
- }
-}
-
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp
deleted file mode 100644
index f61b7647435..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Diagnostics;
-
-[STAThread]
-int main()
-{
- array^args = Environment::GetCommandLineArgs();
-
- //
- EventSourceCreationData ^ mySourceData = gcnew EventSourceCreationData( "","" );
- bool registerSource = true;
-
- // Process input parameters.
- if ( args->Length > 1 )
- {
-
- // Require at least the source name.
- mySourceData->Source = args[ 1 ];
- if ( args->Length > 2 )
- {
- mySourceData->LogName = args[ 2 ];
- }
-
- if ( args->Length > 3 )
- {
- mySourceData->MachineName = args[ 3 ];
- }
-
- if ( (args->Length > 4) && (args[ 4 ]->Length > 0) )
- {
- mySourceData->MessageResourceFile = args[ 4 ];
- }
- }
- else
- {
-
- // Display a syntax help message.
- Console::WriteLine( "Input:" );
- Console::WriteLine( " source [event log] [machine name] [resource file]" );
- registerSource = false;
- }
-
-
- // Set defaults for parameters missing input.
- if ( mySourceData->MachineName->Length == 0 )
- {
-
- // Default to the local computer.
- mySourceData->MachineName = ".";
- }
-
- if ( mySourceData->LogName->Length == 0 )
- {
-
- // Default to the Application log.
- mySourceData->LogName = "Application";
- }
-
-
- //
- // Determine if the source exists on the specified computer.
- if ( !EventLog::SourceExists( mySourceData->Source, mySourceData->MachineName ) )
- {
-
- // The source does not exist.
- // Verify that the message file exists
- // and the event log is local.
- if ( (mySourceData->MessageResourceFile != nullptr) && (mySourceData->MessageResourceFile->Length > 0) )
- {
- if ( mySourceData->MachineName->Equals( "." ) )
- {
- if ( !System::IO::File::Exists( mySourceData->MessageResourceFile ) )
- {
- Console::WriteLine( "File {0} not found - message file not set for source.", mySourceData->MessageResourceFile );
- registerSource = false;
- }
- }
- else
- {
-
- // For simplicity, do not allow setting the message
- // file for a remote event log. To set the message
- // for a remote event log, and for source registration,
- // the file path should be specified with system-wide
- // environment variables that are valid on the remote
- // computer, such as
- // "%SystemRoot%\system32\myresource.dll".
- Console::WriteLine( "Message resource file ignored for remote event log." );
- registerSource = false;
- }
- }
- }
- else
- {
-
- // Do not register the source, it already exists.
- registerSource = false;
-
- // Get the event log corresponding to the existing source.
- String^ sourceLog;
- sourceLog = EventLog::LogNameFromSourceName( mySourceData->Source, mySourceData->MachineName );
-
- // Determine if the event source is registered for the
- // specified log.
- if ( sourceLog->ToUpper( CultureInfo::InvariantCulture ) != mySourceData->LogName->ToUpper( CultureInfo::InvariantCulture ) )
- {
-
- // An existing source is registered
- // to write to a different event log.
- Console::WriteLine( "Warning: source {0} is already registered to write to event log {1}", mySourceData->Source, sourceLog );
- }
- else
- {
-
- // The source is already registered
- // to write to the specified event log.
- Console::WriteLine( "Source {0} already registered to write to event log {1}", mySourceData->Source, sourceLog );
- }
- }
-
- if ( registerSource )
- {
-
- // Register the new event source for the specified event log.
- Console::WriteLine( "Registering new source {0} for event log {1}.", mySourceData->Source, mySourceData->LogName );
- EventLog::CreateEventSource( mySourceData );
- Console::WriteLine( "Event source was registered successfully!" );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp
deleted file mode 100644
index 07109b189ca..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-// System::Diagnostics::EventLog::Exists(String)
-/*
-The following sample demonstrates the 'Exists(String)'method of
-'EventLog' class. It checks for the existence of a log and displays
-the result accordingly.
-*/
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void main()
-{
- try
- {
-
- //
- String^ myLog = "myNewLog";
- if ( EventLog::Exists( myLog ) )
- {
- Console::WriteLine( "Log '{0}' exists.", myLog );
- }
- else
- {
- Console::WriteLine( "Log '{0}' does not exist.", myLog );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception: {0}", e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp
deleted file mode 100644
index 663444e9b51..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// System::Diagnostics::EventLog::WriteEntry(String, String, EventLogEntryType, Int32, Int16)
-// System::Diagnostics::EventLog::WriteEntry(String, String, EventLogEntryType, Int32, Int16, Byte->Item[])
-// System::Diagnostics::EventLog::EventLog.WriteEntry(String, EventLogEntryType, Int32, Int16)
-
-/* The following example demonstrates the method
-'WriteEntry(String, String, EventLogEntryType, Int32, Int16)',
-'WriteEntry(String, String, EventLogEntryType, Int32, Int16, Byte->Item[]) '
-and 'WriteEntry(String, EventLogEntryType, Int32, Int16)' of class
-'EventLog'. The following example writes the information to an event log.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- //
- int myEventID = 20;
- short myCategory = 10;
-
- // Write an informational entry to the event log.
- Console::WriteLine( "Write from first source " );
- EventLog::WriteEntry( "FirstSource", "Writing warning to event log.",
- EventLogEntryType::Information, myEventID, myCategory );
- //
-
- //
- //Create a byte array for binary data to associate with the entry.
- array^myByte = gcnew array(10);
- //Populate the byte array with simulated data.
- for ( int i = 0; i < 10; i++ )
- {
- myByte[ i ] = (Byte)(i % 2);
- }
- //Write an entry to the event log that includes associated binary data.
- Console::WriteLine( "Write from second source " );
- EventLog::WriteEntry( "SecondSource", "Writing warning to event log.",
- EventLogEntryType::Error, myEventID, myCategory, myByte );
- //
-
- //
- // Create an EventLog instance and assign its source.
- EventLog^ myLog = gcnew EventLog;
- myLog->Source = "ThirdSource";
-
- // Write an informational entry to the event log.
- Console::WriteLine( "Write from third source " );
- myLog->WriteEntry( "Writing warning to event log.",
- EventLogEntryType::Warning, myEventID, myCategory );
- //
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp
deleted file mode 100644
index 5d40a7c71c9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// System::Diagnostics::EventLog::WriteEntry(String,String,EventLogEntryType,Int32)
-
-/*
-The following sample demonstrates the
-'WriteEntry(String,String,EventLogEntryType,Int32)' method of
-'EventLog' class. It writes an entry to a custom event log, S"MyNewLog".
-It creates the source S"MySource" if the source does not already exist.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- try
- {
-//
- // Create the source, if it does not already exist.
- if ( !EventLog::SourceExists( "MySource" ) )
- {
- EventLog::CreateEventSource( "MySource", "myNewLog" );
- Console::WriteLine( "Creating EventSource" );
- }
-
- // Set the 'description' for the event.
- String^ myMessage = "This is my event.";
- EventLogEntryType myEventLogEntryType = EventLogEntryType::Warning;
- int myApplicationEventId = 100;
-
- // Write the entry in the event log.
- Console::WriteLine( "Writing to EventLog.. " );
- EventLog::WriteEntry( "MySource", myMessage,
- myEventLogEntryType, myApplicationEventId );
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception:{0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp
deleted file mode 100644
index 4771b4f0eb5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// System::Diagnostics::EventLog::WriteEntry(String, EventLogEntryType, Int32, Int16, Byte[])
-
-/*
-The following sample demonstrates the
-'WriteEntry(String, EventLogEntryType, Int32, Int16, Byte->Item[])' method of
-'EventLog' class. It writes an entry to a custom event log, S"MyLog".
-It creates the source S"MySource" if the source does not already exist.
-It creates an 'EventLog' Object* and calls 'WriteEntry' passing the
-description, Log entry type, application specific identifier for the event,
-application specific subcategory and data to be associated with the entry.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- try
- {
-//
- // Create the source, if it does not already exist.
- String^ myLogName = "myNewLog";
- if ( !EventLog::SourceExists( "MySource" ) )
- {
- EventLog::CreateEventSource( "MySource", myLogName );
- Console::WriteLine( "Creating EventSource" );
- }
- else
- myLogName = EventLog::LogNameFromSourceName( "MySource", "." );
-
- // Create an EventLog and assign source.
- EventLog^ myEventLog = gcnew EventLog;
- myEventLog->Source = "MySource";
- myEventLog->Log = myLogName;
-
- // Set the 'description' for the event.
- String^ myMessage = "This is my event.";
- EventLogEntryType myEventLogEntryType = EventLogEntryType::Warning;
- int myApplicatinEventId = 1100;
- short myApplicatinCategoryId = 1;
-
- // Set the 'data' for the event.
- array^ myRawData = gcnew array(4);
- for ( int i = 0; i < 4; i++ )
- {
- myRawData[ i ] = 1;
- }
- Console::WriteLine( "Writing to EventLog.. " );
- myEventLog->WriteEntry( myMessage, myEventLogEntryType, myApplicatinEventId, myApplicatinCategoryId, myRawData );
-//
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception:{0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp
deleted file mode 100644
index f18b6e52fe0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- FileInfo^ fi = gcnew FileInfo( "c:\\MyTest.txt" );
-
- // This text is added only once to the file.
- if ( !fi->Exists )
- {
- //Create a file to write to.
- StreamWriter^ sw = fi->CreateText();
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
- }
-
- // This text will always be added, making the file longer over time
- // if it is not deleted.
- StreamWriter^ sw = fi->AppendText();
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is Extra" );
- sw->WriteLine( "Text" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
-
- //Open the file to read from.
- StreamReader^ sr = fi->OpenText();
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//Hello
-//And
-//Welcome
-//This
-//is Extra
-//Text
-//
-//When you run this application a second time, you will see the following output:
-//
-//Hello
-//And
-//Welcome
-//This
-//is Extra
-//Text
-//This
-//is Extra
-//Text
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp
deleted file mode 100644
index cd1f26bb6ef..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = Path::GetTempFileName();
- FileInfo^ fi1 = gcnew FileInfo( path );
- //Create a file to write to.
- StreamWriter^ sw = fi1->CreateText();
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
-
- //Open the file to read from.
- StreamReader^ sr = fi1->OpenText();
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-
- try
- {
- String^ path2 = Path::GetTempFileName();
- FileInfo^ fi2 = gcnew FileInfo( path2 );
-
- //Ensure that the target does not exist.
- fi2->Delete();
-
- //Copy the file.
- fi1->CopyTo( path2 );
- Console::WriteLine( "{0} was copied to {1}.", path, path2 );
-
- //Delete the newly created file.
- fi2->Delete();
- Console::WriteLine( "{0} was successfully deleted.", path2 );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp
deleted file mode 100644
index 457a43483a3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- String^ path2 = "c:\\MyTest.txttemp";
- FileInfo^ fi1 = gcnew FileInfo( path );
- FileInfo^ fi2 = gcnew FileInfo( path2 );
- try
- {
- // Create the file and clean up handles.
- FileStream^ fs = fi1->Create();
- if ( fs )
- delete (IDisposable^)fs;
-
- //Ensure that the target does not exist.
- fi2->Delete();
-
- //Copy the file.
- fi1->CopyTo( path2 );
- Console::WriteLine( "{0} was copied to {1}.", path, path2 );
-
- //Try to copy it again, which should succeed.
- fi1->CopyTo( path2, true );
- Console::WriteLine( "The second Copy operation succeeded, which is expected." );
- }
- catch ( Exception^ )
- {
- Console::WriteLine( "Double copying was not allowed, which is not expected." );
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//The second Copy operation succeeded, which is expected.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp
deleted file mode 100644
index 8533b4ee458..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi = gcnew FileInfo( path );
-
- // Delete the file if it exists.
- if ( fi->Exists )
- {
- fi->Delete();
- }
-
- //Create the file.
- FileStream^ fs = fi->Create();
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- //Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-
- //Open the stream and read it back.
- StreamReader^ sr = fi->OpenText();
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is some text in the file.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp
deleted file mode 100644
index eecfff022ed..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi = gcnew FileInfo( path );
- if ( !fi->Exists )
- {
- //Create a file to write to.
- StreamWriter^ sw = fi->CreateText();
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
- }
-
- //Open the file to read from.
- StreamReader^ sr = fi->OpenText();
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//Hello
-//And
-//Welcome
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp
deleted file mode 100644
index d0901ff161a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi1 = gcnew FileInfo( path );
- if ( !fi1->Exists )
- {
- //Create a file to write to.
- StreamWriter^ sw = fi1->CreateText();
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
- }
-
- //Open the file to read from.
- StreamReader^ sr = fi1->OpenText();
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-
- try
- {
- String^ path2 = String::Concat( path, "temp" );
- FileInfo^ fi2 = gcnew FileInfo( path2 );
-
- //Ensure that the target does not exist.
- fi2->Delete();
-
- //Copy the file.
- fi1->CopyTo( path2 );
- Console::WriteLine( "{0} was copied to {1}.", path, path2 );
-
- //Delete the newly created file.
- fi2->Delete();
- Console::WriteLine( "{0} was successfully deleted.", path2 );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//Hello
-//And
-//Welcome
-//c:\MyTest.txt was copied to c:\MyTest.txttemp.
-//c:\MyTest.txttemp was successfully deleted.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp
deleted file mode 100644
index c219e088f8c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi1 = gcnew FileInfo( path );
- try
- {
- StreamWriter^ sw = fi1->CreateText();
- if ( sw )
- delete (IDisposable^)sw;
-
- String^ path2 = String::Concat( path, "temp" );
- FileInfo^ fi2 = gcnew FileInfo( path2 );
-
- //Ensure that the target does not exist.
- fi2->Delete();
-
- //Copy the file.
- fi1->CopyTo( path2 );
- Console::WriteLine( "{0} was copied to {1}.", path, path2 );
-
- //Delete the newly created file.
- fi2->Delete();
- Console::WriteLine( "{0} was successfully deleted.", path2 );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//c:\MyTest.txt was copied to c:\MyTest.txttemp.
-//c:\MyTest.txttemp was successfully deleted.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp
deleted file mode 100644
index 052607a8faf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi = gcnew FileInfo( path );
-
- // Delete the file if it exists.
- if ( !fi->Exists )
- {
- //Create the file.
- FileStream^ fs = fi->Create();
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- //Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- //Open the stream and read it back.
- FileStream^ fs = fi->Open( FileMode::Open );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is some text in the file.
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp
deleted file mode 100644
index 7996e15f1cf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi = gcnew FileInfo( path );
-
- // Delete the file if it exists.
- if ( !fi->Exists )
- {
-
- //Create the file.
- FileStream^ fs = fi->Create();
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- //Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- //Open the stream and read it back.
- FileStream^ fs = fi->Open( FileMode::Open, FileAccess::Read );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- try
- {
- //Try to write to the file.
- fs->Write( b, 0, b->Length );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Writing was disallowed, as expected: {0}", e );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is some text in the file.
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//Writing was disallowed, as expected: System.NotSupportedException: Stream does
-//not support writing.
-// at System.IO.__Error.WriteNotSupported()
-// at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count)
-// at main() in c:\documents and settings\MyComputer\my documents\
-//visual studio 2005\projects\finfo open2\finfo open2\
-//cpp_console_application.cpp:line 46
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp
deleted file mode 100644
index f81348f3afa..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\MyTest.txt";
- FileInfo^ fi = gcnew FileInfo( path );
-
- // Delete the file if it exists.
- if ( !fi->Exists )
- {
- //Create the file.
- FileStream^ fs = fi->Create();
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- //Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- //Open the stream and read it back.
- FileStream^ fs = fi->OpenRead();
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is some text in the file.
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp
deleted file mode 100644
index 3868e7e68fb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-public ref class OpenTextTest
-{
-public:
- static void Main()
- {
- String^ path = "c:\\MyTest.txt";
-
- FileInfo^ fi = gcnew FileInfo(path);
-
- // Check for existing file
- if (!fi->Exists)
- {
- // Create the file.
- FileStream^ fs = fi->Create();
- array^ info =
- (gcnew UTF8Encoding(true))->GetBytes("This is some text in the file.");
-
- // Add some information to the file.
- fs->Write(info, 0, info->Length);
- fs->Close();
- }
-
- // Open the stream and read it back.
- StreamReader^ sr = fi->OpenText();
- String^ s = "";
- while ((s = sr->ReadLine()) != nullptr)
- {
- Console::WriteLine(s);
- }
- }
-};
-
-int main()
-{
- OpenTextTest::Main();
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is some text in the file.
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp
deleted file mode 100644
index e4a0ca98bdb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\Temp\\MyTest.txt";
- FileInfo^ fi = gcnew FileInfo( path );
-
- // Open the stream for writing.
- {
- FileStream^ fs = fi->OpenWrite();
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is to test the OpenWrite method." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- // Open the stream and read it back.
- {
- FileStream^ fs = fi->OpenRead();
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is to test the OpenWrite method.
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FStream CanSeek/CPP/fstream canseek.cpp b/snippets/cpp/VS_Snippets_CLR/FStream CanSeek/CPP/fstream canseek.cpp
deleted file mode 100644
index e79c45b3672..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FStream CanSeek/CPP/fstream canseek.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Delete the file if it exists.
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
-
- //Create the file.
- FileStream^ fs = File::Create( path );
- try
- {
- if ( fs->CanSeek )
- {
- Console::WriteLine( "The stream connected to {0} is seekable.", path );
- }
- else
- {
- Console::WriteLine( "The stream connected to {0} is not seekable.", path );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FStream CanWrite/CPP/fstream canwrite.cpp b/snippets/cpp/VS_Snippets_CLR/FStream CanWrite/CPP/fstream canwrite.cpp
deleted file mode 100644
index 7dd44acda66..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FStream CanWrite/CPP/fstream canwrite.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Ensure that the file is readonly.
- File::SetAttributes( path, static_cast(File::GetAttributes( path ) | FileAttributes::ReadOnly) );
-
- //Create the file.
- FileStream^ fs = gcnew FileStream( path,FileMode::OpenOrCreate,FileAccess::Read );
- try
- {
- if ( fs->CanWrite )
- {
- Console::WriteLine( "The stream for file {0} is writable.", path );
- }
- else
- {
- Console::WriteLine( "The stream for file {0} is not writable.", path );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp b/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp
deleted file mode 100644
index cc2e6916562..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-void AddText( FileStream^ fs, String^ value )
-{
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( value );
- fs->Write( info, 0, info->Length );
-}
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Delete the file if it exists.
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
-
- //Create the file.
- {
- FileStream^ fs = File::Create( path );
- try
- {
- AddText( fs, "This is some text" );
- AddText( fs, "This is some more text," );
- AddText( fs, "\r\nand this is on a new line" );
- AddText( fs, "\r\n\r\nThe following is a subset of characters:\r\n" );
- for ( int i = 1; i < 120; i++ )
- {
- AddText( fs, Convert::ToChar( i ).ToString() );
-
- //Split the output at every 10th character.
- if ( Math::IEEERemainder( Convert::ToDouble( i ), 10 ) == 0 )
- {
- AddText( fs, "\r\n" );
- }
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- //Open the stream and read it back.
- {
- FileStream^ fs = File::OpenRead( path );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp b/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp
deleted file mode 100644
index 1f0ebf4662f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- if ( !File::Exists( path ) )
- {
-
- // Create a file to write to.
- StreamWriter^ sw = File::CreateText( path );
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)(sw);
- }
- }
-
- // Open the file to read from.
- StreamReader^ sr = File::OpenText( path );
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)(sr);
- }
-
- try
- {
- String^ path2 = String::Concat( path, "temp" );
-
- // Ensure that the target does not exist.
- File::Delete( path2 );
-
- // Copy the file.
- File::Copy( path, path2 );
- Console::WriteLine( "{0} was copied to {1}.", path, path2 );
-
- // Delete the newly created file.
- File::Delete( path2 );
- Console::WriteLine( "{0} was successfully deleted.", path2 );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp b/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp
deleted file mode 100644
index 9c511bd99e5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Create the file, or overwrite if the file exists.
- FileStream^ fs = File::Create( path );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-
- // Open the stream and read it back.
- StreamReader^ sr = File::OpenText( path );
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp b/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp
deleted file mode 100644
index e79d7bdd9ac..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Create the file, or overwrite if the file exists.
- FileStream^ fs = File::Create( path, 1024 );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-
- // Open the stream and read it back.
- StreamReader^ sr = File::OpenText( path );
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp b/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp
deleted file mode 100644
index e93de3ce721..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- if ( !File::Exists( path ) )
- {
-
- // Create a file to write to.
- StreamWriter^ sw = File::CreateText( path );
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
- }
-
- // Open the file to read from.
- StreamReader^ sr = File::OpenText( path );
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp b/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp
deleted file mode 100644
index 502539dd149..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Create the file if it does not exist.
- if ( !File::Exists( path ) )
- {
- File::Create( path );
- }
-
- if ( (File::GetAttributes( path ) & FileAttributes::Hidden) == FileAttributes::Hidden )
- {
-
- // Show the file.
- File::SetAttributes(path, File::GetAttributes( path ) & ~FileAttributes::Hidden);
- Console::WriteLine( "The {0} file is no longer hidden.", path );
- }
- else
- {
-
- // Hide the file.
- File::SetAttributes( path, static_cast(File::GetAttributes( path ) | FileAttributes::Hidden) );
- Console::WriteLine( "The {0} file is now hidden.", path );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp
deleted file mode 100644
index 80e27831de7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\Temp\\MyTest.txt";
- if ( !File::Exists( path ) )
- {
- File::Create( path );
- }
- File::SetLastAccessTime( path, DateTime(1985,5,4) );
-
- // Get the creation time of a well-known directory.
- DateTime dt = File::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this file was {0}.", dt );
-
- // Update the last access time.
- File::SetLastAccessTime( path, DateTime::Now );
- dt = File::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this file was {0}.", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp
deleted file mode 100644
index 8b796882ead..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\Temp\\MyTest.txt";
- if ( !File::Exists( path ) )
- {
- File::Create( path );
- }
- else
- {
-
- // Take an action that will affect the write time.
- File::SetLastWriteTime( path, DateTime(1985,4,3) );
- }
-
- // Get the creation time of a well-known directory.
- DateTime dt = File::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this file was {0}.", dt );
-
- // Update the last write time.
- File::SetLastWriteTime( path, DateTime::Now );
- dt = File::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this file was {0}.", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp b/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp
deleted file mode 100644
index 38bf0f2cab3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- String^ path2 = "c:\\temp2\\MyTest.txt";
- try
- {
- if ( !File::Exists( path ) )
- {
-
- // This statement ensures that the file is created,
- // but the handle is not kept.
- FileStream^ fs = File::Create( path );
- if ( fs )
- delete (IDisposable^)fs;
- }
-
- // Ensure that the target does not exist.
- if ( File::Exists( path2 ) )
- File::Delete( path2 );
-
- // Move the file.
- File::Move( path, path2 );
- Console::WriteLine( "{0} was moved to {1}.", path, path2 );
-
- // See if the original exists now.
- if ( File::Exists( path ) )
- {
- Console::WriteLine( "The original file still exists, which is unexpected." );
- }
- else
- {
- Console::WriteLine( "The original file no longer exists, which is expected." );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp b/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp
deleted file mode 100644
index 1378629c6eb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- // Create a temporary file, and put some data into it.
- String^ path = Path::GetTempFileName();
- FileStream^ fs = File::Open( path, FileMode::Open, FileAccess::Write, FileShare::None );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-
- // Open the stream and read it back.
- fs = File::Open( path, FileMode::Open );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp b/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp
deleted file mode 100644
index 09b89e18c7e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- // This sample assumes that you have a folder named "c:\temp" on your computer.
- String^ filePath = "c:\\temp\\MyTest.txt";
- // Delete the file if it exists.
- if (File::Exists( filePath ))
- {
- File::Delete( filePath );
- }
- // Create the file.
- FileStream^ fs = File::Create( filePath );
- try
- {
- array^ info = ( gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-
- // Open the stream and read it back.
- fs = File::Open( filePath, FileMode::Open, FileAccess::Read );
- try
- {
- array^ b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- try
- {
- // Try to write to the file.
- fs->Write( b, 0, b->Length );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Writing was disallowed, as expected: {0}", e->ToString() );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp b/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp
deleted file mode 100644
index c8b21c2f7d7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Create the file if it does not exist.
- if ( !File::Exists( path ) )
- {
- // Create the file.
- FileStream^ fs = File::Create( path );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- // Open the stream and read it back.
- FileStream^ fs = File::Open( path, FileMode::Open, FileAccess::Read, FileShare::None );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- try
- {
- // Try to get another handle to the same file.
- FileStream^ fs2 = File::Open( path, FileMode::Open );
- try
- {
- // Do some task here.
- }
- finally
- {
- if ( fs2 )
- delete (IDisposable^)fs2;
- }
- }
- catch ( Exception^ e )
- {
- Console::Write( "Opening the file twice is disallowed." );
- Console::WriteLine( ", as expected: {0}", e );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp b/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp
deleted file mode 100644
index d257fe26072..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- if ( !File::Exists( path ) )
- {
- // Create the file.
- FileStream^ fs = File::Create( path );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- // Open the stream and read it back.
- FileStream^ fs = File::OpenRead( path );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp b/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp
deleted file mode 100644
index 8bbd948b4c6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- if ( !File::Exists( path ) )
- {
- // Create the file.
- FileStream^ fs = File::Create( path );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- // Open the stream and read it back.
- StreamReader^ sr = File::OpenText( path );
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp b/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp
deleted file mode 100644
index e08318b7bf6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // Open the stream and write to it.
- {
- FileStream^ fs = File::OpenWrite( path );
- try
- {
- array^info = (gcnew UTF8Encoding( true ))->
- GetBytes( "This is to test the OpenWrite method." );
-
- // Add some information to the file.
- fs->Write( info, 0, info->Length );
- }
- finally
- {
- if ( fs )
- delete (IDisposable^)fs;
- }
- }
-
- // Open the stream and read it back.
- {
- FileStream^ fs = File::OpenRead( path );
- try
- {
- array^b = gcnew array(1024);
- UTF8Encoding^ temp = gcnew UTF8Encoding( true );
- while ( fs->Read( b, 0, b->Length ) > 0 )
- {
- Console::WriteLine( temp->GetString( b ) );
- }
- }
- finally
- {
- if ( fs )
- delete(IDisposable^)fs;
- }
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp
deleted file mode 100644
index 3fe8c6832a2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\Temp\\MyTest.txt";
- if ( !File::Exists( path ) )
- {
- File::Create( path );
-
- // Update the last access time.
- }
- File::SetLastAccessTime( path, DateTime(1985,5,4) );
-
- // Get the creation time of a well-known directory.
- DateTime dt = File::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this file was {0}.", dt );
-
- // Update the last access time.
- File::SetLastAccessTime( path, DateTime::Now );
- dt = File::GetLastAccessTime( path );
- Console::WriteLine( "The last access time for this file was {0}.", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp
deleted file mode 100644
index 8b796882ead..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- String^ path = "c:\\Temp\\MyTest.txt";
- if ( !File::Exists( path ) )
- {
- File::Create( path );
- }
- else
- {
-
- // Take an action that will affect the write time.
- File::SetLastWriteTime( path, DateTime(1985,4,3) );
- }
-
- // Get the creation time of a well-known directory.
- DateTime dt = File::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this file was {0}.", dt );
-
- // Update the last write time.
- File::SetLastWriteTime( path, DateTime::Now );
- dt = File::GetLastWriteTime( path );
- Console::WriteLine( "The last write time for this file was {0}.", dt );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp b/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp
deleted file mode 100644
index f16d9cbcb6e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
-
- // Create a reference to a file, which might or might not exist.
- // If it does not exist, it is not yet created.
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Create a writer, ready to add entries to the file.
- StreamWriter^ sw = fi->AppendText();
- sw->WriteLine( "Add as many lines as you like..." );
- sw->WriteLine( "Add another line to the output..." );
- sw->Flush();
- sw->Close();
-
- // Get the information out of the file and display it.
- StreamReader^ sr = gcnew StreamReader( fi->OpenRead() );
- Console::WriteLine( "This is the information in the first file:" );
- while ( sr->Peek() != -1 )
- Console::WriteLine( sr->ReadLine() );
-
- // Copy this file to another file. The file will not be overwritten if it already exists.
- FileInfo^ newfi = fi->CopyTo( "newTemp.txt" );
-
- // Get the information out of the new file and display it.* sr = new StreamReader(newfi->OpenRead());
- Console::WriteLine( "{0}This is the information in the second file:", Environment::NewLine );
- while ( sr->Peek() != -1 )
- Console::WriteLine( sr->ReadLine() );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is the information in the first file:
-//Add as many lines as you like...
-//Add another line to the output...
-//
-//This is the information in the second file:
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp b/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp
deleted file mode 100644
index 49b2ff55954..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-
-//
-// The following example displays the names and sizes
-// of the files in the specified directory.
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Make a reference to a directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" );
-
- // Get a reference to each file in that directory.
- array^fiArr = di->GetFiles();
-
- // Display the names and sizes of the files.
- Console::WriteLine( "The directory {0} contains the following files:", di->Name );
- System::Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- FileInfo^ f = safe_cast(myEnum->Current);
- Console::WriteLine( "The size of {0} is {1} bytes.", f->Name, f->Length );
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//The directory c:\ contains the following files:
-//The size of MyComputer.log is 274 bytes.
-//The size of AUTOEXEC.BAT is 0 bytes.
-//The size of boot.ini is 211 bytes.
-//The size of CONFIG.SYS is 0 bytes.
-//The size of hiberfil.sys is 1072775168 bytes.
-//The size of IO.SYS is 0 bytes.
-//The size of MASK.txt is 2700 bytes.
-//The size of mfc80.dll is 1093632 bytes.
-//The size of mfc80u.dll is 1079808 bytes.
-//The size of MSDOS.SYS is 0 bytes.
-//The size of NTDETECT.COM is 47564 bytes.
-//The size of ntldr is 250032 bytes.
-//The size of pagefile.sys is 1610612736 bytes.
-//The size of UpdatePatch.log is 22778 bytes.
-//The size of UpdatePatch.txt is 30 bytes.
-//The size of wt3d.ini is 234 bytes.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp
deleted file mode 100644
index c6df18efd4e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-
-namespace ConsoleApplication2
-{
- public ref class Program
- {
- public:
- static void Main()
- {
- // Loop through all the immediate subdirectories of C.
- for each (String^ entry in Directory::GetDirectories("C:\\"))
- {
- DisplayFileSystemInfoAttributes(gcnew DirectoryInfo(entry));
- }
- // Loop through all the files in C.
- for each (String^ entry in Directory::GetFiles("C:\\"))
- {
- DisplayFileSystemInfoAttributes(gcnew FileInfo(entry));
- }
- }
- //
- static void DisplayFileSystemInfoAttributes(FileSystemInfo^ fsi)
- {
- // Assume that this entry is a file.
- String^ entryType = "File";
-
- // Determine if entry is really a directory
- if ((fsi->Attributes & FileAttributes::Directory) == FileAttributes::Directory)
- {
- entryType = "Directory";
- }
- // Show this entry's type, name, and creation date.
- Console::WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi->FullName, fsi->CreationTime);
- }
- //
- };
-};
-
-int main()
-{
- ConsoleApplication2::Program::Main();
-}
-
- // Output will vary based on contents of drive C.
-
- // Directory entry C:\Documents and Settings was created on Tuesday, November 25, 2003
- // Directory entry C:\Inetpub was created on Monday, January 12, 2004
- // Directory entry C:\Program Files was created on Tuesday, November 25, 2003
- // Directory entry C:\RECYCLER was created on Tuesday, November 25, 2003
- // Directory entry C:\System Volume Information was created on Tuesday, November 2, 2003
- // Directory entry C:\WINDOWS was created on Tuesday, November 25, 2003
- // File entry C:\IO.SYS was created on Tuesday, November 25, 2003
- // File entry C:\MSDOS.SYS was created on Tuesday, November 25, 2003
- // File entry C:\pagefile.sys was created on Saturday, December 27, 2003
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp b/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp
deleted file mode 100644
index 33129302fbb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
-
- // This text is added only once to the file.
- if ( !File::Exists( path ) )
- {
- // Create a file to write to.
- StreamWriter^ sw = File::CreateText( path );
- try
- {
- sw->WriteLine( "Hello" );
- sw->WriteLine( "And" );
- sw->WriteLine( "Welcome" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
- }
-
- // This text is always added, making the file longer over time
- // if it is not deleted.
- StreamWriter^ sw = File::AppendText( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is Extra" );
- sw->WriteLine( "Text" );
- }
- finally
- {
- if ( sw )
- delete (IDisposable^)sw;
- }
-
- // Open the file to read from.
- StreamReader^ sr = File::OpenText( path );
- try
- {
- String^ s = "";
- while ( s = sr->ReadLine() )
- {
- Console::WriteLine( s );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp
deleted file mode 100644
index 5c9e28f3fbd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- //
- // Create a new dictionary of strings, with string keys.
- //
- Dictionary^ openWith =
- gcnew Dictionary();
-
- // Add some elements to the dictionary. There are no
- // duplicate keys, but some of the values are duplicates.
- openWith->Add("txt", "notepad.exe");
- openWith->Add("bmp", "paint.exe");
- openWith->Add("dib", "paint.exe");
- openWith->Add("rtf", "wordpad.exe");
-
- // The Add method throws an exception if the new key is
- // already in the dictionary.
- try
- {
- openWith->Add("txt", "winword.exe");
- }
- catch (ArgumentException^)
- {
- Console::WriteLine("An element with Key = \"txt\" already exists.");
- }
- //
-
- //
- // The Item property is another name for the indexer, so you
- // can omit its name when accessing elements.
- Console::WriteLine("For key = \"rtf\", value = {0}.",
- openWith["rtf"]);
-
- // The indexer can be used to change the value associated
- // with a key.
- openWith["rtf"] = "winword.exe";
- Console::WriteLine("For key = \"rtf\", value = {0}.",
- openWith["rtf"]);
-
- // If a key does not exist, setting the indexer for that key
- // adds a new key/value pair.
- openWith["doc"] = "winword.exe";
- //
-
- //
- // The indexer throws an exception if the requested key is
- // not in the dictionary.
- try
- {
- Console::WriteLine("For key = \"tif\", value = {0}.",
- openWith["tif"]);
- }
- catch (KeyNotFoundException^)
- {
- Console::WriteLine("Key = \"tif\" is not found.");
- }
- //
-
- //
- // When a program often has to try keys that turn out not to
- // be in the dictionary, TryGetValue can be a more efficient
- // way to retrieve values.
- String^ value = "";
- if (openWith->TryGetValue("tif", value))
- {
- Console::WriteLine("For key = \"tif\", value = {0}.", value);
- }
- else
- {
- Console::WriteLine("Key = \"tif\" is not found.");
- }
- //
-
- //
- // ContainsKey can be used to test keys before inserting
- // them.
- if (!openWith->ContainsKey("ht"))
- {
- openWith->Add("ht", "hypertrm.exe");
- Console::WriteLine("Value added for key = \"ht\": {0}",
- openWith["ht"]);
- }
- //
-
- //
- // When you use foreach to enumerate dictionary elements,
- // the elements are retrieved as KeyValuePair objects.
- Console::WriteLine();
- for each( KeyValuePair kvp in openWith )
- {
- Console::WriteLine("Key = {0}, Value = {1}",
- kvp.Key, kvp.Value);
- }
- //
-
- //
- // To get the values alone, use the Values property.
- Dictionary::ValueCollection^ valueColl =
- openWith->Values;
-
- // The elements of the ValueCollection are strongly typed
- // with the type that was specified for dictionary values.
- Console::WriteLine();
- for each( String^ s in valueColl )
- {
- Console::WriteLine("Value = {0}", s);
- }
- //
-
- //
- // To get the keys alone, use the Keys property.
- Dictionary::KeyCollection^ keyColl =
- openWith->Keys;
-
- // The elements of the KeyCollection are strongly typed
- // with the type that was specified for dictionary keys.
- Console::WriteLine();
- for each( String^ s in keyColl )
- {
- Console::WriteLine("Key = {0}", s);
- }
- //
-
- //
- // Use the Remove method to remove a key/value pair.
- Console::WriteLine("\nRemove(\"doc\")");
- openWith->Remove("doc");
-
- if (!openWith->ContainsKey("doc"))
- {
- Console::WriteLine("Key \"doc\" is not found.");
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
-/* This code example produces the following output:
-
-An element with Key = "txt" already exists.
-For key = "rtf", value = wordpad.exe.
-For key = "rtf", value = winword.exe.
-Key = "tif" is not found.
-Key = "tif" is not found.
-Value added for key = "ht": hypertrm.exe
-
-Key = txt, Value = notepad.exe
-Key = bmp, Value = paint.exe
-Key = dib, Value = paint.exe
-Key = rtf, Value = winword.exe
-Key = doc, Value = winword.exe
-Key = ht, Value = hypertrm.exe
-
-Value = notepad.exe
-Value = paint.exe
-Value = paint.exe
-Value = winword.exe
-Value = winword.exe
-Value = hypertrm.exe
-
-Key = txt
-Key = bmp
-Key = dib
-Key = rtf
-Key = doc
-Key = ht
-
-Remove("doc")
-Key "doc" is not found.
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp
deleted file mode 100644
index b16f6d80b9c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-using namespace System;
-using namespace System::Collections::Generic;
-//using namespace System::Threading;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- // Create a new dictionary of strings, with string keys.
- //
- Dictionary^ myDictionary =
- gcnew Dictionary();
-
- // Add some elements to the dictionary. There are no
- // duplicate keys, but some of the values are duplicates.
- myDictionary->Add("txt", "notepad.exe");
- myDictionary->Add("bmp", "paint.exe");
- myDictionary->Add("dib", "paint.exe");
- myDictionary->Add("rtf", "wordpad.exe");
-
- //
- for each(KeyValuePair kvp in myDictionary)
- {
- Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp
deleted file mode 100644
index 96a21ffd2f0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- //
- // Create a new dictionary of strings, with string keys,
- // and access it through the IDictionary generic interface.
- IDictionary^ openWith =
- gcnew Dictionary();
-
- // Add some elements to the dictionary. There are no
- // duplicate keys, but some of the values are duplicates.
- openWith->Add("txt", "notepad.exe");
- openWith->Add("bmp", "paint.exe");
- openWith->Add("dib", "paint.exe");
- openWith->Add("rtf", "wordpad.exe");
-
- // The Add method throws an exception if the new key is
- // already in the dictionary.
- try
- {
- openWith->Add("txt", "winword.exe");
- }
- catch (ArgumentException^)
- {
- Console::WriteLine("An element with Key = \"txt\" already exists.");
- }
- //
-
- //
- // The Item property is another name for the indexer, so you
- // can omit its name when accessing elements.
- Console::WriteLine("For key = \"rtf\", value = {0}.",
- openWith["rtf"]);
-
- // The indexer can be used to change the value associated
- // with a key.
- openWith["rtf"] = "winword.exe";
- Console::WriteLine("For key = \"rtf\", value = {0}.",
- openWith["rtf"]);
-
- // If a key does not exist, setting the indexer for that key
- // adds a new key/value pair.
- openWith["doc"] = "winword.exe";
- //
-
- //
- // The indexer throws an exception if the requested key is
- // not in the dictionary.
- try
- {
- Console::WriteLine("For key = \"tif\", value = {0}.",
- openWith["tif"]);
- }
- catch (KeyNotFoundException^)
- {
- Console::WriteLine("Key = \"tif\" is not found.");
- }
- //
-
- //
- // When a program often has to try keys that turn out not to
- // be in the dictionary, TryGetValue can be a more efficient
- // way to retrieve values.
- String^ value = "";
- if (openWith->TryGetValue("tif", value))
- {
- Console::WriteLine("For key = \"tif\", value = {0}.", value);
- }
- else
- {
- Console::WriteLine("Key = \"tif\" is not found.");
- }
- //
-
- //
- // ContainsKey can be used to test keys before inserting
- // them.
- if (!openWith->ContainsKey("ht"))
- {
- openWith->Add("ht", "hypertrm.exe");
- Console::WriteLine("Value added for key = \"ht\": {0}",
- openWith["ht"]);
- }
- //
-
- //
- // When you use foreach to enumerate dictionary elements,
- // the elements are retrieved as KeyValuePair objects.
- Console::WriteLine();
- for each( KeyValuePair kvp in openWith )
- {
- Console::WriteLine("Key = {0}, Value = {1}",
- kvp.Key, kvp.Value);
- }
- //
-
- //
- // To get the values alone, use the Values property.
- ICollection^ icoll = openWith->Values;
-
- // The elements of the ValueCollection are strongly typed
- // with the type that was specified for dictionary values.
- Console::WriteLine();
- for each( String^ s in icoll )
- {
- Console::WriteLine("Value = {0}", s);
- }
- //
-
- //
- // To get the keys alone, use the Keys property.
- icoll = openWith->Keys;
-
- // The elements of the ValueCollection are strongly typed
- // with the type that was specified for dictionary values.
- Console::WriteLine();
- for each( String^ s in icoll )
- {
- Console::WriteLine("Key = {0}", s);
- }
- //
-
- //
- // Use the Remove method to remove a key/value pair.
- Console::WriteLine("\nRemove(\"doc\")");
- openWith->Remove("doc");
-
- if (!openWith->ContainsKey("doc"))
- {
- Console::WriteLine("Key \"doc\" is not found.");
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
-/* This code example produces the following output:
-
-An element with Key = "txt" already exists.
-For key = "rtf", value = wordpad.exe.
-For key = "rtf", value = winword.exe.
-Key = "tif" is not found.
-Key = "tif" is not found.
-Value added for key = "ht": hypertrm.exe
-
-Key = txt, Value = notepad.exe
-Key = bmp, Value = paint.exe
-Key = dib, Value = paint.exe
-Key = rtf, Value = winword.exe
-Key = doc, Value = winword.exe
-Key = ht, Value = hypertrm.exe
-
-Value = notepad.exe
-Value = paint.exe
-Value = paint.exe
-Value = winword.exe
-Value = winword.exe
-Value = hypertrm.exe
-
-Key = txt
-Key = bmp
-Key = dib
-Key = rtf
-Key = doc
-Key = ht
-
-Remove("doc")
-Key "doc" is not found.
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp
deleted file mode 100644
index d3c038ba91c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- // Create a new dictionary of strings, with string keys.
- //
- Dictionary^ exDictionary =
- gcnew Dictionary();
-
- // Add some elements to the dictionary. There are no
- // duplicate keys, but some of the values are duplicates.
- exDictionary->Add(0, "notepad.exe");
- exDictionary->Add(1, "paint.exe");
- exDictionary->Add(2, "paint.exe");
- exDictionary->Add(3, "wordpad.exe");
- IDictionary^ myDictionary = exDictionary;
- //
- for each(KeyValuePair kvp in myDictionary)
- {
- Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp
deleted file mode 100644
index 1439a447483..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Text;
-using namespace System::Collections::Generic;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- //
- // Create the link list.
- array^ words =
- { "the", "fox", "jumped", "over", "the", "dog" };
- LinkedList^ sentence = gcnew LinkedList(words);
- Display(sentence, "The linked list values:");
- Console::WriteLine("sentence.Contains(\"jumped\") = {0}",
- sentence->Contains("jumped"));
- //
-
- // Add the word 'today' to the beginning of the linked list.
- sentence->AddFirst("today");
- Display(sentence, "Test 1: Add 'today' to beginning of the list:");
-
- //
- // Move the first node to be the last node.
- LinkedListNode^ mark1 = sentence->First;
- sentence->RemoveFirst();
- sentence->AddLast(mark1);
- //
- Display(sentence, "Test 2: Move first node to be last node:");
-
- // Change the last node to 'yesterday'.
- sentence->RemoveLast();
- sentence->AddLast("yesterday");
- Display(sentence, "Test 3: Change the last node to 'yesterday':");
-
- //
- // Move the last node to be the first node.
- mark1 = sentence->Last;
- sentence->RemoveLast();
- sentence->AddFirst(mark1);
- //
- Display(sentence, "Test 4: Move last node to be first node:");
-
-
- //
- // Indicate the last occurence of 'the'.
- sentence->RemoveFirst();
- LinkedListNode^ current = sentence->FindLast("the");
- //
- IndicateNode(current, "Test 5: Indicate last occurence of 'the':");
-
- //
- // Add 'lazy' and 'old' after 'the' (the LinkedListNode named current).
- sentence->AddAfter(current, "old");
- sentence->AddAfter(current, "lazy");
- //
- IndicateNode(current, "Test 6: Add 'lazy' and 'old' after 'the':");
-
- //
- // Indicate 'fox' node.
- current = sentence->Find("fox");
- IndicateNode(current, "Test 7: Indicate the 'fox' node:");
-
- // Add 'quick' and 'brown' before 'fox':
- sentence->AddBefore(current, "quick");
- sentence->AddBefore(current, "brown");
- //
- IndicateNode(current, "Test 8: Add 'quick' and 'brown' before 'fox':");
-
- // Keep a reference to the current node, 'fox',
- // and to the previous node in the list. Indicate the 'dog' node.
- mark1 = current;
- LinkedListNode^ mark2 = current->Previous;
- current = sentence->Find("dog");
- IndicateNode(current, "Test 9: Indicate the 'dog' node:");
-
- // The AddBefore method throws an InvalidOperationException
- // if you try to add a node that already belongs to a list.
- Console::WriteLine("Test 10: Throw exception by adding node (fox) already in the list:");
- try
- {
- sentence->AddBefore(current, mark1);
- }
- catch (InvalidOperationException^ ex)
- {
- Console::WriteLine("Exception message: {0}", ex->Message);
- }
- Console::WriteLine();
-
- //
- // Remove the node referred to by mark1, and then add it
- // before the node referred to by current.
- // Indicate the node referred to by current.
- sentence->Remove(mark1);
- sentence->AddBefore(current, mark1);
- //
- IndicateNode(current, "Test 11: Move a referenced node (fox) before the current node (dog):");
-
- //
- // Remove the node referred to by current.
- sentence->Remove(current);
- //
- IndicateNode(current, "Test 12: Remove current node (dog) and attempt to indicate it:");
-
- // Add the node after the node referred to by mark2.
- sentence->AddAfter(mark2, current);
- IndicateNode(current, "Test 13: Add node removed in test 11 after a referenced node (brown):");
-
- // The Remove method finds and removes the
- // first node that that has the specified value.
- sentence->Remove("old");
- Display(sentence, "Test 14: Remove node that has the value 'old':");
-
- //
- // When the linked list is cast to ICollection(Of String),
- // the Add method adds a node to the end of the list.
- sentence->RemoveLast();
- ICollection^ icoll = sentence;
- icoll->Add("rhinoceros");
- //
- Display(sentence, "Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':");
-
- Console::WriteLine("Test 16: Copy the list to an array:");
- //
- // Create an array with the same number of
- // elements as the inked list.
- array^ sArray = gcnew array(sentence->Count);
- sentence->CopyTo(sArray, 0);
-
- for each (String^ s in sArray)
- {
- Console::WriteLine(s);
- }
- //
-
-
- //
- // Release all the nodes.
- sentence->Clear();
-
- Console::WriteLine();
- Console::WriteLine("Test 17: Clear linked list. Contains 'jumped' = {0}",
- sentence->Contains("jumped"));
- //
-
- Console::ReadLine();
- }
-
-private:
- static void Display(LinkedList^ words, String^ test)
- {
- Console::WriteLine(test);
- for each (String^ word in words)
- {
- Console::Write(word + " ");
- }
- Console::WriteLine();
- Console::WriteLine();
- }
-
- static void IndicateNode(LinkedListNode^ node, String^ test)
- {
- Console::WriteLine(test);
- if (node->List == nullptr)
- {
- Console::WriteLine("Node '{0}' is not in the list.\n",
- node->Value);
- return;
- }
-
- StringBuilder^ result = gcnew StringBuilder("(" + node->Value + ")");
- LinkedListNode^ nodeP = node->Previous;
-
- while (nodeP != nullptr)
- {
- result->Insert(0, nodeP->Value + " ");
- nodeP = nodeP->Previous;
- }
-
- node = node->Next;
- while (node != nullptr)
- {
- result->Append(" " + node->Value);
- node = node->Next;
- }
-
- Console::WriteLine(result);
- Console::WriteLine();
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
-//This code example produces the following output:
-//
-//The linked list values:
-//the fox jumped over the dog
-
-//Test 1: Add 'today' to beginning of the list:
-//today the fox jumped over the dog
-
-//Test 2: Move first node to be last node:
-//the fox jumped over the dog today
-
-//Test 3: Change the last node to 'yesterday':
-//the fox jumped over the dog yesterday
-
-//Test 4: Move last node to be first node:
-//yesterday the fox jumped over the dog
-
-//Test 5: Indicate last occurence of 'the':
-//the fox jumped over (the) dog
-
-//Test 6: Add 'lazy' and 'old' after 'the':
-//the fox jumped over (the) lazy old dog
-
-//Test 7: Indicate the 'fox' node:
-//the (fox) jumped over the lazy old dog
-
-//Test 8: Add 'quick' and 'brown' before 'fox':
-//the quick brown (fox) jumped over the lazy old dog
-
-//Test 9: Indicate the 'dog' node:
-//the quick brown fox jumped over the lazy old (dog)
-
-//Test 10: Throw exception by adding node (fox) already in the list:
-//Exception message: The LinkedList node belongs a LinkedList.
-
-//Test 11: Move a referenced node (fox) before the current node (dog):
-//the quick brown jumped over the lazy old fox (dog)
-
-//Test 12: Remove current node (dog) and attempt to indicate it:
-//Node 'dog' is not in the list.
-
-//Test 13: Add node removed in test 11 after a referenced node (brown):
-//the quick brown (dog) jumped over the lazy old fox
-
-//Test 14: Remove node that has the value 'old':
-//the quick brown dog jumped over the lazy fox
-
-//Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':
-//the quick brown dog jumped over the lazy rhinoceros
-
-//Test 16: Copy the list to an array:
-//the
-//quick
-//brown
-//dog
-//jumped
-//over
-//the
-//lazy
-//rhinoceros
-
-//Test 17: Clear linked list. Contains 'jumped' = False
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp
deleted file mode 100644
index 8e667bffa93..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- // Create a new sorted list of strings, with string
- // keys.
- SortedList^ mySortedList =
- gcnew SortedList();
-
- // Add some elements to the list. There are no
- // duplicate keys, but some of the values are duplicates.
- mySortedList->Add(0, "notepad.exe");
- mySortedList->Add(1, "paint.exe");
- mySortedList->Add(2, "paint.exe");
- mySortedList->Add(3, "wordpad.exe");
-
- //
- String^ v = mySortedList->Values[3];
- //
-
- Console::WriteLine("Value at index 3: {0}", v);
-
- //
- for each( KeyValuePair kvp in mySortedList )
- {
- Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp
deleted file mode 100644
index 47488deda3e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- //
- // Create a new sorted list of strings, with string
- // keys.
- SortedList^ openWith =
- gcnew SortedList();
-
- // Add some elements to the list. There are no
- // duplicate keys, but some of the values are duplicates.
- openWith->Add("txt", "notepad.exe");
- openWith->Add("bmp", "paint.exe");
- openWith->Add("dib", "paint.exe");
- openWith->Add("rtf", "wordpad.exe");
-
- // The Add method throws an exception if the new key is
- // already in the list.
- try
- {
- openWith->Add("txt", "winword.exe");
- }
- catch (ArgumentException^)
- {
- Console::WriteLine("An element with Key = \"txt\" already exists.");
- }
- //
-
- //
- // The Item property is another name for the indexer, so you
- // can omit its name when accessing elements.
- Console::WriteLine("For key = \"rtf\", value = {0}.",
- openWith["rtf"]);
-
- // The indexer can be used to change the value associated
- // with a key.
- openWith["rtf"] = "winword.exe";
- Console::WriteLine("For key = \"rtf\", value = {0}.",
- openWith["rtf"]);
-
- // If a key does not exist, setting the indexer for that key
- // adds a new key/value pair.
- openWith["doc"] = "winword.exe";
- //
-
- //
- // The indexer throws an exception if the requested key is
- // not in the list.
- try
- {
- Console::WriteLine("For key = \"tif\", value = {0}.",
- openWith["tif"]);
- }
- catch (KeyNotFoundException^)
- {
- Console::WriteLine("Key = \"tif\" is not found.");
- }
- //
-
- //
- // When a program often has to try keys that turn out not to
- // be in the list, TryGetValue can be a more efficient
- // way to retrieve values.
- String^ value = "";
- if (openWith->TryGetValue("tif", value))
- {
- Console::WriteLine("For key = \"tif\", value = {0}.", value);
- }
- else
- {
- Console::WriteLine("Key = \"tif\" is not found.");
- }
- //
-
- //
- // ContainsKey can be used to test keys before inserting
- // them.
- if (!openWith->ContainsKey("ht"))
- {
- openWith->Add("ht", "hypertrm.exe");
- Console::WriteLine("Value added for key = \"ht\": {0}",
- openWith["ht"]);
- }
- //
-
- //
- // When you use foreach to enumerate list elements,
- // the elements are retrieved as KeyValuePair objects.
- Console::WriteLine();
- for each( KeyValuePair kvp in openWith )
- {
- Console::WriteLine("Key = {0}, Value = {1}",
- kvp.Key, kvp.Value);
- }
- //
-
- //
- // To get the values alone, use the Values property.
- IList^ ilistValues = openWith->Values;
-
- // The elements of the list are strongly typed with the
- // type that was specified for the SortedList values.
- Console::WriteLine();
- for each( String^ s in ilistValues )
- {
- Console::WriteLine("Value = {0}", s);
- }
-
- // The Values property is an efficient way to retrieve
- // values by index.
- Console::WriteLine("\nIndexed retrieval using the Values " +
- "property: Values[2] = {0}", openWith->Values[2]);
- //
-
- //
- // To get the keys alone, use the Keys property.
- IList^ ilistKeys = openWith->Keys;
-
- // The elements of the list are strongly typed with the
- // type that was specified for the SortedList keys.
- Console::WriteLine();
- for each( String^ s in ilistKeys )
- {
- Console::WriteLine("Key = {0}", s);
- }
-
- // The Keys property is an efficient way to retrieve
- // keys by index.
- Console::WriteLine("\nIndexed retrieval using the Keys " +
- "property: Keys[2] = {0}", openWith->Keys[2]);
- //
-
- //
- // Use the Remove method to remove a key/value pair.
- Console::WriteLine("\nRemove(\"doc\")");
- openWith->Remove("doc");
-
- if (!openWith->ContainsKey("doc"))
- {
- Console::WriteLine("Key \"doc\" is not found.");
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
-/* This code example produces the following output:
-
-An element with Key = "txt" already exists.
-For key = "rtf", value = wordpad.exe.
-For key = "rtf", value = winword.exe.
-Key = "tif" is not found.
-Key = "tif" is not found.
-Value added for key = "ht": hypertrm.exe
-
-Key = bmp, Value = paint.exe
-Key = dib, Value = paint.exe
-Key = doc, Value = winword.exe
-Key = ht, Value = hypertrm.exe
-Key = rtf, Value = winword.exe
-Key = txt, Value = notepad.exe
-
-Value = paint.exe
-Value = paint.exe
-Value = winword.exe
-Value = hypertrm.exe
-Value = winword.exe
-Value = notepad.exe
-
-Indexed retrieval using the Values property: Values[2] = winword.exe
-
-Key = bmp
-Key = dib
-Key = doc
-Key = ht
-Key = rtf
-Key = txt
-
-Indexed retrieval using the Keys property: Keys[2] = doc
-
-Remove("doc")
-Key "doc" is not found.
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp
deleted file mode 100644
index d26844e8082..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-
-// Computes a keyed hash for a source file, creates a target file with the keyed hash
-// prepended to the contents of the source file, then decodes the file and compares
-// the source and the decoded files.
-void EncodeFile( array^key, String^ sourceFile, String^ destFile )
-{
-
- // Initialize the keyed hash object.
- HMACSHA256^ myhmacsha256 = gcnew HMACSHA256( key );
- FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open );
- FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create );
-
- // Compute the hash of the input file.
- array^hashValue = myhmacsha256->ComputeHash( inStream );
-
- // Reset inStream to the beginning of the file.
- inStream->Position = 0;
-
- // Write the computed hash value to the output file.
- outStream->Write( hashValue, 0, hashValue->Length );
-
- // Copy the contents of the sourceFile to the destFile.
- int bytesRead;
-
- // read 1K at a time
- array^buffer = gcnew array(1024);
- do
- {
-
- // Read from the wrapping CryptoStream.
- bytesRead = inStream->Read( buffer, 0, 1024 );
- outStream->Write( buffer, 0, bytesRead );
- }
- while ( bytesRead > 0 );
-
- myhmacsha256->Clear();
-
- // Close the streams
- inStream->Close();
- outStream->Close();
- return;
-} // end EncodeFile
-
-
-
-// Decode the encoded file and compare to original file.
-bool DecodeFile( array^key, String^ sourceFile )
-{
-
- // Initialize the keyed hash object.
- HMACSHA256^ hmacsha256 = gcnew HMACSHA256( key );
-
- // Create an array to hold the keyed hash value read from the file.
- array^storedHash = gcnew array(hmacsha256->HashSize / 8);
-
- // Create a FileStream for the source file.
- FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open );
-
- // Read in the storedHash.
- inStream->Read( storedHash, 0, storedHash->Length );
-
- // Compute the hash of the remaining contents of the file.
- // The stream is properly positioned at the beginning of the content,
- // immediately after the stored hash value.
- array^computedHash = hmacsha256->ComputeHash( inStream );
-
- // compare the computed hash with the stored value
- bool err = false;
- for ( int i = 0; i < storedHash->Length; i++ )
- {
- if ( computedHash[ i ] != storedHash[ i ] )
- {
- err = true;
- }
- }
- if (err)
- {
- Console::WriteLine("Hash values differ! Encoded file has been tampered with!");
- return false;
- }
- else
- {
- Console::WriteLine("Hash values agree -- no tampering occurred.");
- return true;
- }
-
-} //end DecodeFile
-
-
-int main()
-{
- array^Fileargs = Environment::GetCommandLineArgs();
- String^ usageText = "Usage: HMACSHA256 inputfile.txt encodedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n";
-
- //If no file names are specified, write usage text.
- if ( Fileargs->Length < 3 )
- {
- Console::WriteLine( usageText );
- }
- else
- {
- try
- {
-
- // Create a random key using a random number generator. This would be the
- // secret key shared by sender and receiver.
- array^secretkey = gcnew array(64);
-
- RandomNumberGenerator^ rng = RandomNumberGenerator::Create();
-
- // The array is now filled with cryptographically strong random bytes.
- rng->GetBytes( secretkey );
-
- // Use the secret key to encode the message file.
- EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] );
-
- // Take the encoded file and decode
- DecodeFile( secretkey, Fileargs[ 2 ] );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( "Error: File not found", e );
- }
-
- }
-} //end main
-
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp
deleted file mode 100644
index 6dfcd8a29fa..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-
-// Computes a keyed hash for a source file, creates a target file with the keyed hash
-// prepended to the contents of the source file, then decrypts the file and compares
-// the source and the decrypted files.
-void EncodeFile( array^key, String^ sourceFile, String^ destFile )
-{
-
- // Initialize the keyed hash object.
- HMACSHA384^ myhmacsha384 = gcnew HMACSHA384( key );
- FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open );
- FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create );
-
- // Compute the hash of the input file.
- array^hashValue = myhmacsha384->ComputeHash( inStream );
-
- // Reset inStream to the beginning of the file.
- inStream->Position = 0;
-
- // Write the computed hash value to the output file.
- outStream->Write( hashValue, 0, hashValue->Length );
-
- // Copy the contents of the sourceFile to the destFile.
- int bytesRead;
-
- // read 1K at a time
- array^buffer = gcnew array(1024);
- do
- {
-
- // Read from the wrapping CryptoStream.
- bytesRead = inStream->Read( buffer, 0, 1024 );
- outStream->Write( buffer, 0, bytesRead );
- }
- while ( bytesRead > 0 );
-
- myhmacsha384->Clear();
-
- // Close the streams
- inStream->Close();
- outStream->Close();
- return;
-} // end EncodeFile
-
-
-
-// Decrypt the encoded file and compare to original file.
-bool DecodeFile( array^key, String^ sourceFile )
-{
-
- // Initialize the keyed hash object.
- HMACSHA384^ hmacsha384 = gcnew HMACSHA384( key );
-
- // Create an array to hold the keyed hash value read from the file.
- array^storedHash = gcnew array(hmacsha384->HashSize / 8);
-
- // Create a FileStream for the source file.
- FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open );
-
- // Read in the storedHash.
- inStream->Read( storedHash, 0, storedHash->Length );
-
- // Compute the hash of the remaining contents of the file.
- // The stream is properly positioned at the beginning of the content,
- // immediately after the stored hash value.
- array^computedHash = hmacsha384->ComputeHash( inStream );
-
- // compare the computed hash with the stored value
- bool err = false;
- for ( int i = 0; i < storedHash->Length; i++ )
- {
- if ( computedHash[ i ] != storedHash[ i ] )
- {
- err = true;
- }
- }
- if (err)
- {
- Console::WriteLine("Hash values differ! Encoded file has been tampered with!");
- return false;
- }
- else
- {
- Console::WriteLine("Hash values agree -- no tampering occurred.");
- return true;
- }
-
-} //end DecodeFile
-
-
-int main()
-{
- array^Fileargs = Environment::GetCommandLineArgs();
- String^ usageText = "Usage: HMACSHA384 inputfile.txt encryptedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n";
-
- //If no file names are specified, write usage text.
- if ( Fileargs->Length < 3 )
- {
- Console::WriteLine( usageText );
- }
- else
- {
- try
- {
-
- // Create a random key using a random number generator. This would be the
- // secret key shared by sender and receiver.
- array^secretkey = gcnew array(64);
-
- RandomNumberGenerator^ rng = RandomNumberGenerator::Create();
-
- // The array is now filled with cryptographically strong random bytes.
- rng->GetBytes( secretkey );
-
- // Use the secret key to encode the message file.
- EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] );
-
- // Take the encoded file and decode
- DecodeFile( secretkey, Fileargs[ 2 ] );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( "Error: File not found", e );
- }
-
- }
-} //end main
-
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp
deleted file mode 100644
index 4f83ce4b8b5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-
-// Computes a keyed hash for a source file, creates a target file with the keyed hash
-// prepended to the contents of the source file, then decrypts the file and compares
-// the source and the decrypted files.
-void EncodeFile( array^key, String^ sourceFile, String^ destFile )
-{
-
- // Initialize the keyed hash object.
- HMACSHA512^ myhmacsha512 = gcnew HMACSHA512( key );
- FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open );
- FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create );
-
- // Compute the hash of the input file.
- array^hashValue = myhmacsha512->ComputeHash( inStream );
-
- // Reset inStream to the beginning of the file.
- inStream->Position = 0;
-
- // Write the computed hash value to the output file.
- outStream->Write( hashValue, 0, hashValue->Length );
-
- // Copy the contents of the sourceFile to the destFile.
- int bytesRead;
-
- // read 1K at a time
- array^buffer = gcnew array(1024);
- do
- {
-
- // Read from the wrapping CryptoStream.
- bytesRead = inStream->Read( buffer, 0, 1024 );
- outStream->Write( buffer, 0, bytesRead );
- }
- while ( bytesRead > 0 );
-
- myhmacsha512->Clear();
-
- // Close the streams
- inStream->Close();
- outStream->Close();
- return;
-} // end EncodeFile
-
-
-
-// Decrypt the encoded file and compare to original file.
-bool DecodeFile( array^key, String^ sourceFile )
-{
-
- // Initialize the keyed hash object.
- HMACSHA512^ hmacsha512 = gcnew HMACSHA512( key );
-
- // Create an array to hold the keyed hash value read from the file.
- array^storedHash = gcnew array(hmacsha512->HashSize / 8);
-
- // Create a FileStream for the source file.
- FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open );
-
- // Read in the storedHash.
- inStream->Read( storedHash, 0, storedHash->Length );
-
- // Compute the hash of the remaining contents of the file.
- // The stream is properly positioned at the beginning of the content,
- // immediately after the stored hash value.
- array^computedHash = hmacsha512->ComputeHash( inStream );
-
- // compare the computed hash with the stored value
- bool err = false;
- for ( int i = 0; i < storedHash->Length; i++ )
- {
- if ( computedHash[ i ] != storedHash[ i ] )
- {
- err = true;
- }
- }
- if (err)
- {
- Console::WriteLine("Hash values differ! Encoded file has been tampered with!");
- return false;
- }
- else
- {
- Console::WriteLine("Hash values agree -- no tampering occurred.");
- return true;
- }
-
-} //end DecodeFile
-
-
-int main()
-{
- array^Fileargs = Environment::GetCommandLineArgs();
- String^ usageText = "Usage: HMACSHA512 inputfile.txt encryptedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n";
-
- //If no file names are specified, write usage text.
- if ( Fileargs->Length < 3 )
- {
- Console::WriteLine( usageText );
- }
- else
- {
- try
- {
-
- // Create a random key using a random number generator. This would be the
- // secret key shared by sender and receiver.
- array^secretkey = gcnew array(64);
-
- RandomNumberGenerator^ rng = RandomNumberGenerator::Create();
-
- // The array is now filled with cryptographically strong random bytes.
- rng->GetBytes( secretkey );
-
- // Use the secret key to encode the message file.
- EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] );
-
- // Take the encoded file and decode
- DecodeFile( secretkey, Fileargs[ 2 ] );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( "Error: File not found", e );
- }
-
- }
-} //end main
-
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp
deleted file mode 100644
index 506b780b31a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ fileName = "test.xml";
- if (!File::Exists(fileName))
- {
- Console::WriteLine("The file " + fileName
- + " does not exist.");
- return 0;
- }
- try
- {
- Console::WriteLine("Encrypt " + fileName);
-
- // Encrypt the file.
- File::Encrypt(fileName);
-
- Console::WriteLine("Decrypt " + fileName);
-
- // Decrypt the file.
- File::Decrypt(fileName);
-
- Console::WriteLine("Done");
- }
- catch (IOException^ ex)
- {
- Console::WriteLine("There was an IO problem.");
- Console::WriteLine(ex->Message);
- }
- catch (PlatformNotSupportedException^)
- {
- Console::WriteLine("Encryption is not supported on " +
- "this system.");
- }
- catch (NotSupportedException^)
- {
- Console::WriteLine("Encryption is not supported on " +
- "this system.");
- }
- catch (UnauthorizedAccessException^)
- {
- Console::WriteLine("The operation could not be "
- + "carried out.");
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp
deleted file mode 100644
index 4876d14c2dd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-
-// Move a file into another file, delete the original,
-// and create a backup of the replaced file.
-
-void ReplaceFile(String^ fileToMoveAndDelete,
- String^ fileToReplace, String^ backupOfFileToReplace)
-{
- File::Replace(fileToMoveAndDelete, fileToReplace,
- backupOfFileToReplace, false);
-}
-
-
-int main()
-{
- try
- {
- String^ originalFile = "test.xml";
- String^ fileToReplace = "test2.xml";
- String^ backUpOfFileToReplace = "test2.xml.bac";
-
- Console::WriteLine("Move the contents of " + originalFile + " into "
- + fileToReplace + ", delete " + originalFile
- + ", and create a backup of " + fileToReplace + ".");
-
- // Replace the file.
- ReplaceFile(originalFile, fileToReplace, backUpOfFileToReplace);
-
- Console::WriteLine("Done");
- }
- catch (IOException^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-};
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp
deleted file mode 100644
index 3cbff62e773..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::AccessControl;
-
-
- static void Addencryption(String^ fileName)
-{
- // Create a new FileInfo object.
- FileInfo^ fInfo = gcnew FileInfo(fileName);
- if (!fInfo->Exists)
- {
- fInfo->Create();
- }
- // Add encryption.
- fInfo->Encrypt();
-
-}
-
-
- static void Removeencryption(String^ fileName)
-{
-// Create a new FileInfo object.
- FileInfo^ fInfo = gcnew FileInfo(fileName);
- if (!fInfo->Exists)
- {
- fInfo->Create();
- }
- // Remove encryption.
- fInfo->Decrypt();
-}
-
-int main()
-{
- try
- {
- String^ fileName = "c:\\MyTest.txt";
- Console::WriteLine("Encrypt " + fileName);
-
- // Encrypt the file.
-
- Addencryption(fileName);
- Console::WriteLine("Decrypt " + fileName);
-
- // Decrypt the file.
- Removeencryption(fileName);
- Console::WriteLine("Done");
- }
- catch (IOException^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//Encrypt c:\MyTest.txt
-//Decrypt c:\MyTest.txt
-//Done
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp
deleted file mode 100644
index 27fb4bdc1ae..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-using namespace System;
-using namespace System::IO;
-
-//
-array^ Openfile(String^ fileName)
-{
- // Check the fileName argument.
- if (fileName == nullptr || fileName->Length == 0)
- {
- throw gcnew ArgumentNullException("fileName");
- }
-
- // Check to see if the file exists.
- FileInfo^ fInfo = gcnew FileInfo(fileName);
-
- // You can throw a personalized exception if
- // the file does not exist.
- if (!fInfo->Exists)
- {
- throw gcnew FileNotFoundException("The file was not found.",
- fileName);
- }
-
- try
- {
- // Open the file.
- FileStream^ fStream = gcnew FileStream(fileName, FileMode::Open);
-
- // Create a buffer.
- array^ buffer = gcnew array(fStream->Length);
-
- // Read the file contents to the buffer.
- fStream->Read(buffer, 0, (int)fStream->Length);
-
- // return the buffer.
- return buffer;
- }
- catch (IOException^ ex)
- {
- Console::WriteLine(ex->Message);
- return nullptr;
- }
-}
-//
-
-int main()
-{
-
-};
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp
deleted file mode 100644
index eb8b7aeaec2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-//
-#using
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::AccessControl;
-using namespace System::Security::Principal;
-
-// Adds an ACL entry on the specified file for the specified account.
-static void AddFileSecurity(String^ fileName, String^ account,
- FileSystemRights^ rights,
- AccessControlType^ controlType)
-{
- // Create a new FileInfo object.
- FileInfo^ fInfo = gcnew FileInfo(fileName);
- if (!fInfo->Exists)
- {
- fInfo->Create();
- }
-
- // Get a FileSecurity object that represents the
- // current security settings.
- FileSecurity^ fSecurity = fInfo->GetAccessControl();
-
- // Add the FileSystemAccessRule to the security settings.
- fSecurity->AddAccessRule(gcnew FileSystemAccessRule(account,
- *rights, *controlType));
-
- // Set the new access settings.
- fInfo->SetAccessControl(fSecurity);
-}
-
-// Removes an ACL entry on the specified file for the specified account.
-static void RemoveFileSecurity(String^ fileName, String^ account,
- FileSystemRights^ rights,
- AccessControlType^ controlType)
-{
- // Create a new FileInfo object.
- FileInfo^ fInfo = gcnew FileInfo(fileName);
- if (!fInfo->Exists)
- {
- fInfo->Create();
- }
-
- // Get a FileSecurity object that represents the
- // current security settings.
- FileSecurity^ fSecurity = fInfo->GetAccessControl();
-
- // Remove the FileSystemAccessRule from the security settings.
- fSecurity->RemoveAccessRule(gcnew FileSystemAccessRule(account,
- *rights, *controlType));
-
- // Set the new access settings.
- fInfo->SetAccessControl(fSecurity);
-}
-
-int main()
-{
- try
- {
- String^ fileName = "c:\\test.xml";
-
- Console::WriteLine("Adding access control entry for " +
- fileName);
-
- // Add the access control entry to the file.
- // Before compiling this snippet, change MyDomain to your
- // domain name and MyAccessAccount to the name
- // you use to access your domain.
- AddFileSecurity(fileName, "MyDomain\\MyAccessAccount",
- FileSystemRights::ReadData, AccessControlType::Allow);
-
- Console::WriteLine("Removing access control entry from " +
- fileName);
-
- // Remove the access control entry from the file.
- // Before compiling this snippet, change MyDomain to your
- // domain name and MyAccessAccount to the name
- // you use to access your domain.
- RemoveFileSecurity(fileName, "MyDomain\\MyAccessAccount",
- FileSystemRights::ReadData, AccessControlType::Allow);
-
- Console::WriteLine("Done.");
- }
- catch (Exception^ e)
- {
- Console::WriteLine(e);
- }
-
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//Adding access control entry for c:\test.xml
-//Removing access control entry from c:\test.xml
-//Done.
-//
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp
deleted file mode 100644
index f7dbe0f1cb2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-
-using namespace System;
-using namespace System::IO;
-
-
-// Move a file into another file, delete the original,
-// and create a backup of the replaced file.
-void ReplaceFile(String^ fileToMoveAndDelete,
- String^ fileToReplace, String^ backupOfFileToReplace)
-{
- // Create a new FileInfo object.
- FileInfo^ fInfo = gcnew FileInfo(fileToMoveAndDelete);
-
- // replace the file.
- fInfo->Replace(fileToReplace, backupOfFileToReplace, false);
-}
-
-
-int main()
-{
- try
- {
- // originalFile and fileToReplace must contain
- // the path to files that already exist in the
- // file system. backUpOfFileToReplace is created
- // during the execution of the Replace method.
-
- String^ originalFile = "test.xml";
- String^ fileToReplace = "test2.xml";
- String^ backUpOfFileToReplace = "test2.xml.bak";
-
- if (File::Exists(originalFile) && (File::Exists(fileToReplace)))
- {
- Console::WriteLine("Move the contents of {0} into {1}, " +
- "delete {0}, and create a backup of {1}",
- originalFile, fileToReplace);
-
- // Replace the file.
- ReplaceFile(originalFile, fileToReplace,
- backUpOfFileToReplace);
- Console::WriteLine("Done");
- }
- else
- {
- Console::WriteLine("Either the file {0} or {1} doesn't " +
- "exist.", originalFile, fileToReplace);
- }
- }
- catch (IOException^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-}
-
-
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//Move the contents of c:\test1.xml into c:\test2.xml, delete c:\test1.xml,
-//and create a backup of c:\test2.xml
-//Done
-
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp
deleted file mode 100644
index e5fb1ade0c8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- // Create a temporary file.
- String^ filePath = Path::GetTempFileName();
- Console::WriteLine("Created a temp file at '{0}.", filePath);
-
- // Create a new FileInfo object.
- FileInfo^ fInfo = gcnew FileInfo(filePath);
-
- // Get the read-only value for a file.
- bool isReadOnly = fInfo->IsReadOnly;
-
- // Display whether the file is read-only.
- Console::WriteLine("The file read-only value for '{0}' is {1}.", fInfo->Name, isReadOnly);
-
- // Set the file to read-only.
- Console::WriteLine("Setting the read-only value for '{0}' to true.", fInfo->Name);
- fInfo->IsReadOnly = true;
-
- // Get the read-only value for a file.
- isReadOnly = fInfo->IsReadOnly;
-
- // Display that the file is now read-only.
- Console::WriteLine("The file read-only value for '{0}' is {1}.", fInfo->Name, isReadOnly);
-
- // Make the file mutable again so it can be deleted.
- fInfo->IsReadOnly = false;
-
- // Delete the temporary file.
- fInfo->Delete();
-
- return 0;
-};
-
-// This code produces output similar to the following,
-// though results may vary based on the computer, file structure, etc.:
-//
-// Created a temp file at 'C:\Users\UserName\AppData\Local\Temp\tmpB438.tmp'.
-// The file read-only value for 'tmpB438.tmp' is False.
-// Setting the read-only value for 'tmpB438.tmp' to true.
-// The file read-only value for 'tmpB438.tmp' is True.
-//
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor1/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor1/cpp/example.cpp
deleted file mode 100644
index d31fd98984e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor1/cpp/example.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-using namespace System::Security::AccessControl;
-
-int main()
-{
- try
- {
- // Create a file and write data to it.
-
- // Create an array of bytes.
- array^ messageByte =
- Encoding::ASCII->GetBytes("Here is some data.");
-
- // Create a file using the FileStream class.
- FileStream^ fWrite = gcnew FileStream("test.txt", FileMode::Create,
- FileAccess::ReadWrite, FileShare::None, 8, FileOptions::None);
-
- // Write the number of bytes to the file.
- fWrite->WriteByte((Byte)messageByte->Length);
-
- // Write the bytes to the file.
- fWrite->Write(messageByte, 0, messageByte->Length);
-
- // Close the stream.
- fWrite->Close();
-
-
- // Open a file and read the number of bytes.
-
- FileStream^ fRead = gcnew FileStream("test.txt",
- FileMode::Open);
-
- // The first byte is the string length.
- int length = (int)fRead->ReadByte();
-
- // Create a new byte array for the data.
- array^ readBytes = gcnew array(length);
-
- // Read the data from the file.
- fRead->Read(readBytes, 0, readBytes->Length);
-
- // Close the stream.
- fRead->Close();
-
- // Display the data.
- Console::WriteLine(Encoding::ASCII->GetString(readBytes));
-
- Console::WriteLine("Done writing and reading data.");
- }
- catch (IOException^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor2/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor2/cpp/example.cpp
deleted file mode 100644
index 3c25ca60661..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor2/cpp/example.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-using namespace System::Security::AccessControl;
-using namespace System::Security::Principal;
-
-int main()
-{
- try
- {
- // Create a file and write data to it.
-
- // Create an array of bytes.
- array^ messageByte =
- Encoding::ASCII->GetBytes("Here is some data.");
-
- // Specify an access control list (ACL)
- FileSecurity^ fs = gcnew FileSecurity();
-
- fs->AddAccessRule(
- gcnew FileSystemAccessRule("MYDOMAIN\\MyAccount",
- FileSystemRights::Modify, AccessControlType::Allow));
-
- // Create a file using the FileStream class.
- FileStream^ fWrite = gcnew FileStream("test.txt",
- FileMode::Create, FileSystemRights::Modify,
- FileShare::None, 8, FileOptions::None, fs);
-
- // Write the number of bytes to the file.
- fWrite->WriteByte((Byte)messageByte->Length);
-
- // Write the bytes to the file.
- fWrite->Write(messageByte, 0, messageByte->Length);
-
- // Close the stream.
- fWrite->Close();
-
- // Open a file and read the number of bytes.
-
- FileStream^ fRead =
- gcnew FileStream("test.txt", FileMode::Open);
-
- // The first byte is the string length.
- int length = (int)fRead->ReadByte();
-
- // Create a new byte array for the data.
- array^ readBytes = gcnew array(length);
-
- // Read the data from the file.
- fRead->Read(readBytes, 0, readBytes->Length);
-
- // Close the stream.
- fRead->Close();
-
- // Display the data.
- Console::WriteLine(Encoding::ASCII->GetString(readBytes));
-
- Console::WriteLine("Done writing and reading data.");
- }
-
- catch (IdentityNotMappedException^)
- {
- Console::WriteLine("You need to use your own credentials " +
- " 'MYDOMAIN\\MyAccount'.");
- }
-
- catch (IOException^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp
deleted file mode 100644
index 98e59f68290..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-namespace PathExample
-{
- public ref class GetCharExample
- {
- public:
- static void Main()
- {
- // Get a list of invalid path characters.
- array^ invalidPathChars = Path::GetInvalidPathChars();
-
- Console::WriteLine("The following characters are invalid in a path:");
- ShowChars(invalidPathChars);
- Console::WriteLine();
-
- // Get a list of invalid file characters.
- array^ invalidFileChars = Path::GetInvalidFileNameChars();
-
- Console::WriteLine("The following characters are invalid in a filename:");
- ShowChars(invalidFileChars);
- }
-
- static void ShowChars(array^ charArray)
- {
- Console::WriteLine("Char\tHex Value");
- // Display each invalid character to the console.
- for each (Char someChar in charArray)
- {
- if (Char::IsWhiteSpace(someChar))
- {
- Console::WriteLine(",\t{0:X4}", (Int16)someChar);
- }
- else
- {
- Console::WriteLine("{0:c},\t{1:X4}", someChar, (Int16)someChar);
- }
- }
- }
- };
-};
-
-int main()
-{
- PathExample::GetCharExample::Main();
-}
-// Note: Some characters may not be displayable on the console.
-// The output will look something like:
-//
-// The following characters are invalid in a path:
-// Char Hex Value
-// ", 0022
-// <, 003C
-// >, 003E
-// |, 007C
-// ...
-//
-// The following characters are invalid in a filename:
-// Char Hex Value
-// ", 0022
-// <, 003C
-// >, 003E
-// |, 007C
-// ...
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp
deleted file mode 100644
index 47d43906d84..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO::Ports;
-using namespace System::ComponentModel;
-
-void main()
-{
- array^ serialPorts = nullptr;
- try
- {
- // Get a list of serial port names.
- serialPorts = SerialPort::GetPortNames();
- }
- catch (Win32Exception^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-
- Console::WriteLine("The following serial ports were found:");
-
- // Display each port name to the console.
- for each(String^ port in serialPorts)
- {
- Console::WriteLine(port);
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp
deleted file mode 100644
index 8997b4e85f5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-using namespace System::Collections::ObjectModel;
-
-// This class represents a simple line item in an order. All the
-// values are immutable except quantity.
-//
-public ref class OrderItem
-{
-private:
- int _quantity;
-
-public:
- initonly int PartNumber;
- initonly String^ Description;
- initonly double UnitPrice;
-
- OrderItem(int partNumber, String^ description,
- int quantity, double unitPrice)
- {
- this->PartNumber = partNumber;
- this->Description = description;
- this->Quantity = quantity;
- this->UnitPrice = unitPrice;
- }
-
- property int Quantity
- {
- int get() { return _quantity; }
- void set(int value)
- {
- if (value < 0)
- throw gcnew ArgumentException("Quantity cannot be negative.");
-
- _quantity = value;
- }
- }
-
- virtual String^ ToString() override
- {
- return String::Format(
- "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}",
- PartNumber, _quantity, Description, UnitPrice,
- UnitPrice * _quantity);
- }
-};
-
-// This class represents a very simple keyed list of OrderItems,
-// inheriting most of its behavior from the KeyedCollection and
-// Collection classes. The immediate base class is the constructed
-// type KeyedCollection. When you inherit
-// from KeyedCollection, the second generic type argument is the
-// type that you want to store in the collection -- in this case
-// OrderItem. The first type argument is the type that you want
-// to use as a key. Its values must be calculated from OrderItem;
-// in this case it is the int field PartNumber, so SimpleOrder
-// inherits KeyedCollection.
-//
-public ref class SimpleOrder : KeyedCollection
-{
- // The parameterless constructor of the base class creates a
- // KeyedCollection with an internal dictionary. For this code
- // example, no other constructors are exposed.
- //
-public:
- SimpleOrder() {}
-
- // This is the only method that absolutely must be overridden,
- // because without it the KeyedCollection cannot extract the
- // keys from the items. The input parameter type is the
- // second generic type argument, in this case OrderItem, and
- // the return value type is the first generic type argument,
- // in this case int.
- //
-protected:
- virtual int GetKeyForItem(OrderItem^ item) override
- {
- // In this example, the key is the part number.
- return item->PartNumber;
- }
-};
-
-public ref class Demo
-{
-public:
- static void Main()
- {
- SimpleOrder^ weekly = gcnew SimpleOrder();
-
- // The Add method, inherited from Collection, takes OrderItem.
- //
- weekly->Add(gcnew OrderItem(110072674, "Widget", 400, 45.17));
- weekly->Add(gcnew OrderItem(110072675, "Sprocket", 27, 5.3));
- weekly->Add(gcnew OrderItem(101030411, "Motor", 10, 237.5));
- weekly->Add(gcnew OrderItem(110072684, "Gear", 175, 5.17));
-
- Display(weekly);
-
- // The Contains method of KeyedCollection takes the key,
- // type, in this case int.
- //
- Console::WriteLine("\nContains(101030411): {0}",
- weekly->Contains(101030411));
-
- // The default Item property of KeyedCollection takes a key.
- //
- Console::WriteLine("\nweekly(101030411)->Description: {0}",
- weekly[101030411]->Description);
-
- // The Remove method of KeyedCollection takes a key.
- //
- Console::WriteLine("\nRemove(101030411)");
- weekly->Remove(101030411);
- Display(weekly);
-
- // The Insert method, inherited from Collection, takes an
- // index and an OrderItem.
- //
- Console::WriteLine("\nInsert(2, New OrderItem(...))");
- weekly->Insert(2, gcnew OrderItem(111033401, "Nut", 10, .5));
- Display(weekly);
-
- // The default Item property is overloaded. One overload comes
- // from KeyedCollection; that overload
- // is read-only, and takes Integer because it retrieves by key.
- // The other overload comes from Collection, the
- // base class of KeyedCollection; it
- // retrieves by index, so it also takes an Integer. The compiler
- // uses the most-derived overload, from KeyedCollection, so the
- // only way to access SimpleOrder by index is to cast it to
- // Collection. Otherwise the index is interpreted
- // as a key, and KeyNotFoundException is thrown.
- //
- Collection^ coweekly = weekly;
- Console::WriteLine("\ncoweekly[2].Description: {0}",
- coweekly[2]->Description);
-
- Console::WriteLine("\ncoweekly[2] = gcnew OrderItem(...)");
- coweekly[2] = gcnew OrderItem(127700026, "Crank", 27, 5.98);
-
- OrderItem^ temp = coweekly[2];
-
- // The IndexOf method inherited from Collection
- // takes an OrderItem instead of a key
- //
- Console::WriteLine("\nIndexOf(temp): {0}", weekly->IndexOf(temp));
-
- // The inherited Remove method also takes an OrderItem.
- //
- Console::WriteLine("\nRemove(temp)");
- weekly->Remove(temp);
- Display(weekly);
-
- Console::WriteLine("\nRemoveAt(0)");
- weekly->RemoveAt(0);
- Display(weekly);
-
- }
-
-private:
- static void Display(SimpleOrder^ order)
- {
- Console::WriteLine();
- for each( OrderItem^ item in order )
- {
- Console::WriteLine(item);
- }
- }
-};
-
-void main()
-{
- Demo::Main();
-}
-
-/* This code example produces the following output:
-
-110072674 400 Widget at 45.17 = 18,068.00
-110072675 27 Sprocket at 5.30 = 143.10
-101030411 10 Motor at 237.50 = 2,375.00
-110072684 175 Gear at 5.17 = 904.75
-
-Contains(101030411): True
-
-weekly(101030411)->Description: Motor
-
-Remove(101030411)
-
-110072674 400 Widget at 45.17 = 18,068.00
-110072675 27 Sprocket at 5.30 = 143.10
-110072684 175 Gear at 5.17 = 904.75
-
-Insert(2, New OrderItem(...))
-
-110072674 400 Widget at 45.17 = 18,068.00
-110072675 27 Sprocket at 5.30 = 143.10
-111033401 10 Nut at .50 = 5.00
-110072684 175 Gear at 5.17 = 904.75
-
-coweekly(2)->Description: Nut
-
-coweekly[2] = gcnew OrderItem(...)
-
-IndexOf(temp): 2
-
-Remove(temp)
-
-110072674 400 Widget at 45.17 = 18,068.00
-110072675 27 Sprocket at 5.30 = 143.10
-110072684 175 Gear at 5.17 = 904.75
-
-RemoveAt(0)
-
-110072675 27 Sprocket at 5.30 = 143.10
-110072684 175 Gear at 5.17 = 904.75
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp
deleted file mode 100644
index 37225c227f3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-using namespace System::Collections::ObjectModel;
-
-public enum class ChangeTypes
-{
- Added,
- Removed,
- Replaced,
- Cleared
-};
-
-ref class SimpleOrderChangedEventArgs;
-
-// This class represents a simple line item in an order. All the
-// values are immutable except quantity.
-//
-public ref class OrderItem
-{
-private:
- int _quantity;
-
-public:
- initonly int PartNumber;
- initonly String^ Description;
- initonly double UnitPrice;
-
- OrderItem(int partNumber, String^ description, int quantity,
- double unitPrice)
- {
- this->PartNumber = partNumber;
- this->Description = description;
- this->Quantity = quantity;
- this->UnitPrice = unitPrice;
- };
-
- property int Quantity
- {
- int get() { return _quantity; };
- void set(int value)
- {
- if (value < 0)
- throw gcnew ArgumentException("Quantity cannot be negative.");
-
- _quantity = value;
- };
- };
-
- virtual String^ ToString() override
- {
- return String::Format(
- "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}",
- PartNumber, _quantity, Description, UnitPrice,
- UnitPrice * _quantity);
- };
-};
-
-// Event argument for the Changed event.
-//
-public ref class SimpleOrderChangedEventArgs : EventArgs
-{
-public:
- OrderItem^ ChangedItem;
- initonly ChangeTypes ChangeType;
- OrderItem^ ReplacedWith;
-
- SimpleOrderChangedEventArgs(ChangeTypes change,
- OrderItem^ item, OrderItem^ replacement)
- {
- this->ChangeType = change;
- this->ChangedItem = item;
- this->ReplacedWith = replacement;
- }
-};
-
-// This class derives from KeyedCollection and shows how to override
-// the protected ClearItems, InsertItem, RemoveItem, and SetItem
-// methods in order to change the behavior of the default Item
-// property and the Add, Clear, Insert, and Remove methods. The
-// class implements a Changed event, which is raised by all the
-// protected methods.
-//
-// SimpleOrder is a collection of OrderItem objects, and its key
-// is the PartNumber field of OrderItem-> PartNumber is an Integer,
-// so SimpleOrder inherits KeyedCollection.
-// (Note that the key of OrderItem cannot be changed; if it could
-// be changed, SimpleOrder would have to override ChangeItemKey.)
-//
-public ref class SimpleOrder : KeyedCollection
-{
-public:
- event EventHandler^ Changed;
-
- // This parameterless constructor calls the base class constructor
- // that specifies a dictionary threshold of 0, so that the internal
- // dictionary is created as soon as an item is added to the
- // collection.
- //
- SimpleOrder() : KeyedCollection(nullptr, 0) {};
-
- // This is the only method that absolutely must be overridden,
- // because without it the KeyedCollection cannot extract the
- // keys from the items.
- //
-protected:
- virtual int GetKeyForItem(OrderItem^ item) override
- {
- // In this example, the key is the part number.
- return item->PartNumber;
- }
-
- virtual void InsertItem(int index, OrderItem^ newItem) override
- {
- __super::InsertItem(index, newItem);
-
- Changed(this, gcnew SimpleOrderChangedEventArgs(
- ChangeTypes::Added, newItem, nullptr));
- }
-
- //
- virtual void SetItem(int index, OrderItem^ newItem) override
- {
- OrderItem^ replaced = this->Items[index];
- __super::SetItem(index, newItem);
-
- Changed(this, gcnew SimpleOrderChangedEventArgs(
- ChangeTypes::Replaced, replaced, newItem));
- }
- //
-
- virtual void RemoveItem(int index) override
- {
- OrderItem^ removedItem = Items[index];
- __super::RemoveItem(index);
-
- Changed(this, gcnew SimpleOrderChangedEventArgs(
- ChangeTypes::Removed, removedItem, nullptr));
- }
-
- virtual void ClearItems() override
- {
- __super::ClearItems();
-
- Changed(this, gcnew SimpleOrderChangedEventArgs(
- ChangeTypes::Cleared, nullptr, nullptr));
- }
-
- //
- // This method uses the internal reference to the dictionary
- // to test fo
-public:
- void AddOrMerge(OrderItem^ newItem)
- {
-
- int key = this->GetKeyForItem(newItem);
- OrderItem^ existingItem = nullptr;
-
- // The dictionary is not created until the first item is
- // added, so it is necessary to test for null. Using
- // AndAlso ensures that TryGetValue is not called if the
- // dictionary does not exist.
- //
- if (this->Dictionary != nullptr &&
- this->Dictionary->TryGetValue(key, existingItem))
- {
- existingItem->Quantity += newItem->Quantity;
- }
- else
- {
- this->Add(newItem);
- }
- }
- //
-};
-
-public ref class Demo
-{
-public:
- static void Main()
- {
- SimpleOrder^ weekly = gcnew SimpleOrder();
- weekly->Changed += gcnew
- EventHandler(ChangedHandler);
-
- // The Add method, inherited from Collection, takes OrderItem->
- //
- weekly->Add(gcnew OrderItem(110072674, "Widget", 400, 45.17));
- weekly->Add(gcnew OrderItem(110072675, "Sprocket", 27, 5.3));
- weekly->Add(gcnew OrderItem(101030411, "Motor", 10, 237.5));
- weekly->Add(gcnew OrderItem(110072684, "Gear", 175, 5.17));
-
- Display(weekly);
-
- // The Contains method of KeyedCollection takes TKey.
- //
- Console::WriteLine("\nContains(101030411): {0}",
- weekly->Contains(101030411));
-
- // The default Item property of KeyedCollection takes the key
- // type, Integer. The property is read-only.
- //
- Console::WriteLine("\nweekly[101030411]->Description: {0}",
- weekly[101030411]->Description);
-
- // The Remove method of KeyedCollection takes a key.
- //
- Console::WriteLine("\nRemove(101030411)");
- weekly->Remove(101030411);
-
- // The Insert method, inherited from Collection, takes an
- // index and an OrderItem.
- //
- Console::WriteLine("\nInsert(2, gcnew OrderItem(...))");
- weekly->Insert(2, gcnew OrderItem(111033401, "Nut", 10, .5));
-
- // The default Item property is overloaded. One overload comes
- // from KeyedCollection; that overload
- // is read-only, and takes Integer because it retrieves by key.
- // The other overload comes from Collection, the
- // base class of KeyedCollection; it
- // retrieves by index, so it also takes an Integer. The compiler
- // uses the most-derived overload, from KeyedCollection, so the
- // only way to access SimpleOrder by index is to cast it to
- // Collection. Otherwise the index is interpreted
- // as a key, and KeyNotFoundException is thrown.
- //
- Collection^ coweekly = weekly;
- Console::WriteLine("\ncoweekly[2].Description: {0}",
- coweekly[2]->Description);
-
- Console::WriteLine("\ncoweekly[2] = gcnew OrderItem(...)");
- coweekly[2] = gcnew OrderItem(127700026, "Crank", 27, 5.98);
-
- OrderItem^ temp = coweekly[2];
-
- // The IndexOf method, inherited from Collection,
- // takes an OrderItem instead of a key.
- //
- Console::WriteLine("\nIndexOf(temp): {0}", weekly->IndexOf(temp));
-
- // The inherited Remove method also takes an OrderItem->
- //
- Console::WriteLine("\nRemove(temp)");
- weekly->Remove(temp);
-
- Console::WriteLine("\nRemoveAt(0)");
- weekly->RemoveAt(0);
-
- weekly->AddOrMerge(gcnew OrderItem(110072684, "Gear", 1000, 5.17));
-
- Display(weekly);
-
- Console::WriteLine();
- weekly->Clear();
- }
-
-private:
- static void Display(SimpleOrder^ order)
- {
- Console::WriteLine();
- for each( OrderItem^ item in order )
- {
- Console::WriteLine(item);
- }
- }
-
- static void ChangedHandler(Object^ source,
- SimpleOrderChangedEventArgs^ e)
- {
- OrderItem^ item = e->ChangedItem;
-
- if (e->ChangeType == ChangeTypes::Replaced)
- {
- OrderItem^ replacement = e->ReplacedWith;
-
- Console::WriteLine("{0} (quantity {1}) was replaced " +
- "by {2}, (quantity {3}).", item->Description,
- item->Quantity, replacement->Description,
- replacement->Quantity);
- }
- else if(e->ChangeType == ChangeTypes::Cleared)
- {
- Console::WriteLine("The order list was cleared.");
- }
- else
- {
- Console::WriteLine("{0} (quantity {1}) was {2}.",
- item->Description, item->Quantity, e->ChangeType);
- }
- }
-};
-
-void main()
-{
- Demo::Main();
-}
-
-/* This code example produces the following output:
-
-Widget (quantity 400) was Added.
-Sprocket (quantity 27) was Added.
-Motor (quantity 10) was Added.
-Gear (quantity 175) was Added.
-
-110072674 400 Widget at 45.17 = 18,068.00
-110072675 27 Sprocket at 5.30 = 143.10
-101030411 10 Motor at 237.50 = 2,375.00
-110072684 175 Gear at 5.17 = 904.75
-
-Contains(101030411): True
-
-weekly[101030411]->Description: Motor
-
-Remove(101030411)
-Motor (quantity 10) was Removed.
-
-Insert(2, gcnew OrderItem(...))
-Nut (quantity 10) was Added.
-
-coweekly[2].Description: Nut
-
-coweekly[2] = gcnew OrderItem(...)
-Nut (quantity 10) was replaced by Crank, (quantity 27).
-
-IndexOf(temp): 2
-
-Remove(temp)
-Crank (quantity 27) was Removed.
-
-RemoveAt(0)
-Widget (quantity 400) was Removed.
-
-110072675 27 Sprocket at 5.30 = 143.10
-110072684 1175 Gear at 5.17 = 6,074.75
-
-The order list was cleared.
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp
deleted file mode 100644
index 8fb5233f28b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List(4);
-
- Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity);
-
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Deinonychus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nIList^ roDinosaurs = dinosaurs->AsReadOnly()");
- IList^ roDinosaurs = dinosaurs->AsReadOnly();
-
- Console::WriteLine("\nElements in the read-only IList:");
- for each(String^ dinosaur in roDinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\ndinosaurs[2] = \"Coelophysis\"");
- dinosaurs[2] = "Coelophysis";
-
- Console::WriteLine("\nElements in the read-only IList:");
- for each(String^ dinosaur in roDinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-}
-
-/* This code example produces the following output:
-
-Capacity: 4
-
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Deinonychus
-
-IList^ roDinosaurs = dinosaurs->AsReadOnly()
-
-Elements in the read-only IList:
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Deinonychus
-
-dinosaurs[2] = "Coelophysis"
-
-Elements in the read-only IList:
-Tyrannosaurus
-Amargasaurus
-Coelophysis
-Deinonychus
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp
deleted file mode 100644
index df52855da1d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity);
-
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Deinonychus");
- dinosaurs->Add("Compsognathus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity);
- Console::WriteLine("Count: {0}", dinosaurs->Count);
-
- Console::WriteLine("\nContains(\"Deinonychus\"): {0}",
- dinosaurs->Contains("Deinonychus"));
-
- Console::WriteLine("\nInsert(2, \"Compsognathus\")");
- dinosaurs->Insert(2, "Compsognathus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]);
-
- Console::WriteLine("\nRemove(\"Compsognathus\")");
- dinosaurs->Remove("Compsognathus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- dinosaurs->TrimExcess();
- Console::WriteLine("\nTrimExcess()");
- Console::WriteLine("Capacity: {0}", dinosaurs->Capacity);
- Console::WriteLine("Count: {0}", dinosaurs->Count);
-
- dinosaurs->Clear();
- Console::WriteLine("\nClear()");
- Console::WriteLine("Capacity: {0}", dinosaurs->Capacity);
- Console::WriteLine("Count: {0}", dinosaurs->Count);
-}
-
-/* This code example produces the following output:
-
-Capacity: 0
-
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Deinonychus
-Compsognathus
-
-Capacity: 8
-Count: 5
-
-Contains("Deinonychus"): True
-
-Insert(2, "Compsognathus")
-
-Tyrannosaurus
-Amargasaurus
-Compsognathus
-Mamenchisaurus
-Deinonychus
-Compsognathus
-
-dinosaurs[3]: Mamenchisaurus
-
-Remove("Compsognathus")
-
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Deinonychus
-Compsognathus
-
-TrimExcess()
-Capacity: 5
-Count: 5
-
-Clear()
-Capacity: 5
-Count: 0
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp
deleted file mode 100644
index eb95c6a9af7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Drawing;
-using namespace System::Collections::Generic;
-
-Point PointFToPoint(PointF pf)
-{
- return Point((int) pf.X, (int) pf.Y);
-};
-
-void main()
-{
- List^ lpf = gcnew List();
-
- lpf->Add(PointF(27.8F, 32.62F));
- lpf->Add(PointF(99.3F, 147.273F));
- lpf->Add(PointF(7.5F, 1412.2F));
-
- Console::WriteLine();
- for each(PointF p in lpf)
- {
- Console::WriteLine(p);
- }
-
- List^ lp =
- lpf->ConvertAll(
- gcnew Converter(PointFToPoint)
- );
-
- Console::WriteLine();
- for each(Point p in lp)
- {
- Console::WriteLine(p);
- }
-}
-
-/* This code example produces the following output:
-
-{X=27.8, Y=32.62}
-{X=99.3, Y=147.273}
-{X=7.5, Y=1412.2}
-
-{X=27,Y=32}
-{X=99,Y=147}
-{X=7,Y=1412}
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp
deleted file mode 100644
index ce250927500..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Brachiosaurus");
- dinosaurs->Add("Compsognathus");
-
- Console::WriteLine();
- for each(String^ dinosaurs in dinosaurs )
- {
- Console::WriteLine(dinosaurs);
- }
-
- // Create an array of 15 strings.
- array^ arr = gcnew array(15);
-
- dinosaurs->CopyTo(arr);
- dinosaurs->CopyTo(arr, 6);
- dinosaurs->CopyTo(2, arr, 12, 3);
-
- Console::WriteLine("\nContents of the array:");
- for each(String^ dinosaurs in arr )
- {
- Console::WriteLine(dinosaurs);
- }
-}
-
-/* This code example produces the following output:
-
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Brachiosaurus
-Deinonychus
-Tyrannosaurus
-Compsognathus
-
-IndexOf("Tyrannosaurus"): 0
-
-IndexOf("Tyrannosaurus", 3): 5
-
-IndexOf("Tyrannosaurus", 2, 2): -1
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp
deleted file mode 100644
index d4033713e6c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-// Search predicate returns true if a string ends in "saurus".
-bool EndsWithSaurus(String^ s)
-{
- return s->ToLower()->EndsWith("saurus");
-};
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Compsognathus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Oviraptor");
- dinosaurs->Add("Velociraptor");
- dinosaurs->Add("Deinonychus");
- dinosaurs->Add("Dilophosaurus");
- dinosaurs->Add("Gallimimus");
- dinosaurs->Add("Triceratops");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nTrueForAll(EndsWithSaurus): {0}",
- dinosaurs->TrueForAll(gcnew Predicate(EndsWithSaurus)));
-
- Console::WriteLine("\nFind(EndsWithSaurus): {0}",
- dinosaurs->Find(gcnew Predicate(EndsWithSaurus)));
-
- Console::WriteLine("\nFindLast(EndsWithSaurus): {0}",
- dinosaurs->FindLast(gcnew Predicate(EndsWithSaurus)));
-
- Console::WriteLine("\nFindAll(EndsWithSaurus):");
- List^ sublist =
- dinosaurs->FindAll(gcnew Predicate(EndsWithSaurus));
-
- for each(String^ dinosaur in sublist)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine(
- "\n{0} elements removed by RemoveAll(EndsWithSaurus).",
- dinosaurs->RemoveAll(gcnew Predicate(EndsWithSaurus)));
-
- Console::WriteLine("\nList now contains:");
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nExists(EndsWithSaurus): {0}",
- dinosaurs->Exists(gcnew Predicate(EndsWithSaurus)));
-}
-
-/* This code example produces the following output:
-
-Compsognathus
-Amargasaurus
-Oviraptor
-Velociraptor
-Deinonychus
-Dilophosaurus
-Gallimimus
-Triceratops
-
-TrueForAll(EndsWithSaurus): False
-
-Find(EndsWithSaurus): Amargasaurus
-
-FindLast(EndsWithSaurus): Dilophosaurus
-
-FindAll(EndsWithSaurus):
-Amargasaurus
-Dilophosaurus
-
-2 elements removed by RemoveAll(EndsWithSaurus).
-
-List now contains:
-Compsognathus
-Oviraptor
-Velociraptor
-Deinonychus
-Gallimimus
-Triceratops
-
-Exists(EndsWithSaurus): False
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp
deleted file mode 100644
index 6ca3a08037e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Brachiosaurus");
- dinosaurs->Add("Deinonychus");
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Compsognathus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nIndexOf(\"Tyrannosaurus\"): {0}",
- dinosaurs->IndexOf("Tyrannosaurus"));
-
- Console::WriteLine("\nIndexOf(\"Tyrannosaurus\", 3): {0}",
- dinosaurs->IndexOf("Tyrannosaurus", 3));
-
- Console::WriteLine("\nIndexOf(\"Tyrannosaurus\", 2, 2): {0}",
- dinosaurs->IndexOf("Tyrannosaurus", 2, 2));
-}
-
-/* This code example produces the following output:
-
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Brachiosaurus
-Deinonychus
-Tyrannosaurus
-Compsognathus
-
-IndexOf("Tyrannosaurus"): 0
-
-IndexOf("Tyrannosaurus", 3): 5
-
-IndexOf("Tyrannosaurus", 2, 2): -1
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp
deleted file mode 100644
index c6ffc2e2707..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Brachiosaurus");
- dinosaurs->Add("Deinonychus");
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Compsognathus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nLastIndexOf(\"Tyrannosaurus\"): {0}",
- dinosaurs->LastIndexOf("Tyrannosaurus"));
-
- Console::WriteLine("\nLastIndexOf(\"Tyrannosaurus\", 3): {0}",
- dinosaurs->LastIndexOf("Tyrannosaurus", 3));
-
- Console::WriteLine("\nLastIndexOf(\"Tyrannosaurus\", 4, 4): {0}",
- dinosaurs->LastIndexOf("Tyrannosaurus", 4, 4));
-}
-
-/* This code example produces the following output:
-
-Tyrannosaurus
-Amargasaurus
-Mamenchisaurus
-Brachiosaurus
-Deinonychus
-Tyrannosaurus
-Compsognathus
-
-LastIndexOf("Tyrannosaurus"): 5
-
-LastIndexOf("Tyrannosaurus", 3): 0
-
-LastIndexOf("Tyrannosaurus", 4, 4): -1
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp
deleted file mode 100644
index fbee67ad25b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- array^ input = { "Brachiosaurus",
- "Amargasaurus",
- "Mamenchisaurus" };
-
- List^ dinosaurs =
- gcnew List((IEnumerable^) input);
-
- Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity);
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nAddRange(dinosaurs)");
- dinosaurs->AddRange(dinosaurs);
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nRemoveRange(2, 2)");
- dinosaurs->RemoveRange(2, 2);
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- input = gcnew array { "Tyrannosaurus",
- "Deinonychus",
- "Velociraptor"};
-
- Console::WriteLine("\nInsertRange(3, (IEnumerable^) input)");
- dinosaurs->InsertRange(3, (IEnumerable^) input);
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\noutput = dinosaurs->GetRange(2, 3)->ToArray()");
- array^ output = dinosaurs->GetRange(2, 3)->ToArray();
-
- Console::WriteLine();
- for each(String^ dinosaur in output )
- {
- Console::WriteLine(dinosaur);
- }
-}
-
-/* This code example produces the following output:
-
-Capacity: 3
-
-Brachiosaurus
-Amargasaurus
-Mamenchisaurus
-
-AddRange(dinosaurs)
-
-Brachiosaurus
-Amargasaurus
-Mamenchisaurus
-Brachiosaurus
-Amargasaurus
-Mamenchisaurus
-
-RemoveRange(2, 2)
-
-Brachiosaurus
-Amargasaurus
-Amargasaurus
-Mamenchisaurus
-
-InsertRange(3, (IEnumerable^) input)
-
-Brachiosaurus
-Amargasaurus
-Amargasaurus
-Tyrannosaurus
-Deinonychus
-Velociraptor
-Mamenchisaurus
-
-output = dinosaurs->GetRange(2, 3)->ToArray()
-
-Amargasaurus
-Tyrannosaurus
-Deinonychus
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp
deleted file mode 100644
index 71c584db785..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Pachycephalosaurus");
- dinosaurs->Add("Parasauralophus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Coelophysis");
- dinosaurs->Add("Oviraptor");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- dinosaurs->Reverse();
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- dinosaurs->Reverse(1, 4);
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-}
-
-/* This code example produces the following output:
-
-Pachycephalosaurus
-Parasauralophus
-Mamenchisaurus
-Amargasaurus
-Coelophysis
-Oviraptor
-
-Oviraptor
-Coelophysis
-Amargasaurus
-Mamenchisaurus
-Parasauralophus
-Pachycephalosaurus
-
-Oviraptor
-Parasauralophus
-Mamenchisaurus
-Amargasaurus
-Coelophysis
-Pachycephalosaurus
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp
deleted file mode 100644
index 4ae53587c2f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-int CompareDinosByLength(String^ x, String^ y)
-{
- if (x == nullptr)
- {
- if (y == nullptr)
- {
- // If x is null and y is null, they're
- // equal.
- return 0;
- }
- else
- {
- // If x is null and y is not null, y
- // is greater.
- return -1;
- }
- }
- else
- {
- // If x is not null...
- //
- if (y == nullptr)
- // ...and y is null, x is greater.
- {
- return 1;
- }
- else
- {
- // ...and y is not null, compare the
- // lengths of the two strings.
- //
- int retval = x->Length.CompareTo(y->Length);
-
- if (retval != 0)
- {
- // If the strings are not of equal length,
- // the longer string is greater.
- //
- return retval;
- }
- else
- {
- // If the strings are of equal length,
- // sort them with ordinary string comparison.
- //
- return x->CompareTo(y);
- }
- }
- }
-};
-
-void Display(List^ list)
-{
- Console::WriteLine();
- for each(String^ s in list)
- {
- if (s == nullptr)
- Console::WriteLine("(null)");
- else
- Console::WriteLine("\"{0}\"", s);
- }
-};
-
-void main()
-{
- List^ dinosaurs = gcnew List();
- dinosaurs->Add("Pachycephalosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("");
- dinosaurs->Add(nullptr);
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Deinonychus");
- Display(dinosaurs);
-
- Console::WriteLine("\nSort with generic Comparison delegate:");
- dinosaurs->Sort(
- gcnew Comparison(CompareDinosByLength));
- Display(dinosaurs);
-
-}
-
-/* This code example produces the following output:
-
-"Pachycephalosaurus"
-"Amargasaurus"
-""
-(null)
-"Mamenchisaurus"
-"Deinonychus"
-
-Sort with generic Comparison delegate:
-
-(null)
-""
-"Deinonychus"
-"Amargasaurus"
-"Mamenchisaurus"
-"Pachycephalosaurus"
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp
deleted file mode 100644
index e37961290a5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Pachycephalosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Deinonychus");
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nSort");
- dinosaurs->Sort();
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nBinarySearch and Insert \"Coelophysis\":");
- int index = dinosaurs->BinarySearch("Coelophysis");
- if (index < 0)
- {
- dinosaurs->Insert(~index, "Coelophysis");
- }
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nBinarySearch and Insert \"Tyrannosaurus\":");
- index = dinosaurs->BinarySearch("Tyrannosaurus");
- if (index < 0)
- {
- dinosaurs->Insert(~index, "Tyrannosaurus");
- }
-
- Console::WriteLine();
- for each(String^ dinosaur in dinosaurs)
- {
- Console::WriteLine(dinosaur);
- }
-}
-
-/* This code example produces the following output:
-
-Pachycephalosaurus
-Amargasaurus
-Mamenchisaurus
-Deinonychus
-
-Sort
-
-Amargasaurus
-Deinonychus
-Mamenchisaurus
-Pachycephalosaurus
-
-BinarySearch and Insert "Coelophysis":
-
-Amargasaurus
-Coelophysis
-Deinonychus
-Mamenchisaurus
-Pachycephalosaurus
-
-BinarySearch and Insert "Tyrannosaurus":
-
-Amargasaurus
-Coelophysis
-Deinonychus
-Mamenchisaurus
-Pachycephalosaurus
-Tyrannosaurus
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp
deleted file mode 100644
index 396d3d9f86e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class DinoComparer: IComparer
-{
-public:
- virtual int Compare(String^ x, String^ y)
- {
- if (x == nullptr)
- {
- if (y == nullptr)
- {
- // If x is null and y is null, they're
- // equal.
- return 0;
- }
- else
- {
- // If x is null and y is not null, y
- // is greater.
- return -1;
- }
- }
- else
- {
- // If x is not null...
- //
- if (y == nullptr)
- // ...and y is null, x is greater.
- {
- return 1;
- }
- else
- {
- // ...and y is not null, compare the
- // lengths of the two strings.
- //
- int retval = x->Length.CompareTo(y->Length);
-
- if (retval != 0)
- {
- // If the strings are not of equal length,
- // the longer string is greater.
- //
- return retval;
- }
- else
- {
- // If the strings are of equal length,
- // sort them with ordinary string comparison.
- //
- return x->CompareTo(y);
- }
- }
- }
- }
-};
-
-void SearchAndInsert(List^ list, String^ insert,
- DinoComparer^ dc)
-{
- Console::WriteLine("\nBinarySearch and Insert \"{0}\":", insert);
-
- int index = list->BinarySearch(insert, dc);
-
- if (index < 0)
- {
- list->Insert(~index, insert);
- }
-};
-
-void Display(List^ list)
-{
- Console::WriteLine();
- for each(String^ s in list)
- {
- Console::WriteLine(s);
- }
-};
-
-void main()
-{
- List^ dinosaurs = gcnew List();
- dinosaurs->Add("Pachycephalosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Deinonychus");
- Display(dinosaurs);
-
- DinoComparer^ dc = gcnew DinoComparer();
-
- Console::WriteLine("\nSort with alternate comparer:");
- dinosaurs->Sort(dc);
- Display(dinosaurs);
-
- SearchAndInsert(dinosaurs, "Coelophysis", dc);
- Display(dinosaurs);
-
- SearchAndInsert(dinosaurs, "Oviraptor", dc);
- Display(dinosaurs);
-
- SearchAndInsert(dinosaurs, "Tyrannosaur", dc);
- Display(dinosaurs);
-
- SearchAndInsert(dinosaurs, nullptr, dc);
- Display(dinosaurs);
-}
-
-/* This code example produces the following output:
-
-Pachycephalosaurus
-Amargasaurus
-Mamenchisaurus
-Deinonychus
-
-Sort with alternate comparer:
-
-Deinonychus
-Amargasaurus
-Mamenchisaurus
-Pachycephalosaurus
-
-BinarySearch and Insert "Coelophysis":
-
-Coelophysis
-Deinonychus
-Amargasaurus
-Mamenchisaurus
-Pachycephalosaurus
-
-BinarySearch and Insert "Oviraptor":
-
-Oviraptor
-Coelophysis
-Deinonychus
-Amargasaurus
-Mamenchisaurus
-Pachycephalosaurus
-
-BinarySearch and Insert "Tyrannosaur":
-
-Oviraptor
-Coelophysis
-Deinonychus
-Tyrannosaur
-Amargasaurus
-Mamenchisaurus
-Pachycephalosaurus
-
-BinarySearch and Insert "":
-
-
-Oviraptor
-Coelophysis
-Deinonychus
-Tyrannosaur
-Amargasaurus
-Mamenchisaurus
-Pachycephalosaurus
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp
deleted file mode 100644
index dbb74dd3f43..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class DinoComparer: IComparer
-{
-public:
- virtual int Compare(String^ x, String^ y)
- {
- if (x == nullptr)
- {
- if (y == nullptr)
- {
- // If x is null and y is null, they're
- // equal.
- return 0;
- }
- else
- {
- // If x is null and y is not null, y
- // is greater.
- return -1;
- }
- }
- else
- {
- // If x is not null...
- //
- if (y == nullptr)
- // ...and y is null, x is greater.
- {
- return 1;
- }
- else
- {
- // ...and y is not null, compare the
- // lengths of the two strings.
- //
- int retval = x->Length.CompareTo(y->Length);
-
- if (retval != 0)
- {
- // If the strings are not of equal length,
- // the longer string is greater.
- //
- return retval;
- }
- else
- {
- // If the strings are of equal length,
- // sort them with ordinary string comparison.
- //
- return x->CompareTo(y);
- }
- }
- }
- }
-};
-
-void Display(List^ list)
-{
- Console::WriteLine();
- for each(String^ s in list)
- {
- Console::WriteLine(s);
- }
-};
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Pachycephalosaurus");
- dinosaurs->Add("Parasauralophus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Galimimus");
- dinosaurs->Add("Mamenchisaurus");
- dinosaurs->Add("Deinonychus");
- dinosaurs->Add("Oviraptor");
- dinosaurs->Add("Tyrannosaurus");
-
- int herbivores = 5;
- Display(dinosaurs);
-
- DinoComparer^ dc = gcnew DinoComparer();
-
- Console::WriteLine("\nSort a range with the alternate comparer:");
- dinosaurs->Sort(0, herbivores, dc);
- Display(dinosaurs);
-
- Console::WriteLine("\nBinarySearch a range and Insert \"{0}\":",
- "Brachiosaurus");
-
- int index = dinosaurs->BinarySearch(0, herbivores, "Brachiosaurus", dc);
-
- if (index < 0)
- {
- dinosaurs->Insert(~index, "Brachiosaurus");
- herbivores++;
- }
-
- Display(dinosaurs);
-}
-
-/* This code example produces the following output:
-
-Pachycephalosaurus
-Parasauralophus
-Amargasaurus
-Galimimus
-Mamenchisaurus
-Deinonychus
-Oviraptor
-Tyrannosaurus
-
-Sort a range with the alternate comparer:
-
-Galimimus
-Amargasaurus
-Mamenchisaurus
-Parasauralophus
-Pachycephalosaurus
-Deinonychus
-Oviraptor
-Tyrannosaurus
-
-BinarySearch a range and Insert "Brachiosaurus":
-
-Galimimus
-Amargasaurus
-Brachiosaurus
-Mamenchisaurus
-Parasauralophus
-Pachycephalosaurus
-Deinonychus
-Oviraptor
-Tyrannosaurus
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp b/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp
deleted file mode 100644
index b45d3fbc13a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp
+++ /dev/null
@@ -1,331 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Threading;
-using namespace System::Collections::Generic;
-using namespace System::Text;
-
-generic public ref class SafeQueue
-{
-private:
- //
- //
- // A queue that is protected by Monitor.
- Queue^ m_inputQueue;
- //
-
-public:
- SafeQueue()
- {
- m_inputQueue = gcnew Queue();
- };
-
- // Lock the queue and add an element.
- void Enqueue(T qValue)
- {
- // Request the lock, and block until it is obtained.
- Monitor::Enter(m_inputQueue);
- try
- {
- // When the lock is obtained, add an element.
- m_inputQueue->Enqueue(qValue);
- }
- finally
- {
- // Ensure that the lock is released.
- Monitor::Exit(m_inputQueue);
- }
- };
- //
-
- //
- // Try to add an element to the queue: Add the element to the queue
- // only if the lock is immediately available.
- bool TryEnqueue(T qValue)
- {
- // Request the lock.
- if (Monitor::TryEnter(m_inputQueue))
- {
- try
- {
- m_inputQueue->Enqueue(qValue);
- }
- finally
- {
- // Ensure that the lock is released.
- Monitor::Exit(m_inputQueue);
- }
- return true;
- }
- else
- {
- return false;
- }
- };
- //
-
- //
- // Try to add an element to the queue: Add the element to the queue
- // only if the lock becomes available during the specified time
- // interval.
- bool TryEnqueue(T qValue, int waitTime)
- {
- // Request the lock.
- if (Monitor::TryEnter(m_inputQueue, waitTime))
- {
- try
- {
- m_inputQueue->Enqueue(qValue);
- }
- finally
- {
- // Ensure that the lock is released.
- Monitor::Exit(m_inputQueue);
- }
- return true;
- }
- else
- {
- return false;
- }
- };
- //
-
- // Lock the queue and dequeue an element.
- T Dequeue()
- {
- T retval;
-
- // Request the lock, and block until it is obtained.
- Monitor::Enter(m_inputQueue);
- try
- {
- // When the lock is obtained, dequeue an element.
- retval = m_inputQueue->Dequeue();
- }
- finally
- {
- // Ensure that the lock is released.
- Monitor::Exit(m_inputQueue);
- }
-
- return retval;
- };
-
- // Delete all elements that equal the given object.
- int Remove(T qValue)
- {
- int removedCt = 0;
-
- // Wait until the lock is available and lock the queue.
- Monitor::Enter(m_inputQueue);
- try
- {
- int counter = m_inputQueue->Count;
- while (counter > 0)
- // Check each element.
- {
- T elem = m_inputQueue->Dequeue();
- if (!elem->Equals(qValue))
- {
- m_inputQueue->Enqueue(elem);
- }
- else
- {
- // Keep a count of items removed.
- removedCt += 1;
- }
- counter = counter - 1;
- }
- }
- finally
- {
- // Ensure that the lock is released.
- Monitor::Exit(m_inputQueue);
- }
-
- return removedCt;
- };
-
- // Print all queue elements.
- String^ PrintAllElements()
- {
- StringBuilder^ output = gcnew StringBuilder();
-
- // Lock the queue.
- Monitor::Enter(m_inputQueue);
- try
- {
- for each ( T elem in m_inputQueue )
- {
- // Print the next element.
- output->AppendLine(elem->ToString());
- }
- }
- finally
- {
- // Ensure that the lock is released.
- Monitor::Exit(m_inputQueue);
- }
-
- return output->ToString();
- };
-};
-
-public ref class Example
-{
-private:
- static SafeQueue^ q = gcnew SafeQueue();
- static int threadsRunning = 0;
- static array^>^ results = gcnew array^>(3);
-
- static void ThreadProc(Object^ state)
- {
- DateTime finish = DateTime::Now.AddSeconds(10);
- Random^ rand = gcnew Random();
- array^ result = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int threadNum = (int) state;
-
- while (DateTime::Now < finish)
-
- {
- int what = rand->Next(250);
- int how = rand->Next(100);
-
- if (how < 16)
- {
- q->Enqueue(what);
- result[(int)ThreadResultIndex::EnqueueCt] += 1;
- }
- else if (how < 32)
- {
- if (q->TryEnqueue(what))
- {
- result[(int)ThreadResultIndex::TryEnqueueSucceedCt] += 1;
- }
- else
- {
- result[(int)ThreadResultIndex::TryEnqueueFailCt] += 1;
- }
- }
- else if (how < 48)
- {
- // Even a very small wait significantly increases the success
- // rate of the conditional enqueue operation.
- if (q->TryEnqueue(what, 10))
- {
- result[(int)ThreadResultIndex::TryEnqueueWaitSucceedCt] += 1;
- }
- else
- {
- result[(int)ThreadResultIndex::TryEnqueueWaitFailCt] += 1;
- }
- }
- else if (how < 96)
- {
- result[(int)ThreadResultIndex::DequeueCt] += 1;
- try
- {
- q->Dequeue();
- }
- catch (Exception^ ex)
- {
- result[(int)ThreadResultIndex::DequeueExCt] += 1;
- }
- }
- else
- {
- result[(int)ThreadResultIndex::RemoveCt] += 1;
- result[(int)ThreadResultIndex::RemovedCt] += q->Remove(what);
- }
- }
-
- results[threadNum] = result;
-
- if (0 == Interlocked::Decrement(threadsRunning))
- {
- StringBuilder^ sb = gcnew StringBuilder(
- " Thread 1 Thread 2 Thread 3 Total\n");
-
- for (int row = 0; row < 9; row++)
- {
- int total = 0;
- sb->Append(titles[row]);
-
- for(int col = 0; col < 3; col++)
- {
- sb->Append(String::Format("{0,9}", results[col][row]));
- total += results[col][row];
- }
-
- sb->AppendLine(String::Format("{0,9}", total));
- }
-
- Console::WriteLine(sb->ToString());
- }
- };
-
- static array^ titles = {
- "Enqueue ",
- "TryEnqueue succeeded ",
- "TryEnqueue failed ",
- "TryEnqueue(T, wait) succeeded ",
- "TryEnqueue(T, wait) failed ",
- "Dequeue attempts ",
- "Dequeue exceptions ",
- "Remove operations ",
- "Queue elements removed "};
-
- enum class ThreadResultIndex
- {
- EnqueueCt,
- TryEnqueueSucceedCt,
- TryEnqueueFailCt,
- TryEnqueueWaitSucceedCt,
- TryEnqueueWaitFailCt,
- DequeueCt,
- DequeueExCt,
- RemoveCt,
- RemovedCt
- };
-
-public:
- static void Demo()
- {
- Console::WriteLine("Working...");
-
- for(int i = 0; i < 3; i++)
- {
- Thread^ t = gcnew Thread(gcnew ParameterizedThreadStart(Example::ThreadProc));
- t->Start(i);
- Interlocked::Increment(threadsRunning);
- }
- };
-};
-
-void main()
-{
- Example::Demo();
-}
-
-
-/* This example produces output similar to the following:
-
-Working...
- Thread 1 Thread 2 Thread 3 Total
-Enqueue 274718 513514 337895 1126127
-TryEnqueue succeeded 274502 513516 337480 1125498
-TryEnqueue failed 119 235 141 495
-TryEnqueue(T, wait) succeeded 274552 513116 338532 1126200
-TryEnqueue(T, wait) failed 0 1 0 1
-Dequeue attempts 824038 1541866 1015006 3380910
-Dequeue exceptions 12828 23416 14799 51043
-Remove operations 68746 128218 84306 281270
-Queue elements removed 11464 22024 14470 47958
-Queue elements removed 2921 4690 2982 10593
- */
-//
-
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp b/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp
deleted file mode 100644
index 4836a5745f6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-// The following code example demonstrates the effect of changing the NumberDecimalDigits property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a negative value with the default number of decimal digits (2).
- Int64 myInt = -1234;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-
- // Displays the same value with four decimal digits.
- nfi->NumberDecimalDigits = 4;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-}
-
-/*
-This code produces the following output.
--1, 234.00
--1, 234.0000
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp b/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp
deleted file mode 100644
index 3314e9eab5c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// NumberDecimalSeparator property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S".").
- Int64 myInt = 123456789;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-
- // Displays the same value with a blank as the separator.
- nfi->NumberDecimalSeparator = " ";
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-}
-
-/*
-This code produces the following output.
-123, 456, 789.00
-123, 456, 789 00
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp b/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp
deleted file mode 100644
index 8211f6d47a8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//Types:System.Globalization.NumberFormatInfo
-//
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Text;
-
-int main()
-{
- StringBuilder^ builder = gcnew StringBuilder();
-
- // Loop through all the specific cultures known to the CLR.
- for each(CultureInfo^ culture in
- CultureInfo::GetCultures (CultureTypes::SpecificCultures))
- {
- // Only show the currency symbols for cultures
- // that speak English.
- if (culture->TwoLetterISOLanguageName == "en")
- {
- //
- // Display the culture name and currency symbol.
- NumberFormatInfo^ numberFormat = culture->NumberFormat;
- builder->AppendFormat("The currency symbol for '{0}'"+
- "is '{1}'",culture->DisplayName,
- numberFormat->CurrencySymbol);
- builder->AppendLine();
- //
- }
- }
- Console::WriteLine(builder);
-}
-
-// This code produces the following output.
-//
-// The currency symbol for 'English (United States)' is '$'
-// The currency symbol for 'English (United Kingdom)' is 'Ј'
-// The currency symbol for 'English (Australia)' is '$'
-// The currency symbol for 'English (Canada)' is '$'
-// The currency symbol for 'English (New Zealand)' is '$'
-// The currency symbol for 'English (Ireland)' is '?'
-// The currency symbol for 'English (South Africa)' is 'R'
-// The currency symbol for 'English (Jamaica)' is 'J$'
-// The currency symbol for 'English (Caribbean)' is '$'
-// The currency symbol for 'English (Belize)' is 'BZ$'
-// The currency symbol for 'English (Trinidad and Tobago)' is 'TT$'
-// The currency symbol for 'English (Zimbabwe)' is 'Z$'
-// The currency symbol for 'English (Republic of the Philippines)' is 'Php'
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp b/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp
deleted file mode 100644
index 96cb476c415..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-// The following code example demonstrates the effect of changing the NumberGroupSeparator property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S", ").
- Int64 myInt = 123456789;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-
- // Displays the same value with a blank as the separator.
- nfi->NumberGroupSeparator = " ";
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-}
-
-/*
-This code produces the following output.
-123, 456, 789.00
-123 456 789.00
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp b/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp
deleted file mode 100644
index f51cb7d8d13..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example demonstrates the effect of changing the NumberGroupSizes property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S".").
- Int64 myInt = 123456789012345;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-
- // Displays the same value with different groupings.
- array^mySizes1 = {2,3,4};
- array^mySizes2 = {2,3,0};
- nfi->NumberGroupSizes = mySizes1;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
- nfi->NumberGroupSizes = mySizes2;
- Console::WriteLine( myInt.ToString( "N", nfi ) );
-}
-
-/*
-This code produces the following output.
-123, 456, 789, 012, 345.00
-12, 3456, 7890, 123, 45.00
-1234567890, 123, 45.00
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp b/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp
deleted file mode 100644
index 5fe0650df9b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//Types:System.Globalization.NumberStyles (enum)
-//
-using namespace System;
-using namespace System::Text;
-using namespace System::Globalization;
-
-
-int main()
-{
- // Parse the string as a hex value and display the
- // value as a decimal.
- String^ numberString = "A";
- int stringValue = Int32::Parse(numberString, NumberStyles::HexNumber);
- Console::WriteLine("{0} in hex = {1} in decimal.",
- numberString, stringValue);
-
- // Parse the string, allowing a leading sign, and ignoring
- // leading and trailing white spaces.
- numberString = " -45 ";
- stringValue =Int32::Parse(numberString, NumberStyles::AllowLeadingSign |
- NumberStyles::AllowLeadingWhite | NumberStyles::AllowTrailingWhite);
- Console::WriteLine("'{0}' parsed to an int is '{1}'.",
- numberString, stringValue);
-
- // Parse the string, allowing parentheses, and ignoring
- // leading and trailing white spaces.
- numberString = " (37) ";
- stringValue = Int32::Parse(numberString, NumberStyles::AllowParentheses |
- NumberStyles::AllowLeadingSign | NumberStyles::AllowLeadingWhite |
- NumberStyles::AllowTrailingWhite);
-
- Console::WriteLine("'{0}' parsed to an int is '{1}'.",
- numberString, stringValue);
-}
-
-// This code produces the following output.
-//
-// A in hex = 10 in decimal.
-// ' -45 ' parsed to an int is '-45'.
-// ' (37) ' parsed to an int is '-37'.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp
deleted file mode 100644
index 75724099841..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-using namespace System::Collections::ObjectModel;
-
-public ref class Demo
-{
-public:
- static void Main()
- {
- Collection^ dinosaurs = gcnew Collection();
-
- dinosaurs->Add("Psitticosaurus");
- dinosaurs->Add("Caudipteryx");
- dinosaurs->Add("Compsognathus");
- dinosaurs->Add("Muttaburrasaurus");
-
- Console::WriteLine("{0} dinosaurs:", dinosaurs->Count);
- Display(dinosaurs);
-
- Console::WriteLine("\nIndexOf(\"Muttaburrasaurus\"): {0}",
- dinosaurs->IndexOf("Muttaburrasaurus"));
-
- Console::WriteLine("\nContains(\"Caudipteryx\"): {0}",
- dinosaurs->Contains("Caudipteryx"));
-
- Console::WriteLine("\nInsert(2, \"Nanotyrannus\")");
- dinosaurs->Insert(2, "Nanotyrannus");
- Display(dinosaurs);
-
- Console::WriteLine("\ndinosaurs[2]: {0}", dinosaurs[2]);
-
- Console::WriteLine("\ndinosaurs[2] = \"Microraptor\"");
- dinosaurs[2] = "Microraptor";
- Display(dinosaurs);
-
- Console::WriteLine("\nRemove(\"Microraptor\")");
- dinosaurs->Remove("Microraptor");
- Display(dinosaurs);
-
- Console::WriteLine("\nRemoveAt(0)");
- dinosaurs->RemoveAt(0);
- Display(dinosaurs);
-
- Console::WriteLine("\ndinosaurs.Clear()");
- dinosaurs->Clear();
- Console::WriteLine("Count: {0}", dinosaurs->Count);
- }
-
-private:
- static void Display(Collection^ cs)
- {
- Console::WriteLine();
- for each( String^ item in cs )
- {
- Console::WriteLine(item);
- }
- }
-};
-
-int main()
-{
- Demo::Main();
-}
-
-/* This code example produces the following output:
-
-4 dinosaurs:
-
-Psitticosaurus
-Caudipteryx
-Compsognathus
-Muttaburrasaurus
-
-IndexOf("Muttaburrasaurus"): 3
-
-Contains("Caudipteryx"): True
-
-Insert(2, "Nanotyrannus")
-
-Psitticosaurus
-Caudipteryx
-Nanotyrannus
-Compsognathus
-Muttaburrasaurus
-
-dinosaurs[2]: Nanotyrannus
-
-dinosaurs[2] = "Microraptor"
-
-Psitticosaurus
-Caudipteryx
-Microraptor
-Compsognathus
-Muttaburrasaurus
-
-Remove("Microraptor")
-
-Psitticosaurus
-Caudipteryx
-Compsognathus
-Muttaburrasaurus
-
-RemoveAt(0)
-
-Caudipteryx
-Compsognathus
-Muttaburrasaurus
-
-dinosaurs.Clear()
-Count: 0
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp b/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp
deleted file mode 100644
index 08709a04488..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path1 = "c:\\temp\\MyTest.txt";
- String^ path2 = "c:\\temp\\MyTest";
- String^ path3 = "temp";
- if ( Path::HasExtension( path1 ) )
- {
- Console::WriteLine( "{0} has an extension.", path1 );
- }
-
- if ( !Path::HasExtension( path2 ) )
- {
- Console::WriteLine( "{0} has no extension.", path2 );
- }
-
- if ( !Path::IsPathRooted( path3 ) )
- {
- Console::WriteLine( "The string {0} contains no root information.", path3 );
- }
-
- Console::WriteLine( "The full path of {0} is {1}.", path3, Path::GetFullPath( path3 ) );
- Console::WriteLine( "{0} is the location for temporary files.", Path::GetTempPath() );
- Console::WriteLine( "{0} is a file available for use.", Path::GetTempFileName() );
- Console::WriteLine( "\r\nThe set of invalid characters in a path is:" );
- Console::WriteLine( "(Note that the wildcard characters '*' and '?' are not invalid.):" );
- Collections::IEnumerator^ myEnum = Path::InvalidPathChars->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Char c = *safe_cast(myEnum->Current);
- Console::WriteLine( c );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp b/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp
deleted file mode 100644
index 331d7abbb90..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-// The following code example demonstrates the effect of changing the PercentDecimalDigits property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a negative value with the default number of decimal digits (2).
- Double myInt = 0.1234;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-
- // Displays the same value with four decimal digits.
- nfi->PercentDecimalDigits = 4;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-}
-
-/*
-This code produces the following output.
-12.34 %
-12.3400 %
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp b/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp
deleted file mode 100644
index de975569dfb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// PercentDecimalSeparator property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S".").
- Double myInt = 0.1234;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-
- // Displays the same value with a blank as the separator.
- nfi->PercentDecimalSeparator = " ";
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-}
-
-/*
-This code produces the following output.
-12.34 %
-12 34 %
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp b/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp
deleted file mode 100644
index 39d7c7a20ca..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-// The following code example demonstrates the effect of changing the
-// PercentGroupSeparator property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S", ").
- Double myInt = 1234.5678;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-
- // Displays the same value with a blank as the separator.
- nfi->PercentGroupSeparator = " ";
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-}
-
-/*
-This code produces the following output.
-123, 456.78 %
-123 456.78 %
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp b/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp
deleted file mode 100644
index 2edc2ec4edf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-
-// The following code example demonstrates the effect of changing the PercentGroupSizes property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets a NumberFormatInfo associated with the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- NumberFormatInfo^ nfi = MyCI->NumberFormat;
-
- // Displays a value with the default separator (S".").
- Double myInt = 123456789012345.6789;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-
- // Displays the same value with different groupings.
- array^mySizes1 = {2,3,4};
- array^mySizes2 = {2,3,0};
- nfi->PercentGroupSizes = mySizes1;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
- nfi->PercentGroupSizes = mySizes2;
- Console::WriteLine( myInt.ToString( "P", nfi ) );
-}
-
-/*
-This code produces the following output.
-
-12, 345, 678, 901, 234, 600.00 %
-1234, 5678, 9012, 346, 00.00 %
-123456789012, 346, 00.00 %
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp b/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp
deleted file mode 100644
index ec0c28aeb8c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-#using
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Drawing;
-using namespace System::Collections;
-using namespace System::ComponentModel;
-using namespace System::Windows::Forms;
-using namespace System::Data;
-using namespace System::Diagnostics;
-
-///
-/// Summary description for Form1.
-///
-public ref class Form1: public System::Windows::Forms::Form
-{
-private:
-
- ///
- /// Required designer variable.
- ///
- System::ComponentModel::Container^ components;
-
-public:
- Form1()
- {
- components = nullptr;
-
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
-
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- }
-
-
-protected:
-
- ///
- /// Clean up any resources being used.
- ///
- ~Form1()
- {
- if ( components != nullptr )
- {
- delete components;
- }
- }
-
-private:
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- void InitializeComponent()
- {
- //
- // Form1
- //
- this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 );
- this->ClientSize = System::Drawing::Size( 292, 266 );
- this->Name = "Form1";
- this->Text = "Form1";
- this->Load += gcnew System::EventHandler( this, &Form1::Form1_Load );
- }
-
- void Form1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ )
- {
- //
- PerformanceCounter^ PC = gcnew PerformanceCounter;
- PC->CategoryName = "Process";
- PC->CounterName = "Private Bytes";
- PC->InstanceName = "Explorer";
- MessageBox::Show( PC->NextValue().ToString() );
- //
-
- //
- Array^ PerfCat = PerformanceCounterCategory::GetCategories();
- MessageBox::Show( String::Concat( "The number of performance counter categories in the local machine is ", PerfCat->Length ) );
- //
- }
-};
-
-///
-/// The main entry point for the application.
-///
-
-[STAThread]
-int main()
-{
- Application::Run( gcnew Form1 );
-}
-
-//Output:
-//11.11 %
-//11.11 Percent
diff --git a/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp b/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp
deleted file mode 100644
index 9cdd3a26593..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-int main()
-{
-
- //
- if ( !PerformanceCounterCategory::Exists( "Orders" ) )
- {
- CounterCreationData^ milk = gcnew CounterCreationData;
- milk->CounterName = "milk";
- milk->CounterType = PerformanceCounterType::NumberOfItems32;
-
- CounterCreationData^ milkPerSecond = gcnew CounterCreationData;
- milkPerSecond->CounterName = "milk orders/second";
- milkPerSecond->CounterType = PerformanceCounterType::RateOfCountsPerSecond32;
-
- CounterCreationDataCollection^ ccds = gcnew CounterCreationDataCollection;
- ccds->Add( milkPerSecond );
- ccds->Add( milk );
- PerformanceCounterCategory::Create( "Orders", "Number of processed orders", ccds );
- }
- //
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp b/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp
deleted file mode 100644
index fe5c4b92d7c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// cpp.cpp : main project file.
-// System::Diagnostics.PerformanceCounterInstaller
-/*
-The following example demonstrates 'PerformanceCounterInstaller' class.
-A class is inherited from 'Installer' having 'RunInstallerAttribute' set to true.
-A new instance of 'PerformanceCounterInstaller' is created and its 'CategoryName'
-is set. Then this instance is added to 'InstallerCollection'.
-Note:
-1)To run this example use the following command:
-InstallUtil::exe PerformanceCounterInstaller::exe
-2)To uninstall the perfomance counter use the following command:
-InstallUtil::exe /u PerformanceCounterInstaller::exe
-*/
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Configuration::Install;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-
-[RunInstaller(true)]
-ref class MyPerformanceCounterInstaller: public Installer
-{
-public:
- MyPerformanceCounterInstaller()
- {
- try
- {
- // Create an instance of 'PerformanceCounterInstaller'.
- PerformanceCounterInstaller^ myPerformanceCounterInstaller =
- gcnew PerformanceCounterInstaller;
- // Set the 'CategoryName' for performance counter.
- myPerformanceCounterInstaller->CategoryName =
- "MyPerformanceCounter";
- CounterCreationData^ myCounterCreation = gcnew CounterCreationData;
- myCounterCreation->CounterName = "MyCounter";
- myCounterCreation->CounterHelp = "Counter Help";
- // Add a counter to collection of myPerformanceCounterInstaller.
- myPerformanceCounterInstaller->Counters->Add( myCounterCreation );
- Installers->Add( myPerformanceCounterInstaller );
- }
- catch ( Exception^ e )
- {
- this->Context->LogMessage( "Error occurred : " + e->Message );
- }
- }
-};
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp b/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp
deleted file mode 100644
index f51c915deba..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Diagnostics;
-
-// Output information about the counter sample.
-void OutputSample( CounterSample s )
-{
- Console::WriteLine( "\r\n+++++++++++" );
- Console::WriteLine( "Sample values - \r\n" );
- Console::WriteLine( " BaseValue = {0}", s.BaseValue );
- Console::WriteLine( " CounterFrequency = {0}", s.CounterFrequency );
- Console::WriteLine( " CounterTimeStamp = {0}", s.CounterTimeStamp );
- Console::WriteLine( " CounterType = {0}", s.CounterType );
- Console::WriteLine( " RawValue = {0}", s.RawValue );
- Console::WriteLine( " SystemFrequency = {0}", s.SystemFrequency );
- Console::WriteLine( " TimeStamp = {0}", s.TimeStamp );
- Console::WriteLine( " TimeStamp100nSec = {0}", s.TimeStamp100nSec );
- Console::WriteLine( "++++++++++++++++++++++" );
-}
-
-//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
-// Description - This counter type shows how many items are processed, on average,
-// during an operation. Counters of this type display a ratio of the items
-// processed (such as bytes sent) to the number of operations completed. The
-// ratio is calculated by comparing the number of items processed during the
-// last interval to the number of operations completed during the last interval.
-// Generic type - Average
-// Formula - (N1 - N0) / (D1 - D0), where the numerator (N) represents the number
-// of items processed during the last sample interval and the denominator (D)
-// represents the number of operations completed during the last two sample
-// intervals.
-// Average (Nx - N0) / (Dx - D0)
-// Example PhysicalDisk\ Avg. Disk Bytes/Transfer
-//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++
-float MyComputeCounterValue( CounterSample s0, CounterSample s1 )
-{
- float numerator = (float)s1.RawValue - (float)s0.RawValue;
- float denomenator = (float)s1.BaseValue - (float)s0.BaseValue;
- float counterValue = numerator / denomenator;
- return counterValue;
-}
-
-bool SetupCategory()
-{
- if ( !PerformanceCounterCategory::Exists( "AverageCounter64SampleCategory" ) )
- {
- CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection;
-
- // Add the counter.
- CounterCreationData^ averageCount64 = gcnew CounterCreationData;
- averageCount64->CounterType = PerformanceCounterType::AverageCount64;
- averageCount64->CounterName = "AverageCounter64Sample";
- CCDC->Add( averageCount64 );
-
- // Add the base counter.
- CounterCreationData^ averageCount64Base = gcnew CounterCreationData;
- averageCount64Base->CounterType = PerformanceCounterType::AverageBase;
- averageCount64Base->CounterName = "AverageCounter64SampleBase";
- CCDC->Add( averageCount64Base );
-
- // Create the category.
- PerformanceCounterCategory::Create( "AverageCounter64SampleCategory", "Demonstrates usage of the AverageCounter64 performance counter type.", CCDC );
- return (true);
- }
- else
- {
- Console::WriteLine( "Category exists - AverageCounter64SampleCategory" );
- return (false);
- }
-}
-
-void CreateCounters( PerformanceCounter^% PC, PerformanceCounter^% BPC )
-{
-
- // Create the counters.
- //
- PC = gcnew PerformanceCounter( "AverageCounter64SampleCategory","AverageCounter64Sample",false );
- //
-
- BPC = gcnew PerformanceCounter( "AverageCounter64SampleCategory","AverageCounter64SampleBase",false );
- PC->RawValue = 0;
- BPC->RawValue = 0;
-}
-//
-void CollectSamples( ArrayList^ samplesList, PerformanceCounter^ PC, PerformanceCounter^ BPC )
-{
- Random^ r = gcnew Random( DateTime::Now.Millisecond );
-
- // Loop for the samples.
- for ( int j = 0; j < 100; j++ )
- {
- int value = r->Next( 1, 10 );
- Console::Write( "{0} = {1}", j, value );
- PC->IncrementBy( value );
- BPC->Increment();
- if ( (j % 10) == 9 )
- {
- OutputSample( PC->NextSample() );
- samplesList->Add( PC->NextSample() );
- }
- else
- Console::WriteLine();
- System::Threading::Thread::Sleep( 50 );
- }
-}
-//
-
-void CalculateResults( ArrayList^ samplesList )
-{
- for ( int i = 0; i < (samplesList->Count - 1); i++ )
- {
- // Output the sample.
- OutputSample( *safe_cast(samplesList[ i ]) );
- OutputSample( *safe_cast(samplesList[ i + 1 ]) );
-
- // Use .NET to calculate the counter value.
- Console::WriteLine( ".NET computed counter value = {0}", CounterSampleCalculator::ComputeCounterValue( *safe_cast(samplesList[ i ]), *safe_cast(samplesList[ i + 1 ]) ) );
-
- // Calculate the counter value manually.
- Console::WriteLine( "My computed counter value = {0}", MyComputeCounterValue( *safe_cast(samplesList[ i ]), *safe_cast(samplesList[ i + 1 ]) ) );
- }
-}
-
-int main()
-{
- ArrayList^ samplesList = gcnew ArrayList;
- PerformanceCounter^ PC;
- PerformanceCounter^ BPC;
- SetupCategory();
- CreateCounters( PC, BPC );
- CollectSamples( samplesList, PC, BPC );
- CalculateResults( samplesList );
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp b/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp
deleted file mode 100644
index 0c6d5707320..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp
+++ /dev/null
@@ -1,208 +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
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Diagnostics;
-using namespace System::Runtime::InteropServices;
-
-void OutputSample( CounterSample s )
-{
- Console::WriteLine( "\r\n+++++++++++" );
- Console::WriteLine( "Sample values - \r\n" );
- Console::WriteLine( " BaseValue = {0}", s.BaseValue );
- Console::WriteLine( " CounterFrequency = {0}", s.CounterFrequency );
- Console::WriteLine( " CounterTimeStamp = {0}", s.CounterTimeStamp );
- Console::WriteLine( " CounterType = {0}", s.CounterType );
- Console::WriteLine( " RawValue = {0}", s.RawValue );
- Console::WriteLine( " SystemFrequency = {0}", s.SystemFrequency );
- Console::WriteLine( " TimeStamp = {0}", s.TimeStamp );
- Console::WriteLine( " TimeStamp100nSec = {0}", s.TimeStamp100nSec );
- Console::WriteLine( "++++++++++++++++++++++" );
-}
-
-// Reads the counter information to enable setting the RawValue.
-[DllImport("Kernel32.dll")]
-extern bool QueryPerformanceCounter( [Out]__int64 * value );
-
-bool SetupCategory()
-{
- if ( !PerformanceCounterCategory::Exists( "ElapsedTimeSampleCategory" ) )
- {
- CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection;
-
- // Add the counter.
- CounterCreationData^ ETimeData = gcnew CounterCreationData;
- ETimeData->CounterType = PerformanceCounterType::ElapsedTime;
- ETimeData->CounterName = "ElapsedTimeSample";
- CCDC->Add( ETimeData );
-
- // Create the category.
- PerformanceCounterCategory::Create( "ElapsedTimeSampleCategory",
- "Demonstrates usage of the ElapsedTime performance counter type.",
- CCDC );
- return true;
- }
- else
- {
- Console::WriteLine( "Category exists - ElapsedTimeSampleCategory" );
- return false;
- }
-}
-
-void CreateCounters( PerformanceCounter^% PC )
-{
- // Create the counter.
- PC = gcnew PerformanceCounter( "ElapsedTimeSampleCategory",
- "ElapsedTimeSample",
- false );
-}
-
-void CollectSamples( ArrayList^ samplesList, PerformanceCounter^ PC )
-{
- __int64 pcValue;
- DateTime Start;
-
- // Initialize the counter.
- QueryPerformanceCounter( &pcValue );
- PC->RawValue = pcValue;
- Start = DateTime::Now;
-
- // Loop for the samples.
- for ( int j = 0; j < 1000; j++ )
- {
- // Output the values.
- if ( (j % 10) == 9 )
- {
- Console::WriteLine( "NextValue() = {0}", PC->NextValue() );
- Console::WriteLine( "Actual elapsed time = {0}", DateTime::Now.Subtract( Start ) );
- OutputSample( PC->NextSample() );
- samplesList->Add( PC->NextSample() );
- }
-
- // reset the counter on 100th iteration.
- if ( j % 100 == 0 )
- {
- QueryPerformanceCounter( &pcValue );
- PC->RawValue = pcValue;
- Start = DateTime::Now;
- }
- System::Threading::Thread::Sleep( 50 );
- }
-
- Console::WriteLine( "Elapsed time = {0}", DateTime::Now.Subtract( Start ) );
-}
-
-void main()
-{
- ArrayList^ samplesList = gcnew ArrayList;
-// PerformanceCounter^ PC;
- SetupCategory();
-// CreateCounters( PC );
- CreateCounters();
- CollectSamples( samplesList, PC );
-}
-//
-
-#else
-// Build sample for Whidbey or higher.
-
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Diagnostics;
-using namespace System::Runtime::InteropServices;
-
-void OutputSample( CounterSample s )
-{
- Console::WriteLine( "\r\n+++++++++++" );
- Console::WriteLine( "Sample values - \r\n" );
- Console::WriteLine( " BaseValue = {0}", s.BaseValue );
- Console::WriteLine( " CounterFrequency = {0}", s.CounterFrequency );
- Console::WriteLine( " CounterTimeStamp = {0}", s.CounterTimeStamp );
- Console::WriteLine( " CounterType = {0}", s.CounterType );
- Console::WriteLine( " RawValue = {0}", s.RawValue );
- Console::WriteLine( " SystemFrequency = {0}", s.SystemFrequency );
- Console::WriteLine( " TimeStamp = {0}", s.TimeStamp );
- Console::WriteLine( " TimeStamp100nSec = {0}", s.TimeStamp100nSec );
- Console::WriteLine( "++++++++++++++++++++++" );
-}
-
-void CollectSamples()
-{
- String^ categoryName = "ElapsedTimeSampleCategory";
- String^ counterName = "ElapsedTimeSample";
-
- // Create the performance counter category.
- if ( !PerformanceCounterCategory::Exists( categoryName ) )
- {
- CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection;
-
- // Add the counter.
- CounterCreationData^ ETimeData = gcnew CounterCreationData;
- ETimeData->CounterType = PerformanceCounterType::ElapsedTime;
- ETimeData->CounterName = counterName;
- CCDC->Add( ETimeData );
-
- // Create the category.
- PerformanceCounterCategory::Create( categoryName,
- "Demonstrates ElapsedTime performance counter usage.",
- CCDC );
- }
- else
- {
- Console::WriteLine( "Category exists - {0}", categoryName );
- }
-
-
- //
- // Create the performance counter.
- PerformanceCounter^ PC = gcnew PerformanceCounter( categoryName,
- counterName,
- false );
- // Initialize the counter.
- PC->RawValue = Stopwatch::GetTimestamp();
- //
-
- DateTime Start = DateTime::Now;
-
- // Loop for the samples.
- for ( int j = 0; j < 100; j++ )
- {
- // Output the values.
- if ( (j % 10) == 9 )
- {
- Console::WriteLine( "NextValue() = {0}", PC->NextValue() );
- Console::WriteLine( "Actual elapsed time = {0}", DateTime::Now.Subtract( Start ) );
- OutputSample( PC->NextSample() );
- }
-
- // Reset the counter on every 20th iteration.
- if ( j % 20 == 0 )
- {
- PC->RawValue = Stopwatch::GetTimestamp();
- Start = DateTime::Now;
- }
- System::Threading::Thread::Sleep( 50 );
- }
-
- Console::WriteLine( "Elapsed time = {0}", DateTime::Now.Subtract( Start ) );
-}
-
-int main()
-{
- CollectSamples();
-}
-//
-#endif
diff --git a/snippets/cpp/VS_Snippets_CLR/Process.GetProcesses_noexception/CPP/processstaticget.cpp b/snippets/cpp/VS_Snippets_CLR/Process.GetProcesses_noexception/CPP/processstaticget.cpp
deleted file mode 100644
index c551e40c3f6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process.GetProcesses_noexception/CPP/processstaticget.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-int main()
-{
- // Get the current process.
- Process^ currentProcess = Process::GetCurrentProcess();
-
- // Get all processes running on the local computer.
- array^localAll = Process::GetProcesses();
-
- // Get all instances of Notepad running on the local computer.
- // This will return an empty array if notepad isn't running.
- array^localByName = Process::GetProcessesByName("notepad");
-
- // Get a process on the local computer, using the process id.
- // This will throw an exception if there is no such process.
- Process^ localById = Process::GetProcessById(1234);
-
-
- // Get processes running on a remote computer. Note that this
- // and all the following calls will timeout and throw an exception
- // if "myComputer" and 169.0.0.0 do not exist on your local network.
-
- // Get all processes on a remote computer.
- array^remoteAll = Process::GetProcesses("myComputer");
-
- // Get all instances of Notepad running on the specific computer, using machine name.
- array^remoteByName = Process::GetProcessesByName( "notepad", "myComputer" );
-
- // Get all instances of Notepad running on the specific computer, using IP address.
- array^ipByName = Process::GetProcessesByName( "notepad", "169.0.0.0" );
-
- // Get a process on a remote computer, using the process id and machine name.
- Process^ remoteById = Process::GetProcessById( 2345, "myComputer" );
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp
deleted file mode 100644
index b4879144d08..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-#using
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-
-int main()
-{
- Process^ myProcess = gcnew Process;
-
- try
- {
- myProcess->StartInfo->UseShellExecute = false;
- // You can start any process, HelloWorld is a do-nothing example.
- myProcess->StartInfo->FileName = "C:\\HelloWorld.exe";
- myProcess->StartInfo->CreateNoWindow = true;
- myProcess->Start();
- // This code assumes the process you are starting will terminate itself.
- // Given that it is started without a window so you cannot terminate it
- // on the desktop, it must terminate itself or you can do it programmatically
- // from this application using the Kill method.
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp
deleted file mode 100644
index 6db5fa36f59..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-
-// Opens the Internet Explorer application.
-void OpenApplication(String^ myFavoritesPath)
-{
- // Start Internet Explorer. Defaults to the home page.
- Process::Start("IExplore.exe");
-
- // Display the contents of the favorites folder in the browser.
- Process::Start(myFavoritesPath);
-}
-
-// Opens urls and .html documents using Internet Explorer.
-void OpenWithArguments()
-{
- // URLs are not considered documents. They can only be opened
- // by passing them as arguments.
- Process::Start("IExplore.exe", "www.northwindtraders.com");
-
- // Start a Web page using a browser associated with .html and .asp files.
- Process::Start("IExplore.exe", "C:\\myPath\\myFile.htm");
- Process::Start("IExplore.exe", "C:\\myPath\\myFile.asp");
-}
-
-// Uses the ProcessStartInfo class to start new processes,
-// both in a minimized mode.
-void OpenWithStartInfo()
-{
- ProcessStartInfo^ startInfo = gcnew ProcessStartInfo("IExplore.exe");
- startInfo->WindowStyle = ProcessWindowStyle::Minimized;
- Process::Start(startInfo);
- startInfo->Arguments = "www.northwindtraders.com";
- Process::Start(startInfo);
-}
-
-int main()
-{
- // Get the path that stores favorite links.
- String^ myFavoritesPath = Environment::GetFolderPath(Environment::SpecialFolder::Favorites);
- OpenApplication(myFavoritesPath);
- OpenWithArguments();
- OpenWithStartInfo();
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic2.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic2.cpp
deleted file mode 100644
index b84436e8b00..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic2.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// Place the following code into a console project called StartArgsEcho. It depends on the
-// console application named argsecho.exe.
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- ProcessStartInfo^ startInfo = gcnew ProcessStartInfo("argsecho.exe");
- startInfo->WindowStyle = ProcessWindowStyle::Normal;
-
- // Start with one argument.
- // Output of ArgsEcho:
- // [0]=/a
- startInfo->Arguments = "/a";
- Process::Start(startInfo);
-
- // Start with multiple arguments separated by spaces.
- // Output of ArgsEcho:
- // [0] = /a
- // [1] = /b
- // [2] = c:\temp
- startInfo->Arguments = "/a /b c:\\temp";
- Process::Start(startInfo);
-
- // An argument with spaces inside quotes is interpreted as multiple arguments.
- // Output of ArgsEcho:
- // [0] = /a
- // [1] = literal string arg
- startInfo->Arguments = "/a \"literal string arg\"";
- Process::Start(startInfo);
-
- // An argument inside double quotes is interpreted as if the quote weren't there,
- // that is, as separate arguments.
- // Output of ArgsEcho:
- // [0] = /a
- // [1] = /b:string
- // [2] = in
- // [3] = double
- // [4] = quotes
- startInfo->Arguments = "/a /b:\"\"string in double quotes\"\"";
- Process::Start(startInfo);
-
- // Triple-escape quotation marks to include the character in the final argument received
- // by the target process.
- // [0] = /a
- // [1] = /b:"quoted string"
- startInfo->Arguments = "/a /b:\"\"\"quoted string\"\"\"";
- Process::Start(startInfo);
-
- return 0;
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic3.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic3.cpp
deleted file mode 100644
index d4fd5c0b6cd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic3.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Place this code into a console project called ArgsEcho to build the argsecho.exe target
-
-using namespace System;
-
-int main(array ^args)
-{
- Console::WriteLine("Received the following arguments:\n");
-
- for (int i = 0; i < args->Length; i++)
- {
- Console::WriteLine("[" + i + "] = " + args[i]);
- }
-
- Console::WriteLine("\nPress any key to exit");
- Console::ReadLine();
- return 0;
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp
deleted file mode 100644
index 57ea4cc3263..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// System::Diagnostics::ProcessModule
-/* The following program demonstrates the use of 'ProcessModule' class.
-It creates a notepad, gets the 'MainModule' and all other modules of
-the process 'notepad.exe', displays some of the properties of each modules.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "Properties of the modules associated with 'notepad' are:" );
-
- // Display the properties of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "The moduleName is {0}", myProcessModule->ModuleName );
- Console::WriteLine( "The {0}'s base address is: {1}", myProcessModule->ModuleName, myProcessModule->BaseAddress );
- Console::WriteLine( "The {0}'s Entry point address is: {1}", myProcessModule->ModuleName, myProcessModule->EntryPointAddress );
- Console::WriteLine( "The {0}'s File name is: {1}", myProcessModule->ModuleName, myProcessModule->FileName );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the properties of the main module.
- Console::WriteLine( "The process's main moduleName is: {0}", myProcessModule->ModuleName );
- Console::WriteLine( "The process's main module's base address is: {0}", myProcessModule->BaseAddress );
- Console::WriteLine( "The process's main module's Entry point address is: {0}", myProcessModule->EntryPointAddress );
- Console::WriteLine( "The process's main module's File name is: {0}", myProcessModule->FileName );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp
deleted file mode 100644
index c941fb56f0d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// System::Diagnostics::ProcessModule::BaseAddress
-
-/* The following program demonstrates the use of 'BaseAddress' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'BaseAddress'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "Base addresses of the modules associated with 'notepad' are:" );
-
- // Display the 'BaseAddress' of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->BaseAddress );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the 'BaseAddress' of the main module.
- Console::WriteLine( "The process's main module's base address is: {0}", myProcessModule->BaseAddress );
- myProcess->CloseMainWindow();
- //
-
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp
deleted file mode 100644
index a03a38206d4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// System::Diagnostics::ProcessModule::EntryPointAddress
-
-/* The following program demonstrates the use of 'EntryPointAddress' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'EntryPointAddress'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "Entry point addresses of the modules associated with 'notepad' are:" );
-
- // Display the 'EntryPointAddress' of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->EntryPointAddress );
- }
- myProcessModule = myProcess->MainModule;
- Console::WriteLine( "The process's main module's EntryPointAddress is: {0}", myProcessModule->EntryPointAddress );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp
deleted file mode 100644
index a67c20e8412..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// System::Diagnostics::ProcessModule::FileName
-
-/* The following program demonstrates the use of 'FileName' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'FileName'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "File names of the modules associated with 'notepad' are:" );
-
- // Display the 'FileName' of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "{0:s} : {1:s}", myProcessModule->ModuleName, myProcessModule->FileName );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the 'FileName' of the main module.
- Console::WriteLine( "The process's main module's FileName is: {0}", myProcessModule->FileName );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp
deleted file mode 100644
index 62a1569e9f3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// System::Diagnostics::ProcessModule::FileVersionInfo
-
-/* The following program demonstrates the use of 'FileVersionInfo' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'FileVersionInfo'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "'FileversionInfo' of the modules associated with 'notepad' are:" );
-
- // Display the 'FileVersionInfo' of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->FileVersionInfo );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the 'FileVersionInfo' of main module.
- Console::WriteLine( "The process's main module's FileVersionInfo is: {0}", myProcessModule->FileVersionInfo );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp
deleted file mode 100644
index 8d5907528ee..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// System::Diagnostics::ProcessModule::ModuleMemorySize
-
-/* The following program demonstrates the use of 'ModuleMemorySize' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'ModuleMemorySize'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "Module memory sizes of the modules associated with 'notepad' are:" );
-
- // Display the 'ModuleMemorySize' of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->ModuleMemorySize );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the 'ModuleMemorySize' of the main module.
- Console::WriteLine( "The process's main module's ModuleMemorySize is: {0}", myProcessModule->ModuleMemorySize );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp
deleted file mode 100644
index 96abbee1dab..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// System::Diagnostics::ProcessModule::ModuleName
-
-/* The following program demonstrates the use of 'ModuleName' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'ModuleName'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "Module names of the modules associated with 'notepad' are:" );
-
- // Display the 'ModuleName' of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( myProcessModule->ModuleName );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the 'ModuleName' of the main module.
- Console::WriteLine( "The process's main moduleName is: {0}", myProcessModule->ModuleName );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp
deleted file mode 100644
index 9bd9a254aa0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// System::Diagnostics::ProcessModule::ToString
-
-/* The following program demonstrates the use of 'ToString' property of
-'ProcessModule' class. It creates a notepad, gets the 'MainModule' and
-all other modules of the process 'notepad.exe', displays 'ToString'
-for all the modules and the main module.
-*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-int main()
-{
- try
- {
- //
- Process^ myProcess = gcnew Process;
-
- // Get the process start information of notepad.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" );
-
- // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*.
- myProcess->StartInfo = myProcessStartInfo;
-
- // Create a notepad.
- myProcess->Start();
- System::Threading::Thread::Sleep( 1000 );
- ProcessModule^ myProcessModule;
-
- // Get all the modules associated with 'myProcess'.
- ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules;
- Console::WriteLine( "ToString properties of the modules associated with 'notepad' are:" );
-
- // Display the ToString of each of the modules.
- for ( int i = 0; i < myProcessModuleCollection->Count; i++ )
- {
- myProcessModule = myProcessModuleCollection[ i ];
- Console::WriteLine( "{0} : {1}", myProcessModuleCollection[ i ]->ModuleName, myProcessModule->ToString() );
- }
- myProcessModule = myProcess->MainModule;
-
- // Display the ToString of the main module.
- Console::WriteLine( "The process's main module is : {0}", myProcessModule->ToString() );
- myProcess->CloseMainWindow();
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception : {0}", e->Message );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp
deleted file mode 100644
index dc1a08793ee..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-void main()
-{
- //
- // Run "cl.exe /cld stdstr.cpp /link /out:sample.exe". UseShellExecute is false because we're specifying
- // an executable directly and in this case depending on it being in a PATH folder. By setting
- // RedirectStandardOutput to true, the output of cl.exe is directed to the Process.StandardOutput stream
- // which is then displayed in this console window directly.
- Process^ compiler = gcnew Process;
- compiler->StartInfo->FileName = "cl.exe";
- compiler->StartInfo->Arguments = "/clr stdstr.cpp /link /out:sample.exe";
- compiler->StartInfo->UseShellExecute = false;
- compiler->StartInfo->RedirectStandardOutput = true;
- compiler->Start();
-
- Console::WriteLine( compiler->StandardOutput->ReadToEnd() );
-
- compiler->WaitForExit();
- //
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/Process_MainWindowTitle/CPP/process_mainwindowtitle.cpp b/snippets/cpp/VS_Snippets_CLR/Process_MainWindowTitle/CPP/process_mainwindowtitle.cpp
deleted file mode 100644
index 194770fb873..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process_MainWindowTitle/CPP/process_mainwindowtitle.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-// System::Diagnostics::Process::MainWindowTitle
-/* The following program demonstrates the property 'MainWindowTitle' of class 'Process'.
-It creates a new process notepad on local computer and displays its caption to console.
-*/
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-int main()
-{
- try
- {
-
- // Create an instance of process component.
- Process^ myProcess = gcnew Process;
-
- // Create an instance of 'myProcessStartInfo'.
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo;
- myProcessStartInfo->FileName = "notepad";
- myProcess->StartInfo = myProcessStartInfo;
-
- // Start process.
- myProcess->Start();
-
- // Allow the process to finish starting.
- myProcess->WaitForInputIdle();
- Console::Write( "Main window Title : {0}", myProcess->MainWindowTitle );
- myProcess->CloseMainWindow();
- myProcess->Close();
- }
- catch ( Exception^ e )
- {
- Console::Write( " Message : {0}", e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp
deleted file mode 100644
index b295733c646..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// System::Diagnostics::Process::StandardError
-/*
-The following example demonstrates property 'StandardError' of
-'Process' class.
-
-It starts a process(net.exe) which writes an error message on to the standard
-error when a bad network path is given. This program gets 'StandardError' of
-net.exe process and reads output from its stream reader.*/
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-using namespace System::IO;
-
-void GetStandardError( array^args )
-{
-//
- Process^ myProcess = gcnew Process;
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "net ",String::Concat( "use ", args[ 0 ] ) );
-
- myProcessStartInfo->UseShellExecute = false;
- myProcessStartInfo->RedirectStandardError = true;
- myProcess->StartInfo = myProcessStartInfo;
- myProcess->Start();
-
- StreamReader^ myStreamReader = myProcess->StandardError;
- // Read the standard error of net.exe and write it on to console.
- Console::WriteLine( myStreamReader->ReadLine() );
- myProcess->Close();
-//
-}
-
-void main( int argc, char *argv[] )
-{
- if ( argc < 2 )
- {
- Console::WriteLine( "\nThis requires a machine name as a parameter which is not on the network." );
- Console::WriteLine( "\nUsage:" );
- Console::WriteLine( "Process_StandardError <\\\\machine name>" );
- }
- else
- {
- GetStandardError( Environment::GetCommandLineArgs() );
- }
- return;
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp b/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp
deleted file mode 100644
index 02249c8a531..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-/// System.Diagnostics.Process.StandardInput
-//
-//
-// The following example illustrates how to redirect the StandardInput
-// stream of a process. The example starts the sort command with
-// redirected input. It then prompts the user for text, and passes
-// that to the sort command by means of the redirected input stream.
-// The sort command results are displayed to the user on the console.
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-int main()
-{
- Console::WriteLine( "Ready to sort one or more text lines..." );
-
- // Start the Sort.exe process with redirected input.
- // Use the sort command to sort the input text.
- Process^ myProcess = gcnew Process;
- if ( myProcess )
- {
- myProcess->StartInfo->FileName = "Sort.exe";
- myProcess->StartInfo->UseShellExecute = false;
- myProcess->StartInfo->RedirectStandardInput = true;
- myProcess->Start();
- StreamWriter^ myStreamWriter = myProcess->StandardInput;
- if ( myStreamWriter )
- {
-
- // Prompt the user for input text lines to sort.
- // Write each line to the StandardInput stream of
- // the sort command.
- String^ inputText;
- int numLines = 0;
- do
- {
- Console::WriteLine( "Enter a line of text (or press the Enter key to stop):" );
- inputText = Console::ReadLine();
- if ( inputText && inputText->Length > 0 )
- {
- numLines++;
- myStreamWriter->WriteLine( inputText );
- }
- }
- while ( inputText && inputText->Length != 0 );
-
- // Write a report header to the console.
- if ( numLines > 0 )
- {
- Console::WriteLine( " {0} sorted text line(s) ", numLines.ToString() );
- Console::WriteLine( "------------------------" );
- }
- else
- {
- Console::WriteLine( " No input was sorted" );
- }
-
- // End the input stream to the sort command.
- // When the stream closes, the sort command
- // writes the sorted text lines to the
- // console.
- myStreamWriter->Close();
- }
-
- // Wait for the sort process to write the sorted text lines.
- myProcess->WaitForExit();
- myProcess->Close();
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp b/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp
deleted file mode 100644
index 6820437e824..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-using namespace System;
-using namespace System::IO;
-using namespace System::Diagnostics;
-
-int main()
-{
- Process^ process = gcnew Process();
- process->StartInfo->FileName = "ipconfig.exe";
- process->StartInfo->UseShellExecute = false;
- process->StartInfo->RedirectStandardOutput = true;
- process->Start();
-
- // Synchronously read the standard output of the spawned process->
- StreamReader^ reader = process->StandardOutput;
- String^ output = reader->ReadToEnd();
-
- // Write the redirected output to this application's window.
- Console::WriteLine(output);
-
- process->WaitForExit();
- process->Close();
-
- Console::WriteLine("\n\nPress any key to exit");
- Console::ReadLine();
- return 0;
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp b/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp
deleted file mode 100644
index 7494c07f40a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// System::Diagnostics::Process::SynchronizingObject
-
-/*
-The following example demonstrates the property 'SynchronizingObject'
-of 'Process' class.
-
-It starts a process 'mspaint.exe' on button click.
-It attaches 'MyProcessExited' method of 'MyButton' class as EventHandler to
-'Exited' event of the process.
-*/
-
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::Windows::Forms;
-
-ref class Form1: public System::Windows::Forms::Form
-{
-private:
- System::ComponentModel::Container^ components;
-
- //
- ref class MyButton: public Button
- {
- public:
- void MyProcessExited( Object^ source, EventArgs^ e )
- {
- MessageBox::Show( "The process has exited." );
- }
- };
-
-public:
- MyButton^ button1;
-private:
- void MyProcessExited( Object^ source, EventArgs^ e )
- {
- MessageBox::Show( "The process has exited." );
- }
- void button1_Click( Object^ sender, EventArgs^ e )
- {
- Process^ myProcess = gcnew Process;
- ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "mspaint" );
- myProcess->StartInfo = myProcessStartInfo;
- myProcess->Start();
- myProcess->Exited += gcnew System::EventHandler( this, &Form1::MyProcessExited );
-
- // Set 'EnableRaisingEvents' to true, to raise 'Exited' event when process is terminated.
- myProcess->EnableRaisingEvents = true;
-
- // Set method handling the exited event to be called ;
- // on the same thread on which MyButton was created.
- myProcess->SynchronizingObject = button1;
- MessageBox::Show( "Waiting for the process 'mspaint' to exit...." );
- myProcess->WaitForExit();
- myProcess->Close();
- }
- //
-
- void InitializeComponent()
- {
- this->button1 = gcnew MyButton;
- this->SuspendLayout();
-
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point( 40, 80 );
- this->button1->Name = "button1";
- this->button1->Size = System::Drawing::Size( 168, 32 );
- this->button1->TabIndex = 0;
- this->button1->Text = "Click Me";
- this->button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click );
-
- //
- // Form1
- //
- this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 );
- this->ClientSize = System::Drawing::Size( 292, 273 );
- array^newControls = {this->button1};
- this->Controls->AddRange( newControls );
- this->Name = "Form1";
- this->Text = "Form1";
- this->ResumeLayout( false );
- }
-
-public:
- ~Form1()
- {
- if ( components != nullptr )
- {
- delete components;
- }
- }
-
-public:
- Form1()
- : components( nullptr )
- {
- InitializeComponent();
- }
-};
-
-[STAThread]
-void main()
-{
- Application::Run( gcnew Form1 );
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp
deleted file mode 100644
index 70a6c01850b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// This is kind of a ripoff of 'process_synchronizingobject.cs' for use as a znippet
-// for the remarks section.
-
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::Windows::Forms;
-
-namespace SynchronizingObjectTest
-{
- public ref class SyncForm : System::Windows::Forms::Form
- {
-
- public:
- SyncForm() : components( nullptr )
- {
- InitializeComponent();
- }
-
- ~SyncForm()
- {
- if ( components != nullptr )
- {
- delete components;
- }
- }
-
- static void Main()
- {
- Application::Run(gcnew SyncForm);
- }
-#if 0 // Dispose is implicit
- protected:
- virtual void Dispose( bool disposing ) override
- {
- if( disposing )
- {
- if (components != null)
- {
- components->Dispose();
- }
- }
- base->Dispose( disposing );
- }
-#endif
-
- private:
- System::ComponentModel::Container^ components;
- Process^ process1;
- Button^ button1;
- Label^ label1;
-
- void InitializeComponent()
- {
- this->button1 = gcnew Button();
- this->label1 = gcnew Label();
- this->SuspendLayout();
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(20, 20);
- this->button1->Name = "button1";
- this->button1->Size = System::Drawing::Size(160, 30);
- this->button1->TabIndex = 0;
- this->button1->Text = "Click Me";
- this->button1->Click += gcnew EventHandler(this, &SyncForm::button1_Click);
- //
- // textbox
- //
- this->label1->Location = System::Drawing::Point(20, 20);
- this->label1->Name = "textbox1";
- this->label1->Size = System::Drawing::Size(160, 30);
- this->label1->TabIndex = 1;
- this->label1->Text = "Waiting for the process 'notepad' to exit....";
- this->label1->ForeColor = System::Drawing::Color::Red;
- this->label1->Visible = false;
- //
- // Form1
- //
- this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
- this->ClientSize = System::Drawing::Size(200, 70);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->label1);
- this->Name = "SyncForm";
- this->Text = "SyncForm";
- this->ResumeLayout(false);
- }
-
-
-
- void button1_Click(Object^ sender, System::EventArgs^ e)
- {
- this->button1->Hide();
- this->label1->Show();
-
- process1 = gcnew Process();
- ProcessStartInfo^ process1StartInfo= gcnew ProcessStartInfo("notepad");
-
- //
- this->process1->StartInfo->Domain = "";
- this->process1->StartInfo->LoadUserProfile = false;
- this->process1->StartInfo->Password = nullptr;
- this->process1->StartInfo->StandardErrorEncoding = nullptr;
- this->process1->StartInfo->StandardOutputEncoding = nullptr;
- this->process1->StartInfo->UserName = "";
- this->process1->SynchronizingObject = this;
- //
-
- // Set method handling the exited event to be called
- process1->Exited += gcnew EventHandler(this, &SyncForm::TheProcessExited);
- // Set 'EnableRaisingEvents' to true, to raise 'Exited' event when process is terminated.
- process1->EnableRaisingEvents = true;
-
- this->Refresh();
- process1->StartInfo = process1StartInfo;
- process1->Start();
-
- process1->WaitForExit();
- process1->Close();
- }
-
- void TheProcessExited(Object^ source, EventArgs^ e)
- {
- this->label1->Hide();
- this->button1->Show();
- MessageBox::Show("The process has exited.");
- }
- };
-}
-
-[STAThread]
-int main()
-{
- SynchronizingObjectTest::SyncForm::Main();
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp b/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp
deleted file mode 100644
index 743f3c8001f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-//The following sample uses the Cryptography class to simulate the roll of a dice.
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-
-ref class RNGCSP
-{
-public:
- // Main method.
- static void Main()
- {
- const int totalRolls = 25000;
- array^ results = gcnew array(6);
-
- // Roll the dice 25000 times and display
- // the results to the console.
- for (int x = 0; x < totalRolls; x++)
- {
- Byte roll = RollDice((Byte)results->Length);
- results[roll - 1]++;
- }
- for (int i = 0; i < results->Length; ++i)
- {
- Console::WriteLine("{0}: {1} ({2:p1})", i + 1, results[i], (double)results[i] / (double)totalRolls);
- }
- }
-
- // This method simulates a roll of the dice. The input parameter is the
- // number of sides of the dice.
-
- static Byte RollDice(Byte numberSides)
- {
- if (numberSides <= 0)
- throw gcnew ArgumentOutOfRangeException("numberSides");
- // Create a new instance of the RNGCryptoServiceProvider.
- RNGCryptoServiceProvider^ rngCsp = gcnew RNGCryptoServiceProvider();
- // Create a byte array to hold the random value.
- array^ randomNumber = gcnew array(1);
- do
- {
- // Fill the array with a random value.
- rngCsp->GetBytes(randomNumber);
- }
- while (!IsFairRoll(randomNumber[0], numberSides));
- // Return the random number mod the number
- // of sides. The possible values are zero-
- // based, so we add one.
- return (Byte)((randomNumber[0] % numberSides) + 1);
- }
-
-private:
- static bool IsFairRoll(Byte roll, Byte numSides)
- {
- // There are MaxValue / numSides full sets of numbers that can come up
- // in a single byte. For instance, if we have a 6 sided die, there are
- // 42 full sets of 1-6 that come up. The 43rd set is incomplete.
- int fullSetsOfValues = Byte::MaxValue / numSides;
-
- // If the roll is within this range of fair values, then we let it continue.
- // In the 6 sided die case, a roll between 0 and 251 is allowed. (We use
- // < rather than <= since the = portion allows through an extra 0 value).
- // 252 through 255 would provide an extra 0, 1, 2, 3 so they are not fair
- // to use.
- return roll < numSides * fullSetsOfValues;
- }
-};
-
-int main()
-{
- RNGCSP::Main();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp b/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp
deleted file mode 100644
index 327d731d991..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- try
- {
- // Create an instance of StreamReader to read from a file.
- StreamReader^ sr = gcnew StreamReader( "TestFile.txt" );
- try
- {
- String^ line;
-
- // Read and display lines from the file until the end of
- // the file is reached.
- while ( line = sr->ReadLine() )
- {
- Console::WriteLine( line );
- }
- }
- finally
- {
- if ( sr )
- delete (IDisposable^)sr;
- }
- }
- catch ( Exception^ e )
- {
- // Let the user know what went wrong.
- Console::WriteLine( "The file could not be read:" );
- Console::WriteLine( e->Message );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp b/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp
deleted file mode 100644
index abd2bed7dea..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-
-//
-// For Directory::GetFiles and Directory::GetDirectories
-//
-// For File::Exists, Directory::Exists
-using namespace System;
-using namespace System::IO;
-using namespace System::Collections;
-
-// Insert logic for processing found files here.
-void ProcessFile( String^ path )
-{
- Console::WriteLine( "Processed file '{0}'.", path );
-}
-
-
-// Process all files in the directory passed in, recurse on any directories
-// that are found, and process the files they contain.
-void ProcessDirectory( String^ targetDirectory )
-{
-
- // Process the list of files found in the directory.
- array^fileEntries = Directory::GetFiles( targetDirectory );
- IEnumerator^ files = fileEntries->GetEnumerator();
- while ( files->MoveNext() )
- {
- String^ fileName = safe_cast(files->Current);
- ProcessFile( fileName );
- }
-
-
- // Recurse into subdirectories of this directory.
- array^subdirectoryEntries = Directory::GetDirectories( targetDirectory );
- IEnumerator^ dirs = subdirectoryEntries->GetEnumerator();
- while ( dirs->MoveNext() )
- {
- String^ subdirectory = safe_cast(dirs->Current);
- ProcessDirectory( subdirectory );
- }
-}
-
-int main( int argc, char *argv[] )
-{
- for ( int i = 1; i < argc; i++ )
- {
- String^ path = gcnew String(argv[ i ]);
- if ( File::Exists( path ) )
- {
-
- // This path is a file
- ProcessFile( path );
- }
- else
- if ( Directory::Exists( path ) )
- {
-
- // This path is a directory
- ProcessDirectory( path );
- }
- else
- {
- Console::WriteLine( "{0} is not a valid file or directory.", path );
- }
-
- }
-}
-
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp b/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp
deleted file mode 100644
index 1cfed0722c1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Text::RegularExpressions;
-int main()
-{
- //
- // Define a regular expression for repeated words.
- Regex^ rx = gcnew Regex( "\\b(?\\w+)\\s+(\\k)\\b",static_cast(RegexOptions::Compiled | RegexOptions::IgnoreCase) );
- //
-
- // Define a test string.
- String^ text = "The the quick brown fox fox jumps over the lazy dog dog.";
-
- //
- // Find matches.
- MatchCollection^ matches = rx->Matches( text );
- //
-
- //
- // Report the number of matches found.
- Console::WriteLine( "{0} matches found.", matches->Count );
- //
-
- //
- // Report on each match.
- for each (Match^ match in matches)
- {
- String^ word = match->Groups["word"]->Value;
- int index = match->Index;
- Console::WriteLine("{0} repeated at position {1}", word, index);
- }
- //
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp
deleted file mode 100644
index cb616efc570..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-
-
-class RijndaelMemoryExample
-{
-public:
- static array^ encryptStringToBytes_AES(String^ plainText, array^ Key, array^ IV)
- {
- // Check arguments.
- if (!plainText || plainText->Length <= 0)
- throw gcnew ArgumentNullException("plainText");
- if (!Key || Key->Length <= 0)
- throw gcnew ArgumentNullException("Key");
- if (!IV || IV->Length <= 0)
- throw gcnew ArgumentNullException("IV");
-
- // Declare the streams used
- // to encrypt to an in memory
- // array of bytes.
- MemoryStream^ msEncrypt;
- CryptoStream^ csEncrypt;
- StreamWriter^ swEncrypt;
-
- // Declare the RijndaelManaged object
- // used to encrypt the data.
- RijndaelManaged^ aesAlg;
-
- try
- {
- // Create a RijndaelManaged object
- // with the specified key and IV.
- aesAlg = gcnew RijndaelManaged();
- aesAlg->Padding = PaddingMode::PKCS7;
- aesAlg->Key = Key;
- aesAlg->IV = IV;
-
- // Create an encryptor to perform the stream transform.
- ICryptoTransform^ encryptor = aesAlg->CreateEncryptor(aesAlg->Key, aesAlg->IV);
-
- // Create the streams used for encryption.
- msEncrypt = gcnew MemoryStream();
- csEncrypt = gcnew CryptoStream(msEncrypt, encryptor, CryptoStreamMode::Write);
- swEncrypt = gcnew StreamWriter(csEncrypt);
-
- //Write all data to the stream.
- swEncrypt->Write(plainText);
- swEncrypt->Flush();
- csEncrypt->FlushFinalBlock();
- msEncrypt->Flush();
- }
- finally
- {
- // Clean things up.
-
- // Close the streams.
- if(swEncrypt)
- swEncrypt->Close();
- if (csEncrypt)
- csEncrypt->Close();
-
-
- // Clear the RijndaelManaged object.
- if (aesAlg)
- aesAlg->Clear();
- }
-
- // Return the encrypted bytes from the memory stream.
- return msEncrypt->ToArray();
- }
-
- static String^ decryptStringFromBytes_AES(array^ cipherText, array^ Key, array^ IV)
- {
- // Check arguments.
- if (!cipherText || cipherText->Length <= 0)
- throw gcnew ArgumentNullException("cipherText");
- if (!Key || Key->Length <= 0)
- throw gcnew ArgumentNullException("Key");
- if (!IV || IV->Length <= 0)
- throw gcnew ArgumentNullException("IV");
-
- // TDeclare the streams used
- // to decrypt to an in memory
- // array of bytes.
- MemoryStream^ msDecrypt;
- CryptoStream^ csDecrypt;
- StreamReader^ srDecrypt;
-
- // Declare the RijndaelManaged object
- // used to decrypt the data.
- RijndaelManaged^ aesAlg;
-
- // Declare the string used to hold
- // the decrypted text.
- String^ plaintext;
-
- try
- {
- // Create a RijndaelManaged object
- // with the specified key and IV.
- aesAlg = gcnew RijndaelManaged();
- aesAlg->Padding = PaddingMode::PKCS7;
- aesAlg->Key = Key;
- aesAlg->IV = IV;
-
- // Create a decryptor to perform the stream transform.
- ICryptoTransform^ decryptor = aesAlg->CreateDecryptor(aesAlg->Key, aesAlg->IV);
-
- // Create the streams used for decryption.
- msDecrypt = gcnew MemoryStream(cipherText);
- csDecrypt = gcnew CryptoStream(msDecrypt, decryptor, CryptoStreamMode::Read);
- srDecrypt = gcnew StreamReader(csDecrypt);
-
- // Read the decrypted bytes from the decrypting stream
- // and place them in a string.
- plaintext = srDecrypt->ReadToEnd();
- }
- finally
- {
- // Clean things up.
-
- // Close the streams.
- if (srDecrypt)
- srDecrypt->Close();
- if (csDecrypt)
- csDecrypt->Close();
- if (msDecrypt)
- msDecrypt->Close();
-
- // Clear the RijndaelManaged object.
- if (aesAlg)
- aesAlg->Clear();
- }
-
- return plaintext;
- }
-};
-
-int main()
-{
- try
- {
- String^ original = "Here is some data to encrypt!";
-
- // Create a new instance of the RijndaelManaged
- // class. This generates a new key and initialization
- // vector (IV).
- RijndaelManaged^ myRijndael = gcnew RijndaelManaged();
-
- // Encrypt the string to an array of bytes.
- array^ encrypted = RijndaelMemoryExample::encryptStringToBytes_AES(original, myRijndael->Key, myRijndael->IV);
-
- // Decrypt the bytes to a string.
- String^ roundtrip = RijndaelMemoryExample::decryptStringFromBytes_AES(encrypted, myRijndael->Key, myRijndael->IV);
-
- //Display the original data and the decrypted data.
- Console::WriteLine("Original: {0}", original);
- Console::WriteLine("Round Trip: {0}", roundtrip);
- }
- catch (Exception^ e)
- {
- Console::WriteLine("Error: {0}", e->Message);
- }
-
- return 0;
-}
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp b/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp
deleted file mode 100644
index bdc5fda9a9e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-using namespace System;
-using namespace System::Security;
-
-void main()
-{
- String^ msg = L" The current length of the SecureString object: {0}\n";
- SecureString ^ ss = gcnew SecureString;
-
- Console::WriteLine(L"1) Instantiate the SecureString object:");
- Console::WriteLine(msg, ss->Length );
-
- Console::WriteLine(L"2) Append 'a' to the value:");
- ss->AppendChar('a');
- Console::WriteLine(msg, ss->Length );
-
- Console::WriteLine(L"3) Append 'X' to the value:");
- ss->AppendChar('X');
- Console::WriteLine(msg, ss->Length);
-
- Console::WriteLine(L"4) Append 'c' to the value:");
- ss->AppendChar('c');
- Console::WriteLine(msg, ss->Length);
-
- Console::WriteLine(L"5) Insert 'd' at the end of the value:");
- ss->InsertAt(ss->Length, 'd');
- Console::WriteLine(msg, ss->Length);
-
- Console::WriteLine(L"6) Remove the last character ('d') from the value:");
- ss->RemoveAt(3);
- Console::WriteLine(msg, ss->Length);
-
- Console::WriteLine(L"7) Set the second character ('X') of the value to 'b':" );
- ss->SetAt(1, 'b');
- Console::WriteLine(msg, ss->Length );
-
- Console::WriteLine(L"8) Delete the value of the SecureString object:");
- ss->Clear();
- Console::WriteLine(msg, ss->Length);
-
- delete ss;
-}
-
-/*
-This code example produces the following results:
-
-This example demonstrates the effect of the AppendChar, InsertAt,
-RemoveAt, SetAt, and Clear methods on the value of a SecureString
-object. This example simulates the value of the object because the
-actual value is encrypted.
-
-1) The initial value of the SecureString object:
- SecureString = ""
- Length = 0
-
-2) AppendChar: Append 'a' to the value:
- SecureString = "a"
- Length = 1
-
-3) AppendChar: Append 'X' to the value:
- SecureString = "aX"
- Length = 2
-
-4) AppendChar: Append 'c' to the value:
- SecureString = "aXc"
- Length = 3
-
-5) InsertAt: Insert 'd' at the end of the value (equivalent
- to AppendChar):
- SecureString = "aXcd"
- Length = 4
-
-6) RemoveAt: Remove the last character ('d') from the value:
- SecureString = "aXc"
- Length = 3
-
-7) SetAt: Set the second character ('X') of the value to 'b':
- SecureString = "abc"
- Length = 3
-
-8) Clear: Delete the value of the SecureString object:
- SecureString = ""
- Length = 0
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp b/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp
deleted file mode 100644
index 4a5db9f067c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security;
-
-void main()
-{
- bool go = true;
- ConsoleKeyInfo cki;
- String^ m = L"\nEnter your password (up to 15 letters, numbers, and underscores)\n"
- L"Press BACKSPACE to delete the last character entered. " +
- L"\nPress Enter when done, or ESCAPE to quit:";
- SecureString ^ password = gcnew SecureString;
- int top;
- int left;
-
- // The Console.TreatControlCAsInput property prevents CTRL+C from
- // ending this example.
- Console::TreatControlCAsInput = true;
-
- Console::Clear();
- Console::WriteLine(m);
-
- top = Console::CursorTop;
- left = Console::CursorLeft;
-
- do {
- cki = Console::ReadKey(true);
- if (cki.Key == ConsoleKey::Escape)
- break;
-
- if (cki.Key == ConsoleKey::Backspace){
- if (password->Length > 0) {
- Console::SetCursorPosition(left + password->Length - 1, top);
- Console::Write(' ');
- Console::SetCursorPosition(left + password->Length - 1, top);
- password->RemoveAt(password->Length - 1);
- }
- }
- else {
- if ((password->Length < 15) &&
- (Char::IsLetterOrDigit( cki.KeyChar ) ||
- cki.KeyChar == '_') ) {
- password->AppendChar( cki.KeyChar );
- Console::SetCursorPosition( left + password->Length - 1, top );
- Console::Write("*");
- }
- }
- } while (cki.Key != ConsoleKey::Enter & password->Length < 15);
-
- // Make the password read-only to prevent modification.
- password->MakeReadOnly();
- // Dispose of the SecureString instance.
- delete password;
-
-}
-// The example displays output like the following:
-// Enter your password (up to 15 letters, numbers, and underscores)
-// Press BACKSPACE to delete the last character entered.
-// Press Enter when done, or ESCAPE to quit:
-// ************
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp b/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp
deleted file mode 100644
index 51ea424f825..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-
-// This sample demonstrates how to use members of the SecurityElement class.
-// The sample creates a SecurityElement for the root of the XML tree and
-// demonstrates how to add attributes and child elements.
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Collections;
-ref class SecurityElementMembers
-{
-public:
-
- [STAThread]
- int TestSecurityElementMembers()
- {
- //
- SecurityElement^ xmlRootElement = gcnew SecurityElement( L"RootTag",L"XML security tree" );
- //
-
- AddAttribute( xmlRootElement, L"creationdate", DateTime::Now.ToString() );
- AddChildElement( xmlRootElement, L"destroytime", DateTime::Now.AddSeconds( 1.0 ).ToString() );
-
- //
- SecurityElement^ windowsRoleElement = gcnew SecurityElement( L"WindowsMembership.WindowsRole" );
- //
-
- //
- windowsRoleElement->AddAttribute( L"version", L"1.00" );
- //
-
- // Add a child element and a creationdate attribute.
- AddChildElement( windowsRoleElement, L"BabyElement", L"This is a child element" );
- AddAttribute( windowsRoleElement, L"creationdate", DateTime::Now.ToString() );
-
- //
- xmlRootElement->AddChild( windowsRoleElement );
- //
-
- CompareAttributes( xmlRootElement, L"creationdate" );
- ConvertToHashTable( xmlRootElement );
- DisplaySummary( xmlRootElement );
-
- // Determine if the security element is too old to keep.
- xmlRootElement = DestroyTree( xmlRootElement );
- if ( xmlRootElement != nullptr )
- {
- //
- String^ elementInXml = xmlRootElement->ToString();
- //
-
- Console::WriteLine( elementInXml );
- }
-
- Console::WriteLine( L"This sample completed successfully; "
- L"press Enter to exit." );
- Console::ReadLine();
- return 1;
- }
-
-
-private:
-
- // Add an attribute to the specified security element.
- static SecurityElement^ AddAttribute( SecurityElement^ xmlElement, String^ attributeName, String^ attributeValue )
- {
- if ( xmlElement != nullptr )
- {
- // Verify that the attribute name and value are valid XML formats.
- //
- //
- if ( SecurityElement::IsValidAttributeName( attributeName ) &&
- SecurityElement::IsValidAttributeValue( attributeValue ) )
- //
- //
- {
- // Add the attribute to the security element.
- //
- xmlElement->AddAttribute( attributeName, attributeValue );
- //
- }
- }
-
- return xmlElement;
- }
-
-
- // Add a child element to the specified security element.
- static SecurityElement^ AddChildElement( SecurityElement^ parentElement, String^ tagName, String^ tagText )
- {
- if ( parentElement != nullptr )
- {
- // Ensure that the tag text is in valid XML format.
- //
- if ( !SecurityElement::IsValidText( tagText ) )
- //
- {
- // Replace invalid text with valid XML text
- // to enforce proper XML formatting.
- //
- tagText = SecurityElement::Escape( tagText );
- //
- }
-
- // Determine whether the tag is in valid XML format.
- //
- if ( SecurityElement::IsValidTag( tagName ) )
- //
- {
- //
- SecurityElement^ childElement;
- childElement = parentElement->SearchForChildByTag( tagName );
- //
- if ( childElement != nullptr )
- {
- //
- String^ elementText;
- elementText = parentElement->SearchForTextOfTag( tagName );
- //
- if ( !elementText->Equals( tagText ) )
- {
- // Add child element to the parent security element.
- parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) );
- }
- }
- else
- {
- // Add child element to the parent security element.
- parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) );
- }
- }
- }
-
- return parentElement;
- }
-
-
- // Create and display a summary sentence
- // about the specified security element.
- static void DisplaySummary( SecurityElement^ xmlElement )
- {
- // Retrieve tag name for the security element.
- //
- String^ xmlTreeName = xmlElement->Tag->ToString();
- //
- // Retrieve tag text for the security element.
- //
- String^ xmlTreeDescription = xmlElement->Text;
- //
- // Retrieve value of the creationdate attribute.
- //
- String^ xmlCreationDate = xmlElement->Attribute(L"creationdate");
- //
- // Retrieve the number of children under the security element.
- //
- String^ childrenCount = xmlElement->Children->Count.ToString();
- //
- String^ outputMessage = String::Format( L"The security XML tree named {0}", xmlTreeName );
- outputMessage = String::Concat( outputMessage, String::Format( L"({0})", xmlTreeDescription ) );
- outputMessage = String::Concat( outputMessage, String::Format( L" was created on {0} and ", xmlCreationDate ) );
- outputMessage = String::Concat( outputMessage, String::Format( L"contains {0} child elements.", childrenCount ) );
- Console::WriteLine( outputMessage );
- }
-
- // Compare the first two occurrences of an attribute
- // in the specified security element.
- static void CompareAttributes( SecurityElement^ xmlElement, String^ attributeName )
- {
- // Create a hash table containing the security element's attributes.
- //
- Hashtable^ attributeKeys = xmlElement->Attributes;
- String^ attributeValue = attributeKeys[ attributeName ]->ToString();
- //
- IEnumerator^ myEnum = xmlElement->Children->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- SecurityElement^ xmlChild = safe_cast(myEnum->Current);
- if ( attributeValue->Equals( xmlChild->Attribute(attributeName) ) )
- {
- // The security elements were created at the exact same time.
- }
- }
- }
-
- // Convert the contents of the specified security element
- // to hash codes stored in a hash table.
- static void ConvertToHashTable( SecurityElement^ xmlElement )
- {
- // Create a hash table to hold hash codes of the security elements.
- //
- Hashtable^ xmlAsHash = gcnew Hashtable;
- int rootIndex = xmlElement->GetHashCode();
- xmlAsHash->Add( rootIndex, L"root" );
- //
- int parentNum = 0;
- IEnumerator^ myEnum1 = xmlElement->Children->GetEnumerator();
- while ( myEnum1->MoveNext() )
- {
- SecurityElement^ xmlParent = safe_cast(myEnum1->Current);
- parentNum++;
- xmlAsHash->Add( xmlParent->GetHashCode(), String::Format( L"parent{0}", parentNum ) );
- if ( (xmlParent->Children != nullptr) && (xmlParent->Children->Count > 0) )
- {
- int childNum = 0;
- IEnumerator^ myEnum2 = xmlParent->Children->GetEnumerator();
- while ( myEnum2->MoveNext() )
- {
- SecurityElement^ xmlChild = safe_cast(myEnum2->Current);
- childNum++;
- xmlAsHash->Add( xmlChild->GetHashCode(), String::Format( L"child{0}", childNum ) );
- }
- }
- }
- }
-
- // Delete the specified security element if the current time is past
- // the time stored in the destroytime tag.
- static SecurityElement^ DestroyTree( SecurityElement^ xmlElement )
- {
- SecurityElement^ localXmlElement = xmlElement;
- SecurityElement^ destroyElement = localXmlElement->SearchForChildByTag( L"destroytime" );
-
- // Verify that a destroytime tag exists.
- //
- if ( localXmlElement->SearchForChildByTag( L"destroytime" ) != nullptr )
- //
- {
- // Retrieve the destroytime text to get the time
- // the tree can be destroyed.
- //
- String^ storedDestroyTime = localXmlElement->SearchForTextOfTag( L"destroytime" );
- //
- DateTime destroyTime = DateTime::Parse( storedDestroyTime );
- if ( DateTime::Now > destroyTime )
- {
- localXmlElement = nullptr;
- Console::WriteLine( L"The XML security tree has been deleted." );
- }
- }
-
-
- // Verify that xmlElement is of type SecurityElement.
- //
- if ( xmlElement->GetType()->Equals( System::Security::SecurityElement::typeid ) )
- //
- {
- // Determine whether the localXmlElement object
- // differs from xmlElement.
- //
- if ( xmlElement->Equals( localXmlElement ) )
- //
- {
- // Verify that the tags, attributes and children of the
- // two security elements are identical.
- //
- if ( xmlElement->Equal( localXmlElement ) )
- //
- {
- // Return the original security element.
- return xmlElement;
- }
- }
- }
-
- // Return the modified security element.
- return localXmlElement;
- }
-
-};
-
-int main()
-{
- SecurityElementMembers^ sem = gcnew SecurityElementMembers;
- sem->TestSecurityElementMembers();
-}
-
-//
-// This sample produces the following output:
-//
-// The security XML tree named RootTag(XML security tree)
-// was created on 2/23/2004 1:23:00 PM and contains 2 child elements.
-//XML security tree
-// 2/23/2004 1:23:01 PM
-//
-// This is a child element.
-//
-//
-//
-//This sample completed successfully; press Exit to continue.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp
deleted file mode 100644
index b873188879c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-// This console application illustrates various uses
-// of the StackTrace and StackFrame classes.
-namespace SampleInternal
-{
- public ref class ClassLevel6
- {
- public:
- void Level6Method()
- {
- throw gcnew Exception( "An error occurred in the lowest internal class method." );
- }
-
- };
-
- public ref class ClassLevel5
- {
- public:
-
- //
- void Level5Method()
- {
- try
- {
- ClassLevel6^ nestedClass = gcnew ClassLevel6;
- nestedClass->Level6Method();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( " Level5Method exception handler" );
- StackTrace^ st = gcnew StackTrace;
-
- // Display the most recent function call.
- StackFrame^ sf = st->GetFrame( 0 );
- Console::WriteLine();
- Console::WriteLine( " Exception in method: " );
- Console::WriteLine( " {0}", sf->GetMethod() );
- if ( st->FrameCount > 1 )
- {
-
- // Display the highest-level function call
- // in the trace.
- sf = st->GetFrame( st->FrameCount - 1 );
- Console::WriteLine( " Original function call at top of call stack):" );
- Console::WriteLine( " {0}", sf->GetMethod() );
- }
- Console::WriteLine();
- Console::WriteLine( " ... throwing exception to next level ..." );
- Console::WriteLine( "-------------------------------------------------\n" );
- throw e;
- }
-
- }
-
- //
- };
-
- public ref class ClassLevel4
- {
- public:
- void Level4Method()
- {
-
- //
- try
- {
- ClassLevel5^ nestedClass = gcnew ClassLevel5;
- nestedClass->Level5Method();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( " Level4Method exception handler" );
-
- // Build a stack trace from a dummy stack frame.
- // Explicitly specify the source file name, line number
- // and column number.
- StackTrace^ st = gcnew StackTrace( gcnew StackFrame( "source.cs",79,24 ) );
- Console::WriteLine( " Stack trace with dummy stack frame: {0}", st->ToString() );
-
- // Access the StackFrames explicitly to display the file
- // name, line number and column number properties.
- // StackTrace.ToString only includes the method name.
- for ( int i = 0; i < st->FrameCount; i++ )
- {
- StackFrame^ sf = st->GetFrame( i );
- Console::WriteLine( " File: {0}", sf->GetFileName() );
- Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );
- Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );
-
- }
- Console::WriteLine();
- Console::WriteLine( " ... throwing exception to next level ..." );
- Console::WriteLine( "-------------------------------------------------\n" );
- throw e;
- }
-
-
- //
- }
-
- };
-
- public ref class ClassLevel3
- {
- public:
-
- //
- void Level3Method()
- {
- try
- {
- ClassLevel4^ nestedClass = gcnew ClassLevel4;
- nestedClass->Level4Method();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( " Level3Method exception handler" );
-
- // Build a stack trace from a dummy stack frame.
- // Explicitly specify the source file name and line number.
- StackTrace^ st = gcnew StackTrace( gcnew StackFrame( "source.cs",60 ) );
- Console::WriteLine( " Stack trace with dummy stack frame: {0}", st->ToString() );
- for ( int i = 0; i < st->FrameCount; i++ )
- {
-
- //
- // Display the stack frame properties.
- StackFrame^ sf = st->GetFrame( i );
- Console::WriteLine( " File: {0}", sf->GetFileName() );
- Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );
-
- // Note that the column number defaults to zero
- // when not initialized.
- Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );
- Console::WriteLine( " Intermediate Language Offset: {0}", sf->GetILOffset().ToString() );
- Console::WriteLine( " Native Offset: {0}", sf->GetNativeOffset().ToString() );
-
- //
-
- }
- Console::WriteLine();
- Console::WriteLine( " ... throwing exception to next level ..." );
- Console::WriteLine( "-------------------------------------------------\n" );
- throw e;
- }
-
- }
-
- //
- };
-
- public ref class ClassLevel2
- {
- public:
-
- //
- void Level2Method()
- {
- try
- {
- ClassLevel3^ nestedClass = gcnew ClassLevel3;
- nestedClass->Level3Method();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( " Level2Method exception handler" );
-
- // Display the full call stack at this level.
- StackTrace^ st1 = gcnew StackTrace( true );
- Console::WriteLine( " Stack trace for this level: {0}", st1->ToString() );
-
- // Build a stack trace from one frame, skipping the
- // current frame and using the next frame.
- StackTrace^ st2 = gcnew StackTrace( gcnew StackFrame( 1,true ) );
- Console::WriteLine( " Stack trace built with next level frame: {0}", st2->ToString() );
-
- // Build a stack trace skipping the current frame, and
- // including all the other frames.
- StackTrace^ st3 = gcnew StackTrace( 1,true );
- Console::WriteLine( " Stack trace built from the next level up: {0}", st3->ToString() );
- Console::WriteLine();
- Console::WriteLine( " ... throwing exception to next level ..." );
- Console::WriteLine( "-------------------------------------------------\n" );
- throw e;
- }
-
- }
-
- //
- };
-
- public ref class ClassLevel1
- {
- public:
-
- //
- void InternalMethod()
- {
- try
- {
- ClassLevel2^ nestedClass = gcnew ClassLevel2;
- nestedClass->Level2Method();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( " InternalMethod exception handler" );
-
- // Build a stack trace from one frame, skipping the
- // current frame and using the next frame. By
- // default, file and line information are not displayed.
- StackTrace^ st = gcnew StackTrace( gcnew StackFrame( 1 ) );
- Console::WriteLine( " Stack trace for next level frame: {0}", st->ToString() );
- Console::WriteLine( " Stack frame for next level: " );
- Console::WriteLine( " {0}", st->GetFrame( 0 )->ToString() );
- Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() );
- Console::WriteLine();
- Console::WriteLine( " ... throwing exception to next level ..." );
- Console::WriteLine( "-------------------------------------------------\n" );
- throw e;
- }
-
- }
-
- //
- };
-
-}
-
-
-using namespace SampleInternal;
-
-namespace SamplePublic
-{
- class ConsoleApp
- {
- public:
-
- //
-
- [STAThread]
- static void Main()
- {
- ClassLevel1 ^ mainClass = gcnew ClassLevel1;
- try
- {
- mainClass->InternalMethod();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( " Main method exception handler" );
-
- // Display file and line information, if available.
- StackTrace^ st = gcnew StackTrace( gcnew StackFrame( true ) );
- Console::WriteLine( " Stack trace for current level: {0}", st->ToString() );
- Console::WriteLine( " File: {0}", st->GetFrame( 0 )->GetFileName() );
- Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() );
- Console::WriteLine();
- Console::WriteLine( "-------------------------------------------------\n" );
- }
-
- }
-
- //
- };
-
-}
-
-int main()
-{
- SamplePublic::ConsoleApp::Main();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp b/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp
deleted file mode 100644
index 83e6e596d61..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-ref class StackTraceSample
-{
-private:
- ref class MyInternalClass
- {
- public:
- void ThrowsException()
- {
- try
- {
- throw gcnew Exception( "A problem was encountered." );
- }
- catch ( Exception^ e )
- {
-
- // Create a StackTrace that captures
- // filename, line number, and column
- // information for the current thread.
- StackTrace^ st = gcnew StackTrace( true );
- String^ stackIndent = "";
- for ( int i = 0; i < st->FrameCount; i++ )
- {
-
- // Note that at this level, there are five
- // stack frames, one for each method invocation.
- StackFrame^ sf = st->GetFrame( i );
- Console::WriteLine();
- Console::WriteLine( "{0}Method: {1}", stackIndent, sf->GetMethod() );
- Console::WriteLine( "{0}File: {1}", stackIndent, sf->GetFileName() );
- Console::WriteLine( "{0}Line Number: {1}", stackIndent, sf->GetFileLineNumber().ToString() );
- stackIndent = String::Concat( stackIndent, " " );
-
- }
- throw e;
- }
-
- }
-
- };
-
-
-protected:
- void MyProtectedMethod()
- {
- MyInternalClass^ mic = gcnew MyInternalClass;
- mic->ThrowsException();
- }
-
-
-public:
- void MyPublicMethod()
- {
- MyProtectedMethod();
- }
-
-};
-
-int main()
-{
- StackTraceSample^ sample = gcnew StackTraceSample;
- try
- {
- sample->MyPublicMethod();
- }
- catch ( Exception^ )
- {
-
- // Create a StackTrace that captures
- // filename, line number, and column
- // information for the current thread.
- StackTrace^ st = gcnew StackTrace( true );
- for ( int i = 0; i < st->FrameCount; i++ )
- {
-
- // For an executable built from C++, there
- // are two stack frames here: one for main,
- // and one for the _mainCRTStartup stub.
- StackFrame^ sf = st->GetFrame( i );
- Console::WriteLine();
- Console::WriteLine( "High up the call stack, Method: {0}", sf->GetMethod()->ToString() );
- Console::WriteLine( "High up the call stack, Line Number: {0}", sf->GetFileLineNumber().ToString() );
-
- }
- }
-
-}
-
-/*
-This console application produces the following output when
-compiled with the Debug configuration.
-
- Method: Void ThrowsException()
- File: c:\samples\stacktraceframe\myclass.cpp
- Line Number: 20
-
- Method: Void MyProtectedMethod()
- File: c:\samples\stacktraceframe\myclass.cpp
- Line Number: 45
-
- Method: Void MyPublicMethod()
- File: c:\samples\stacktraceframe\myclass.cpp
- Line Number: 50
-
- Method: Int32 main()
- File: c:\samples\stacktraceframe\myclass.cpp
- Line Number: 56
-
- Method: UInt32 _mainCRTStartup()
- File:
- Line Number: 0
-
- High up the call stack, Method: Int32 main()
- High up the call stack, Line Number: 62
-
- High up the call stack, Method: UInt32 _mainCRTStartup()
- High up the call stack, Line Number: 0
-
-This console application produces the following output when
-compiled with the Release configuration.
-
- Method: Void ThrowsException()
- File:
- Line Number: 0
-
- Method: Int32 main()
- File:
- Line Number: 0
-
- Method: UInt32 _mainCRTStartup()
- File:
- Line Number: 0
-
- High up the call stack, Method: Int32 main()
- High up the call stack, Line Number: 0
-
- High up the call stack, Method: UInt32 _mainCRTStartup()
- High up the call stack, Line Number: 0
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp b/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp
deleted file mode 100644
index 2dcb2ce73fc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-ref class MyConsoleApp
-{
-private:
- ref class MyInnerClass
- {
- public:
- void ThrowsException()
- {
- try
- {
- throw gcnew Exception( "A problem was encountered." );
- }
- catch ( Exception^ )
- {
-
- // Create a StackTrace starting at the next level
- // stack frame. Skip the first frame, the frame of
- // this level, which hides the internal implementation
- // of the ThrowsException method. Include the line
- // number, file name, and column number information
- // for each frame.
- //
- StackTrace^ st = gcnew StackTrace( 1,true );
- array^stFrames = st->GetFrames();
- for ( int i; i < stFrames->Length; i++ )
- {
- StackFrame^ sf = stFrames[ i ];
- Console::WriteLine( "Method: {0}", sf->GetMethod() );
-
- }
- //
- }
-
- }
-
- };
-
-
-public:
- void MyPublicMethod()
- {
- MyInnerClass^ helperClass = gcnew MyInnerClass;
- helperClass->ThrowsException();
- }
-
-};
-
-void main()
-{
- MyConsoleApp^ myApp = gcnew MyConsoleApp;
- myApp->MyPublicMethod();
-}
-
-/*
-This console application produces the following output
-when compiled with optimization off.
-
-Note that the ThrowsException() method is not identified in
-this stack trace.
-
- Method: Void MyPublicMethod()
- Method: Void Main()
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp b/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp
deleted file mode 100644
index 49e44641a2b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-ref class MyConsoleApp
-{
-private:
-
- //
- ref class MyInnerClass
- {
- public:
- void ThrowsException()
- {
- try
- {
- throw gcnew Exception( "A problem was encountered." );
- }
- catch ( Exception^ )
- {
-
- // Log the Exception. We do not want to reveal the
- // inner workings of the class, or be too verbose, so
- // we will create a StackTrace with a single
- // StackFrame, where the frame is that of the calling
- // method.
- //
- StackFrame^ fr = gcnew StackFrame( 1,true );
- StackTrace^ st = gcnew StackTrace( fr );
- EventLog::WriteEntry( fr->GetMethod()->Name, st->ToString(), EventLogEntryType::Warning );
- //
-
- // Note that whenever this application is run, the EventLog
- // contains an Event similar to the following Event.
- //
- // Event Type: Warning
- // Event Source: MyPublicMethod
- // Event Category: None
- // Event ID: 0
- // Date: 6/17/2001
- // Time: 6:39:56 PM
- // User: N/A
- // Computer: MYCOMPUTER
- // Description:
- //
- // at MyConsoleApp.MyPublicMethod()
- //
- // For more information, see Help and Support Center at
- // http://go.microsoft.com/fwlink/events.asp.
- }
-
- }
-
- };
- //
-
-
-public:
-
- //
- void MyPublicMethod()
- {
- MyInnerClass^ helperClass = gcnew MyInnerClass;
- helperClass->ThrowsException();
- }
-
-};
-
-void main()
-{
- MyConsoleApp^ helperClass = gcnew MyConsoleApp;
- helperClass->MyPublicMethod();
-}
-
-/*
-This console application produces the following output
-when compiled with optimization off.
-
-Note that the ThrowsException() method is not identified in
-this stack trace.
-
- Method: Void MyPublicMethod()
- Method: Void Main()
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp
deleted file mode 100644
index 3b2fe7a7575..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-
-
-// System.Diagnostics.Stopwatch
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-//
-void DisplayTimerProperties()
-{
- // Display the timer frequency and resolution.
- if ( Stopwatch::IsHighResolution )
- {
- Console::WriteLine( "Operations timed using the system's high-resolution performance counter." );
- }
- else
- {
- Console::WriteLine( "Operations timed using the DateTime class." );
- }
-
- Int64 frequency = Stopwatch::Frequency;
- Console::WriteLine( " Timer frequency in ticks per second = {0}", frequency );
- Int64 nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
- Console::WriteLine( " Timer is accurate within {0} nanoseconds", nanosecPerTick );
-}
-//
-
-//
-void TimeOperations()
-{
- Int64 nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch::Frequency;
- const long numIterations = 10000;
-
- // Define the operation title names.
- array^operationNames = {"Operation: Int32.Parse(\"0\")","Operation: Int32.TryParse(\"0\")","Operation: Int32.Parse(\"a\")","Operation: Int32.TryParse(\"a\")"};
-
- // Time four different implementations for parsing
- // an integer from a string.
- for ( int operation = 0; operation <= 3; operation++ )
- {
- //
- // Define variables for operation statistics.
- Int64 numTicks = 0;
- Int64 numRollovers = 0;
- Int64 maxTicks = 0;
- Int64 minTicks = Int64::MaxValue;
- int indexFastest = -1;
- int indexSlowest = -1;
- Int64 milliSec = 0;
- Stopwatch ^ time10kOperations = Stopwatch::StartNew();
-
- // Run the current operation 10001 times.
- // The first execution time will be tossed
- // out, since it can skew the average time.
- for ( int i = 0; i <= numIterations; i++ )
- {
- //
- Int64 ticksThisTime = 0;
- int inputNum;
- Stopwatch ^ timePerParse;
- switch ( operation )
- {
- case 0:
-
- // Parse a valid integer using
- // a try-catch statement.
- // Start a new stopwatch timer.
- timePerParse = Stopwatch::StartNew();
- try
- {
- inputNum = Int32::Parse( "0" );
- }
- catch ( FormatException^ )
- {
- inputNum = 0;
- }
-
- // Stop the timer, and save the
- // elapsed ticks for the operation.
- timePerParse->Stop();
- ticksThisTime = timePerParse->ElapsedTicks;
- break;
-
- case 1:
-
- // Parse a valid integer using
- // the TryParse statement.
- // Start a new stopwatch timer.
- timePerParse = Stopwatch::StartNew();
- if ( !Int32::TryParse( "0", inputNum ) )
- {
- inputNum = 0;
- }
-
- // Stop the timer, and save the
- // elapsed ticks for the operation.
- timePerParse->Stop();
- ticksThisTime = timePerParse->ElapsedTicks;
- break;
-
- case 2:
-
- // Parse an invalid value using
- // a try-catch statement.
- // Start a new stopwatch timer.
- timePerParse = Stopwatch::StartNew();
- try
- {
- inputNum = Int32::Parse( "a" );
- }
- catch ( FormatException^ )
- {
- inputNum = 0;
- }
-
- // Stop the timer, and save the
- // elapsed ticks for the operation.
- timePerParse->Stop();
- ticksThisTime = timePerParse->ElapsedTicks;
- break;
-
- case 3:
-
- // Parse an invalid value using
- // the TryParse statement.
- // Start a new stopwatch timer.
- timePerParse = Stopwatch::StartNew();
- if ( !Int32::TryParse( "a", inputNum ) )
- {
- inputNum = 0;
- }
-
- // Stop the timer, and save the
- // elapsed ticks for the operation.
- timePerParse->Stop();
- ticksThisTime = timePerParse->ElapsedTicks;
- break;
-
- default:
- break;
- }
- //
-
- // Skip over the time for the first operation,
- // just in case it caused a one-time
- // performance hit.
- if ( i == 0 )
- {
- time10kOperations->Reset();
- time10kOperations->Start();
- }
- else
- {
- // Update operation statistics
- // for iterations 1-10001.
- if ( maxTicks < ticksThisTime )
- {
- indexSlowest = i;
- maxTicks = ticksThisTime;
- }
- if ( minTicks > ticksThisTime )
- {
- indexFastest = i;
- minTicks = ticksThisTime;
- }
- numTicks += ticksThisTime;
- if ( numTicks < ticksThisTime )
- {
- // Keep track of rollovers.
- numRollovers++;
- }
- }
- }
-
- // Display the statistics for 10000 iterations.
- time10kOperations->Stop();
- milliSec = time10kOperations->ElapsedMilliseconds;
- Console::WriteLine();
- Console::WriteLine( "{0} Summary:", operationNames[ operation ] );
- Console::WriteLine( " Slowest time: #{0}/{1} = {2} ticks", indexSlowest, numIterations, maxTicks );
- Console::WriteLine( " Fastest time: #{0}/{1} = {2} ticks", indexFastest, numIterations, minTicks );
- Console::WriteLine( " Average time: {0} ticks = {1} nanoseconds", numTicks / numIterations, (numTicks * nanosecPerTick) / numIterations );
- Console::WriteLine( " Total time looping through {0} operations: {1} milliseconds", numIterations, milliSec );
- //
-
- }
-}
-//
-
-int main()
-{
- DisplayTimerProperties();
- Console::WriteLine();
- Console::WriteLine( "Press the Enter key to begin:" );
- Console::ReadLine();
- Console::WriteLine();
- TimeOperations();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp b/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp
deleted file mode 100644
index ba044bc83d7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//Code Modification: Removed AppendLine and associated comment after the AppendFormat line.
-//The CR/LF bytes introduces by AppendLine made the sb.Length appear incorrect.
-// Before
-//sb.AppendFormat("GHI{0}{1}", 'J', 'k');
-////APpend a blank line to the end of the StringBuilder.
-// sb.AppendLine();
-// After
-//sb.AppendFormat("GHI{0}{1}", 'J', 'k');
-//Code Modification: End
-//Types:System.Text.StringBuilder
-//
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- //
- // Create a StringBuilder that expects to hold 50 characters.
- // Initialize the StringBuilder with "ABC".
- StringBuilder^ sb = gcnew StringBuilder("ABC", 50);
- //
-
- //
- // Append three characters (D, E, and F) to the end of the
- // StringBuilder.
- sb->Append(gcnew array{'D', 'E', 'F'});
- //
-
- //
- // Append a format string to the end of the StringBuilder.
- sb->AppendFormat("GHI{0}{1}", (Char)'J', (Char)'k');
- //
-
- //
- // Display the number of characters in the StringBuilder
- // and its string.
- Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString());
- //
-
- //
- // Insert a string at the beginning of the StringBuilder.
- sb->Insert(0, "Alphabet: ");
- //
-
- //
- // Replace all lowercase k's with uppercase K's.
- sb->Replace('k', 'K');
- //
-
- // Display the number of characters in the StringBuilder
- // and its string.
- Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString());
-}
-
-// This code produces the following output.
-//
-// 11 chars: ABCDEFGHIJk
-// 21 chars: Alphabet: ABCDEFGHIJK
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp b/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp
deleted file mode 100644
index 15c96facbe9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-//Types:System.Globalization.StringInfo
-//
-using namespace System;
-using namespace System::Text;
-using namespace System::Globalization;
-
-
-// Show how to enumerate each real character (honoring surrogates)
-// in a string.
-
-void EnumTextElements(String^ combiningChars)
-{
- // This StringBuilder holds the output results.
- StringBuilder^ sb = gcnew StringBuilder();
-
- // Use the enumerator returned from GetTextElementEnumerator
- // method to examine each real character.
- TextElementEnumerator^ charEnum =
- StringInfo::GetTextElementEnumerator(combiningChars);
- while (charEnum->MoveNext())
- {
- sb->AppendFormat("Character at index {0} is '{1}'{2}",
- charEnum->ElementIndex, charEnum->GetTextElement(),
- Environment::NewLine);
- }
-
- // Show the results.
- Console::WriteLine("Result of GetTextElementEnumerator:");
- Console::WriteLine(sb);
-}
-
-
-// Show how to discover the index of each real character
-// (honoring surrogates) in a string.
-
-void EnumTextElementIndexes(String^ combiningChars)
-{
- // This StringBuilder holds the output results.
- StringBuilder^ sb = gcnew StringBuilder();
-
- // Use the ParseCombiningCharacters method to
- // get the index of each real character in the string.
- array ^ textElemIndex =
- StringInfo::ParseCombiningCharacters(combiningChars);
-
- // Iterate through each real character showing the character
- // and the index where it was found.
- for (int i = 0; i < textElemIndex->Length; i++)
- {
- sb->AppendFormat("Character {0} starts at index {1}{2}",
- i, textElemIndex[i], Environment::NewLine);
- }
-
- // Show the results.
- Console::WriteLine("Result of ParseCombiningCharacters:");
- Console::WriteLine(sb);
-}
-
-int main()
-{
-
- // The string below contains combining characters.
- String^ combiningChars = L"a\u0304\u0308bc\u0327";
-
- // Show each 'character' in the string.
- EnumTextElements(combiningChars);
-
- // Show the index in the string where each 'character' starts.
- EnumTextElementIndexes(combiningChars);
-
-};
-
-// This code produces the following output.
-//
-// Result of GetTextElementEnumerator:
-// Character at index 0 is 'a-"'
-// Character at index 3 is 'b'
-// Character at index 4 is 'c,'
-//
-// Result of ParseCombiningCharacters:
-// Character 0 starts at index 0
-// Character 1 starts at index 3
-// Character 2 starts at index 4
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp b/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp
deleted file mode 100644
index 7d915b93810..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- //Create a FileInfo instance representing an existing text file.
- FileInfo^ MyFile = gcnew FileInfo( "c:\\csc.txt" );
-
- //Instantiate a StreamReader to read from the text file.
- StreamReader^ sr = MyFile->OpenText();
-
- //Read a single character.
- int FirstChar = sr->Read();
-
- //Display the ASCII number of the character read in both decimal and hexadecimal format.
- Console::WriteLine( "The ASCII number of the first character read is {0:D} in decimal and {1:X} in hexadecimal.", FirstChar, FirstChar );
-
- //
- sr->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp
deleted file mode 100644
index 91fe38d447f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- FileStream^ fs = gcnew FileStream( path,FileMode::Open );
- try
- {
- StreamReader^ sr = gcnew StreamReader( fs );
- try
- {
- while ( sr->Peek() >= 0 )
- {
- Console::WriteLine( sr->ReadLine() );
- }
- }
- finally
- {
- delete sr;
- }
- }
- finally
- {
- delete fs;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp
deleted file mode 100644
index 9966a619ccf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path );
- try
- {
- while ( sr->Peek() >= 0 )
- {
- Console::WriteLine( sr->ReadLine() );
- }
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp
deleted file mode 100644
index 2bd7741e9da..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
-
- //Use an encoding other than the default (UTF8).
- StreamWriter^ sw = gcnew StreamWriter( path,false,gcnew UnicodeEncoding );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path,true );
- try
- {
- while ( sr->Peek() >= 0 )
- {
- Console::Write( (Char)sr->Read() );
- }
-
- //Test for the encoding after reading, or at least
- //after the first read.
- Console::WriteLine( "The encoding used was {0}.", sr->CurrentEncoding );
- Console::WriteLine();
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp
deleted file mode 100644
index cbfd1711768..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path );
- try
- {
- while ( sr->Peek() > -1 )
- {
- Console::WriteLine( sr->ReadLine() );
- }
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp
deleted file mode 100644
index 3b817c31cf1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path );
- try
- {
- while ( sr->Peek() >= 0 )
- {
- Console::Write( (Char)sr->Read() );
- }
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp
deleted file mode 100644
index 5ce83649e21..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path );
- try
- {
- //This is an arbitrary size for this example.
- array^c = nullptr;
- while ( sr->Peek() >= 0 )
- {
- c = gcnew array(5);
- sr->Read( c, 0, c->Length );
-
- //The output will look odd, because
- //only five characters are read at a time.
- Console::WriteLine( c );
- }
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp
deleted file mode 100644
index 5829e1a8108..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path );
- try
- {
- while ( sr->Peek() >= 0 )
- {
- Console::WriteLine( sr->ReadLine() );
- }
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp
deleted file mode 100644
index 5ae01bcfc2e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ path = "c:\\temp\\MyTest.txt";
- try
- {
- if ( File::Exists( path ) )
- {
- File::Delete( path );
- }
- StreamWriter^ sw = gcnew StreamWriter( path );
- try
- {
- sw->WriteLine( "This" );
- sw->WriteLine( "is some text" );
- sw->WriteLine( "to test" );
- sw->WriteLine( "Reading" );
- }
- finally
- {
- delete sw;
- }
-
- StreamReader^ sr = gcnew StreamReader( path );
- try
- {
- //This allows you to do one Read operation.
- Console::WriteLine( sr->ReadToEnd() );
- }
- finally
- {
- delete sr;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The process failed: {0}", e );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp
deleted file mode 100644
index 00fb6116cb7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-using namespace System;
-using namespace System::Threading;
-
-void ThreadProc()
-{
- Thread::Sleep(2000);
-};
-
-void main()
-{
- Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc));
- Console::WriteLine("Before setting apartment state: {0}",
- t->GetApartmentState());
-
- t->SetApartmentState(ApartmentState::STA);
- Console::WriteLine("After setting apartment state: {0}",
- t->GetApartmentState());
-
- bool result = t->TrySetApartmentState(ApartmentState::MTA);
- Console::WriteLine("Try to change state: {0}", result);
-
- t->Start();
-
- Thread::Sleep(500);
-
- try
- {
- t->TrySetApartmentState(ApartmentState::STA);
- }
- catch (ThreadStateException^)
- {
- Console::WriteLine("ThreadStateException occurs " +
- "if apartment state is set after starting thread.");
- }
-
- t->Join();
-}
-
-/* This code example produces the following output:
-
-Before setting apartment state: Unknown
-After setting apartment state: STA
-Try to change state: False
-ThreadStateException occurs if apartment state is set after starting thread.
- */
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp
deleted file mode 100644
index b1f06ee79ff..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Threading;
-using namespace System::Security::Permissions;
-ref class ThreadWork
-{
-public:
- static void DoWork()
- {
- try
- {
- for ( int i = 0; i < 100; i++ )
- {
- Console::WriteLine( "Thread - working." );
- Thread::Sleep( 100 );
-
- }
- }
- catch ( ThreadAbortException^ e )
- {
- Console::WriteLine( "Thread - caught ThreadAbortException - resetting." );
- Console::WriteLine( "Exception message: {0}", e->Message );
- Thread::ResetAbort();
- }
-
- Console::WriteLine( "Thread - still alive and working." );
- Thread::Sleep( 1000 );
- Console::WriteLine( "Thread - finished working." );
- }
-
-};
-
-int main()
-{
- ThreadStart^ myThreadDelegate = gcnew ThreadStart( ThreadWork::DoWork );
- Thread^ myThread = gcnew Thread( myThreadDelegate );
- myThread->Start();
- Thread::Sleep( 100 );
- Console::WriteLine( "Main - aborting my thread." );
- myThread->Abort();
- myThread->Join();
- Console::WriteLine( "Main ending." );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp
deleted file mode 100644
index 45cf4ed9674..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Threading;
-ref class ThreadWork
-{
-public:
- static void DoWork()
- {
- Console::WriteLine( "Working thread..." );
- }
-
-};
-
-int main()
-{
- ThreadStart^ myThreadDelegate = gcnew ThreadStart( ThreadWork::DoWork );
- Thread^ myThread = gcnew Thread( myThreadDelegate );
- myThread->Start();
- Thread::Sleep( 0 );
- Console::WriteLine( "In main. Attempting to restart myThread." );
- try
- {
- myThread->Start();
- }
- catch ( ThreadStateException^ e )
- {
- Console::WriteLine( "Caught: {0}", e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp
deleted file mode 100644
index d59246f431a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Threading;
-
-public ref class ThreadWork
-{
-public:
- static void DoWork()
- {
- for ( int i = 0; i < 3; i++ )
- {
- Console::WriteLine( "Working thread..." );
- Thread::Sleep( 100 );
- }
- }
-};
-
-int main()
-{
- ThreadStart^ myThreadDelegate = gcnew ThreadStart(&ThreadWork::DoWork);
- Thread^ thread1 = gcnew Thread( myThreadDelegate );
- thread1->Start();
- for ( int i = 0; i < 3; i++ )
- {
- Console::WriteLine( "In main." );
- Thread::Sleep( 100 );
- }
-}
-// The example displays output like the following:
-// In main.
-// Working thread...
-// In main.
-// Working thread...
-// In main.
-// Working thread...
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp b/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp
deleted file mode 100644
index a5590808eaa..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//Types:System.Threading.WaitHandle
-//
-using namespace System;
-using namespace System::Threading;
-
-public ref class WaitHandleExample
-{
- // Define a random number generator for testing.
-private:
- static Random^ random = gcnew Random();
-public:
- static void DoTask(Object^ state)
- {
- AutoResetEvent^ autoReset = (AutoResetEvent^) state;
- int time = 1000 * random->Next(2, 10);
- Console::WriteLine("Performing a task for {0} milliseconds.", time);
- Thread::Sleep(time);
- autoReset->Set();
- }
-};
-
-//
-int main()
-{
- // Define an array with two AutoResetEvent WaitHandles.
- array^ handles = gcnew array {
- gcnew AutoResetEvent(false), gcnew AutoResetEvent(false)};
-
- // Queue up two tasks on two different threads;
- // wait until all tasks are completed.
- DateTime timeInstance = DateTime::Now;
- Console::WriteLine("Main thread is waiting for BOTH tasks to " +
- "complete.");
- ThreadPool::QueueUserWorkItem(
- gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]);
- ThreadPool::QueueUserWorkItem(
- gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]);
- WaitHandle::WaitAll(handles);
- // The time shown below should match the longest task.
- Console::WriteLine("Both tasks are completed (time waited={0})",
- (DateTime::Now - timeInstance).TotalMilliseconds);
-
- // Queue up two tasks on two different threads;
- // wait until any tasks are completed.
- timeInstance = DateTime::Now;
- Console::WriteLine();
- Console::WriteLine("The main thread is waiting for either task to " +
- "complete.");
- ThreadPool::QueueUserWorkItem(
- gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]);
- ThreadPool::QueueUserWorkItem(
- gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]);
- int index = WaitHandle::WaitAny(handles);
- // The time shown below should match the shortest task.
- Console::WriteLine("Task {0} finished first (time waited={1}).",
- index + 1, (DateTime::Now - timeInstance).TotalMilliseconds);
-}
-//
-
-// This code produces the following sample output.
-//
-// Main thread is waiting for BOTH tasks to complete.
-// Performing a task for 7000 milliseconds.
-// Performing a task for 4000 milliseconds.
-// Both tasks are completed (time waited=7064.8052)
-
-// The main thread is waiting for either task to complete.
-// Performing a task for 2000 milliseconds.
-// Performing a task for 2000 milliseconds.
-// Task 1 finished first (time waited=2000.6528).
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp
deleted file mode 100644
index 9772134cfdc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
- String^ OtherCertificate = "OtherCertificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ certTwo = X509Certificate::CreateFromCertFile( OtherCertificate );
-
- // Get the value.
- bool result = cert->Equals( certTwo );
-
- // Display the value to the console.
- Console::WriteLine( result );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp
deleted file mode 100644
index 5af220ab9f7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- array^results = cert->GetCertHash();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp
deleted file mode 100644
index 55ab6046d0b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetCertHashString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp
deleted file mode 100644
index bdd5c733874..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetEffectiveDateString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp
deleted file mode 100644
index 7c7ba844a14..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetExpirationDateString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp
deleted file mode 100644
index 478464e28d5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetFormat();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp
deleted file mode 100644
index fbd037afed5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- int results = cert->GetHashCode();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp
deleted file mode 100644
index c8cc924a1df..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetIssuerName();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp
deleted file mode 100644
index 6c0355deedf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetKeyAlgorithm();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp
deleted file mode 100644
index 834343b8ca2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- array^results = cert->GetKeyAlgorithmParameters();
-
- // Display the value to the console.
- System::Collections::IEnumerator^ enum0 = results->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- Byte b = safe_cast(enum0->Current);
- Console::Write( b );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp
deleted file mode 100644
index 3ebc0887b84..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetKeyAlgorithmParametersString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp
deleted file mode 100644
index 14cc5940220..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetName();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp
deleted file mode 100644
index e30ffdb3735..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- array^results = cert->GetPublicKey();
-
- // Display the value to the console.
- System::Collections::IEnumerator^ enum0 = results->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- Byte b = safe_cast(enum0->Current);
- Console::Write( b );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp
deleted file mode 100644
index 53861be1cdc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetPublicKeyString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp
deleted file mode 100644
index da8eae2d858..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- array^results = cert->GetRawCertData();
-
- // Display the value to the console.
- System::Collections::IEnumerator^ enum0 = results->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- Byte b = safe_cast(enum0->Current);
- Console::Write( b );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp
deleted file mode 100644
index 17f1ada058c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetRawCertDataString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp
deleted file mode 100644
index fe0562f72c8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- array^results = cert->GetSerialNumber();
-
- // Display the value to the console.
- System::Collections::IEnumerator^ enum0 = results->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- Byte b = safe_cast(enum0->Current);
- Console::Write( b );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp
deleted file mode 100644
index f0bcfd5314f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ results = cert->GetSerialNumberString();
-
- // Display the value to the console.
- Console::WriteLine( results );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp
deleted file mode 100644
index 311195b9c1b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Cryptography::X509Certificates;
-int main()
-{
-
- // The path to the certificate.
- String^ Certificate = "Certificate.cer";
-
- // Load the certificate into an X509Certificate object.
- X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Get the value.
- String^ resultsTrue = cert->ToString( true );
-
- // Display the value to the console.
- Console::WriteLine( resultsTrue );
-
- // Get the value.
- String^ resultsFalse = cert->ToString( false );
-
- // Display the value to the console.
- Console::WriteLine( resultsFalse );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp
deleted file mode 100644
index aa1fd739b5b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-//
-//
-// This example signs a URL using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-
-namespace Sample
-{
- public ref class SignVerifyEnvelope
- {
- public:
- static void Work()
- {
- // Generate a signing key.
- RSA^ key = RSA::Create();
-
- try
- {
-
- // Sign the detached resource and save the
- // signature in an XML file.
- SignDetachedResource("http://www.microsoft.com",
- "SignedExample.xml", key);
-
- Console::WriteLine("XML file signed.");
-
- // Verify the signature of the signed XML.
- Console::WriteLine("Verifying signature...");
-
- bool result = VerifyXmlFile("SignedExample.xml");
-
- // Display the results of the signature verification
- // to the console.
- if (result)
- {
- Console::WriteLine("The XML signature"
- " is valid.");
- }
- else
- {
- Console::WriteLine("The XML signature"
- " is not valid.");
- }
- Console::ReadLine();
- }
-
- catch (CryptographicException^ ex)
- {
- Console::WriteLine(ex->Message);
- }
- finally
- {
- // Clear resources associated with the
- // RSA instance.
- key->Clear();
- }
- }
-
-
- // Sign an XML file and save the signature in a new file.
- static void SignDetachedResource(String^ uri,
- String^ xmlFileName, RSA^ key)
- {
- // Check the arguments.
- if (uri->Length == 0)
- {
- throw gcnew ArgumentException("uri");
- }
- if (xmlFileName->Length == 0)
- {
- throw gcnew ArgumentException("xmlFileName");
- }
- if (key->KeySize == 0)
- {
- throw gcnew ArgumentException("key");
- }
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml();
-
- // Assign the key to the SignedXml object.
- signedXml->SigningKey = key;
-
- // Get the signature object from the SignedXml object.
- Signature^ xmlSignature = signedXml->Signature;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference();
-
- // Add the passed URI to the reference object.
- reference->Uri = uri;
-
- // Add the Reference object to the Signature object.
- xmlSignature->SignedInfo->AddReference(reference);
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient
- // find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo();
- keyInfo->AddClause(
- gcnew RSAKeyValue(key));
-
- // Add the KeyInfo object to the Reference object.
- xmlSignature->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmlTextWriter = gcnew XmlTextWriter(
- xmlFileName, gcnew UTF8Encoding(false));
-
- xmlDigitalSignature->WriteTo(xmlTextWriter);
- xmlTextWriter->Close();
- }
-
-
- // Verify the signature of an XML file and return the result.
- static Boolean VerifyXmlFile(String^ documentName)
- {
- // Check the arguments.
- if (documentName->Length == 0)
- {
- throw gcnew ArgumentException("documentName");
- }
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument();
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load(documentName);
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml(xmlDocument);
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList =
- xmlDocument->GetElementsByTagName("Signature");
-
- // Load the signature node.
- signedXml->LoadXml(
- (XmlElement^) nodeList->Item(0));
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
- }
- };
-}
-
-
-int main()
-{
- Sample::SignVerifyEnvelope::Work();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp
deleted file mode 100644
index 95b151171e8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Xml;
-int main()
-{
-
- // Create example data to sign.
- XmlDocument^ document = gcnew XmlDocument;
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
- node->InnerText = "This is some text";
- document->AppendChild( node );
- Console::Error->WriteLine( "Data to sign:\n{0}\n", document->OuterXml );
-
- // Create the SignedXml message.
- SignedXml^ signedXml = gcnew SignedXml;
- RSA^ key = RSA::Create();
- signedXml->SigningKey = key;
-
- // Create a data object to hold the data to sign.
- DataObject^ dataObject = gcnew DataObject;
- dataObject->Data = document->ChildNodes;
- dataObject->Id = "MyObjectId";
-
- // Add the data object to the signature.
- signedXml->AddObject( dataObject );
-
- // Create a reference to be able to package everything into the
- // message.
- Reference^ reference = gcnew Reference;
- reference->Uri = "#MyObjectId";
-
- // Add it to the message.
- signedXml->AddReference( reference );
-
- // Add a KeyInfo.
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( key ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature.
- XmlElement^ xmlSignature = signedXml->GetXml();
- Console::WriteLine( xmlSignature->OuterXml );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp
deleted file mode 100644
index 74689b19c1f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::IO;
-using namespace System::Xml;
-int main()
-{
- array^args = System::Environment::GetCommandLineArgs();
- Console::WriteLine( "Verifying {0}...", args[ 1 ] );
-
- // Create a SignedXml.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Load the XML.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
- xmlDocument->PreserveWhitespace = true;
- xmlDocument->Load( gcnew XmlTextReader( args[ 1 ] ) );
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
- signedXml->LoadXml( safe_cast(nodeList[ 0 ]) );
- if ( signedXml->CheckSignature() )
- {
- Console::WriteLine( "Signature check OK" );
- }
- else
- {
- Console::WriteLine( "Signature check FAILED" );
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp b/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp
deleted file mode 100644
index e3a2a599d6d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-int main()
-{
-
- // creates the CspParameters object and sets the key container name used to store the RSA key pair
- CspParameters^ cp = gcnew CspParameters;
- cp->KeyContainerName = "MyKeyContainerName";
-
- // instantiates the rsa instance accessing the key container MyKeyContainerName
- RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp );
-
- // add the below line to delete the key entry in MyKeyContainerName
- // rsa.PersistKeyInCsp = false;
- //writes out the current key pair used in the rsa instance
- Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp b/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp
deleted file mode 100644
index 486c6233b75..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::IO;
-
-/// This sample used the EncryptedData class to create a EncryptedData element
-/// and write it to an XML file.
-int main()
-{
- //
- // Create a new CipherData object.
- CipherData^ cipher = gcnew CipherData();
- // Assign a byte array to be the CipherValue. This is a
- // byte array representing encrypted data.
- cipher->CipherValue = gcnew array(8);
- //
- //
- // Create a new EncryptedData object.
- EncryptedData^ encryptionRoot = gcnew EncryptedData();
- //
- //Add an encryption method to the object.
- encryptionRoot->Id = "ED";
- encryptionRoot->EncryptionMethod = gcnew EncryptionMethod(
- "http://www.w3.org/2001/04/xmlenc#aes128-cbc");
- encryptionRoot->CipherData = cipher;
-
- //Add key information to the object.
- KeyInfo^ keyDetails = gcnew KeyInfo();
- keyDetails->AddClause(gcnew KeyInfoRetrievalMethod("#EK",
- "http://www.w3.org/2001/04/xmlenc#EncryptedKey"));
- encryptionRoot->KeyInfo = keyDetails;
-
- // Create new XML document and put encrypted data into it.
- XmlDocument^ doc = gcnew XmlDocument();
- XmlElement^ encryptionPropertyElement =
- doc->CreateElement("EncryptionProperty",
- EncryptedXml::XmlEncNamespaceUrl);
- EncryptionProperty^ property = gcnew EncryptionProperty(
- encryptionPropertyElement);
- encryptionRoot->AddProperty(property);
-
- // Output the resulting XML information into a file.
- String^ path = "test.xml";
- try
- {
- File::WriteAllText(path, encryptionRoot->GetXml()->OuterXml);
- }
- catch (IOException^ ex)
- {
- Console::WriteLine("There was an error writing to {0}", path);
- Console::WriteLine(ex->Message);
- }
- //Console.WriteLine(ed.GetXml().OuterXml);
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp
deleted file mode 100644
index e1fe39c2ee1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Xml;
-using namespace System::IO;
-
-/// This sample used the EncryptedData class to create an encrypted data element
-/// and write it to an XML file. It demonstrates the use of CipherReference.
-
-[STAThread]
-int main()
-{
-
- //Create a URI string.
- String^ uri = "http://www.woodgrovebank.com/document.xml";
-
- // Create a Base64 transform. The input content retrieved from the
- // URI should be Base64-decoded before other processing.
- Transform^ base64 = gcnew XmlDsigBase64Transform;
-
- //Create a transform chain and add the transform to it.
- TransformChain^ tc = gcnew TransformChain;
- tc->Add( base64 );
-
- //Create information.
- CipherReference ^ reference = gcnew CipherReference( uri,tc );
-
- // Create a new CipherData object using the CipherReference information.
- // Note that you cannot assign both a CipherReference and a CipherValue
- // to a CipherData object.
- CipherData ^ cd = gcnew CipherData( reference );
-
- // Create a new EncryptedData object.
- EncryptedData^ ed = gcnew EncryptedData;
-
- //Add an encryption method to the object.
- ed->Id = "ED";
- ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" );
- ed->CipherData = cd;
-
- //Add key information to the object.
- KeyInfo^ ki = gcnew KeyInfo;
- ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) );
- ed->KeyInfo = ki;
-
- // Create new XML document and put encrypted data into it.
- XmlDocument^ doc = gcnew XmlDocument;
- XmlElement^ encryptionPropertyElement = dynamic_cast(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl ));
- EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement );
- ed->AddProperty( ep );
-
- // Output the resulting XML information into a file.
- try
- {
- String^ path = "c:\\test\\MyTest.xml";
- File::WriteAllText( path, ed->GetXml()->OuterXml );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( "File IO error. {0}", e );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp b/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp
deleted file mode 100644
index a13819251ee..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Xml;
-using namespace System::IO;
-
-/// This sample used the EncryptedData class to create a EncryptedData element
-/// and write it to an XML file.
-
-[STAThread]
-int main()
-{
-
- //
- //
- // Create a new CipherData object using a byte array to represent encrypted data.
- array^sampledata = gcnew array(8);
- CipherData ^ cd = gcnew CipherData( sampledata );
-
- //
- // Create a new EncryptedData object.
- EncryptedData^ ed = gcnew EncryptedData;
-
- //Add an encryption method to the object.
- ed->Id = "ED";
- ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" );
- ed->CipherData = cd;
-
- //
- //
- //Add key information to the object.
- KeyInfo^ ki = gcnew KeyInfo;
- ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) );
- ed->KeyInfo = ki;
-
- //
- // Create new XML document and put encrypted data into it.
- XmlDocument^ doc = gcnew XmlDocument;
- XmlElement^ encryptionPropertyElement = dynamic_cast(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl ));
- EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement );
- ed->AddProperty( ep );
-
- // Output the resulting XML information into a file. Change the path variable to point to a directory where
- // the XML file should be written.
- String^ path = "c:\\test\\MyTest.xml";
- File::WriteAllText( path, ed->GetXml()->OuterXml );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp
deleted file mode 100644
index ab6a5a558b4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Create a reference to a directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" );
-
- // Create the directory only if it does not already exist.
- if ( !di->Exists )
- di->Create();
-
-
- // Create a subdirectory in the directory just created.
- DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" );
-
- // Process that directory as required.
- // ...
- // Delete the subdirectory.
- dis->Delete( true );
-
- // Delete the directory.
- di->Delete( true );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp
deleted file mode 100644
index 26deda48521..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Make a reference to a directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" );
-
- // Create the directory only if it does not already exist.
- if ( !di->Exists )
- di->Create();
-
-
- // Create a subdirectory in the directory just created.
- DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" );
-
- // Process that directory as required.
- // ...
- // Delete the subdirectory. The true indicates that if subdirectories
- // or files are in this directory, they are to be deleted as well.
- dis->Delete( true );
-
- // Delete the directory.
- di->Delete( true );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp
deleted file mode 100644
index e9e232e4458..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Make a reference to a directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" );
-
- // Get a reference to each directory in that directory.
- array^diArr = di->GetDirectories();
-
- // Display the names of the directories.
- Collections::IEnumerator^ myEnum = diArr->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DirectoryInfo^ dri = safe_cast(myEnum->Current);
- Console::WriteLine( dri->Name );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp
deleted file mode 100644
index 3acf01cd274..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Make a reference to a directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" );
-
- // Create the directory only if it does not already exist.
- if ( !di->Exists )
- di->Create();
-
-
- // Create a subdirectory in the directory just created.
- DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" );
-
- // Move the main directory. Note that the contents move with the directory.
- if ( !Directory::Exists( "NewTempDir" ) )
- di->MoveTo( "NewTempDir" );
-
- try
- {
-
- // Attempt to delete the subdirectory. Note that because it has been
- // moved, an exception is thrown.
- dis->Delete( true );
- }
- catch ( Exception^ )
- {
-
- // Handle this exception in some way, such as with the following code:
- // Console::WriteLine(S"That directory does not exist.");
- }
-
-
- // Point the DirectoryInfo reference to the new directory.
- //di = new DirectoryInfo(S"NewTempDir");
- // Delete the directory.
- //di->Delete(true);
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp
deleted file mode 100644
index 73ca8a192a8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Make a reference to a directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" );
-
- // Create the directory only if it does not already exist.
- if ( !di->Exists )
- di->Create();
-
-
- // Create a subdirectory in the directory just created.
- DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" );
-
- // Get a reference to the parent directory of the subdirectory you just made.
- DirectoryInfo^ parentDir = dis->Parent;
- Console::WriteLine( "The parent directory of '{0}' is '{1}'", dis->Name, parentDir->Name );
-
- // Delete the parent directory.
- di->Delete( true );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp
deleted file mode 100644
index becae48d9ab..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-// System.Diagnostics.EventLogInstaller
-// The following example demonstrates the EventLogInstaller class.
-// It defines the instance SampleEventLogInstaller with the
-// attribute RunInstallerAttribute.
-//
-// The Log and Source properties of the new instance are set,
-// along with the new resource file properties,
-// and the instance is added to the collection of installers
-// to be run during an installation.
-//
-// Note:
-// 1) Run this program using the following command:
-// InstallUtil.exe
-// 2) Uninstall the event log created in step 1 using the
-// following command:
-// InstallUtil.exe /u
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Configuration::Install;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-
-[RunInstaller(true)]
-public ref class SampleEventLogInstaller : public Installer
-{
-private:
- EventLogInstaller^ myEventLogInstaller;
-
-public:
- SampleEventLogInstaller()
- {
-
- // Create an instance of an EventLogInstaller.
- myEventLogInstaller = gcnew EventLogInstaller;
-
- // Set the source name of the event log.
- myEventLogInstaller->Source = "ApplicationEventSource";
-
- // Set the event log into which the source writes entries.
- //myEventLogInstaller.Log = "MyCustomLog";
- myEventLogInstaller->Log = "myNewLog";
-
- // Set the resource file for the event log.
- // The message strings are defined in EventLogMsgs.mc; the message
- // identifiers used in the application must match those defined in the
- // corresponding message resource file. The messages must be built
- // into a Win32 resource library and copied to the target path on the
- // system.
- myEventLogInstaller->CategoryResourceFile =
- Environment::SystemDirectory + "\\eventlogmsgs.dll";
- myEventLogInstaller->CategoryCount = 3;
- myEventLogInstaller->MessageResourceFile =
- Environment::SystemDirectory + "\\eventlogmsgs.dll";
- myEventLogInstaller->ParameterResourceFile =
- Environment::SystemDirectory + "\\eventlogmsgs.dll";
-
- // Add myEventLogInstaller to the installer collection.
- Installers->Add( myEventLogInstaller );
- }
-
-};
-
-int main()
-{
- Console::WriteLine( "Usage: InstallUtil.exe [.exe | .dll]" );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp
deleted file mode 100644
index 7bfe2badf7e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-void CleanUp();
-void CreateEventSourceSample1( String^ messageFile );
-void WriteEventSample1();
-void WriteEventSample2();
-void EventInstanceSamples();
-
-//
-// The following constants match the message definitions
-// in the message resource file. They are used to specify
-// the resource identifier for a localized string in the
-// message resource file.
-// The message resource file is an .mc file built into a
-// Win32 resource file using the message compiler (MC) tool.
-//
-const short InstallCategoryMsgId = 1;
-const short QueryCategoryMsgId = 2;
-const short RefreshCategoryMsgId = 3;
-const short CategoryCount = 3;
-
-//
-//
-// Define the resource identifiers for the event messages.
-// Resource identifiers combine the message ID and the severity field.
-const long AuditSuccessMsgId = 1000;
-const long AuditFailedMsgId = 1001 + 0x80000000;
-const long InformationMsgId = 1002;
-const long WarningMsgId = 1003 + 0x80000000;
-const long UpdateCycleCompleteMsgId = 1004;
-const long ServerConnectionDownMsgId = 1005 + 0x80000000;
-
-//
-//
-const long DisplayNameMsgId = 5001;
-const long ServiceNameMsgId = 5002;
-
-//
-//
-
-[STAThread]
-int main()
-{
- array^args = Environment::GetCommandLineArgs();
- String^ messageFile;
- if ( args->Length > 1 )
- {
-
- // Use the input argument as the message resource file.
- messageFile = args[ 1 ];
- }
- else
- {
-
- // Use the default message dll.
- messageFile = String::Format( "{0}\\{1}", System::Environment::CurrentDirectory, "EventLogMsgs.dll" );
- }
-
- CleanUp();
- CreateEventSourceSample1( messageFile );
- WriteEventSample1();
- WriteEventSample2();
- EventInstanceSamples();
-}
-
-void CleanUp()
-{
- String^ sourceName = "SampleApplicationSource";
-
- // Delete the event source in order to re-register
- // the source with the latest configuration properties.
- if ( EventLog::SourceExists( sourceName ) )
- {
- Console::WriteLine( "Deleting event source {0}.", sourceName );
- EventLog::DeleteEventSource( sourceName );
- }
-}
-//
-void CreateEventSourceSample1( String^ messageFile )
-{
- String^ myLogName;
- String^ sourceName = "SampleApplicationSource";
-
- // Create the event source if it does not exist.
- if ( !EventLog::SourceExists( sourceName ) )
- {
-
- // Create a new event source for the custom event log
- // named "myNewLog."
- myLogName = "myNewLog";
- EventSourceCreationData ^ mySourceData = gcnew EventSourceCreationData( sourceName,myLogName );
-
- // Set the message resource file that the event source references.
- // All event resource identifiers correspond to text in this file.
- if ( !System::IO::File::Exists( messageFile ) )
- {
- Console::WriteLine( "Input message resource file does not exist - {0}", messageFile );
- messageFile = "";
- }
- else
- {
-
- // Set the specified file as the resource
- // file for message text, category text, and
- // message parameter strings.
- mySourceData->MessageResourceFile = messageFile;
- mySourceData->CategoryResourceFile = messageFile;
- mySourceData->CategoryCount = CategoryCount;
- mySourceData->ParameterResourceFile = messageFile;
- Console::WriteLine( "Event source message resource file set to {0}", messageFile );
- }
-
- Console::WriteLine( "Registering new source for event log." );
- EventLog::CreateEventSource( mySourceData );
- }
- else
- {
-
- // Get the event log corresponding to the existing source.
- myLogName = EventLog::LogNameFromSourceName( sourceName, "." );
- }
-
-
- // Register the localized name of the event log.
- // For example, the actual name of the event log is "myNewLog," but
- // the event log name displayed in the Event Viewer might be
- // "Sample Application Log" or some other application-specific
- // text.
- EventLog^ myEventLog = gcnew EventLog( myLogName,".",sourceName );
- if ( messageFile->Length > 0 )
- {
- myEventLog->RegisterDisplayName( messageFile, DisplayNameMsgId );
- }
-}
-//
-
-void WriteEventSample1()
-{
- //
- // Create the event source if it does not exist.
- String^ sourceName = "SampleApplicationSource";
- if ( !EventLog::SourceExists( sourceName ) )
- {
-
- // Call a local method to register the event log source
- // for the event log "myNewLog." Use the resource file
- // EventLogMsgs.dll in the current directory for message text.
- String^ messageFile = String::Format( "{0}\\{1}", System::Environment::CurrentDirectory, "EventLogMsgs.dll" );
- CreateEventSourceSample1( messageFile );
- }
-
- // Get the event log corresponding to the existing source.
- String^ myLogName = EventLog::LogNameFromSourceName( sourceName, "." );
- EventLog^ myEventLog = gcnew EventLog( myLogName,".",sourceName );
-
- // Define two audit events.
- // The message identifiers correspond to the message text in the
- // message resource file defined for the source.
- EventInstance ^ myAuditSuccessEvent = gcnew EventInstance( AuditSuccessMsgId,0,EventLogEntryType::SuccessAudit );
- EventInstance ^ myAuditFailEvent = gcnew EventInstance( AuditFailedMsgId,0,EventLogEntryType::FailureAudit );
-
- // Insert the method name into the event log message.
- array^insertStrings = {"EventLogSamples.WriteEventSample1"};
-
- // Write the events to the event log.
- myEventLog->WriteEvent( myAuditSuccessEvent, insertStrings );
-
- // Append binary data to the audit failure event entry.
- array^binaryData = {3,4,5,6};
- myEventLog->WriteEvent( myAuditFailEvent, binaryData, insertStrings );
-
- //
-}
-
-void WriteEventSample2()
-{
- //
- String^ sourceName = "SampleApplicationSource";
- if ( EventLog::SourceExists( sourceName ) )
- {
-
- // Define an informational event and a warning event.
- // The message identifiers correspond to the message text in the
- // message resource file defined for the source.
- EventInstance ^ myInfoEvent = gcnew EventInstance( InformationMsgId,0,EventLogEntryType::Information );
- EventInstance ^ myWarningEvent = gcnew EventInstance( WarningMsgId,0,EventLogEntryType::Warning );
-
- // Insert the method name into the event log message.
- array^insertStrings = {"EventLogSamples.WriteEventSample2"};
-
- // Write the events to the event log.
- EventLog::WriteEvent( sourceName, myInfoEvent, 0 );
-
- // Append binary data to the warning event entry.
- array^binaryData = {7,8,9,10};
- EventLog::WriteEvent( sourceName, myWarningEvent, binaryData, insertStrings );
- }
- else
- {
- Console::WriteLine( "Warning - event source {0} not registered", sourceName );
- }
- //
-}
-
-void EventInstanceSamples()
-{
-
- //
- // Ensure that the source has already been registered using
- // EventLogInstaller or EventLog.CreateEventSource.
- String^ sourceName = "SampleApplicationSource";
- if ( EventLog::SourceExists( sourceName ) )
- {
- // Define an informational event with no category.
- // The message identifier corresponds to the message text in the
- // message resource file defined for the source.
- EventInstance ^ myEvent = gcnew EventInstance( UpdateCycleCompleteMsgId,0 );
-
- // Write the event to the event log using the registered source.
- EventLog::WriteEvent( sourceName, myEvent, 0 );
-
- // Reuse the event data instance for another event entry.
- // Set the entry category and message identifiers for
- // the appropriate resource identifiers in the resource files
- // for the registered source. Set the event type to Warning.
- myEvent->CategoryId = RefreshCategoryMsgId;
- myEvent->EntryType = EventLogEntryType::Warning;
- myEvent->InstanceId = ServerConnectionDownMsgId;
-
- // Write the event to the event log using the registered source.
- // Insert the machine name into the event message text.
- array^ss = {Environment::MachineName};
- EventLog::WriteEvent( sourceName, myEvent, ss );
- }
- else
- {
- Console::WriteLine( "Warning - event source {0} not registered", sourceName );
- }
- //
- //
-
- // Get the event log corresponding to the existing source.
- String^ myLogName = EventLog::LogNameFromSourceName( sourceName, "." );
-
- // Find each instance of a specific event log entry in a
- // particular event log.
- EventLog^ myEventLog = gcnew EventLog( myLogName,"." );
- int count = 0;
- Console::WriteLine( "Searching event log entries for the event ID {0}...", ServerConnectionDownMsgId );
-
- // Search for the resource ID, display the event text,
- // and display the number of matching entries.
- System::Collections::IEnumerator^ myEnum = myEventLog->Entries->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- EventLogEntry^ entry = safe_cast(myEnum->Current);
- if ( entry->InstanceId == ServerConnectionDownMsgId )
- {
- count++;
- Console::WriteLine();
- Console::WriteLine( "Entry ID = {0}", entry->InstanceId );
- Console::WriteLine( "Reported at {0}", entry->TimeWritten );
- Console::WriteLine( "Message text:" );
- Console::WriteLine( "\t{0}", entry->Message );
- }
- }
-
- Console::WriteLine();
- Console::WriteLine( "Found {0} events with ID {1} in event log {2}.", count, ServerConnectionDownMsgId, myLogName );
- //
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp
deleted file mode 100644
index 9006e0e4c6d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Create a writer, ready to add entries to the file.
- StreamWriter^ sw = fi->AppendText();
- sw->WriteLine( "Add as many lines as you like..." );
- sw->WriteLine( "Add another line to the output..." );
- sw->Flush();
- sw->Close();
-
- // Get the information out of the file and display it.
- // Remember that the file might have other lines if it already existed.
- StreamReader^ sr = gcnew StreamReader( fi->OpenRead() );
- while ( sr->Peek() != -1 )
- Console::WriteLine( sr->ReadLine() );
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//Add as many lines as you like...
-//Add another line to the output...
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp
deleted file mode 100644
index 3b56ad744a1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Create a reference to a file, which might or might not exist.
- // If it does not exist, it is not yet created.
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Create a writer, ready to add entries to the file.
- StreamWriter^ sw = fi->AppendText();
- sw->WriteLine( "Add as many lines as you like..." );
- sw->WriteLine( "Add another line to the output..." );
- sw->Flush();
- sw->Close();
-
- // Get the information out of the file and display it.
- StreamReader^ sr = gcnew StreamReader( fi->OpenRead() );
- Console::WriteLine( "This is the information in the first file:" );
- while ( sr->Peek() != -1 )
- Console::WriteLine( sr->ReadLine() );
-
-
- // Copy this file to another file. The true parameter specifies
- // that the file will be overwritten if it already exists.
- FileInfo^ newfi = fi->CopyTo( "newTemp.txt", true );
-
- // Get the information out of the new file and display it.* sr = new StreamReader( newfi->OpenRead() );
- Console::WriteLine( "{0}This is the information in the second file:", Environment::NewLine );
- while ( sr->Peek() != -1 )
- Console::WriteLine( sr->ReadLine() );
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is the information in the first file:
-//Add as many lines as you like...
-//Add another line to the output...
-//This is the information in the second file:
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp
deleted file mode 100644
index a5bcc91ed5d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Create a reference to a file.
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Actually create the file.
- FileStream^ fs = fi->Create();
-
- // Modify the file as required, and then close the file.
- fs->Close();
-
- // Delete the file.
- fi->Delete();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp
deleted file mode 100644
index 194a71d29f4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Open an existing file, or create a new one.
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Determine the full path of the file just created.
- DirectoryInfo^ di = fi->Directory;
-
- // Figure out what other entries are in that directory.
- array^fsi = di->GetFileSystemInfos();
- Console::WriteLine( "The directory '{0}' contains the following files and directories:", di->FullName );
-
- // Print the names of all the files and subdirectories of that directory.
- Collections::IEnumerator^ myEnum = fsi->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- FileSystemInfo^ info = safe_cast(myEnum->Current);
- Console::WriteLine( info->Name );
- }
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//The directory 'C:\Visual Studio 2005\release' contains the following files
-//and directories:
-//fileinfodirectory.exe
-//fileinfodirectory.pdb
-//newTemp.txt
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp
deleted file mode 100644
index bdd66b10555..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Open an existing file, or create a new one.
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Create a writer, ready to add entries to the file.
- StreamWriter^ sw = fi->AppendText();
- sw->WriteLine( "This is a new entry to add to the file" );
- sw->WriteLine( "This is yet another line to add..." );
- sw->Flush();
- sw->Close();
-
- // Get the information out of the file and display it.
- StreamReader^ sr = gcnew StreamReader( fi->OpenRead() );
- while ( sr->Peek() != -1 )
- Console::WriteLine( sr->ReadLine() );
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//This is a new entry to add to the file
-//This is yet another line to add...
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp
deleted file mode 100644
index e29a987391a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Create a reference to the current directory.
- DirectoryInfo^ di = gcnew DirectoryInfo( Environment::CurrentDirectory );
-
- // Create an array representing the files in the current directory.
- array^fi = di->GetFiles();
- Console::WriteLine( "The following files exist in the current directory:" );
-
- // Print out the names of the files in the current directory.
- Collections::IEnumerator^ myEnum = fi->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- FileInfo^ fiTemp = safe_cast(myEnum->Current);
- Console::WriteLine( fiTemp->Name );
- }
-}
-
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//The following files exist in the current directory:
-//fileinfoname.exe
-//fileinfoname.pdb
-//newTemp.txt
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp
deleted file mode 100644
index 7919473364a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Open an existing file, or create a new one.
- FileInfo^ fi = gcnew FileInfo( "temp.txt" );
-
- // Open the file just specified such that no one else can use it.
- FileStream^ fs = fi->Open( FileMode::OpenOrCreate, FileAccess::ReadWrite, FileShare::None );
-
- // Create another reference to the same file.
- FileInfo^ nextfi = gcnew FileInfo( "temp.txt" );
- try
- {
-
- // Try opening the same file, which was locked by the previous process.
- nextfi->Open( FileMode::OpenOrCreate, FileAccess::Read );
- Console::WriteLine( "The file was not locked, and was opened by a second process." );
- }
- catch ( IOException^ )
- {
- Console::WriteLine( "The file could not be opened because it was locked by another process." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e );
- }
-
-
- // Close the file so it can be deleted.
- fs->Close();
-}
-//This code produces output similar to the following;
-//results may vary based on the computer/file structure/etc.:
-//
-//The file could not be opened because it was locked by another process.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp
deleted file mode 100644
index feda725012e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections::Generic;
-using namespace System::Collections::ObjectModel;
-
-void main()
-{
- List^ dinosaurs = gcnew List();
-
- dinosaurs->Add("Tyrannosaurus");
- dinosaurs->Add("Amargasaurus");
- dinosaurs->Add("Deinonychus");
- dinosaurs->Add("Compsognathus");
-
- ReadOnlyCollection^ readOnlyDinosaurs =
- gcnew ReadOnlyCollection(dinosaurs);
-
- Console::WriteLine();
- for each(String^ dinosaur in readOnlyDinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- Console::WriteLine("\nCount: {0}", readOnlyDinosaurs->Count);
-
- Console::WriteLine("\nContains(\"Deinonychus\"): {0}",
- readOnlyDinosaurs->Contains("Deinonychus"));
-
- Console::WriteLine("\nreadOnlyDinosaurs[3]: {0}",
- readOnlyDinosaurs[3]);
-
- Console::WriteLine("\nIndexOf(\"Compsognathus\"): {0}",
- readOnlyDinosaurs->IndexOf("Compsognathus"));
-
- Console::WriteLine("\nInsert into the wrapped List:");
- Console::WriteLine("Insert(2, \"Oviraptor\")");
- dinosaurs->Insert(2, "Oviraptor");
-
- Console::WriteLine();
- for each( String^ dinosaur in readOnlyDinosaurs )
- {
- Console::WriteLine(dinosaur);
- }
-
- array^ dinoArray =
- gcnew array(readOnlyDinosaurs->Count + 2);
- readOnlyDinosaurs->CopyTo(dinoArray, 1);
-
- Console::WriteLine("\nCopied array has {0} elements:",
- dinoArray->Length);
- for each( String^ dinosaur in dinoArray )
- {
- Console::WriteLine("\"{0}\"", dinosaur);
- }
-}
-
-/* This code example produces the following output:
-
-Tyrannosaurus
-Amargasaurus
-Deinonychus
-Compsognathus
-
-Count: 4
-
-Contains("Deinonychus"): True
-
-readOnlyDinosaurs[3]: Compsognathus
-
-IndexOf("Compsognathus"): 3
-
-Insert into the wrapped List:
-Insert(2, "Oviraptor")
-
-Tyrannosaurus
-Amargasaurus
-Oviraptor
-Deinonychus
-Compsognathus
-
-Copied array has 7 elements:
-""
-"Tyrannosaurus"
-"Amargasaurus"
-"Oviraptor"
-"Deinonychus"
-"Compsognathus"
-""
- */
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp b/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp
deleted file mode 100644
index c576f3dc408..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-void CombinePaths( String^ p1, String^ p2 )
-{
- try
- {
- String^ combination = Path::Combine( p1, p2 );
- Console::WriteLine( "When you combine '{0}' and '{1}', the result is: {2}'{3}'", p1, p2, Environment::NewLine, combination );
- }
- catch ( Exception^ e )
- {
- if (p1 == nullptr)
- p1 = "nullptr";
- if (p2 == nullptr)
- p2 = "nullptr";
- Console::WriteLine( "You cannot combine '{0}' and '{1}' because: {2}{3}", p1, p2, Environment::NewLine, e->Message );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
- String^ path1 = "c:\\temp";
- String^ path2 = "subdir\\file.txt";
- String^ path3 = "c:\\temp.txt";
- String^ path4 = "c:^*&)(_=@#'\\^.*(.txt";
- String^ path5 = "";
- String^ path6 = nullptr;
- CombinePaths( path1, path2 );
- CombinePaths( path1, path3 );
- CombinePaths( path3, path2 );
- CombinePaths( path4, path2 );
- CombinePaths( path5, path2 );
- CombinePaths( path6, path2 );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp
deleted file mode 100644
index ea3629d178b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Diagnostics;
-using namespace System::Text;
-
-ref class StandardAsyncOutputExample
-{
-private:
- static int lineCount = 0;
- static StringBuilder^ output = nullptr;
-
-public:
- static void Run()
- {
- Process^ process = gcnew Process();
- process->StartInfo->FileName = "ipconfig.exe";
- process->StartInfo->UseShellExecute = false;
- process->StartInfo->RedirectStandardOutput = true;
- output = gcnew StringBuilder();
- process->OutputDataReceived += gcnew DataReceivedEventHandler(OutputHandler);
- process->Start();
-
- // Asynchronously read the standard output of the spawned process.
- // This raises OutputDataReceived events for each line of output.
- process->BeginOutputReadLine();
- process->WaitForExit();
-
- // Write the redirected output to this application's window.
- Console::WriteLine(output);
-
- process->WaitForExit();
- process->Close();
-
- Console::WriteLine("\n\nPress any key to exit");
- Console::ReadLine();
- }
-
-private:
- static void OutputHandler(Object^ sender, DataReceivedEventArgs^ e)
- {
- // Prepend line numbers to each line of the output.
- if (!String::IsNullOrEmpty(e->Data))
- {
- lineCount++;
- output->Append("\n[" + lineCount + "]: " + e->Data);
- }
- }
-};
-
-int main()
-{
- StandardAsyncOutputExample::Run();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp
deleted file mode 100644
index 6dc1d4e11d3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-// System.Diagnostics
-//
-// Requires .NET Framework version 1.2 or higher.
-
-// The following example uses the net view command to list the
-// available network resources available on a remote computer,
-// and displays the results to the console. Specifying the optional
-// error log file redirects error output to that file.
-
-//
-// Define the namespaces used by this sample.
-#using
-
-using namespace System;
-using namespace System::Text;
-using namespace System::Globalization;
-using namespace System::IO;
-using namespace System::Diagnostics;
-using namespace System::Threading;
-using namespace System::ComponentModel;
-
-ref class ProcessNetStreamRedirection
-{
-private:
- // Define static variables shared by class methods.
- static StreamWriter^ streamError = nullptr;
- static String^ netErrorFile = "";
- static StringBuilder^ netOutput = nullptr;
- static bool errorRedirect = false;
- static bool errorsWritten = false;
-
-public:
- static void RedirectNetCommandStreams()
- {
- String^ netArguments;
- Process^ netProcess;
-
- // Get the input computer name.
- Console::WriteLine( "Enter the computer name for the net view command:" );
- netArguments = Console::ReadLine()->ToUpper( CultureInfo::InvariantCulture );
- if ( String::IsNullOrEmpty( netArguments ) )
- {
- // Default to the help command if there is not an input argument.
- netArguments = "/?";
- }
-
- // Check if errors should be redirected to a file.
- errorsWritten = false;
- Console::WriteLine( "Enter a fully qualified path to an error log file" );
- Console::WriteLine( " or just press Enter to write errors to console:" );
- netErrorFile = Console::ReadLine()->ToUpper( CultureInfo::InvariantCulture );
- if ( !String::IsNullOrEmpty( netErrorFile ) )
- {
- errorRedirect = true;
- }
-
- // Note that at this point, netArguments and netErrorFile
- // are set with user input. If the user did not specify
- // an error file, then errorRedirect is set to false.
-
- // Initialize the process and its StartInfo properties.
- netProcess = gcnew Process;
- netProcess->StartInfo->FileName = "Net.exe";
-
- // Build the net command argument list.
- netProcess->StartInfo->Arguments = String::Format( "view {0}", netArguments );
-
- // Set UseShellExecute to false for redirection.
- netProcess->StartInfo->UseShellExecute = false;
-
- // Redirect the standard output of the net command.
- // This stream is read asynchronously using an event handler.
- netProcess->StartInfo->RedirectStandardOutput = true;
- netProcess->OutputDataReceived += gcnew DataReceivedEventHandler( NetOutputDataHandler );
- netOutput = gcnew StringBuilder;
- if ( errorRedirect )
- {
-
- // Redirect the error output of the net command.
- netProcess->StartInfo->RedirectStandardError = true;
- netProcess->ErrorDataReceived += gcnew DataReceivedEventHandler( NetErrorDataHandler );
- }
- else
- {
-
- // Do not redirect the error output.
- netProcess->StartInfo->RedirectStandardError = false;
- }
-
- Console::WriteLine( "\nStarting process: net {0}",
- netProcess->StartInfo->Arguments );
- if ( errorRedirect )
- {
- Console::WriteLine( "Errors will be written to the file {0}", netErrorFile );
- }
-
- // Start the process.
- netProcess->Start();
-
- // Start the asynchronous read of the standard output stream.
- netProcess->BeginOutputReadLine();
-
- if ( errorRedirect )
- {
- // Start the asynchronous read of the standard
- // error stream.
- netProcess->BeginErrorReadLine();
- }
-
- // Let the net command run, collecting the output.
- netProcess->WaitForExit();
-
- if ( streamError != nullptr )
- {
- // Close the error file.
- streamError->Close();
- }
- else
- {
- // Set errorsWritten to false if the stream is not
- // open. Either there are no errors, or the error
- // file could not be opened.
- errorsWritten = false;
- }
-
- if ( netOutput->Length > 0 )
- {
- // If the process wrote more than just
- // white space, write the output to the console.
- Console::WriteLine( "\nPublic network shares from net view:\n{0}\n",
- netOutput->ToString() );
- }
-
- if ( errorsWritten )
- {
- // Signal that the error file had something
- // written to it.
- array^errorOutput = File::ReadAllLines( netErrorFile );
- if ( errorOutput->Length > 0 )
- {
- Console::WriteLine( "\nThe following error output was appended to {0}.",
- netErrorFile );
- System::Collections::IEnumerator^ myEnum = errorOutput->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- String^ errLine = safe_cast(myEnum->Current);
- Console::WriteLine( " {0}", errLine );
- }
- }
- Console::WriteLine();
- }
-
- netProcess->Close();
-
- }
-
-private:
- static void NetOutputDataHandler( Object^ /*sendingProcess*/,
- DataReceivedEventArgs^ outLine )
- {
- // Collect the net view command output.
- if ( !String::IsNullOrEmpty( outLine->Data ) )
- {
- // Add the text to the collected output.
- netOutput->AppendFormat( "\n {0}", outLine->Data );
- }
- }
-
- static void NetErrorDataHandler( Object^ /*sendingProcess*/,
- DataReceivedEventArgs^ errLine )
- {
- // Write the error text to the file if there is something to
- // write and an error file has been specified.
-
- if ( !String::IsNullOrEmpty( errLine->Data ) )
- {
- if ( !errorsWritten )
- {
- if ( streamError == nullptr )
- {
- // Open the file.
- try
- {
- streamError = gcnew StreamWriter( netErrorFile,true );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Could not open error file!" );
- Console::WriteLine( e->Message->ToString() );
- }
- }
-
- if ( streamError != nullptr )
- {
- // Write a header to the file if this is the first
- // call to the error output handler.
- streamError->WriteLine();
- streamError->WriteLine( DateTime::Now.ToString() );
- streamError->WriteLine( "Net View error output:" );
- }
- errorsWritten = true;
- }
-
- if ( streamError != nullptr )
- {
- // Write redirected errors to the file.
- streamError->WriteLine( errLine->Data );
- streamError->Flush();
- }
- }
- }
-};
-//
-
-/// The main entry point for the application.
-void main()
-{
- try
- {
- ProcessNetStreamRedirection::RedirectNetCommandStreams();
- }
- catch ( InvalidOperationException^ e )
- {
- Console::WriteLine( "Exception:" );
- Console::WriteLine( e );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp
deleted file mode 100644
index 037704e8279..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-// System.Diagnostics
-//
-// Requires .NET Framework version 1.2 or higher.
-
-// Define the namespaces used by this sample.
-#using
-
-using namespace System;
-using namespace System::Text;
-using namespace System::IO;
-using namespace System::Diagnostics;
-using namespace System::Threading;
-using namespace System::ComponentModel;
-
-//
-ref class ProcessNMakeStreamRedirection
-{
-private:
- // Define static variables shared by class methods.
- static StreamWriter^ buildLogStream = nullptr;
- static Mutex^ logMutex = gcnew Mutex;
- static int maxLogLines = 25;
- static int currentLogLines = 0;
-
-public:
- static void RedirectNMakeCommandStreams()
- {
- String^ nmakeArguments = nullptr;
- Process^ nmakeProcess;
-
- // Get the input nmake command-line arguments.
- Console::WriteLine( "Enter the NMake command line arguments (@commandfile or /f makefile, etc):" );
- String^ inputText = Console::ReadLine();
- if ( !String::IsNullOrEmpty( inputText ) )
- {
- nmakeArguments = inputText;
- }
-
- Console::WriteLine( "Enter max line limit for log file (default is 25):" );
- inputText = Console::ReadLine();
- if ( !String::IsNullOrEmpty( inputText ) )
- {
- if ( !Int32::TryParse( inputText, maxLogLines ) )
- {
- maxLogLines = 25;
- }
- }
- Console::WriteLine( "Output beyond {0} lines will be ignored.",
- maxLogLines.ToString() );
-
- // Initialize the process and its StartInfo properties.
- nmakeProcess = gcnew Process;
- nmakeProcess->StartInfo->FileName = "NMake.exe";
-
- // Build the nmake command argument list.
- if ( !String::IsNullOrEmpty( nmakeArguments ) )
- {
- nmakeProcess->StartInfo->Arguments = nmakeArguments;
- }
-
- // Set UseShellExecute to false for redirection.
- nmakeProcess->StartInfo->UseShellExecute = false;
-
- // Redirect the standard output of the nmake command.
- // Read the stream asynchronously using an event handler.
- nmakeProcess->StartInfo->RedirectStandardOutput = true;
- nmakeProcess->OutputDataReceived += gcnew DataReceivedEventHandler( NMakeOutputDataHandler );
-
- // Redirect the error output of the nmake command.
- nmakeProcess->StartInfo->RedirectStandardError = true;
- nmakeProcess->ErrorDataReceived += gcnew DataReceivedEventHandler( NMakeErrorDataHandler );
-
- logMutex->WaitOne();
-
- currentLogLines = 0;
-
- // Write a header to the log file.
- String^ buildLogFile = "NmakeCmd.Txt";
- try
- {
- buildLogStream = gcnew StreamWriter( buildLogFile,true );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Could not open output file {0}", buildLogFile );
- Console::WriteLine( "Exception = {0}", e->ToString() );
- Console::WriteLine( e->Message->ToString() );
-
- buildLogStream = nullptr;
- }
-
- if ( buildLogStream != nullptr )
- {
- Console::WriteLine( "Nmake output logged to {0}", buildLogFile );
-
- buildLogStream->WriteLine();
- buildLogStream->WriteLine( DateTime::Now.ToString() );
- if ( !String::IsNullOrEmpty( nmakeArguments ) )
- {
- buildLogStream->Write( "Command line = NMake {0}", nmakeArguments );
- }
- else
- {
- buildLogStream->Write( "Command line = Nmake" );
- }
- buildLogStream->WriteLine();
- buildLogStream->Flush();
-
- logMutex->ReleaseMutex();
-
- // Start the process.
- Console::WriteLine();
- Console::WriteLine( "\nStarting Nmake command" );
- Console::WriteLine();
- nmakeProcess->Start();
-
- // Start the asynchronous read of the output stream.
- nmakeProcess->BeginOutputReadLine();
-
- // Start the asynchronous read of the error stream.
- nmakeProcess->BeginErrorReadLine();
-
- // Let the nmake command run, collecting the output.
- nmakeProcess->WaitForExit();
-
- nmakeProcess->Close();
- buildLogStream->Close();
- logMutex->Dispose();
- }
- }
-
-private:
- static void NMakeOutputDataHandler( Object^ sendingProcess,
- DataReceivedEventArgs^ outLine )
- {
- // Collect the output, displaying it to the screen and
- // logging it to the output file. Cancel the read
- // operation when the maximum line limit is reached.
-
- if ( !String::IsNullOrEmpty( outLine->Data ) )
- {
- logMutex->WaitOne();
-
- currentLogLines++;
- if ( currentLogLines > maxLogLines )
- {
- // Display the line to the console.
- // Skip writing the line to the log file.
- Console::WriteLine( "StdOut: {0}", outLine->Data->ToString() );
- }
- else
- if ( currentLogLines == maxLogLines )
- {
- LogToFile( "StdOut", "", true );
-
- // Stop reading the output streams.
- Process^ p = dynamic_cast(sendingProcess);
- if ( p != nullptr )
- {
- p->CancelOutputRead();
- p->CancelErrorRead();
- }
- }
- else
- {
- // Write the line to the log file.
- LogToFile( "StdOut", outLine->Data, true );
- }
- logMutex->ReleaseMutex();
- }
- }
-
- static void NMakeErrorDataHandler( Object^ sendingProcess,
- DataReceivedEventArgs^ errLine )
- {
-
- // Collect the error output, displaying it to the screen and
- // logging it to the output file. Cancel the error output
- // read operation when the maximum line limit is reached.
-
- if ( !String::IsNullOrEmpty( errLine->Data ) )
- {
- logMutex->WaitOne();
-
- currentLogLines++;
- if ( currentLogLines > maxLogLines )
- {
-
- // Display the line to the console.
- // Skip writing the line to the log file.
- Console::WriteLine( "StdErr: {0}", errLine->Data->ToString() );
- }
- else
- if ( currentLogLines == maxLogLines )
- {
- LogToFile( "StdOut", "", true );
-
- // Stop reading the output streams.
- Process^ p = dynamic_cast(sendingProcess);
- if ( p != nullptr )
- {
- p->CancelOutputRead();
- p->CancelErrorRead();
- }
- }
- else
- {
- // Write the line to the log file.
- LogToFile( "StdErr", errLine->Data, true );
- }
- logMutex->ReleaseMutex();
- }
- }
-
- static void LogToFile( String^ logPrefix, String^ logText,
- bool echoToConsole )
- {
- // Write the specified line to the log file stream.
- StringBuilder^ logString = gcnew StringBuilder;
-
- if ( !String::IsNullOrEmpty( logPrefix ) )
- {
- logString->AppendFormat( "{0}> ", logPrefix );
- }
-
- if ( !String::IsNullOrEmpty( logText ) )
- {
- logString->Append( logText );
- }
-
- if ( buildLogStream != nullptr )
- {
- buildLogStream->WriteLine( "[{0}] {1}",
- DateTime::Now.ToString(), logString->ToString() );
- buildLogStream->Flush();
- }
-
- if ( echoToConsole )
- {
- Console::WriteLine( logString->ToString() );
- }
- }
-};
-//
-
-/// The main entry point for the application.
-void main()
-{
- try
- {
- ProcessNMakeStreamRedirection::RedirectNMakeCommandStreams();
- }
- catch ( InvalidOperationException^ e )
- {
- Console::WriteLine( "Exception:" );
- Console::WriteLine( e );
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp
deleted file mode 100644
index 87b8730cbc4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// System.Diagnostics
-//
-// Requires .NET Framework version 1.2 or higher.
-
-// The following example uses the sort command to sort a list
-// of input text lines, and displays the sorted list to the console.
-
-//
-// Define the namespaces used by this sample.
-#using
-
-using namespace System;
-using namespace System::Text;
-using namespace System::IO;
-using namespace System::Diagnostics;
-using namespace System::Threading;
-using namespace System::ComponentModel;
-
-ref class SortOutputRedirection
-{
-private:
- // Define static variables shared by class methods.
- static StringBuilder^ sortOutput = nullptr;
- static int numOutputLines = 0;
-
-public:
- static void SortInputListText()
- {
- // Initialize the process and its StartInfo properties.
- // The sort command is a console application that
- // reads and sorts text input.
-
- Process^ sortProcess;
- sortProcess = gcnew Process;
- sortProcess->StartInfo->FileName = "Sort.exe";
-
- // Set UseShellExecute to false for redirection.
- sortProcess->StartInfo->UseShellExecute = false;
-
- // Redirect the standard output of the sort command.
- // This stream is read asynchronously using an event handler.
- sortProcess->StartInfo->RedirectStandardOutput = true;
- sortOutput = gcnew StringBuilder;
-
- // Set our event handler to asynchronously read the sort output.
- sortProcess->OutputDataReceived += gcnew DataReceivedEventHandler( SortOutputHandler );
-
- // Redirect standard input as well. This stream
- // is used synchronously.
- sortProcess->StartInfo->RedirectStandardInput = true;
-
- // Start the process.
- sortProcess->Start();
-
- // Use a stream writer to synchronously write the sort input.
- StreamWriter^ sortStreamWriter = sortProcess->StandardInput;
-
- // Start the asynchronous read of the sort output stream.
- sortProcess->BeginOutputReadLine();
-
- // Prompt the user for input text lines. Write each
- // line to the redirected input stream of the sort command.
- Console::WriteLine( "Ready to sort up to 50 lines of text" );
-
- String^ inputText;
- int numInputLines = 0;
- do
- {
- Console::WriteLine( "Enter a text line (or press the Enter key to stop):" );
-
- inputText = Console::ReadLine();
- if ( !String::IsNullOrEmpty( inputText ) )
- {
- numInputLines++;
- sortStreamWriter->WriteLine( inputText );
- }
- }
- while ( !String::IsNullOrEmpty( inputText ) && (numInputLines < 50) );
-
- Console::WriteLine( "" );
- Console::WriteLine();
-
- // End the input stream to the sort command.
- sortStreamWriter->Close();
-
- // Wait for the sort process to write the sorted text lines.
- sortProcess->WaitForExit();
-
- if ( numOutputLines > 0 )
- {
-
- // Write the formatted and sorted output to the console.
- Console::WriteLine( " Sort results = {0} sorted text line(s) ",
- numOutputLines.ToString() );
- Console::WriteLine( "----------" );
- Console::WriteLine( sortOutput->ToString() );
- }
- else
- {
- Console::WriteLine( " No input lines were sorted." );
- }
-
- sortProcess->Close();
- }
-
-private:
- static void SortOutputHandler( Object^ /*sendingProcess*/,
- DataReceivedEventArgs^ outLine )
- {
- // Collect the sort command output.
- if ( !String::IsNullOrEmpty( outLine->Data ) )
- {
- numOutputLines++;
-
- // Add the text to the collected output.
- sortOutput->AppendFormat( "\n[{0}] {1}",
- numOutputLines.ToString(), outLine->Data );
- }
- }
-};
-
-/// The main entry point for the application.
-void main()
-{
- try
- {
- SortOutputRedirection::SortInputListText();
- }
- catch ( InvalidOperationException^ e )
- {
- Console::WriteLine( "Exception:" );
- Console::WriteLine( e );
- }
-}
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp b/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp
deleted file mode 100644
index 5289fe8f30b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-// System::Diagnostics::Process::Refresh
-// System::Diagnostics::Process::HasExited
-// System::Diagnostics::Process::Close
-// System::Diagnostics::Process::CloseMainWindow
-// The following example starts an instance of Notepad. It then
-// retrieves the physical memory usage of the associated process at
-// 2 second intervals for a maximum of 10 seconds. The example detects
-// whether the process exits before 10 seconds have elapsed.
-// The example closes the process if it is still running after
-// 10 seconds.
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::Threading;
-int main()
-{
- try
- {
- Process^ myProcess;
- myProcess = Process::Start( "Notepad.exe" );
-
- // Display physical memory usage 5 times at intervals of 2 seconds.
- for ( int i = 0; i < 5; i++ )
- {
- if ( !myProcess->HasExited )
- {
-
- // Discard cached information about the process.
- myProcess->Refresh();
-
- // Print working set to console.
- Console::WriteLine( "Physical Memory Usage : {0}", myProcess->WorkingSet.ToString() );
-
- // Wait 2 seconds.
- Thread::Sleep( 2000 );
- }
- else
- {
- break;
- }
-
- }
- myProcess->CloseMainWindow();
-
- // Free resources associated with process.
- myProcess->Close();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The following exception was raised: " );
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp b/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp
deleted file mode 100644
index db06be9bee1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-// System::Diagnostics::Process::WorkingSet
-// System::Diagnostics::Process::BasePriority
-// System::Diagnostics::Process::UserProcessorTime
-// System::Diagnostics::Process::PrivilegedProcessorTime
-// System::Diagnostics::Process::TotalProcessorTime
-// System::Diagnostics::Process::ToString
-// System::Diagnostics::Process::Responding
-// System::Diagnostics::Process::PriorityClass
-// System::Diagnostics::Process::ExitCode
-// The following example starts an instance of Notepad. The example
-// then retrieves and displays various properties of the associated
-// process. The example detects when the process exits, and displays the process's exit code.
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-using namespace System::Threading;
-int main()
-{
- try
- {
- Process^ myProcess;
- myProcess = Process::Start( "NotePad.exe" );
- while ( !myProcess->HasExited )
- {
- Console::WriteLine();
-
- // Get physical memory usage of the associated process.
- Console::WriteLine( "Process's physical memory usage: {0}", myProcess->WorkingSet.ToString() );
-
- // Get base priority of the associated process.
- Console::WriteLine( "Base priority of the associated process: {0}", myProcess->BasePriority.ToString() );
-
- // Get priority class of the associated process.
- Console::WriteLine( "Priority class of the associated process: {0}", myProcess->PriorityClass );
-
- // Get user processor time for this process.
- Console::WriteLine( "User Processor Time: {0}", myProcess->UserProcessorTime.ToString() );
-
- // Get privileged processor time for this process.
- Console::WriteLine( "Privileged Processor Time: {0}", myProcess->PrivilegedProcessorTime.ToString() );
-
- // Get total processor time for this process.
- Console::WriteLine( "Total Processor Time: {0}", myProcess->TotalProcessorTime.ToString() );
-
- // Invoke overloaded ToString function.
- Console::WriteLine( "Process's Name: {0}", myProcess->ToString() );
- Console::WriteLine( "-------------------------------------" );
- if ( myProcess->Responding )
- {
- Console::WriteLine( "Status: Responding to user interface" );
- myProcess->Refresh();
- }
- else
- {
- Console::WriteLine( "Status: Not Responding" );
- }
- Thread::Sleep( 1000 );
- }
- Console::WriteLine();
- Console::WriteLine( "Process exit code: {0}", myProcess->ExitCode.ToString() );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The following exception was raised: {0}", e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp b/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp
deleted file mode 100644
index 8695804de6c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Text::RegularExpressions;
-void main()
-{
-
- String^ text = "One car red car blue car";
- String^ pat = "(\\w+)\\s+(car)";
-
- // Compile the regular expression.
- Regex^ r = gcnew Regex( pat,RegexOptions::IgnoreCase );
-
- // Match the regular expression pattern against a text string.
- Match^ m = r->Match(text);
- int matchCount = 0;
- while ( m->Success )
- {
- Console::WriteLine( "Match{0}", ++matchCount );
- for ( int i = 1; i <= 2; i++ )
- {
- Group^ g = m->Groups[ i ];
- Console::WriteLine( "Group{0}='{1}'", i, g );
- CaptureCollection^ cc = g->Captures;
- for ( int j = 0; j < cc->Count; j++ )
- {
- Capture^ c = cc[ j ];
- System::Console::WriteLine( "Capture{0}='{1}', Position={2}", j, c, c->Index );
- }
- }
- m = m->NextMatch();
- }
-}
-// This example displays the following output:
-// Match1
-// Group1='One'
-// Capture0='One', Position=0
-// Group2='car'
-// Capture0='car', Position=4
-// Match2
-// Group1='red'
-// Capture0='red', Position=8
-// Group2='car'
-// Capture0='car', Position=12
-// Match3
-// Group1='blue'
-// Capture0='blue', Position=16
-// Group2='car'
-// Capture0='car', Position=21
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp b/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp
deleted file mode 100644
index 0494e4ad274..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-
-// Generate a key k1 with password pwd1 and salt salt1.
-// Generate a key k2 with password pwd1 and salt salt1.
-// Encrypt data1 with key k1 using symmetric encryption, creating edata1.
-// Decrypt edata1 with key k2 using symmetric decryption, creating data2.
-// data2 should equal data1.
-
-int main()
-{
- array^passwordargs = Environment::GetCommandLineArgs();
- String^ usageText = "Usage: RFC2898 \nYou must specify the password for encryption.\n";
-
- //If no file name is specified, write usage text.
- if ( passwordargs->Length == 1 )
- {
- Console::WriteLine( usageText );
- }
- else
- {
- //
- String^ pwd1 = passwordargs[ 1 ];
-
- array^salt1 = gcnew array(8);
- RandomNumberGenerator^ rng = RandomNumberGenerator::Create();
- rng->GetBytes(salt1);
- //data1 can be a string or contents of a file.
- String^ data1 = "Some test data";
-
- //
- //The default iteration count is 1000 so the two methods use the same iteration count.
- int myIterations = 1000;
- //
-
- //
- try
- {
- //
- Rfc2898DeriveBytes ^ k1 = gcnew Rfc2898DeriveBytes( pwd1,salt1,myIterations );
- Rfc2898DeriveBytes ^ k2 = gcnew Rfc2898DeriveBytes( pwd1,salt1 );
- //
-
- // Encrypt the data.
- Aes^ encAlg = Aes::Create();
- encAlg->Key = k1->GetBytes( 16 );
- MemoryStream^ encryptionStream = gcnew MemoryStream;
- CryptoStream^ encrypt = gcnew CryptoStream( encryptionStream,encAlg->CreateEncryptor(),CryptoStreamMode::Write );
- array^utfD1 = (gcnew System::Text::UTF8Encoding( false ))->GetBytes( data1 );
- //
-
- encrypt->Write( utfD1, 0, utfD1->Length );
- encrypt->FlushFinalBlock();
- encrypt->Close();
- array^edata1 = encryptionStream->ToArray();
- k1->Reset();
-
- // Try to decrypt, thus showing it can be round-tripped.
- Aes^ decAlg = Aes::Create();
- decAlg->Key = k2->GetBytes( 16 );
- decAlg->IV = encAlg->IV;
- MemoryStream^ decryptionStreamBacking = gcnew MemoryStream;
- CryptoStream^ decrypt = gcnew CryptoStream( decryptionStreamBacking,decAlg->CreateDecryptor(),CryptoStreamMode::Write );
-
- //
- decrypt->Write( edata1, 0, edata1->Length );
- decrypt->Flush();
- decrypt->Close();
- k2->Reset();
- //
-
- String^ data2 = (gcnew UTF8Encoding( false ))->GetString( decryptionStreamBacking->ToArray() );
- if ( !data1->Equals( data2 ) )
- {
- Console::WriteLine( "Error: The two values are not equal." );
- }
- else
- {
- Console::WriteLine( "The two values are equal." );
- Console::WriteLine( "k1 iterations: {0}", k1->IterationCount );
- Console::WriteLine( "k2 iterations: {0}", k2->IterationCount );
- }
- //
- }
-
- catch ( Exception^ e )
- {
- Console::WriteLine( "Error: ", e );
- }
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp
deleted file mode 100644
index 3cb652fc45a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-// This example demonstrates the StringBuilder.AppendFormat method
-//
-using namespace System;
-using namespace System::Text;
-using namespace System::Globalization;
-void Show( StringBuilder^ sbs )
-{
- Console::WriteLine( sbs );
- sbs->Length = 0;
-}
-
-int main()
-{
- StringBuilder^ sb = gcnew StringBuilder;
- int var1 = 111;
- float var2 = 2.22F;
- String^ var3 = "abcd";
- array^var4 = {3,4.4,(Char)'X'};
- Console::WriteLine();
- Console::WriteLine( "StringBuilder.AppendFormat method:" );
- sb->AppendFormat( "1) {0}", var1 );
- Show( sb );
- sb->AppendFormat( "2) {0}, {1}", var1, var2 );
- Show( sb );
- sb->AppendFormat( "3) {0}, {1}, {2}", var1, var2, var3 );
- Show( sb );
- sb->AppendFormat( "4) {0}, {1}, {2}", var4 );
- Show( sb );
- CultureInfo^ ci = gcnew CultureInfo( "es-ES",true );
- array^temp1 = {var2};
- sb->AppendFormat( ci, "5) {0}", temp1 );
- Show( sb );
-}
-
-/*
-This example produces the following results:
-
-StringBuilder.AppendFormat method:
-1) 111
-2) 111, 2.22
-3) 111, 2.22, abcd
-4) 3, 4.4, X
-5) 2,22
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp
deleted file mode 100644
index 8d70a9a85d3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// This example demonstrates the StringBuilder.AppendLine()
-// method.
-
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- StringBuilder^ sb = gcnew StringBuilder;
- String^ line = L"A line of text.";
- int number = 123;
-
- // Append two lines of text.
- sb->AppendLine( L"The first line of text." );
- sb->AppendLine( line );
-
- // Append a new line, an empty string, and a null cast as a string.
- sb->AppendLine();
- sb->AppendLine( L"" );
- sb->AppendLine( L"" );
-
- // Append the non-string value, 123, and two new lines.
- sb->Append( number )->AppendLine()->AppendLine();
-
- // Append two lines of text.
- sb->AppendLine( line );
- sb->AppendLine( L"The last line of text." );
-
- // Convert the value of the StringBuilder to a string and display the string.
- Console::WriteLine( sb );
-
- return 0;
-}
-
-/*
-This example produces the following results:
-
-The first line of text.
-A line of text.
-
-
-
-123
-
-A line of text.
-The last line of text.
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp
deleted file mode 100644
index be8fea41b47..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// This example demonstrates the CopyTo(Int32, Char[], Int32, Int32) method.
-// Typically the destination array is small, preallocated, and global while
-// the StringBuilder is large with programmatically defined data.
-// However, for this example both the array and StringBuilder are small
-// and the StringBuilder has predefined data.
-
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- array^dest = gcnew array(6);
- StringBuilder^ src = gcnew StringBuilder( "abcdefghijklmnopqrstuvwxyz!" );
- dest[ 1 ] = ')';
- dest[ 2 ] = ' ';
-
- // Copy the source to the destination in 9 pieces, 3 characters per piece.
- Console::WriteLine( "\nPiece) Data:" );
- for ( int ix = 0; ix < 9; ix++ )
- {
- dest[ 0 ] = ix.ToString()[ 0 ];
- src->CopyTo( ix * 3, dest, 3, 3 );
- Console::Write( " " );
- Console::WriteLine( dest );
- }
-}
-
-/*
-This example produces the following results:
-
-Piece) Data:
- 0) abc
- 1) def
- 2) ghi
- 3) jkl
- 4) mno
- 5) pqr
- 6) stu
- 7) vwx
- 8) yz!
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp
deleted file mode 100644
index 8043d615414..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-
-// This example demonstrates StringBuilder.EnsureCapacity
-// StringBuilder.Capacity
-// StringBuilder.Length
-// StringBuilder.Equals
-//
-using namespace System;
-using namespace System::Text;
-int main()
-{
- StringBuilder^ sb1 = gcnew StringBuilder( "abc" );
- StringBuilder^ sb2 = gcnew StringBuilder( "abc",16 );
- Console::WriteLine();
- Console::WriteLine( "a1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity );
- Console::WriteLine( "a2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity );
- Console::WriteLine( "a3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 );
- Console::WriteLine( "a4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) );
- Console::WriteLine();
- Console::WriteLine( "Ensure sb1 has a capacity of at least 50 characters." );
- sb1->EnsureCapacity( 50 );
- Console::WriteLine();
- Console::WriteLine( "b1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity );
- Console::WriteLine( "b2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity );
- Console::WriteLine( "b3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 );
- Console::WriteLine( "b4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) );
- Console::WriteLine();
- Console::WriteLine( "Set the length of sb1 to zero." );
- Console::WriteLine( "Set the capacity of sb2 to 51 characters." );
- sb1->Length = 0;
- sb2->Capacity = 51;
- Console::WriteLine();
- Console::WriteLine( "c1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity );
- Console::WriteLine( "c2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity );
- Console::WriteLine( "c3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 );
- Console::WriteLine( "c4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) );
-}
-
-/*
-The example displays the following output:
-
-a1) sb1->Length = 3, sb1->Capacity = 16
-a2) sb2->Length = 3, sb2->Capacity = 16
-a3) sb1 = "abc", sb2 = "abc"
-a4) sb1 equals sb2: True
-
-Ensure sb1 has a capacity of at least 50 characters.
-
-b1) sb1->Length = 3, sb1->Capacity = 50
-b2) sb2->Length = 3, sb2->Capacity = 16
-b3) sb1 = "abc", sb2 = "abc"
-b4) sb1 equals sb2: False
-
-Set the length of sb1 to zero.
-Set the capacity of sb2 to 51 characters.
-
-c1) sb1->Length = 0, sb1->Capacity = 50
-c2) sb2->Length = 3, sb2->Capacity = 51
-c3) sb1 = "", sb2 = "abc"
-c4) sb1 equals sb2: False
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp
deleted file mode 100644
index 03de6cb972e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-
-// This example demonstrates StringBuilder.Insert()
-//
-using namespace System;
-using namespace System::Text;
-ref class Sample
-{
-private:
-
- // index: 012345
- static String^ initialValue = "--[]--";
- static StringBuilder^ sb;
-
-public:
- static void Main()
- {
- String^ xyz = "xyz";
- array^abc = {'a','b','c'};
- Char star = '*';
- Object^ obj = 0;
- bool xBool = true;
- Byte xByte = 1;
- short xInt16 = 2;
- int xInt32 = 3;
- long xInt64 = 4;
- Decimal xDecimal = 5;
- float xSingle = 6.6F;
- double xDouble = 7.7;
-
- // The following types are not CLS-compliant.
- UInt16 xUInt16 = 8;
- UInt32 xUInt32 = 9;
- UInt64 xUInt64 = 10;
- SByte xSByte = -11;
-
- //
- Console::WriteLine( "StringBuilder.Insert method" );
- sb = gcnew StringBuilder( initialValue );
- sb->Insert( 3, xyz, 2 );
- Show( 1, sb );
- sb->Insert( 3, xyz );
- Show( 2, sb );
- sb->Insert( 3, star );
- Show( 3, sb );
- sb->Insert( 3, abc );
- Show( 4, sb );
- sb->Insert( 3, abc, 1, 2 );
- Show( 5, sb );
- sb->Insert( 3, xBool ); // True
- Show( 6, sb );
- sb->Insert( 3, obj ); // 0
- Show( 7, sb );
- sb->Insert( 3, xByte ); // 1
- Show( 8, sb );
- sb->Insert( 3, xInt16 ); // 2
- Show( 9, sb );
- sb->Insert( 3, xInt32 ); // 3
- Show( 10, sb );
- sb->Insert( 3, xInt64 ); // 4
- Show( 11, sb );
- sb->Insert( 3, xDecimal ); // 5
- Show( 12, sb );
- sb->Insert( 3, xSingle ); // 6.6
- Show( 13, sb );
- sb->Insert( 3, xDouble ); // 7.7
- Show( 14, sb );
-
- // The following Insert methods are not CLS-compliant.
- sb->Insert( 3, xUInt16 ); // 8
- Show( 15, sb );
- sb->Insert( 3, xUInt32 ); // 9
- Show( 16, sb );
- sb->Insert( 3, xUInt64 ); // 10
- Show( 17, sb );
- sb->Insert( 3, xSByte ); // -11
- Show( 18, sb );
-
- //
- }
-
- static void Show( int overloadNumber, StringBuilder^ sbs )
- {
- Console::WriteLine( "{0,2:G} = {1}", overloadNumber, sbs );
- sb = gcnew StringBuilder( initialValue );
- }
-
-};
-
-int main()
-{
- Sample::Main();
-}
-
-/*
-This example produces the following results:
-
-StringBuilder.Insert method
- 1 = --[xyzxyz]--
- 2 = --[xyz]--
- 3 = --[*]--
- 4 = --[abc]--
- 5 = --[bc]--
- 6 = --[True]--
- 7 = --[0]--
- 8 = --[1]--
- 9 = --[2]--
-10 = --[3]--
-11 = --[4]--
-12 = --[5]--
-13 = --[6.6]--
-14 = --[7.7]--
-15 = --[8]--
-16 = --[9]--
-17 = --[10]--
-18 = --[-11]--
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp
deleted file mode 100644
index df36afedca8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// This example demonstrates StringBuilder.Remove()
-//
-using namespace System;
-using namespace System::Text;
-int main()
-{
- String^ rule1 = "0----+----1----+----2----+----3----+----4---";
- String^ rule2 = "01234567890123456789012345678901234567890123";
- String^ str = "The quick brown fox jumps over the lazy dog.";
- StringBuilder^ sb = gcnew StringBuilder( str );
- Console::WriteLine();
- Console::WriteLine( "StringBuilder.Remove method" );
- Console::WriteLine();
- Console::WriteLine( "Original value:" );
- Console::WriteLine( rule1 );
- Console::WriteLine( rule2 );
- Console::WriteLine( "{0}", sb );
- Console::WriteLine();
- sb->Remove( 10, 6 ); // Remove "brown "
- Console::WriteLine( "New value:" );
- Console::WriteLine( rule1 );
- Console::WriteLine( rule2 );
- Console::WriteLine( "{0}", sb );
-}
-
-/*
-This example produces the following results:
-
-StringBuilder.Remove method
-
-Original value:
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick brown fox jumps over the lazy dog.
-
-New value:
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick fox jumps over the lazy dog.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp
deleted file mode 100644
index 56420a34a24..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-
-// This example demonstrates StringBuilder.Replace()
-//
-using namespace System;
-using namespace System::Text;
-void Show( StringBuilder^ sbs )
-{
- String^ rule1 = "0----+----1----+----2----+----3----+----4---";
- String^ rule2 = "01234567890123456789012345678901234567890123";
- Console::WriteLine( rule1 );
- Console::WriteLine( rule2 );
- Console::WriteLine( "{0}", sbs );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // 0----+----1----+----2----+----3----+----4---
- // 01234567890123456789012345678901234567890123
- String^ str = "The quick br!wn d#g jumps #ver the lazy cat.";
- StringBuilder^ sb = gcnew StringBuilder( str );
- Console::WriteLine();
- Console::WriteLine( "StringBuilder.Replace method" );
- Console::WriteLine();
- Console::WriteLine( "Original value:" );
- Show( sb );
- sb->Replace( '#', '!', 15, 29 ); // Some '#' -> '!'
- Show( sb );
- sb->Replace( '!', 'o' ); // All '!' -> 'o'
- Show( sb );
- sb->Replace( "cat", "dog" ); // All "cat" -> "dog"
- Show( sb );
- sb->Replace( "dog", "fox", 15, 20 ); // Some "dog" -> "fox"
- Console::WriteLine( "Final value:" );
- Show( sb );
-}
-
-/*
-This example produces the following results:
-
-StringBuilder.Replace method
-
-Original value:
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick br!wn d#g jumps #ver the lazy cat.
-
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick br!wn d!g jumps !ver the lazy cat.
-
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick brown dog jumps over the lazy cat.
-
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick brown dog jumps over the lazy dog.
-
-Final value:
-0----+----1----+----2----+----3----+----4---
-01234567890123456789012345678901234567890123
-The quick brown fox jumps over the lazy dog.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp
deleted file mode 100644
index 7af27ada416..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// This example demonstrates the NativeDigits property.
-
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Threading;
-
-int main()
-{
- CultureInfo^ currentCI = Thread::CurrentThread->CurrentCulture;
- NumberFormatInfo^ nfi = currentCI->NumberFormat;
- array^ nativeDigitList = nfi->NativeDigits;
-
- Console::WriteLine("The native digits for the {0} culture are:",
- currentCI->Name);
-
- for each (String^ nativeDigit in nativeDigitList)
- {
- Console::Write("\"{0}\" ", nativeDigit);
- }
-
- Console::WriteLine();
-}
-/*
-This code example produces the following results:
-
-The native digits for the en-US culture are:
-"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp
deleted file mode 100644
index 415a49fc640..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-using namespace System;
-using namespace System::Globalization;
-
-namespace CalendarTypeExample
-{
- static void Display(Calendar^ genericCalendar)
- {
- String^ calendarName =
- genericCalendar->ToString()->PadRight(50, '.');
- Console::WriteLine("{0} {1}", calendarName, genericCalendar->GetType());
- }
-}
-
-int main()
-{
- GregorianCalendar^ gregorianCalendar = gcnew GregorianCalendar();
- HijriCalendar^ hijriCalendar = gcnew HijriCalendar();
- JapaneseLunisolarCalendar^ japaneseCalendar =
- gcnew JapaneseLunisolarCalendar();
- CalendarTypeExample::Display(gregorianCalendar);
- CalendarTypeExample::Display(hijriCalendar);
- CalendarTypeExample::Display(japaneseCalendar);
- return 0;
-}
-
-/* This code example produces the following output.
-
-System.Globalization.GregorianCalendar............ System.Globalization.GregorianCalendar
-System.Globalization.HijriCalendar................ System.Globalization.HijriCalendar
-System.Globalization.JapaneseLunisolarCalendar.... System.Globalization.JapaneseLunisolarCalendar
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp
deleted file mode 100644
index 0e754047e7d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// This example demonstrates a System.Globalization.Culture-
-// AndRegionInfoBuilder constructor and some of the properties
-// of a custom culture object created with the constructor.
-
-#using
-
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- CultureAndRegionInfoBuilder^ builder =
- gcnew CultureAndRegionInfoBuilder
- ("x-en-US-sample", CultureAndRegionModifiers::None);
-
- // Display some of the properties
- // for the en-US culture.
- Console::WriteLine("CultureName:. . . . . . . . . . {0}",
- builder->CultureName);
- Console::WriteLine("CultureEnglishName: . . . . . . {0}",
- builder->CultureEnglishName);
- Console::WriteLine("CultureNativeName:. . . . . . . {0}",
- builder->CultureNativeName);
- Console::WriteLine("GeoId:. . . . . . . . . . . . . {0}",
- builder->GeoId);
- Console::WriteLine("IsMetric: . . . . . . . . . . . {0}",
- builder->IsMetric);
- Console::WriteLine("ISOCurrencySymbol:. . . . . . . {0}",
- builder->ISOCurrencySymbol);
- Console::WriteLine("RegionEnglishName:. . . . . . . {0}",
- builder->RegionEnglishName);
- Console::WriteLine("RegionName: . . . . . . . . . . {0}",
- builder->RegionName);
- Console::WriteLine("RegionNativeName: . . . . . . . {0}",
- builder->RegionNativeName);
- Console::WriteLine("ThreeLetterISOLanguageName: . . {0}",
- builder->ThreeLetterISOLanguageName);
- Console::WriteLine("ThreeLetterISORegionName: . . . {0}",
- builder->ThreeLetterISORegionName);
- Console::WriteLine("ThreeLetterWindowsLanguageName: {0}",
- builder->ThreeLetterWindowsLanguageName);
- Console::WriteLine("ThreeLetterWindowsRegionName: . {0}",
- builder->ThreeLetterWindowsRegionName);
- Console::WriteLine("TwoLetterISOLanguageName: . . . {0}",
- builder->TwoLetterISOLanguageName);
- Console::WriteLine("TwoLetterISORegionName: . . . . {0}",
- builder->TwoLetterISORegionName);
-}
-
-/*
-This code example produces the following results:
-
-CultureName:. . . . . . . . . . en-US
-CultureEnglishName: . . . . . . English (United States)
-CultureNativeName:. . . . . . . English (United States)
-GeoId:. . . . . . . . . . . . . 244
-IsMetric: . . . . . . . . . . . False
-ISOCurrencySymbol:. . . . . . . USD
-RegionEnglishName:. . . . . . . United States
-RegionName: . . . . . . . . . . US
-RegionNativeName: . . . . . . . United States
-ThreeLetterISOLanguageName: . . eng
-ThreeLetterISORegionName: . . . USA
-ThreeLetterWindowsLanguageName: ENU
-ThreeLetterWindowsRegionName: . USA
-TwoLetterISOLanguageName: . . . en
-TwoLetterISORegionName: . . . . US
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp
deleted file mode 100644
index 846861d5752..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// This example demonstrates the GetConsoleFallbackUICulture() method
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- CultureInfo^ ci = gcnew CultureInfo("ar-DZ");
- Console::WriteLine("Culture name: . . . . . . . . . {0}", ci->Name);
- Console::WriteLine("Console fallback UI culture:. . {0}",
- ci->GetConsoleFallbackUICulture()->Name);
-}
-/*
-This code example produces the following results:
-
-Culture name: . . . . . . . . . ar-DZ
-Console fallback UI culture:. . fr-FR
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp
deleted file mode 100644
index 573d82f64eb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// This example demonstrates the RegionInfo.EnglishName, NativeName,
-// CurrencyEnglishName, CurrencyNativeName, and GeoId properties.
-
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Regional Info for Sweden
- RegionInfo^ ri = gcnew RegionInfo("SE");
-
- Console::WriteLine("Region English Name: . . . {0}", ri->EnglishName);
- Console::WriteLine("Native Name: . . . . . . . {0}", ri->NativeName);
- Console::WriteLine("Currency English Name: . . {0}",
- ri->CurrencyEnglishName);
- Console::WriteLine("Currency Native Name:. . . {0}",
- ri->CurrencyNativeName);
- Console::WriteLine("Geographical ID: . . . . . {0}", ri->GeoId);
-}
-/*
-This code example produces the following results:
-
-Region English Name: . . . Sweden
-Native Name: . . . . . . . Sverige
-Currency English Name: . . Swedish Krona
-Currency Native Name:. . . Svensk krona
-Geographical ID: . . . . . 221
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp
deleted file mode 100644
index 6728f14abce..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-//
-// This example demonstrates the DecoderExceptionFallback class.
-
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- // Create an encoding, which is equivalent to calling the
- // ASCIIEncoding class constructor.
- // The DecoderExceptionFallback parameter specifies that an exception
- // is thrown if a character cannot be encoded.
- // An encoder exception fallback is also specified, but in this code
- // example the encoding operation cannot fail.
-
- Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii",
- gcnew EncoderExceptionFallback(), gcnew DecoderExceptionFallback());
- String^ inputString = "XYZ";
- String^ decodedString;
- String^ twoNewLines = Environment::NewLine + Environment::NewLine ;
-
- array^ encodedBytes =
- gcnew array(asciiEncoding->GetByteCount(inputString));
- int numberOfEncodedBytes = 0;
-
- // ---------------------------------------------------------------------
- Console::Clear();
-
- // Display the name of the encoding.
- Console::WriteLine("The name of the encoding is \"{0}\".{1}",
- asciiEncoding->WebName, Environment::NewLine);
-
- // Display the input string in text.
- Console::WriteLine("Input string ({0} characters): \"{1}\"",
- inputString->Length, inputString);
-
- // Display the input string in hexadecimal.
- Console::Write("Input string in hexadecimal: ");
- for each (char c in inputString)
- {
- Console::Write("0x{0:X2} ", c);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Encode the input string.
-
- Console::WriteLine("Encode the input string...");
-
- numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0,
- inputString->Length, encodedBytes, 0);
-
- // Display the encoded bytes.
- Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}",
- numberOfEncodedBytes, Environment::NewLine);
- for each (Byte b in encodedBytes)
- {
- Console::Write("0x{0:X2} ", b);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
-
- // Replace the encoded byte sequences for the characters 'X' and 'Z'
- // with the value 0xFF, which is outside the valid range of 0x00 to 0x7F
- // for ASCIIEncoding. The resulting byte sequence is actually the
- // beginning of this code example because it is the input to the decoder
- // operation, and is equivalent to a corrupted or improperly encoded
- // byte sequence.
-
- encodedBytes[0] = 0xFF;
- encodedBytes[2] = 0xFF;
-
- Console::WriteLine("Display the corrupted byte sequence...");
- Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}",
- numberOfEncodedBytes, Environment::NewLine);
- for each (Byte b in encodedBytes)
- {
- Console::Write("0x{0:X2} ", b);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Attempt to decode the encoded bytes. However, an exception is thrown
- // before the byte sequence can be decoded.
-
- Console::WriteLine("Compare the decoded bytes to the input string...");
-
- try
- {
- decodedString = asciiEncoding->GetString(encodedBytes);
- // This statement is never executed.
- Console::WriteLine("This statement is never executed.");
- }
- catch (DecoderFallbackException^ ex)
- {
- Console::WriteLine(ex);
- Console::WriteLine(
- "{0}*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***",
- Environment::NewLine);
- }
-}
-
-
-/*
-This code example produces the following results:
-
-The name of the encoding is "us-ascii".
-
-Input string (3 characters): "XYZ"
-Input string in hexadecimal: 0x58 0x59 0x5A
-
-Encode the input string...
-Encoded bytes in hexadecimal (3 bytes):
-
-0x58 0x59 0x5A
-
-Display the corrupted byte sequence...
-Encoded bytes in hexadecimal (3 bytes):
-
-0xFF 0x59 0xFF
-
-Compare the decoded bytes to the input string...
-System.Text.DecoderFallbackException: Unable to translate bytes [FF] at index 0 from speci
-fied code page to Unicode.
-at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
-at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index
-)
-at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes)
-at System.Text.ASCIIEncoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS decoder)
-
-at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encod
-ing)
-at System.Text.ASCIIEncoding.GetString(Byte[] bytes, Int32 byteIndex, Int32 byteCount)
-at System.Text.Encoding.GetString(Byte[] bytes)
-at Sample.Main()
-
-*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp
deleted file mode 100644
index 332c5a91b7d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// This example demonstrates the DecoderReplacementFallback class.
-
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- // Create an encoding, which is equivalent to calling the
- // ASCIIEncoding class constructor.
- // The DecoderReplacementFallback parameter specifies that the
- // string "(error)" is to replace characters that cannot be decoded.
- // An encoder replacement fallback is also specified, but in this code
- // example the encoding operation cannot fail.
-
- Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii",
- gcnew EncoderReplacementFallback("(unknown)"),
- gcnew DecoderReplacementFallback("(error)"));
- String^ inputString = "XYZ";
- String^ decodedString;
- String^ twoNewLines = Environment::NewLine + Environment::NewLine;
- array^ encodedBytes = gcnew array(
- asciiEncoding->GetByteCount(inputString));
- int numberOfEncodedBytes = 0;
-
- // ---------------------------------------------------------------------
- Console::Clear();
-
- // Display the name of the encoding.
- Console::WriteLine("The name of the encoding is \"{0}\".{1}",
- asciiEncoding->WebName, Environment::NewLine);
-
- // Display the input string in text.
- Console::WriteLine("Input string ({0} characters): \"{1}\"",
- inputString->Length, inputString);
-
- // Display the input string in hexadecimal.
- Console::Write("Input string in hexadecimal: ");
- for each (char c in inputString)
- {
- Console::Write("0x{0:X2} ", c);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Encode the input string.
-
- Console::WriteLine("Encode the input string...");
- numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0,
- inputString->Length, encodedBytes, 0);
-
- // Display the encoded bytes.
- Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}",
- numberOfEncodedBytes, Environment::NewLine);
- for each (Byte b in encodedBytes)
- {
- Console::Write("0x{0:X2} ", b);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
-
- // Replace the encoded byte sequences for the characters 'X' and 'Z'
- // with the value 0xFF, which is outside the valid range of 0x00 to 0x7F
- // for ASCIIEncoding. The resulting byte sequence is actually the
- // beginning of this code example because it is the input to the decoder
- // operation, and is equivalent to a corrupted or improperly encoded
- // byte sequence.
-
- encodedBytes[0] = 0xFF;
- encodedBytes[2] = 0xFF;
-
- Console::WriteLine("Display the corrupted byte sequence...");
- Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}",
- numberOfEncodedBytes, Environment::NewLine);
- for each (Byte b in encodedBytes)
- {
- Console::Write("0x{0:X2} ", b);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Decode the encoded bytes.
-
- Console::WriteLine("Compare the decoded bytes to the input string...");
- decodedString = asciiEncoding->GetString(encodedBytes);
-
- // Display the input string and the decoded string for comparison.
- Console::WriteLine("Input string: \"{0}\"", inputString);
- Console::WriteLine("Decoded string:\"{0}\"", decodedString);
-}
-/*
-This code example produces the following results:
-
-The name of the encoding is "us-ascii".
-
-Input string (3 characters): "XYZ"
-Input string in hexadecimal: 0x58 0x59 0x5A
-
-Encode the input string...
-Encoded bytes in hexadecimal (3 bytes):
-
-0x58 0x59 0x5A
-
-Display the corrupted byte sequence...
-Encoded bytes in hexadecimal (3 bytes):
-
-0xFF 0x59 0xFF
-
-Compare the decoded bytes to the input string...
-Input string: "XYZ"
-Decoded string:"(error)Y(error)"
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp
deleted file mode 100644
index 3207d7a7fb2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// This example demonstrates the EncoderExceptionFallback class.
-
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- // Create an encoding, which is equivalent to calling the
- // ASCIIEncoding class constructor.
- // The EncoderExceptionFallback parameter causes an exception to
- // be thrown when a character cannot be encoded.
- // A decoder exception fallback is also specified, but it is not
- // used because this example terminates during the encoding operation.
-
- Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii",
- gcnew EncoderExceptionFallback(), gcnew DecoderExceptionFallback());
-
- // The input string consists of the Unicode characters LEFT POINTING
- // DOUBLE ANGLE QUOTATION MARK (U+00AB), 'X' (U+0058), and RIGHT
- // POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB).
- // The encoding can only encode characters in the US-ASCII range of
- // U+0000 through U+007F. Consequently, the characters bracketing the
- // 'X' character cause an exception.
- String^ inputString = L"\u00abX\u00bb";
-
- String^ twoNewLines = Environment::NewLine + Environment::NewLine;
- array^ encodedBytes = gcnew array(
- asciiEncoding->GetMaxByteCount(inputString->Length));
- int numberOfEncodedBytes = 0;
-
- // ---------------------------------------------------------------------
- Console::Clear();
-
- // Display the name of the encoding.
- Console::WriteLine("The name of the encoding is \"{0}\".{1}",
- asciiEncoding->WebName, Environment::NewLine);
-
- // Display the input string in text.
- Console::WriteLine("Input string ({0} characters): \"{1}\"",
- inputString->Length, inputString);
-
- // Display the input string in hexadecimal.
- Console::Write("Input string in hexadecimal: ");
- for each (char c in inputString)
- {
- Console::Write("0x{0:X2} ", c);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Attempt to encode the input string. However, an exception is thrown
- // before the input string can be encoded.
-
- Console::WriteLine("Encode the input string...");
-
- // The code example terminates during the call to the GetBytes() method.
- try
- {
- numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0,
- inputString->Length, encodedBytes, 0);
- // This statement is never executed.
- Console::WriteLine("This statement is never executed.");
- }
- catch (EncoderFallbackException^ ex)
- {
- Console::WriteLine(ex);
- Console::WriteLine(
- "{0}*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***",
- Environment::NewLine);
- }
-}
-
-/*
-This code example produces the following results:
-
-The name of the encoding is "us-ascii".
-
-Input string (3 characters): "X"
-Input string in hexadecimal: 0xAB 0x58 0xBB
-
-Encode the input string...
-System.Text.EncoderFallbackException: Unable to translate Unicode character \u00AB at inde
-x 0 to specified code page.
-at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
-at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars)
-at System.Text.ASCIIEncoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32
-byteCount, EncoderNLS encoder)
-at System.Text.ASCIIEncoding.GetBytes(String chars, Int32 charIndex, Int32 charCount, B
-yte[] bytes, Int32 byteIndex)
-at Sample.Main()
-
-*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp
deleted file mode 100644
index ec4a3456bd1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// This example demonstrates the EncoderReplacementFallback class.
-
-using namespace System;
-using namespace System::Text;
-
-int main()
-{
- // Create an encoding, which is equivalent to calling the
- // ASCIIEncoding class constructor.
- // The EncoderReplacementFallback parameter specifies that the
- // string, "(unknown)", replace characters that cannot be encoded.
- // A decoder replacement fallback is also specified, but in this
- // code example the decoding operation cannot fail.
-
- Encoding^ ascii = Encoding::GetEncoding("us-ascii",
- gcnew EncoderReplacementFallback("(unknown)"),
- gcnew DecoderReplacementFallback("(error)"));
-
- // The input string consists of the Unicode characters LEFT POINTING
- // DOUBLE ANGLE QUOTATION MARK (U+00AB), 'X' (U+0058), and RIGHT
- // POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB).
- // The encoding can only encode characters in the US-ASCII range of
- // U+0000 through U+007F. Consequently, the characters bracketing the
- // 'X' character are replaced with the fallback replacement string,
- // "(unknown)".
-
- String^ inputString = "\u00abX\u00bb";
- String^ decodedString;
- String^ twoNewLines = Environment::NewLine + Environment::NewLine;
- array ^ encodedBytes =
- gcnew array(ascii->GetByteCount(inputString));
- int numberOfEncodedBytes = 0;
-
- // ---------------------------------------------------------------------
- // Display the name of the encoding.
- Console::WriteLine("The name of the encoding is \"{0}\".{1}",
- ascii->WebName, Environment::NewLine);
-
- // Display the input string in text.
- Console::WriteLine("Input string ({0} characters): \"{1}\"",
- inputString->Length, inputString);
-
- // Display the input string in hexadecimal.
- Console::Write("Input string in hexadecimal: ");
- for each (char c in inputString)
- {
- Console::Write("0x{0:X2} ", c);
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Encode the input string.
-
- Console::WriteLine("Encode the input string...");
- numberOfEncodedBytes = ascii->GetBytes(inputString, 0, inputString->Length,
- encodedBytes, 0);
-
- // Display the encoded bytes.
- Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}",
- numberOfEncodedBytes, Environment::NewLine);
- for(int i = 0; i < encodedBytes->Length; i++)
- {
- Console::Write("0x{0:X2} ", encodedBytes[i]);
- if(((i + 1) % 6) == 0)
- {
- Console::WriteLine();
- }
- }
- Console::Write(twoNewLines);
-
- // ---------------------------------------------------------------------
- // Decode the encoded bytes, yielding a reconstituted string.
-
- Console::WriteLine("Decode the encoded bytes...");
- decodedString = ascii->GetString(encodedBytes);
-
- // Display the input string and the decoded string for comparison.
- Console::WriteLine("Input string: \"{0}\"", inputString);
- Console::WriteLine("Decoded string:\"{0}\"", decodedString);
-}
-
-
-
-/*
-This code example produces the following results:
-
-The name of the encoding is "us-ascii".
-
-Input string (3 characters): "X"
-Input string in hexadecimal: 0xAB 0x58 0xBB
-
-Encode the input string...
-Encoded bytes in hexadecimal (19 bytes):
-
-0x28 0x75 0x6E 0x6B 0x6E 0x6F
-0x77 0x6E 0x29 0x58 0x28 0x75
-0x6E 0x6B 0x6E 0x6F 0x77 0x6E
-0x29
-
-Decode the encoded bytes...
-Input string: "X"
-Decoded string:"(unknown)X(unknown)"
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp
deleted file mode 100644
index 79399d8f51e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-using namespace System;
-using namespace System::Threading;
-
-int main()
-{
- for (int i = 0; i < 5; i++)
- {
- Console::WriteLine("Sleep for 2 seconds.");
- Thread::Sleep(2000);
- }
-
- Console::WriteLine("Main thread exits.");
-}
-
-/* This example produces the following output:
-
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Main thread exits.
- */
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp
deleted file mode 100644
index 4f50e318256..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-using namespace System;
-using namespace System::Threading;
-
-int main()
-{
- TimeSpan interval = TimeSpan(0, 0, 2);
-
- for (int i = 0; i < 5; i++)
- {
- Console::WriteLine("Sleep for 2 seconds.");
- Thread::Sleep(interval);
- }
-
- Console::WriteLine("Main thread exits.");
-}
-
-/* This example produces the following output:
-
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Sleep for 2 seconds.
-Main thread exits.
- */
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp
deleted file mode 100644
index fbbf07e7429..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::IO;
-
-int main()
-{
-//
- X509Chain^ ch = gcnew X509Chain();
- ch->ChainPolicy->ApplicationPolicy->Add(gcnew Oid("1.2.1.1"));
-//
- //Output chain information about the chain.
- Console::WriteLine("Chain Information");
- ch->ChainPolicy->RevocationMode = X509RevocationMode::Online;
- Console::WriteLine("Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag);
- Console::WriteLine("Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode);
- Console::WriteLine("Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags);
- Console::WriteLine("Chain verification time: {0}", ch->ChainPolicy->VerificationTime);
- Console::WriteLine("Chain status length: {0}", ch->ChainStatus->Length);
- Console::WriteLine("Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count);
- Console::WriteLine("Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine);
-}
diff --git a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp b/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp
deleted file mode 100644
index 7b57914985d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::IO;
-
-int main()
-{
- //
- //Create new X509 store from local certificate store.
- X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser );
- store->Open( static_cast(OpenFlags::OpenExistingOnly | OpenFlags::ReadWrite) );
-
- //Output store information.
- Console::WriteLine( "Store Information" );
- Console::WriteLine( "Number of certificates in the store: {0}", store->Certificates->Count );
- Console::WriteLine( "Store location: {0}", store->Location );
- Console::WriteLine( "Store name: {0} {1}", store->Name, Environment::NewLine );
-
- //Put certificates from the store into a collection so user can select one.
- X509Certificate2Collection ^ fcollection = dynamic_cast(store->Certificates);
- X509Certificate2Collection ^ collection = X509Certificate2UI::SelectFromCollection(fcollection, "Select an X509 Certificate","Choose a certificate to examine.",X509SelectionFlag::SingleSelection);
- X509Certificate2 ^ certificate = collection[ 0 ];
- X509Certificate2UI::DisplayCertificate(certificate);
- //
-
- //
- //Output chain information of the selected certificate.
- X509Chain ^ ch = gcnew X509Chain;
- ch->ChainPolicy->RevocationMode = X509RevocationMode::Online;
- ch->Build( certificate );
- Console::WriteLine( "Chain Information" );
- Console::WriteLine( "Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag );
- Console::WriteLine( "Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode );
- Console::WriteLine( "Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags );
- Console::WriteLine( "Chain verification time: {0}", ch->ChainPolicy->VerificationTime );
- Console::WriteLine( "Chain status length: {0}", ch->ChainStatus->Length );
- Console::WriteLine( "Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count );
- Console::WriteLine( "Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine );
- //
-
- //
- //Output chain element information.
- Console::WriteLine( "Chain Element Information" );
- Console::WriteLine( "Number of chain elements: {0}", ch->ChainElements->Count );
- Console::WriteLine( "Chain elements synchronized? {0} {1}", ch->ChainElements->IsSynchronized, Environment::NewLine );
- System::Collections::IEnumerator^ myEnum = ch->ChainElements->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- X509ChainElement ^ element = safe_cast(myEnum->Current);
- Console::WriteLine( "Element issuer name: {0}", element->Certificate->Issuer );
- Console::WriteLine( "Element certificate valid until: {0}", element->Certificate->NotAfter );
- Console::WriteLine( "Element certificate is valid: {0}", element->Certificate->Verify() );
- Console::WriteLine( "Element error status length: {0}", element->ChainElementStatus->Length );
- Console::WriteLine( "Element information: {0}", element->Information );
- Console::WriteLine( "Number of element extensions: {0}{1}", element->Certificate->Extensions->Count, Environment::NewLine );
- if ( ch->ChainStatus->Length > 1 )
- {
- for ( int index = 0; index < element->ChainElementStatus->Length; index++ )
- {
- Console::WriteLine( element->ChainElementStatus[ index ].Status );
- Console::WriteLine( element->ChainElementStatus[ index ].StatusInformation );
- }
- }
- }
-
- store->Close();
- //
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp b/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp
deleted file mode 100644
index e1db565ed35..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::IO;
-int main()
-{
-
- //Create new X509 store called teststore from the local certificate store.
- X509Store ^ store = gcnew X509Store( "teststore",StoreLocation::CurrentUser );
- store->Open( OpenFlags::ReadWrite );
- X509Certificate2 ^ certificate = gcnew X509Certificate2;
-
- //Create certificates from certificate files.
- //You must put in a valid path to three certificates in the following constructors.
- X509Certificate2 ^ certificate1 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" );
- X509Certificate2 ^ certificate2 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" );
- X509Certificate2 ^ certificate5 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" );
-
- //Create a collection and add two of the certificates.
- X509Certificate2Collection ^ collection = gcnew X509Certificate2Collection;
- collection->Add( certificate2 );
- collection->Add( certificate5 );
-
- //Add certificates to the store.
- store->Add( certificate1 );
- store->AddRange( collection );
- X509Certificate2Collection ^ storecollection = dynamic_cast(store->Certificates);
- Console::WriteLine( "Store name: {0}", store->Name );
- Console::WriteLine( "Store location: {0}", store->Location );
- System::Collections::IEnumerator^ myEnum = storecollection->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- X509Certificate2 ^ x509 = safe_cast(myEnum->Current);
- Console::WriteLine( "certificate name: {0}", x509->Subject );
- }
-
-
- //Remove a certificate.
- store->Remove( certificate1 );
- X509Certificate2Collection ^ storecollection2 = dynamic_cast(store->Certificates);
- Console::WriteLine( "{1}Store name: {0}", store->Name, Environment::NewLine );
- System::Collections::IEnumerator^ myEnum1 = storecollection2->GetEnumerator();
- while ( myEnum1->MoveNext() )
- {
- X509Certificate2 ^ x509 = safe_cast(myEnum1->Current);
- Console::WriteLine( "certificate name: {0}", x509->Subject );
- }
-
-
- //Remove a range of certificates.
- store->RemoveRange( collection );
- X509Certificate2Collection ^ storecollection3 = dynamic_cast(store->Certificates);
- Console::WriteLine( "{1}Store name: {0}", store->Name, Environment::NewLine );
- if ( storecollection3->Count == 0 )
- {
- Console::WriteLine( "Store contains no certificates." );
- }
- else
- {
- System::Collections::IEnumerator^ myEnum2 = storecollection3->GetEnumerator();
- while ( myEnum2->MoveNext() )
- {
- X509Certificate2 ^ x509 = safe_cast(myEnum2->Current);
- Console::WriteLine( "certificate name: {0}", x509->Subject );
- }
- }
-
-
- //Close the store.
- store->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp
deleted file mode 100644
index d67485dbd80..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::ComponentModel;
-using namespace System::Security::Cryptography;
-
-//
-void EncryptData( String^ inName, String^ outName, array^aesKey, array^aesIV )
-{
-
- //Create the file streams to handle the input and output files.
- FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read );
- FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write );
- fout->SetLength( 0 );
-
- //Create variables to help with read and write.
- array^bin = gcnew array(100);
- long rdlen = 0; //This is the total number of bytes written.
-
- long totlen = (long)fin->Length; //This is the total length of the input file.
-
- int len; //This is the number of bytes to be written at a time.
-
- Aes^ aes = Aes::Create();
-
- CryptoStream^ encStream = gcnew CryptoStream( fout,aes->CreateEncryptor( aesKey, aesIV ),CryptoStreamMode::Write );
- Console::WriteLine( "Encrypting..." );
-
- //Read from the input file, then encrypt and write to the output file.
- while ( rdlen < totlen )
- {
- len = fin->Read( bin, 0, 100 );
- encStream->Write( bin, 0, len );
- rdlen = rdlen + len;
- Console::WriteLine( "{0} bytes processed", rdlen );
- }
-
- encStream->Close();
- fout->Close();
- fin->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp
deleted file mode 100644
index 505973f52b6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-#using
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Windows::Forms;
-using namespace System::Security::Cryptography;
-
-//
-void EncryptData( String^ inName, String^ outName, array^desKey, array^desIV )
-{
-
- //Create the file streams to handle the input and output files.
- FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read );
- FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write );
- fout->SetLength( 0 );
-
- //Create variables to help with read and write.
- array^bin = gcnew array(100);
- long rdlen = 0; //This is the total number of bytes written.
-
- long totlen = (long)fin->Length; //This is the total length of the input file.
-
- int len; //This is the number of bytes to be written at a time.
-
- DES^ des = gcnew DESCryptoServiceProvider;
- CryptoStream^ encStream = gcnew CryptoStream( fout,des->CreateEncryptor( desKey, desIV ),CryptoStreamMode::Write );
- Console::WriteLine( "Encrypting..." );
-
- //Read from the input file, then encrypt and write to the output file.
- while ( rdlen < totlen )
- {
- len = fin->Read( bin, 0, 100 );
- encStream->Write( bin, 0, len );
- rdlen = rdlen + len;
- Console::WriteLine( "{0} bytes processed", rdlen );
- }
-
- encStream->Close();
- fout->Close();
- fin->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp
deleted file mode 100644
index 56512d92aca..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Text;
-int main()
-{
-
- // These bytes in UTF-8 correspond to 3 different Unicode
- // characters: space (U+0020), # (U+0023), and the biohazard
- // symbol (U+2623). Note the biohazard symbol requires 3 bytes
- // in UTF-8 (hexadecimal e2, 98, a3). Decoders store state across
- // multiple calls to GetChars, handling the case when one char
- // is in multiple byte arrays.
- array^bytes1 = {0x20,0x23,0xe2};
- array^bytes2 = {0x98,0xa3};
- array^chars = gcnew array(3);
- Decoder^ d = Encoding::UTF8->GetDecoder();
- int charLen = d->GetChars( bytes1, 0, bytes1->Length, chars, 0 );
-
- // The value of charLen should be 2 now.
- charLen += d->GetChars( bytes2, 0, bytes2->Length, chars, charLen );
- for ( UInt16 index(0); index < chars->Length; ++index )
- {
- Console::Write( "U+{0:X4} ", static_cast(chars[ index ]) );
-
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp
deleted file mode 100644
index df797ae34f0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// Use this code inside a project created with the Visual C++ > CLR > CLR Console Application template.
-// Replace the code in the default .cpp file with this code.
-
-#include "stdafx.h"
-#using
-
-using namespace System;
-
-// To avoid confusion with other Timer classes, this sample always uses the fully-qualified
-// name of System::Timers::Timer instead of a using statement for System::Timer.
-
-public ref class Example
-{
-private:
- static System::Timers::Timer^ aTimer;
-
-public:
- static void Demo()
- {
- // Normally, the timer is declared at the class level, so that it stays in scope as long as it
- // is needed. If the timer is declared in a long-running method, KeepAlive must be used to prevent
- // the JIT compiler from allowing aggressive garbage collection to occur before the method ends.
- // You can experiment with this by commenting out the class-level declaration and uncommenting
- // the declaration below; then uncomment the GC.KeepAlive(aTimer) at the end of the method.
- //System::Timers::Timer^ aTimer;
-
- // Create a timer and set a two second interval.
- aTimer = gcnew System::Timers::Timer();
- aTimer->Interval = 2000;
-
- // Alternate method: create a Timer with an interval argument to the constructor.
- //aTimer = gcnew System::Timers::Timer(2000);
-
- // Hook up the Elapsed event for the timer.
- aTimer->Elapsed += gcnew System::Timers::ElapsedEventHandler(Example::OnTimedEvent);
-
- // Have the timer fire repeated events (true is the default)
- aTimer->AutoReset = true;
-
- // Start the timer
- aTimer->Enabled = true;
-
- Console::WriteLine("Press the Enter key to exit the program at any time... ");
- Console::ReadLine();
-
- // If the timer is declared in a long-running method, use KeepAlive to prevent garbage collection
- // from occurring before the method ends.
- //GC::KeepAlive(aTimer);
- }
-
-private:
- static void OnTimedEvent(Object^ source, System::Timers::ElapsedEventArgs^ e)
- {
- Console::WriteLine("The Elapsed event was raised at {0}", e->SignalTime);
- }
-
-};
-
-int main()
-{
- Example::Demo();
-}
-
-// This example displays output like the following:
-// Press the Enter key to exit the program at any time...
-// The Elapsed event was raised at 5/20/2015 8:48:58 PM
-// The Elapsed event was raised at 5/20/2015 8:49:00 PM
-// The Elapsed event was raised at 5/20/2015 8:49:02 PM
-// The Elapsed event was raised at 5/20/2015 8:49:04 PM
-// The Elapsed event was raised at 5/20/2015 8:49:06 PM
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp
deleted file mode 100644
index 6f843e8ba21..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Timers;
-
-public ref class Timer2
-{
-private:
- static System::Timers::Timer^ aTimer;
-
-public:
- static void Main()
- {
- // Create a new Timer with Interval set to 1.5 seconds.
- double interval = 1500.0;
- aTimer = gcnew System::Timers::Timer(interval);
-
- // Hook up the event handler for the Elapsed event.
- aTimer->Elapsed += gcnew ElapsedEventHandler( OnTimedEvent );
-
- // Only raise the event the first time Interval elapses.
- aTimer->AutoReset = false;
- aTimer->Enabled = true;
-
- // Ensure the event fires before the exit message appears.
- System::Threading::Thread::Sleep((int) interval * 2);
- Console::WriteLine("Press the Enter key to exit the program.");
- Console::ReadLine();
-
- // If the timer is declared in a long-running method, use
- // KeepAlive to prevent garbage collection from occurring
- // before the method ends.
- //GC::KeepAlive(aTimer);
- }
-
-private:
- // Handle the Elapsed event.
- static void OnTimedEvent( Object^ /*source*/, ElapsedEventArgs^ /*e*/ )
- {
- Console::WriteLine( "Hello World!" );
- }
-
-};
-
-int main()
-{
- Timer2::Main();
-}
-// The example displays the following output:
-// Hello World!
-// Press the Enter key to exit the program.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp
deleted file mode 100644
index f17fb57cbb7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
-//
-// This example uses the SHA1 algorithm.
-// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
-#using
-
-using namespace System;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-ref class Sender
-{
-private:
- RSAParameters rsaPubParams;
- RSAParameters rsaPrivateParams;
-
-public:
- Sender()
- {
- RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider;
-
- //Generate public and private key data.
- rsaPrivateParams = rsaCSP->ExportParameters( true );
- rsaPubParams = rsaCSP->ExportParameters( false );
- }
-
-
- property RSAParameters PublicParameters
- {
- RSAParameters get()
- {
- return rsaPubParams;
- }
-
- }
-
- //Manually performs hash and then signs hashed value.
- array^ HashAndSign( array^encrypted )
- {
- RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider;
- SHA1Managed^ hash = gcnew SHA1Managed;
- array^hashedData;
- rsaCSP->ImportParameters( rsaPrivateParams );
- hashedData = hash->ComputeHash( encrypted );
- return rsaCSP->SignHash( hashedData, CryptoConfig::MapNameToOID( "SHA1" ) );
- }
-
-
- //Encrypts using only the public key data.
- array^ EncryptData( RSAParameters rsaParams, array^toEncrypt )
- {
- RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider;
- rsaCSP->ImportParameters( rsaParams );
- return rsaCSP->Encrypt( toEncrypt, false );
- }
-
-};
-
-ref class Receiver
-{
-private:
- RSAParameters rsaPubParams;
- RSAParameters rsaPrivateParams;
-
-public:
- Receiver()
- {
- RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider;
-
- //Generate public and private key data.
- rsaPrivateParams = rsaCSP->ExportParameters( true );
- rsaPubParams = rsaCSP->ExportParameters( false );
- }
-
-
- property RSAParameters PublicParameters
- {
- RSAParameters get()
- {
- return rsaPubParams;
- }
-
- }
-
- //Manually performs hash and then verifies hashed value.
- //
- bool VerifyHash( RSAParameters rsaParams, array^signedData, array^signature )
- {
- RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider;
- SHA1Managed^ hash = gcnew SHA1Managed;
- array^hashedData;
- rsaCSP->ImportParameters( rsaParams );
- bool dataOK = rsaCSP->VerifyData(signedData, CryptoConfig::MapNameToOID("SHA1"), signature);
- hashedData = hash->ComputeHash( signedData );
- return rsaCSP->VerifyHash( hashedData, CryptoConfig::MapNameToOID( "SHA1" ), signature );
- }
- //
-
-
- //Decrypt using the private key data.
- void DecryptData( array^encrypted )
- {
- array^fromEncrypt;
- String^ roundTrip;
- ASCIIEncoding^ myAscii = gcnew ASCIIEncoding;
- RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider;
- rsaCSP->ImportParameters( rsaPrivateParams );
- fromEncrypt = rsaCSP->Decrypt( encrypted, false );
- roundTrip = myAscii->GetString( fromEncrypt );
- Console::WriteLine( "RoundTrip: {0}", roundTrip );
- }
-
-};
-
-int main()
-{
- array^toEncrypt;
- array^encrypted;
- array^signature;
-
- //Choose a small amount of data to encrypt.
- String^ original = "Hello";
- ASCIIEncoding^ myAscii = gcnew ASCIIEncoding;
-
- //Create a sender and receiver.
- Sender^ mySender = gcnew Sender;
- Receiver^ myReceiver = gcnew Receiver;
-
- //Convert the data string to a byte array.
- toEncrypt = myAscii->GetBytes( original );
-
- //Encrypt data using receiver's public key.
- encrypted = mySender->EncryptData( myReceiver->PublicParameters, toEncrypt );
-
- //Hash the encrypted data and generate a signature on the hash
- // using the sender's private key.
- signature = mySender->HashAndSign( encrypted );
- Console::WriteLine( "Original: {0}", original );
-
- //Verify the signature is authentic using the sender's public key.
- if ( myReceiver->VerifyHash( mySender->PublicParameters, encrypted, signature ) )
- {
-
- //Decrypt the data using the receiver's private key.
- myReceiver->DecryptData( encrypted );
- }
- else
- {
- Console::WriteLine( "Invalid signature" );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp
deleted file mode 100644
index de9be7b2fe4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Threading;
-
-public ref class SamplesStringDictionary
-{
-public:
- static void Main()
- {
- //
- StringDictionary^ myCollection = gcnew StringDictionary();
- 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()
-{
- SamplesStringDictionary::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp
deleted file mode 100644
index 5423aa171ec..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-// The following code example demonstrates several of the properties and methods of StringDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues2( StringDictionary^ myCol );
-void PrintKeysAndValues3( StringDictionary^ myCol );
-
-int main()
-{
- // Creates and initializes a new StringDictionary.
- StringDictionary^ myCol = gcnew StringDictionary;
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IEnumerator:" );
- PrintKeysAndValues2( myCol );
-
- // Display the contents of the collection using the Keys, Values, Count, and Item properties.
- Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
- PrintKeysAndValues3( myCol );
-
- // Copies the StringDictionary to an array with DictionaryEntry elements.
- array^myArr = gcnew array(myCol->Count);
- myCol->CopyTo( myArr, 0 );
-
- // Displays the values in the array.
- Console::WriteLine( "Displays the elements in the array:" );
- Console::WriteLine( " KEY VALUE" );
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( " {0,-10} {1}", myArr[ i ].Key, myArr[ i ].Value );
- Console::WriteLine();
-
- // Searches for a value.
- if ( myCol->ContainsValue( "amarillo" ) )
- Console::WriteLine( "The collection contains the value \"amarillo\"." );
- else
- Console::WriteLine( "The collection does not contain the value \"amarillo\"." );
-
- Console::WriteLine();
-
- // Searches for a key and deletes it.
- if ( myCol->ContainsKey( "green" ) )
- myCol->Remove( "green" );
-
- Console::WriteLine( "The collection contains the following elements after removing \"green\":" );
- PrintKeysAndValues2( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues2( myCol );
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( StringDictionary^ myCol )
-{
- IEnumerator^ myEnumerator = myCol->GetEnumerator();
- DictionaryEntry de;
- Console::WriteLine( " KEY VALUE" );
- while ( myEnumerator->MoveNext() )
- {
- de = *dynamic_cast(myEnumerator->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-// Uses the Keys, Values, Count, and Item properties.
-void PrintKeysAndValues3( StringDictionary^ myCol )
-{
- array^myKeys = gcnew array(myCol->Count);
- myCol->Keys->CopyTo( myKeys, 0 );
- Console::WriteLine( " INDEX KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] );
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Displays the elements using the IEnumerator:
- KEY VALUE
- red rojo
- blue azul
- green verde
-
-Displays the elements using the Keys, Values, Count, and Item properties:
- INDEX KEY VALUE
- 0 red rojo
- 1 blue azul
- 2 green verde
-
-Displays the elements in the array:
- KEY VALUE
- red rojo
- blue azul
- green verde
-
-The collection does not contain the value "amarillo".
-
-The collection contains the following elements after removing "green":
- KEY VALUE
- red rojo
- blue azul
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp
deleted file mode 100644
index c477bb3710f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-// The following code example demonstrates how to add and remove elements from a StringDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( StringDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ enum0 = myCol->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- DictionaryEntry^ de = safe_cast(enum0->Current);
- Console::WriteLine( " {0,-10} {1}", de->Key, de->Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new StringDictionary.
- StringDictionary^ myCol = gcnew StringDictionary;
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
-
- // Displays the values in the StringDictionary.
- Console::WriteLine( "Initial contents of the StringDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Deletes an element.
- myCol->Remove( "green" );
- Console::WriteLine( "The collection contains the following elements after removing \"green\":" );
- PrintKeysAndValues( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues( myCol );
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the StringDictionary:
- KEY VALUE
- green verde
- red rojo
- blue azul
-
-The collection contains the following elements after removing "green":
- KEY VALUE
- red rojo
- blue azul
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp
deleted file mode 100644
index 854a898a04a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-// The following code example searches for an element in a StringDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( StringDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ enum0 = myCol->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- DictionaryEntry^ de = safe_cast(enum0->Current);
- Console::WriteLine( " {0,-10} {1}", de->Key, de->Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new StringDictionary.
- StringDictionary^ myCol = gcnew StringDictionary;
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
-
- // Displays the values in the StringDictionary.
- Console::WriteLine( "Initial contents of the StringDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Searches for a key.
- if ( myCol->ContainsKey( "red" ) )
- Console::WriteLine( "The collection contains the key \"red\"." );
- else
- Console::WriteLine( "The collection does not contain the key \"red\"." );
-
- Console::WriteLine();
-
- // Searches for a value.
- if ( myCol->ContainsValue( "amarillo" ) )
- Console::WriteLine( "The collection contains the value \"amarillo\"." );
- else
- Console::WriteLine( "The collection does not contain the value \"amarillo\"." );
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the StringDictionary:
- KEY VALUE
- green verde
- red rojo
- blue azul
-
-The collection contains the key "red".
-
-The collection does not contain the value "amarillo".
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp
deleted file mode 100644
index a7c20a92885..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-// The following code example enumerates the elements of a StringDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintKeysAndValues1( StringDictionary^ myCol );
-void PrintKeysAndValues2( StringDictionary^ myCol );
-void PrintKeysAndValues3( StringDictionary^ myCol );
-
-int main()
-{
- // Creates and initializes a new StringDictionary.
- StringDictionary^ myCol = gcnew StringDictionary;
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
-
- // Display the contents of the collection using for each. This is the preferred method.
- Console::WriteLine( "Displays the elements using for each:" );
- PrintKeysAndValues1( myCol );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IEnumerator:" );
- PrintKeysAndValues2( myCol );
-
- // Display the contents of the collection using the Keys, Values, Count, and Item properties.
- Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
- PrintKeysAndValues3( myCol );
-}
-
-// Uses the for each statement which hides the complexity of the enumerator.
-// NOTE: The for each statement is the preferred way of enumerating the contents of a collection.
-void PrintKeysAndValues1( StringDictionary^ myCol ) {
- Console::WriteLine( " KEY VALUE" );
- for each ( DictionaryEntry^ de in myCol )
- Console::WriteLine( " {0,-25} {1}", de->Key, de->Value );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( StringDictionary^ myCol )
-{
- IEnumerator^ myEnumerator = myCol->GetEnumerator();
- DictionaryEntry^ de;
- Console::WriteLine( " KEY VALUE" );
- while ( myEnumerator->MoveNext() )
- {
- de = (DictionaryEntry^)(myEnumerator->Current);
- Console::WriteLine( " {0,-25} {1}", de->Key, de->Value );
- }
- Console::WriteLine();
-}
-
-// Uses the Keys, Values, Count, and Item properties.
-void PrintKeysAndValues3( StringDictionary^ myCol )
-{
- array^myKeys = gcnew array(myCol->Count);
- myCol->Keys->CopyTo( myKeys, 0 );
- Console::WriteLine( " INDEX KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] );
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Displays the elements using for each:
- KEY VALUE
- red rojo
- blue azul
- green verde
-
-Displays the elements using the IEnumerator:
- KEY VALUE
- red rojo
- blue azul
- green verde
-
-Displays the elements using the Keys, Values, Count, and Item properties:
- INDEX KEY VALUE
- 0 red rojo
- 1 blue azul
- 2 green verde
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp
deleted file mode 100644
index b62ad64ac50..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// The following code example enumerates the elements of a StringDictionary.
-
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class SamplesStringDictionary
-{
-public:
- static void Main()
- {
- // Creates and initializes a new StringDictionary.
- StringDictionary^ myCol = gcnew StringDictionary();
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
-
- Console::WriteLine("VALUES");
- for each (String^ val in myCol->Values)
- {
- Console::WriteLine(val);
- }
- }
-};
-
-int main()
-{
- SamplesStringDictionary::Main();
-}
-// This code produces the following output.
-// VALUES
-// verde
-// rojo
-// azul
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp
deleted file mode 100644
index a412d7c2739..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- // Create an empty ArrayList, and add some elements.
- ArrayList^ stringList = gcnew ArrayList();
-
- stringList->Add("a");
- stringList->Add("abc");
- stringList->Add("abcdef");
- stringList->Add("abcdefg");
-
- // The Item property is an indexer, so the property name is
- // not required.
- Console::WriteLine("Element {0} is \"{1}\"", 2, stringList[2]);
-
- // Assigning a value to the property changes the value of
- // the indexed element.
- stringList[2] = "abcd";
- Console::WriteLine("Element {0} is \"{1}\"", 2, stringList[2]);
-
- // Accessing an element outside the current element count
- // causes an exception.
- Console::WriteLine("Number of elements in the list: {0}",
- stringList->Count);
- try
- {
- Console::WriteLine("Element {0} is \"{1}\"",
- stringList->Count, stringList[stringList->Count]);
- }
- catch (ArgumentOutOfRangeException^ aoore)
- {
- Console::WriteLine("stringList({0}) is out of range.",
- stringList->Count);
- }
-
- // You cannot use the Item property to add new elements.
- try
- {
- stringList[stringList->Count] = "42";
- }
- catch (ArgumentOutOfRangeException^ aoore)
- {
- Console::WriteLine("stringList({0}) is out of range.",
- stringList->Count);
- }
-
- Console::WriteLine();
- for (int i = 0; i < stringList->Count; i++)
- {
- Console::WriteLine("Element {0} is \"{1}\"", i,
- stringList[i]);
- }
-
- Console::WriteLine();
- for each (Object^ o in stringList)
- {
- Console::WriteLine(o);
- }
- }
-};
-
-int main()
-{
- Example::Main();
-}
-/*
- This code example produces the following output:
-
-Element 2 is "abcdef"
-Element 2 is "abcd"
-Number of elements in the list: 4
-stringList(4) is out of range.
-stringList(4) is out of range.
-
-Element 0 is "a"
-Element 1 is "abc"
-Element 2 is "abcd"
-Element 3 is "abcdefg"
-
-a
-abc
-abcd
-abcdefg
- */
-//
-
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp
deleted file mode 100644
index 5a66b7c3b74..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections;
-
-public ref class ScrambleList : public ArrayList
-{
-public:
- static void Main()
- {
- // Create an empty ArrayList, and add some elements.
- ScrambleList^ integerList = gcnew ScrambleList();
-
- for (int i = 0; i < 10; i++)
- {
- integerList->Add(i);
- }
-
- Console::WriteLine("Ordered:\n");
- for each (int value in integerList)
- {
- Console::Write("{0}, ", value);
- }
- Console::WriteLine("\n\nScrambled:\n");
-
- // Scramble the order of the items in the list.
- integerList->Scramble();
-
- for each (int value in integerList)
- {
- Console::Write("{0}, ", value);
- }
- Console::WriteLine("\n");
- }
-
- void Scramble()
- {
- int limit = this->Count;
- int temp;
- int swapindex;
- Random^ rnd = gcnew Random();
- for (int i = 0; i < limit; i++)
- {
- // The Item property of ArrayList is the default indexer. Thus,
- // this->default[i] and this[i] are used interchangeably.
- temp = (int)this->default[i];
- swapindex = rnd->Next(0, limit - 1);
- this[i] = this->default[swapindex];
- this[swapindex] = temp;
- }
- }
-};
-
-int main()
-{
- ScrambleList::Main();
-}
-// The program produces output similar to the following:
-//
-// Ordered:
-//
-// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-//
-// Scrambled:
-//
-// 5, 2, 8, 9, 6, 1, 7, 0, 4, 3,
-//
-
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp
deleted file mode 100644
index c56559204dd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-
-// The following example shows how to sort the values in an using the default comparer and a custom comparer which reverses the sort order.
-//
-using namespace System;
-using namespace System::Collections;
-void PrintIndexAndValues( IEnumerable^ myList );
-ref class myReverserClass: public IComparer
-{
-private:
-
- // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
- virtual int Compare( Object^ x, Object^ y ) sealed = IComparer::Compare
- {
- return ((gcnew CaseInsensitiveComparer)->Compare( y, x ));
- }
-
-};
-
-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:" );
- PrintIndexAndValues( myAL );
-
- // Sorts the values of the ArrayList using the default comparer.
- myAL->Sort();
- Console::WriteLine( "After sorting with the default comparer:" );
- PrintIndexAndValues( myAL );
-
- // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
- IComparer^ myComparer = gcnew myReverserClass;
- myAL->Sort( myComparer );
- Console::WriteLine( "After sorting with the reverse case-insensitive comparer:" );
- PrintIndexAndValues( myAL );
-}
-
-void PrintIndexAndValues( IEnumerable^ myList )
-{
- int i = 0;
- IEnumerator^ myEnum = myList->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ obj = safe_cast(myEnum->Current);
- Console::WriteLine( "\t[{0}]:\t{1}", i++, obj );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-The ArrayList initially contains the following values:
- [0]: The
- [1]: quick
- [2]: brown
- [3]: fox
- [4]: jumps
- [5]: over
- [6]: the
- [7]: lazy
- [8]: dog
-
-After sorting with the default comparer:
- [0]: brown
- [1]: dog
- [2]: fox
- [3]: jumps
- [4]: lazy
- [5]: over
- [6]: quick
- [7]: the
- [8]: The
-
-After sorting with the reverse case-insensitive comparer:
- [0]: the
- [1]: The
- [2]: quick
- [3]: over
- [4]: lazy
- [5]: jumps
- [6]: fox
- [7]: dog
- [8]: brown
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp
deleted file mode 100644
index 41bde08602c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-
-// The following example shows how to sort the values in a section of an using the default comparer and a custom comparer which reverses the sort order.
-//
-using namespace System;
-using namespace System::Collections;
-void PrintIndexAndValues( IEnumerable^ myList );
-ref class myReverserClass: public IComparer
-{
-private:
-
- // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
- virtual int Compare( Object^ x, Object^ y ) = IComparer::Compare
- {
- return ((gcnew CaseInsensitiveComparer)->Compare( y, x ));
- }
-
-};
-
-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:" );
- PrintIndexAndValues( myAL );
-
- // Sorts the values of the ArrayList using the default comparer.
- myAL->Sort( 1, 3, nullptr );
- Console::WriteLine( "After sorting from index 1 to index 3 with the default comparer:" );
- PrintIndexAndValues( myAL );
-
- // Sorts the values of the ArrayList using the reverse case-insensitive comparer.
- IComparer^ myComparer = gcnew myReverserClass;
- myAL->Sort( 1, 3, myComparer );
- Console::WriteLine( "After sorting from index 1 to index 3 with the reverse case-insensitive comparer:" );
- PrintIndexAndValues( myAL );
-}
-
-void PrintIndexAndValues( IEnumerable^ myList )
-{
- int i = 0;
- IEnumerator^ myEnum = myList->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ obj = safe_cast(myEnum->Current);
- Console::WriteLine( "\t[{0}]:\t{1}", i++, obj );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-The ArrayList initially contains the following values:
- [0]: The
- [1]: QUICK
- [2]: BROWN
- [3]: FOX
- [4]: jumps
- [5]: over
- [6]: the
- [7]: lazy
- [8]: dog
-
-After sorting from index 1 to index 3 with the default comparer:
- [0]: The
- [1]: BROWN
- [2]: FOX
- [3]: QUICK
- [4]: jumps
- [5]: over
- [6]: the
- [7]: lazy
- [8]: dog
-
-After sorting from index 1 to index 3 with the reverse case-insensitive comparer:
- [0]: The
- [1]: QUICK
- [2]: FOX
- [3]: BROWN
- [4]: jumps
- [5]: over
- [6]: the
- [7]: lazy
- [8]: dog
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp
deleted file mode 100644
index 4ffd521bcd4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-
-// The following example shows how to copy the elements of an ArrayList to a string array.
-//
-using namespace System;
-using namespace System::Collections;
-void PrintIndexAndValues( ArrayList^ myList );
-void PrintIndexAndValues( array^myArr );
-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 contains the following values:" );
- PrintIndexAndValues( myAL );
-
- // Copies the elements of the ArrayList to a string array.
- array^myArr = reinterpret_cast^>(myAL->ToArray( String::typeid ));
-
- // Displays the contents of the string array.
- Console::WriteLine( "The string array contains the following values:" );
- PrintIndexAndValues( myArr );
-}
-
-void PrintIndexAndValues( ArrayList^ myList )
-{
- int i = 0;
- IEnumerator^ myEnum = myList->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ o = safe_cast(myEnum->Current);
- Console::WriteLine( "\t[{0}]:\t{1}", i++, o );
- }
-
- Console::WriteLine();
-}
-
-void PrintIndexAndValues( array^myArr )
-{
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( "\t[{0}]:\t{1}", i, myArr[ i ] );
- 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
-
-The string array contains the following values:
- [0]: The
- [1]: quick
- [2]: brown
- [3]: fox
- [4]: jumps
- [5]: over
- [6]: the
- [7]: lazy
- [8]: dog
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp
deleted file mode 100644
index 352f55da5ea..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example creates a case-sensitive hashtable and a case-insensitive hashtable
-// and demonstrates the difference in their behavior, even if both contain the same elements.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-int main()
-{
-
- // Create a Hashtable using the default hash code provider and the default comparer.
- Hashtable^ myHT1 = gcnew Hashtable;
- myHT1->Add( "FIRST", "Hello" );
- myHT1->Add( "SECOND", "World" );
- myHT1->Add( "THIRD", "!" );
-
- // Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer,
- // based on the culture of the current thread.
- Hashtable^ myHT2 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider,gcnew CaseInsensitiveComparer );
- myHT2->Add( "FIRST", "Hello" );
- myHT2->Add( "SECOND", "World" );
- myHT2->Add( "THIRD", "!" );
-
- // Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer,
- // based on the InvariantCulture.
- Hashtable^ myHT3 = gcnew Hashtable( CaseInsensitiveHashCodeProvider::DefaultInvariant,CaseInsensitiveComparer::DefaultInvariant );
- myHT3->Add( "FIRST", "Hello" );
- myHT3->Add( "SECOND", "World" );
- myHT3->Add( "THIRD", "!" );
-
- // Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer,
- // based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i".
- CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
- Hashtable^ myHT4 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider( myCul ),gcnew CaseInsensitiveComparer( myCul ) );
- myHT4->Add( "FIRST", "Hello" );
- myHT4->Add( "SECOND", "World" );
- myHT4->Add( "THIRD", "!" );
-
- // Search for a key in each hashtable.
- Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey( "first" ) );
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-first is in myHT1: False
-first is in myHT2: True
-first is in myHT3: True
-first is in myHT4: False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp
deleted file mode 100644
index c12910d57c1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-
-
-// The following code example implements the CollectionBase class and uses that implementation to create a collection of Int16 objects.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-
-public ref class Int16Collection: public CollectionBase
-{
-public:
-
- property Int16 Item [int]
- {
- Int16 get( int index )
- {
- return ( (Int16)(List[ index ]));
- }
-
- void set( int index, Int16 value )
- {
- List[ index ] = value;
- }
- }
- int Add( Int16 value )
- {
- return (List->Add( value ));
- }
-
- int IndexOf( Int16 value )
- {
- return (List->IndexOf( value ));
- }
-
- void Insert( int index, Int16 value )
- {
- List->Insert( index, value );
- }
-
- void Remove( Int16 value )
- {
- List->Remove( value );
- }
-
- bool Contains( Int16 value )
- {
- // If value is not of type Int16, this will return false.
- return (List->Contains( value ));
- }
-
-protected:
- virtual void OnInsert( int /*index*/, Object^ /*value*/ ) override
- {
- // Insert additional code to be run only when inserting values.
- }
-
- virtual void OnRemove( int /*index*/, Object^ /*value*/ ) override
- {
- // Insert additional code to be run only when removing values.
- }
-
- virtual void OnSet( int /*index*/, Object^ /*oldValue*/, Object^ /*newValue*/ ) override
- {
- // Insert additional code to be run only when setting values.
- }
-
- virtual void OnValidate( Object^ value ) override
- {
- if ( value->GetType() != Type::GetType( "System.Int16" ) )
- throw gcnew ArgumentException( "value must be of type Int16.","value" );
- }
-
-};
-
-void PrintIndexAndValues( Int16Collection^ myCol );
-void PrintValues2( Int16Collection^ myCol );
-int main()
-{
- // Create and initialize a new CollectionBase.
- Int16Collection^ myI16 = gcnew Int16Collection;
-
- // Add elements to the collection.
- myI16->Add( (Int16)1 );
- myI16->Add( (Int16)2 );
- myI16->Add( (Int16)3 );
- myI16->Add( (Int16)5 );
- myI16->Add( (Int16)7 );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Contents of the collection (using enumerator):" );
- PrintValues2( myI16 );
-
- // Display the contents of the collection using the Count property and the Item property.
- Console::WriteLine( "Initial contents of the collection (using Count and Item):" );
- PrintIndexAndValues( myI16 );
-
- // Search the collection with Contains and IndexOf.
- Console::WriteLine( "Contains 3: {0}", myI16->Contains( 3 ) );
- Console::WriteLine( "2 is at index {0}.", myI16->IndexOf( 2 ) );
- Console::WriteLine();
-
- // Insert an element into the collection at index 3.
- myI16->Insert( 3, (Int16)13 );
- Console::WriteLine( "Contents of the collection after inserting at index 3:" );
- PrintIndexAndValues( myI16 );
-
- // Get and set an element using the index.
- myI16->Item[ 4 ] = 123;
- Console::WriteLine( "Contents of the collection after setting the element at index 4 to 123:" );
- PrintIndexAndValues( myI16 );
-
- // Remove an element from the collection.
- myI16->Remove( (Int16)2 );
-
- // Display the contents of the collection using the Count property and the Item property.
- Console::WriteLine( "Contents of the collection after removing the element 2:" );
- PrintIndexAndValues( myI16 );
-}
-
-// Uses the Count property and the Item property.
-void PrintIndexAndValues( Int16Collection^ myCol )
-{
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " [{0}]: {1}", i, myCol->Item[ i ] );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintValues2( Int16Collection^ myCol )
-{
- System::Collections::IEnumerator^ myEnumerator = myCol->GetEnumerator();
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0}", myEnumerator->Current );
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Contents of the collection (using enumerator):
- 1
- 2
- 3
- 5
- 7
-
-Initial contents of the collection (using Count and Item):
- [0]: 1
- [1]: 2
- [2]: 3
- [3]: 5
- [4]: 7
-
-Contains 3: True
-2 is at index 1.
-
-Contents of the collection after inserting at index 3:
- [0]: 1
- [1]: 2
- [2]: 3
- [3]: 13
- [4]: 5
- [5]: 7
-
-Contents of the collection after setting the element at index 4 to 123:
- [0]: 1
- [1]: 2
- [2]: 3
- [3]: 13
- [4]: 123
- [5]: 7
-
-Contents of the collection after removing the element 2:
- [0]: 1
- [1]: 3
- [2]: 13
- [3]: 123
- [4]: 7
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp
deleted file mode 100644
index 5c672dbc203..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
-// The following code example implements the CollectionBase class and uses that implementation to create a collection of Int16 objects.
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Threading;
-
-public ref class Int16Collection: public CollectionBase
-{
-public:
-
- property Int16 Item [int]
- {
- Int16 get( int index )
- {
- return ( (Int16)(List[ index ]));
- }
-
- void set( int index, Int16 value )
- {
- List[ index ] = value;
- }
- }
- int Add( Int16 value )
- {
- return (List->Add( value ));
- }
-
- int IndexOf( Int16 value )
- {
- return (List->IndexOf( value ));
- }
-
- void Insert( int index, Int16 value )
- {
- List->Insert( index, value );
- }
-
- void Remove( Int16 value )
- {
- List->Remove( value );
- }
-
- bool Contains( Int16 value )
- {
- // If value is not of type Int16, this will return false.
- return (List->Contains( value ));
- }
-
-protected:
- virtual void OnInsert( int /*index*/, Object^ /*value*/ ) override
- {
- // Insert additional code to be run only when inserting values.
- }
-
- virtual void OnRemove( int /*index*/, Object^ /*value*/ ) override
- {
- // Insert additional code to be run only when removing values.
- }
-
- virtual void OnSet( int /*index*/, Object^ /*oldValue*/, Object^ /*newValue*/ ) override
- {
- // Insert additional code to be run only when setting values.
- }
-
- virtual void OnValidate( Object^ value ) override
- {
- if ( value->GetType() != Type::GetType( "System.Int16" ) )
- throw gcnew ArgumentException( "value must be of type Int16.","value" );
- }
-
-};
-
-public ref class SamplesCollectionBase
-{
-public:
- static void Main()
- {
- // Create and initialize a new CollectionBase.
- Int16Collection^ myCollectionBase = gcnew Int16Collection();
-
- // Add elements to the collection.
- myCollectionBase->Add( (Int16) 1 );
- myCollectionBase->Add( (Int16) 2 );
- myCollectionBase->Add( (Int16) 3 );
- myCollectionBase->Add( (Int16) 5 );
- myCollectionBase->Add( (Int16) 7 );
-
- //
- // Get the ICollection interface from the CollectionBase
- // derived class.
- ICollection^ myCollection = myCollectionBase;
- 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()
-{
- SamplesCollectionBase::Main();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp
deleted file mode 100644
index 8103ba2ad12..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example shows how Compare returns different values depending on the culture associated with the Comparer.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates the strings to compare.
- String^ str1 = "llegar";
- String^ str2 = "lugar";
- Console::WriteLine( "Comparing \"{0}\" and \"{1}\" ...", str1, str2 );
-
- // Uses the DefaultInvariant Comparer.
- Console::WriteLine( " Invariant Comparer: {0}", Comparer::DefaultInvariant->Compare( str1, str2 ) );
-
- // Uses the Comparer based on the culture "es-ES" (Spanish - Spain, international sort).
- Comparer^ myCompIntl = gcnew Comparer( gcnew CultureInfo( "es-ES",false ) );
- Console::WriteLine( " International Sort: {0}", myCompIntl->Compare( str1, str2 ) );
-
- // Uses the Comparer based on the culture identifier 0x040A (Spanish - Spain, traditional sort).
- Comparer^ myCompTrad = gcnew Comparer( gcnew CultureInfo( 0x040A,false ) );
- Console::WriteLine( " Traditional Sort : {0}", myCompTrad->Compare( str1, str2 ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing "llegar" and "lugar" ...
- Invariant Comparer: -1
- International Sort: -1
- Traditional Sort : 1
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp
deleted file mode 100644
index f22de93e8e7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-
-// The following code example implements the DictionaryBase class and uses that implementation to create a dictionary of String keys and values that have a Length of 5 or less.
-//
-using namespace System;
-using namespace System::Collections;
-
-public ref class ShortStringDictionary: public DictionaryBase
-{
-public:
-
- property String^ Item [String^]
- {
- String^ get( String^ key )
- {
- return (dynamic_cast(Dictionary[ key ]));
- }
-
- void set( String^ value, String^ key )
- {
- Dictionary[ key ] = value;
- }
- }
-
- property ICollection^ Keys
- {
- ICollection^ get()
- {
- return (Dictionary->Keys);
- }
- }
-
- property ICollection^ Values
- {
- ICollection^ get()
- {
- return (Dictionary->Values);
- }
- }
- void Add( String^ key, String^ value )
- {
- Dictionary->Add( key, value );
- }
-
- bool Contains( String^ key )
- {
- return (Dictionary->Contains( key ));
- }
-
- void Remove( String^ key )
- {
- Dictionary->Remove( key );
- }
-
-
-protected:
- virtual void OnInsert( Object^ key, Object^ value ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
-
- if ( value->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "value must be of type String.","value" );
- else
- {
- String^ strValue = dynamic_cast(value);
- if ( strValue->Length > 5 )
- throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" );
- }
- }
-
- virtual void OnRemove( Object^ key, Object^ /*value*/ ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
- }
-
- virtual void OnSet( Object^ key, Object^ /*oldValue*/, Object^ newValue ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
-
- if ( newValue->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "newValue must be of type String.","newValue" );
- else
- {
- String^ strValue = dynamic_cast(newValue);
- if ( strValue->Length > 5 )
- throw gcnew ArgumentException( "newValue must be no more than 5 characters in length.","newValue" );
- }
- }
-
- virtual void OnValidate( Object^ key, Object^ value ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
-
- if ( value->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "value must be of type String.","value" );
- else
- {
- String^ strValue = dynamic_cast(value);
- if ( strValue->Length > 5 )
- throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" );
- }
- }
-
-};
-
-void PrintKeysAndValues2( ShortStringDictionary^ myCol );
-void PrintKeysAndValues3( ShortStringDictionary^ myCol );
-int main()
-{
- // Creates and initializes a new DictionaryBase.
- ShortStringDictionary^ mySSC = gcnew ShortStringDictionary;
-
- // Adds elements to the collection.
- mySSC->Add( "One", "a" );
- mySSC->Add( "Two", "ab" );
- mySSC->Add( "Three", "abc" );
- mySSC->Add( "Four", "abcd" );
- mySSC->Add( "Five", "abcde" );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Contents of the collection (using enumerator):" );
- PrintKeysAndValues2( mySSC );
-
- // Display the contents of the collection using the Keys property and the Item property.
- Console::WriteLine( "Initial contents of the collection (using Keys and Item):" );
- PrintKeysAndValues3( mySSC );
-
- // Tries to add a value that is too long.
- try
- {
- mySSC->Add( "Ten", "abcdefghij" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- // Tries to add a key that is too long.
- try
- {
- mySSC->Add( "Eleven", "ijk" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- Console::WriteLine();
-
- // Searches the collection with Contains.
- Console::WriteLine( "Contains \"Three\": {0}", mySSC->Contains( "Three" ) );
- Console::WriteLine( "Contains \"Twelve\": {0}", mySSC->Contains( "Twelve" ) );
- Console::WriteLine();
-
- // Removes an element from the collection.
- mySSC->Remove( "Two" );
-
- // Displays the contents of the collection.
- Console::WriteLine( "After removing \"Two\":" );
- PrintKeysAndValues2( mySSC );
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( ShortStringDictionary^ myCol )
-{
- DictionaryEntry myDE;
- System::Collections::IEnumerator^ myEnumerator = myCol->GetEnumerator();
- while ( myEnumerator->MoveNext() )
- if ( myEnumerator->Current != nullptr )
- {
- myDE = *dynamic_cast(myEnumerator->Current);
- Console::WriteLine( " {0,-5} : {1}", myDE.Key, myDE.Value );
- }
-
- Console::WriteLine();
-}
-
-
-// Uses the Keys property and the Item property.
-void PrintKeysAndValues3( ShortStringDictionary^ myCol )
-{
- ICollection^ myKeys = myCol->Keys;
- IEnumerator^ myEnum1 = myKeys->GetEnumerator();
- while ( myEnum1->MoveNext() )
- {
- String^ k = safe_cast(myEnum1->Current);
- Console::WriteLine( " {0,-5} : {1}", k, myCol->Item[ k ] );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Contents of the collection (using enumerator):
- Three : abc
- Five : abcde
- Two : ab
- One : a
- Four : abcd
-
-Initial contents of the collection (using Keys and Item):
- Three : abc
- Five : abcde
- Two : ab
- One : a
- Four : abcd
-
-System.ArgumentException: value must be no more than 5 characters in length.
-Parameter name: value
- at ShortStringDictionary.OnValidate(Object key, Object value)
- at System.Collections.DictionaryBase.System.Collections.IDictionary.Add(Object key, Object value)
- at SamplesDictionaryBase.Main()
-System.ArgumentException: key must be no more than 5 characters in length.
-Parameter name: key
- at ShortStringDictionary.OnValidate(Object key, Object value)
- at System.Collections.DictionaryBase.System.Collections.IDictionary.Add(Object key, Object value)
- at SamplesDictionaryBase.Main()
-
-Contains "Three": True
-Contains "Twelve": False
-
-After removing "Two":
- Three : abc
- Five : abcde
- One : a
- Four : abcd
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp
deleted file mode 100644
index 6d4bc281691..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Threading;
-
-public ref class ShortStringDictionary: public DictionaryBase
-{
-public:
-
- property String^ Item [String^]
- {
- String^ get( String^ key )
- {
- return (dynamic_cast(Dictionary[ key ]));
- }
-
- void set( String^ value, String^ key )
- {
- Dictionary[ key ] = value;
- }
- }
-
- property ICollection^ Keys
- {
- ICollection^ get()
- {
- return (Dictionary->Keys);
- }
- }
-
- property ICollection^ Values
- {
- ICollection^ get()
- {
- return (Dictionary->Values);
- }
- }
- void Add( String^ key, String^ value )
- {
- Dictionary->Add( key, value );
- }
-
- bool Contains( String^ key )
- {
- return (Dictionary->Contains( key ));
- }
-
- void Remove( String^ key )
- {
- Dictionary->Remove( key );
- }
-
-
-protected:
- virtual void OnInsert( Object^ key, Object^ value ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
-
- if ( value->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "value must be of type String.","value" );
- else
- {
- String^ strValue = dynamic_cast(value);
- if ( strValue->Length > 5 )
- throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" );
- }
- }
-
- virtual void OnRemove( Object^ key, Object^ /*value*/ ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
- }
-
- virtual void OnSet( Object^ key, Object^ /*oldValue*/, Object^ newValue ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
-
- if ( newValue->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "newValue must be of type String.","newValue" );
- else
- {
- String^ strValue = dynamic_cast(newValue);
- if ( strValue->Length > 5 )
- throw gcnew ArgumentException( "newValue must be no more than 5 characters in length.","newValue" );
- }
- }
-
- virtual void OnValidate( Object^ key, Object^ value ) override
- {
- if ( key->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "key must be of type String.","key" );
- else
- {
- String^ strKey = dynamic_cast(key);
- if ( strKey->Length > 5 )
- throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" );
- }
-
- if ( value->GetType() != Type::GetType( "System.String" ) )
- throw gcnew ArgumentException( "value must be of type String.","value" );
- else
- {
- String^ strValue = dynamic_cast(value);
- if ( strValue->Length > 5 )
- throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" );
- }
- }
-
-};
-
-public ref class SamplesDictionaryBase
-{
-public:
- static void Main()
- {
- DictionaryBase^ myDictionary = gcnew ShortStringDictionary();
-
- //
- for each (DictionaryEntry de in myDictionary)
- {
- //...
- }
- //
-
- //
- ICollection^ myCollection = gcnew ShortStringDictionary();
- 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()
-{
- SamplesDictionaryBase::Main();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp
deleted file mode 100644
index e7587a1e80f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// A simple example for the DictionaryEntry structure.
-using namespace System;
-using namespace System::Collections;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- // Create a new hash table.
- //
- Hashtable^ openWith = gcnew Hashtable();
-
- // Add some elements to the hash table. There are no
- // duplicate keys, but some of the values are duplicates.
- openWith->Add("txt", "notepad.exe");
- openWith->Add("bmp", "paint.exe");
- openWith->Add("dib", "paint.exe");
- openWith->Add("rtf", "wordpad.exe");
-
- // When you use foreach to enumerate hash table elements,
- // the elements are retrieved as DictionaryEntry objects.
- Console::WriteLine();
- //
- for each (DictionaryEntry de in openWith)
- {
- Console::WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
- }
- //
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
-/* This code example produces output similar to the following:
-
-Key = rtf, Value = wordpad.exe
-Key = txt, Value = notepad.exe
-Key = dib, Value = paint.exe
-Key = bmp, Value = paint.exe
- */
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp
deleted file mode 100644
index 4378b0f208a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Generic;
-
-ref class Program
-{
-public:
- //
- static void Main()
- {
- HashSet^ lowNumbers = gcnew HashSet();
- HashSet^ highNumbers = gcnew HashSet();
-
- for (int i = 0; i < 6; i++)
- {
- lowNumbers->Add(i);
- }
-
- for (int i = 3; i < 10; i++)
- {
- highNumbers->Add(i);
- }
-
- Console::Write("lowNumbers contains {0} elements: ", lowNumbers->Count);
- DisplaySet(lowNumbers);
-
- Console::Write("highNumbers contains {0} elements: ", highNumbers->Count);
- DisplaySet(highNumbers);
-
- Console::WriteLine("highNumbers ExceptWith lowNumbers...");
- highNumbers->ExceptWith(lowNumbers);
-
- Console::Write("highNumbers contains {0} elements: ", highNumbers->Count);
- DisplaySet(highNumbers);
- }
- /* This example provides output similar to the following:
- * lowNumbers contains 6 elements: { 0 1 2 3 4 5 }
- * highNumbers contains 7 elements: { 3 4 5 6 7 8 9 }
- * highNumbers ExceptWith lowNumbers...
- * highNumbers contains 4 elements: { 6 7 8 9 }
- */
- //
-
-private:
- static void DisplaySet(HashSet^ set)
- {
- Console::Write("{");
- for each (int i in set)
- {
- Console::Write(" {0}", i);
- }
- Console::WriteLine(" }");
- }
-};
-
-int main()
-{
- Program::Main();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp
deleted file mode 100644
index 2ff29223cc6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Generic;
-
-ref class Program
-{
-public:
- static void Main()
- {
- HashSet ^allVehicles = gcnew HashSet(StringComparer::OrdinalIgnoreCase);
- List^ someVehicles = gcnew List();
-
- someVehicles->Add("Planes");
- someVehicles->Add("Trains");
- someVehicles->Add("Automobiles");
-
- // Add in the vehicles contained in the someVehicles list.
- allVehicles->UnionWith(someVehicles);
-
- Console::WriteLine("The current HashSet contains:\n");
- for each (String^ vehicle in allVehicles)
- {
- Console::WriteLine(vehicle);
- }
-
- allVehicles->Add("Ships");
- allVehicles->Add("Motorcycles");
- allVehicles->Add("Rockets");
- allVehicles->Add("Helicopters");
- allVehicles->Add("Submarines");
-
- Console::WriteLine("\nThe updated HashSet contains:\n");
- for each (String^ vehicle in allVehicles)
- {
- Console::WriteLine(vehicle);
- }
-
- // Verify that the 'All Vehicles' set contains at least the vehicles in
- // the 'Some Vehicles' list.
- if (allVehicles->IsSupersetOf(someVehicles))
- {
- Console::Write("\nThe 'All' vehicles set contains everything in ");
- Console::WriteLine("'Some' vechicles list.");
- }
-
- // Check for Rockets. Here the OrdinalIgnoreCase comparer will compare
- // true for the mixed-case vehicle type.
- if (allVehicles->Contains("roCKeTs"))
- {
- Console::WriteLine("\nThe 'All' vehicles set contains 'roCKeTs'");
- }
-
- allVehicles->ExceptWith(someVehicles);
- Console::WriteLine("\nThe excepted HashSet contains:\n");
- for each (String^ vehicle in allVehicles)
- {
- Console::WriteLine(vehicle);
- }
-
- // Remove all the vehicles that are not 'super cool'.
- allVehicles->RemoveWhere(gcnew Predicate(&isNotSuperCool));
-
- Console::WriteLine("\nThe super cool vehicles are:\n");
- for each (String^ vehicle in allVehicles)
- {
- Console::WriteLine(vehicle);
- }
- }
-
-private:
- // Predicate to determine vehicle 'coolness'.
- static bool isNotSuperCool(String^ vehicle)
- {
- bool superCool = (vehicle == "Helicopters") || (vehicle == "Motorcycles");
-
- return !superCool;
- }
-};
-
-int main()
-{
- Program::Main();
-}
-
-// The program writes the following output to the console::
-//
-// The current HashSet contains:
-//
-// Planes
-// Trains
-// Automobiles
-//
-// The updated HashSet contains:
-//
-// Planes
-// Trains
-// Automobiles
-// Ships
-// Motorcycles
-// Rockets
-// Helicopters
-// Submarines
-//
-// The 'All' vehicles set contains everything in 'Some' vechicles list.
-//
-// The 'All' vehicles set contains 'roCKeTs'
-//
-// The excepted HashSet contains:
-//
-// Ships
-// Motorcycles
-// Rockets
-// Helicopters
-// Submarines
-//
-// The super cool vehicles are:
-//
-// Motorcycles
-// Helicopters
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp
deleted file mode 100644
index 3533f81fe87..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-
-// The following code example creates and initializes a LinkedList of type String and then displays its contents.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Generic;
-
-void main()
-{
- // Create and initialize a new LinkedList.
- LinkedList< String^ > ^ ll = gcnew LinkedList< String^ >;
- ll->AddLast(L"red");
- ll->AddLast(L"orange");
- ll->AddLast(L"yellow");
- ll->AddLast(L"orange");
-
- // Display the contents of the LinkedList.
- if (ll->Count > 0)
- {
- Console::WriteLine(L"The first item in the list is {0}.", ll->First->Value);
- Console::WriteLine(L"The last item in the list is {0}.", ll->Last->Value);
- Console::WriteLine(L"The LinkedList contains:");
-
- for each (String^ s in ll)
- {
- Console::WriteLine(L" {0}", s);
- }
- }
- else
- {
- Console::WriteLine(L"The LinkedList is empty.");
- }
-}
-
-/* This code produces the following output.
-
-The first item in the list is red.
-The last item in the list is orange.
-The LinkedList contains:
- red
- orange
- yellow
- orange
-*/
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp
deleted file mode 100644
index e6f279e12f3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// The following code example creates a LinkedList node, adds it to a LinkedList, and tracks the values of its properties as the LinkedList changes.
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Generic;
-
-public ref class GenericCollection {
-
-public:
- static void Main() {
-
- // Create a new LinkedListNode of type String and displays its properties.
- LinkedListNode^ lln = gcnew LinkedListNode( "orange" );
- Console::WriteLine( "After creating the node ...." );
- DisplayProperties( lln );
-
- // Create a new LinkedList.
- LinkedList^ ll = gcnew LinkedList();
-
- // Add the "orange" node and display its properties.
- ll->AddLast( lln );
- Console::WriteLine( "After adding the node to the empty LinkedList ...." );
- DisplayProperties( lln );
-
- // Add nodes before and after the "orange" node and display the "orange" node's properties.
- ll->AddFirst( "red" );
- ll->AddLast( "yellow" );
- Console::WriteLine( "After adding red and yellow ...." );
- DisplayProperties( lln );
-
- }
-
- static void DisplayProperties( LinkedListNode^ lln ) {
- if ( lln->List == nullptr )
- Console::WriteLine( " Node is not linked." );
- else
- Console::WriteLine( " Node belongs to a linked list with {0} elements.", lln->List->Count );
-
- if ( lln->Previous == nullptr )
- Console::WriteLine( " Previous node is null." );
- else
- Console::WriteLine( " Value of previous node: {0}", lln->Previous->Value );
-
- Console::WriteLine( " Value of current node: {0}", lln->Value );
-
- if ( lln->Next == nullptr )
- Console::WriteLine( " Next node is null." );
- else
- Console::WriteLine( " Value of next node: {0}", lln->Next->Value );
-
- Console::WriteLine();
- }
-
-};
-
-int main()
-{
- GenericCollection::Main();
-}
-
-/*
-
-This code produces the following output.
-
-After creating the node ....
- Node is not linked.
- Previous node is null.
- Value of current node: orange
- Next node is null.
-
-After adding the node to the empty LinkedList ....
- Node belongs to a linked list with 1 elements.
- Previous node is null.
- Value of current node: orange
- Next node is null.
-
-After adding red and yellow ....
- Node belongs to a linked list with 3 elements.
- Value of previous node: red
- Value of current node: orange
- Value of next node: yellow
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp
deleted file mode 100644
index 987e041929f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-//
-using namespace System;
-using namespace System::Collections;
-
-public ref class Example
-{
-public:
- static void Main()
- {
- // Create a new hash table.
- //
- Hashtable^ openWith = gcnew Hashtable();
-
- // Add some elements to the hash table. There are no
- // duplicate keys, but some of the values are duplicates.
- openWith->Add("txt", "notepad.exe");
- openWith->Add("bmp", "paint.exe");
- openWith->Add("dib", "paint.exe");
- openWith->Add("rtf", "wordpad.exe");
-
- // The Add method throws an exception if the new key is
- // already in the hash table.
- try
- {
- openWith->Add("txt", "winword.exe");
- }
- catch(...)
- {
- Console::WriteLine("An element with Key = \"txt\" already exists.");
- }
-
- // The Item property is the default property, so you
- // can omit its name when accessing elements.
- Console::WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);
-
- // The default Item property can be used to change the value
- // associated with a key.
- openWith["rtf"] = "winword.exe";
- Console::WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);
-
- // If a key does not exist, setting the default Item property
- // for that key adds a new key/value pair.
- openWith["doc"] = "winword.exe";
-
- // ContainsKey can be used to test keys before inserting
- // them.
- if (!openWith->ContainsKey("ht"))
- {
- openWith->Add("ht", "hypertrm.exe");
- Console::WriteLine("Value added for key = \"ht\": {0}", openWith["ht"]);
- }
-
- // When you use foreach to enumerate hash table elements,
- // the elements are retrieved as KeyValuePair objects.
- Console::WriteLine();
- for each( DictionaryEntry de in openWith )
- {
- Console::WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
- }
-
- // To get the values alone, use the Values property.
- ICollection^ valueColl = openWith->Values;
-
- // The elements of the ValueCollection are strongly typed
- // with the type that was specified for hash table values.
- Console::WriteLine();
- for each( String^ s in valueColl )
- {
- Console::WriteLine("Value = {0}", s);
- }
-
- // To get the keys alone, use the Keys property.
- ICollection^ keyColl = openWith->Keys;
-
- // The elements of the KeyCollection are strongly typed
- // with the type that was specified for hash table keys.
- Console::WriteLine();
- for each( String^ s in keyColl )
- {
- Console::WriteLine("Key = {0}", s);
- }
-
- // Use the Remove method to remove a key/value pair.
- Console::WriteLine("\nRemove(\"doc\")");
- openWith->Remove("doc");
-
- if (!openWith->ContainsKey("doc"))
- {
- Console::WriteLine("Key \"doc\" is not found.");
- }
- }
-};
-
-int main()
-{
- Example::Main();
-}
-
-/* This code example produces the following output:
-
-An element with Key = "txt" already exists.
-For key = "rtf", value = wordpad.exe.
-For key = "rtf", value = winword.exe.
-Value added for key = "ht": hypertrm.exe
-
-Key = dib, Value = paint.exe
-Key = txt, Value = notepad.exe
-Key = ht, Value = hypertrm.exe
-Key = bmp, Value = paint.exe
-Key = rtf, Value = winword.exe
-Key = doc, Value = winword.exe
-
-Value = paint.exe
-Value = notepad.exe
-Value = hypertrm.exe
-Value = paint.exe
-Value = winword.exe
-Value = winword.exe
-
-Key = dib
-Key = txt
-Key = ht
-Key = bmp
-Key = rtf
-Key = doc
-
-Remove("doc")
-Key "doc" is not found.
- */
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp
deleted file mode 100644
index 5b410769391..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-using namespace System;
-using namespace System::Collections;
-
-public ref class Remarks
-{
-public:
- static void Main()
- {
- // Create a new hash table.
- //
- Hashtable^ myHashtable = gcnew Hashtable();
-
- // Add some elements to the hash table. There are no
- // duplicate keys, but some of the values are duplicates.
- myHashtable->Add("txt", "notepad.exe");
- myHashtable->Add("bmp", "paint.exe");
- myHashtable->Add("dib", "paint.exe");
- myHashtable->Add("rtf", "wordpad.exe");
-
-
- // When you use foreach to enumerate hash table elements,
- // the elements are retrieved as KeyValuePair objects.
- //
- for each(DictionaryEntry de in myHashtable)
- {
- // ...
- }
- //
- }
-};
-
-int main()
-{
- Remarks::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp
deleted file mode 100644
index a614056e17b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-
-// The following code example creates hash tables using different Hashtable constructors
-// and demonstrates the differences in the behavior of the hash tables,
-// even if each one contains the same elements.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-ref class myComparer : IEqualityComparer
-{
-public:
- virtual bool Equals(Object^ x, Object^ y)
- {
- return x->Equals(y);
- }
-
- virtual int GetHashCode(Object^ obj)
- {
- return obj->ToString()->ToLower()->GetHashCode();
- }
-};
-
-//
-ref class myCultureComparer : IEqualityComparer
-{
-private:
- CaseInsensitiveComparer^ myComparer;
-
-public:
- myCultureComparer()
- {
- myComparer = CaseInsensitiveComparer::DefaultInvariant;
- }
-
- myCultureComparer(CultureInfo^ myCulture)
- {
- myComparer = gcnew CaseInsensitiveComparer(myCulture);
- }
-
- virtual bool Equals(Object^ x, Object^ y)
- {
- if (myComparer->Compare(x, y) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- virtual int GetHashCode(Object^ obj)
- {
- return obj->ToString()->ToLower()->GetHashCode();
- }
-};
-//
-
-int main()
-{
-
- // Create a hash table using the default hash code provider and the default comparer.
- Hashtable^ myHT1 = gcnew Hashtable((IEqualityComparer^)nullptr);
- myHT1->Add( "FIRST", "Hello" );
- myHT1->Add( "SECOND", "World" );
- myHT1->Add( "THIRD", "!" );
-
- // Create a hash table using the specified IEqualityComparer that uses
- // the default Object.Equals to determine equality.
- Hashtable^ myHT2 = gcnew Hashtable(gcnew myComparer());
- myHT2->Add( "FIRST", "Hello" );
- myHT2->Add( "SECOND", "World" );
- myHT2->Add( "THIRD", "!" );
-
- // Create a hash table using a case-insensitive hash code provider and
- // case-insensitive comparer based on the InvariantCulture.
- Hashtable^ myHT3 = gcnew Hashtable(
- CaseInsensitiveHashCodeProvider::DefaultInvariant,
- CaseInsensitiveComparer::DefaultInvariant);
- myHT3->Add( "FIRST", "Hello" );
- myHT3->Add( "SECOND", "World" );
- myHT3->Add( "THIRD", "!" );
-
- // Create a hash table using an IEqualityComparer that is based on
- // the Turkish culture (tr-TR) where "I" is not the uppercase
- // version of "i".
- CultureInfo^ myCul = gcnew CultureInfo("tr-TR");
- Hashtable^ myHT4 = gcnew Hashtable( gcnew myCultureComparer(myCul) );
- myHT4->Add( "FIRST", "Hello" );
- myHT4->Add( "SECOND", "World" );
- myHT4->Add( "THIRD", "!" );
-
- // Search for a key in each hash table.
- Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey( "first" ) );
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-first is in myHT1: False
-first is in myHT2: False
-first is in myHT3: True
-first is in myHT4: False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp
deleted file mode 100644
index ddc083162d8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-// The following code example creates hash tables using different Hashtable
-// constructors and demonstrates the differences in the behavior of the hash
-// tables, even if each one contains the same elements.
-
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-ref class myCultureComparer : public IEqualityComparer
-{
-public:
- CaseInsensitiveComparer^ myComparer;
-
-public:
- myCultureComparer()
- {
- myComparer = CaseInsensitiveComparer::DefaultInvariant;
- }
-
-public:
- myCultureComparer(CultureInfo^ myCulture)
- {
- myComparer = gcnew CaseInsensitiveComparer(myCulture);
- }
-
-public:
- virtual bool Equals(Object^ x, Object^ y)
- {
- if (myComparer->Compare(x, y) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-public:
- virtual int GetHashCode(Object^ obj)
- {
- // Compare the hash code for the lowercase versions of the strings.
- return obj->ToString()->ToLower()->GetHashCode();
- }
-};
-
-public ref class SamplesHashtable
-{
-
-public:
- static void Main()
- {
- // Create the dictionary.
- SortedList^ mySL = gcnew SortedList();
- mySL->Add("FIRST", "Hello");
- mySL->Add("SECOND", "World");
- mySL->Add("THIRD", "!");
-
- // Create a hash table using the default comparer.
- Hashtable^ myHT1 = gcnew Hashtable(mySL);
-
- // Create a hash table using the specified IEqualityComparer that uses
- // the CaseInsensitiveComparer.DefaultInvariant to determine equality.
- Hashtable^ myHT2 = gcnew Hashtable(mySL, gcnew myCultureComparer());
-
- // Create a hash table using an IEqualityComparer that is based on
- // the Turkish culture (tr-TR) where "I" is not the uppercase
- // version of "i".
- CultureInfo^ myCul = gcnew CultureInfo("tr-TR");
- Hashtable^ myHT3 = gcnew Hashtable(mySL, gcnew myCultureComparer(myCul));
-
- // Search for a key in each hash table.
- Console::WriteLine("first is in myHT1: {0}", myHT1->ContainsKey("first"));
- Console::WriteLine("first is in myHT2: {0}", myHT2->ContainsKey("first"));
- Console::WriteLine("first is in myHT3: {0}", myHT3->ContainsKey("first"));
- }
-};
-
-int main()
-{
- SamplesHashtable::Main();
-};
-
-/*
-This code produces the following output.
-Results vary depending on the system's culture settings.
-
-first is in myHT1: False
-first is in myHT2: True
-first is in myHT3: False
-
-*/
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp
deleted file mode 100644
index aeefb15d534..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-
-// The following code example creates hash tables using different Hashtable constructors
-// and demonstrates the differences in the behavior of the hash tables,
-// even if each one contains the same elements.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-ref class myCultureComparer : public IEqualityComparer
-{
-public:
- CaseInsensitiveComparer^ myComparer;
-
-public:
- myCultureComparer()
- {
- myComparer = CaseInsensitiveComparer::DefaultInvariant;
- }
-
-public:
- myCultureComparer(CultureInfo^ myCulture)
- {
- myComparer = gcnew CaseInsensitiveComparer(myCulture);
- }
-
-public:
- virtual bool Equals(Object^ x, Object^ y)
- {
- if (myComparer->Compare(x, y) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-public:
- virtual int GetHashCode(Object^ obj)
- {
- // Compare the hash code for the lowercase versions of the strings.
- return obj->ToString()->ToLower()->GetHashCode();
- }
-};
-
-public ref class SamplesHashtable
-{
-
-public:
- static void Main()
- {
-
- // Create the dictionary.
- SortedList^ mySL = gcnew SortedList;
- mySL->Add( "FIRST", "Hello" );
- mySL->Add( "SECOND", "World" );
- mySL->Add( "THIRD", "!" );
-
- // Create a hash table using the default hash code provider and the default comparer.
- Hashtable^ myHT1 = gcnew Hashtable( mySL, .8f );
-
- // Create a hash table using the specified case-insensitive hash code provider and case-insensitive comparer.
- Hashtable^ myHT2 = gcnew Hashtable( mySL, .8f, gcnew myCultureComparer() );
-
- // Create a hash table using the specified KeyComparer.
- // The KeyComparer uses a case-insensitive hash code provider and a case-insensitive comparer,
- // which are based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i".
- CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
- Hashtable^ myHT3 = gcnew Hashtable( mySL, .8f, gcnew myCultureComparer( myCul ) );
-
- // Search for a key in each hash table.
- Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey( "first" ) );
- Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey( "first" ) );
- }
-};
-
-int main()
-{
- SamplesHashtable::Main();
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-first is in myHT1: False
-first is in myHT2: True
-first is in myHT3: False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp
deleted file mode 100644
index 90be7623a99..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-
-// The following code example creates hash tables using different Hashtable constructors
-// and demonstrates the differences in the behavior of the hash tables,
-// even if each one contains the same elements.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-ref class myCultureComparer : public IEqualityComparer
-{
-public:
- CaseInsensitiveComparer^ myComparer;
-
-public:
- myCultureComparer()
- {
- myComparer = CaseInsensitiveComparer::DefaultInvariant;
- }
-
-public:
- myCultureComparer(CultureInfo^ myCulture)
- {
- myComparer = gcnew CaseInsensitiveComparer(myCulture);
- }
-
-public:
- virtual bool Equals(Object^ x, Object^ y)
- {
- if (myComparer->Compare(x, y) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-public:
- virtual int GetHashCode(Object^ obj)
- {
- // Compare the hash code for the lowercase versions of the strings.
- return obj->ToString()->ToLower()->GetHashCode();
- }
-};
-
-public ref class SamplesHashtable
-{
-
-public:
- static void Main()
- {
- // Create a hash table using the default comparer.
- Hashtable^ myHT1 = gcnew Hashtable(3);
- myHT1->Add("FIRST", "Hello");
- myHT1->Add("SECOND", "World");
- myHT1->Add("THIRD", "!");
-
- // Create a hash table using the specified IEqualityComparer that uses
- // the CaseInsensitiveComparer.DefaultInvariant to determine equality.
- Hashtable^ myHT2 = gcnew Hashtable(3, gcnew myCultureComparer());
- myHT2->Add("FIRST", "Hello");
- myHT2->Add("SECOND", "World");
- myHT2->Add("THIRD", "!");
-
- // Create a hash table using an IEqualityComparer that is based on
- // the Turkish culture (tr-TR) where "I" is not the uppercase
- // version of "i".
- CultureInfo^ myCul = gcnew CultureInfo("tr-TR");
- Hashtable^ myHT3 = gcnew Hashtable(3, gcnew myCultureComparer(myCul));
- myHT3->Add("FIRST", "Hello");
- myHT3->Add("SECOND", "World");
- myHT3->Add("THIRD", "!");
-
- // Search for a key in each hash table.
- Console::WriteLine("first is in myHT1: {0}", myHT1->ContainsKey("first"));
- Console::WriteLine("first is in myHT2: {0}", myHT2->ContainsKey("first"));
- Console::WriteLine("first is in myHT3: {0}", myHT3->ContainsKey("first"));
-
- }
-};
-
-int main()
-{
- SamplesHashtable::Main();
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-first is in myHT1: False
-first is in myHT2: True
-first is in myHT3: False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp
deleted file mode 100644
index a55776fd358..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-
-// The following code example creates hash tables using different Hashtable constructors
-// and demonstrates the differences in the behavior of the hash tables,
-// even if each one contains the same elements.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-ref class myCultureComparer : public IEqualityComparer
-{
-public:
- CaseInsensitiveComparer^ myComparer;
-
-public:
- myCultureComparer()
- {
- myComparer = CaseInsensitiveComparer::DefaultInvariant;
- }
-
-public:
- myCultureComparer(CultureInfo^ myCulture)
- {
- myComparer = gcnew CaseInsensitiveComparer(myCulture);
- }
-
-public:
- virtual bool Equals(Object^ x, Object^ y)
- {
- if (myComparer->Compare(x, y) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-public:
- virtual int GetHashCode(Object^ obj)
- {
- // Compare the hash code for the lowercase versions of the strings.
- return obj->ToString()->ToLower()->GetHashCode();
- }
-};
-
-public ref class SamplesHashtable
-{
-
-public:
- static void Main()
- {
- // Create a hash table using the default comparer.
- Hashtable^ myHT1 = gcnew Hashtable(3, .8f);
- myHT1->Add("FIRST", "Hello");
- myHT1->Add("SECOND", "World");
- myHT1->Add("THIRD", "!");
-
- // Create a hash table using the specified IEqualityComparer that uses
- // the CaseInsensitiveComparer.DefaultInvariant to determine equality.
- Hashtable^ myHT2 = gcnew Hashtable(3, .8f, gcnew myCultureComparer());
- myHT2->Add("FIRST", "Hello");
- myHT2->Add("SECOND", "World");
- myHT2->Add("THIRD", "!");
-
- // Create a hash table using an IEqualityComparer that is based on
- // the Turkish culture (tr-TR) where "I" is not the uppercase
- // version of "i".
- CultureInfo^ myCul = gcnew CultureInfo("tr-TR");
- Hashtable^ myHT3 = gcnew Hashtable(3, .8f, gcnew myCultureComparer(myCul));
- myHT3->Add("FIRST", "Hello");
- myHT3->Add("SECOND", "World");
- myHT3->Add("THIRD", "!");
-
- // Search for a key in each hash table.
- Console::WriteLine("first is in myHT1: {0}", myHT1->ContainsKey("first"));
- Console::WriteLine("first is in myHT2: {0}", myHT2->ContainsKey("first"));
- Console::WriteLine("first is in myHT3: {0}", myHT3->ContainsKey("first"));
-
- }
-};
-
-int main()
-{
- SamplesHashtable::Main();
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-first is in myHT1: False
-first is in myHT2: True
-first is in myHT3: False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp
deleted file mode 100644
index f1919addfd6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-
-// The following code example implements the ReadOnlyCollectionBase class.
-//
-using namespace System;
-using namespace System::Collections;
-public ref class ROCollection: public ReadOnlyCollectionBase
-{
-public:
- ROCollection( IList^ sourceList )
- {
- InnerList->AddRange( sourceList );
- }
-
- property Object^ Item [int]
- {
- Object^ get( int index )
- {
- return (InnerList[ index ]);
- }
-
- }
- int IndexOf( Object^ value )
- {
- return (InnerList->IndexOf( value ));
- }
-
- bool Contains( Object^ value )
- {
- return (InnerList->Contains( value ));
- }
-
-};
-
-void PrintIndexAndValues( ROCollection^ myCol );
-void PrintValues2( ROCollection^ myCol );
-int main()
-{
- // Create an ArrayList.
- ArrayList^ myAL = gcnew ArrayList;
- myAL->Add( "red" );
- myAL->Add( "blue" );
- myAL->Add( "yellow" );
- myAL->Add( "green" );
- myAL->Add( "orange" );
- myAL->Add( "purple" );
-
- // Create a new ROCollection that contains the elements in myAL.
- ROCollection^ myCol = gcnew ROCollection( myAL );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Contents of the collection (using enumerator):" );
- PrintValues2( myCol );
-
- // Display the contents of the collection using the Count property and the Item property.
- Console::WriteLine( "Contents of the collection (using Count and Item):" );
- PrintIndexAndValues( myCol );
-
- // Search the collection with Contains and IndexOf.
- Console::WriteLine( "Contains yellow: {0}", myCol->Contains( "yellow" ) );
- Console::WriteLine( "orange is at index {0}.", myCol->IndexOf( "orange" ) );
- Console::WriteLine();
-}
-
-
-// Uses the Count property and the Item property.
-void PrintIndexAndValues( ROCollection^ myCol )
-{
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " [{0}]: {1}", i, myCol->Item[ i ] );
- Console::WriteLine();
-}
-
-
-// Uses the enumerator.
-void PrintValues2( ROCollection^ myCol )
-{
- System::Collections::IEnumerator^ myEnumerator = myCol->GetEnumerator();
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0}", myEnumerator->Current );
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Contents of the collection (using enumerator):
- red
- blue
- yellow
- green
- orange
- purple
-
-Contents of the collection (using Count and Item):
- [0]: red
- [1]: blue
- [2]: yellow
- [3]: green
- [4]: orange
- [5]: purple
-
-Contains yellow: True
-orange is at index 4.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp
deleted file mode 100644
index aea5c5a39cb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-
-// The following code example implements the ReadOnlyCollectionBase class.
-using namespace System;
-using namespace System::Collections;
-using namespace System::Threading;
-
-public ref class ROCollection: public ReadOnlyCollectionBase
-{
-public:
- ROCollection( IList^ sourceList )
- {
- InnerList->AddRange( sourceList );
- }
-
- property Object^ Item [int]
- {
- Object^ get( int index )
- {
- return (InnerList[ index ]);
- }
-
- }
- int IndexOf( Object^ value )
- {
- return (InnerList->IndexOf( value ));
- }
-
- bool Contains( Object^ value )
- {
- return (InnerList->Contains( value ));
- }
-
-};
-
-public ref class SamplesCollectionBase
-{
-public:
- static void Main()
- {
-
- // Create an ArrayList.
- ArrayList^ myAL = gcnew ArrayList();
- myAL->Add( "red" );
- myAL->Add( "blue" );
- myAL->Add( "yellow" );
- myAL->Add( "green" );
- myAL->Add( "orange" );
- myAL->Add( "purple" );
-
- // Create a new ROCollection that contains the elements in myAL.
- ROCollection^ myReadOnlyCollection = gcnew ROCollection( myAL );
-
- //
- // Get the ICollection interface from the ReadOnlyCollectionBase
- // derived class.
- ICollection^ myCollection = myReadOnlyCollection;
- 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()
-{
- SamplesCollectionBase::Main();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp
deleted file mode 100644
index 89c82b72244..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-
-//
-
-// The following code example creates SortedList instances using different constructors
-// and demonstrates the differences in the behavior of the SortedList instances.
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-void PrintKeysAndValues( SortedList^ myList )
-{
- Console::WriteLine( " -KEY- -VALUE-" );
- for ( int i = 0; i < myList->Count; i++ )
- {
- Console::WriteLine( " {0,-6}: {1}", myList->GetKey( i ), myList->GetByIndex( i ) );
-
- }
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Create a SortedList using the default comparer.
- SortedList^ mySL1 = gcnew SortedList;
- Console::WriteLine( "mySL1 (default):" );
- mySL1->Add( "FIRST", "Hello" );
- mySL1->Add( "SECOND", "World" );
- mySL1->Add( "THIRD", "!" );
-
- try { mySL1->Add( "first", "Ola!" ); }
- catch ( ArgumentException^ e ) { Console::WriteLine( e ); }
-
- PrintKeysAndValues( mySL1 );
-
- // Create a SortedList using the specified case-insensitive comparer.
- SortedList^ mySL2 = gcnew SortedList( gcnew CaseInsensitiveComparer );
- Console::WriteLine( "mySL2 (case-insensitive comparer):" );
- mySL2->Add( "FIRST", "Hello" );
- mySL2->Add( "SECOND", "World" );
- mySL2->Add( "THIRD", "!" );
-
- try { mySL2->Add( "first", "Ola!" ); }
- catch ( ArgumentException^ e ) { Console::WriteLine( e ); }
-
- PrintKeysAndValues( mySL2 );
-
- // Create a SortedList using the specified KeyComparer.
- // The KeyComparer uses a case-insensitive hash code provider and a case-insensitive comparer,
- // which are based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i".
- CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
- SortedList^ mySL3 = gcnew SortedList( gcnew CaseInsensitiveComparer( myCul ) );
- Console::WriteLine( "mySL3 (case-insensitive comparer, Turkish culture):" );
- mySL3->Add( "FIRST", "Hello" );
- mySL3->Add( "SECOND", "World" );
- mySL3->Add( "THIRD", "!" );
-
- try { mySL3->Add( "first", "Ola!" ); }
- catch ( ArgumentException^ e ) { Console::WriteLine( e ); }
-
- PrintKeysAndValues( mySL3 );
-
- // Create a SortedList using the ComparisonType.InvariantCultureIgnoreCase value.
- SortedList^ mySL4 = gcnew SortedList( StringComparer::InvariantCultureIgnoreCase );
- Console::WriteLine( "mySL4 (InvariantCultureIgnoreCase):" );
- mySL4->Add( "FIRST", "Hello" );
- mySL4->Add( "SECOND", "World" );
- mySL4->Add( "THIRD", "!" );
-
- try { mySL4->Add( "first", "Ola!" ); }
- catch ( ArgumentException^ e ) { Console::WriteLine( e ); }
-
- PrintKeysAndValues( mySL4 );
-
- Console::WriteLine("\n\nHit ENTER to return");
- Console::ReadLine();
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-mySL1 (default):
- -KEY- -VALUE-
- first : Ola!
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-mySL2 (case-insensitive comparer):
-System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first'
- at System.Collections.SortedList.Add(Object key, Object value)
- at SamplesSortedList.Main()
- -KEY- -VALUE-
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-mySL3 (case-insensitive comparer, Turkish culture):
- -KEY- -VALUE-
- FIRST : Hello
- first : Ola!
- SECOND: World
- THIRD : !
-
-mySL4 (InvariantCultureIgnoreCase):
-System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first'
- at System.Collections.SortedList.Add(Object key, Object value)
- at SamplesSortedList.Main()
- -KEY- -VALUE-
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp
deleted file mode 100644
index 89748fd1f54..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-
-// The following code example creates SortedList instances using different constructors
-// and demonstrates the differences in the behavior of the SortedList instances.
-//
-
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-void PrintKeysAndValues( SortedList^ myList )
-{
- Console::WriteLine( " -KEY- -VALUE-" );
- for ( int i = 0; i < myList->Count; i++ )
- {
- Console::WriteLine( " {0,-6}: {1}", myList->GetKey( i ), myList->GetByIndex( i ) );
-
- }
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Create the dictionary.
- Hashtable^ myHT = gcnew Hashtable;
- myHT->Add( "FIRST", "Hello" );
- myHT->Add( "SECOND", "World" );
- myHT->Add( "THIRD", "!" );
-
- // Create a SortedList using the default comparer.
- SortedList^ mySL1 = gcnew SortedList( myHT );
- Console::WriteLine( "mySL1 (default):" );
- try
- {
- mySL1->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL1 );
-
- // Create a SortedList using the specified case-insensitive comparer.
- SortedList^ mySL2 = gcnew SortedList( myHT,gcnew CaseInsensitiveComparer );
- Console::WriteLine( "mySL2 (case-insensitive comparer):" );
- try
- {
- mySL2->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL2 );
-
- // Create a SortedList using the specified CaseInsensitiveComparer,
- // which is based on the Turkish culture (tr-TR), where "I" is not
- // the uppercase version of "i".
- CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" );
- SortedList^ mySL3 = gcnew SortedList( myHT, gcnew CaseInsensitiveComparer( myCul ) );
- Console::WriteLine( "mySL3 (case-insensitive comparer, Turkish culture):" );
- try
- {
- mySL3->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL3 );
-
- // Create a SortedList using the ComparisonType.InvariantCultureIgnoreCase value.
- SortedList^ mySL4 = gcnew SortedList( myHT, StringComparer::InvariantCultureIgnoreCase );
- Console::WriteLine( "mySL4 (InvariantCultureIgnoreCase):" );
- try
- {
- mySL4->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL4 );
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-mySL1 (default):
- -KEY- -VALUE-
- first : Ola!
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-mySL2 (case-insensitive comparer):
-System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first'
- at System.Collections.SortedList.Add(Object key, Object value)
- at SamplesSortedList.Main()
- -KEY- -VALUE-
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-mySL3 (case-insensitive comparer, Turkish culture):
- -KEY- -VALUE-
- FIRST : Hello
- first : Ola!
- SECOND: World
- THIRD : !
-
-mySL4 (InvariantCultureIgnoreCase):
-System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first'
- at System.Collections.SortedList.Add(Object key, Object value)
- at SamplesSortedList.Main()
- -KEY- -VALUE-
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp
deleted file mode 100644
index 047062c6747..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-// The following code example creates SortedList instances using different constructors
-// and demonstrates the differences in the behavior of the SortedList instances.
-
-
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-void PrintKeysAndValues( SortedList^ myList )
-{
- Console::WriteLine( " Capacity is {0}.", myList->Capacity );
- Console::WriteLine( " -KEY- -VALUE-" );
- for ( int i = 0; i < myList->Count; i++ )
- {
- Console::WriteLine( " {0,-6}: {1}", myList->GetKey( i ), myList->GetByIndex( i ) );
-
- }
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Create a SortedList using the default comparer.
- SortedList^ mySL1 = gcnew SortedList( 3 );
- Console::WriteLine( "mySL1 (default):" );
- mySL1->Add( "FIRST", "Hello" );
- mySL1->Add( "SECOND", "World" );
- mySL1->Add( "THIRD", "!" );
- try
- {
- mySL1->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL1 );
-
- // Create a SortedList using the specified case-insensitive comparer.
- SortedList^ mySL2 = gcnew SortedList( gcnew CaseInsensitiveComparer,3 );
- Console::WriteLine( "mySL2 (case-insensitive comparer):" );
- mySL2->Add( "FIRST", "Hello" );
- mySL2->Add( "SECOND", "World" );
- mySL2->Add( "THIRD", "!" );
- try
- {
- mySL2->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL2 );
-
- // Create a SortedList using the specified CaseInsensitiveComparer,
- // which is based on the Turkish culture (tr-TR), where "I" is not
- // the uppercase version of "i".
- CultureInfo^ myCul = gcnew CultureInfo("tr-TR");
- SortedList^ mySL3 = gcnew SortedList(gcnew CaseInsensitiveComparer(myCul), 3);
-
- Console::WriteLine("mySL3 (case-insensitive comparer, Turkish culture):");
-
- mySL3->Add("FIRST", "Hello");
- mySL3->Add("SECOND", "World");
- mySL3->Add("THIRD", "!");
- try
- {
- mySL3->Add("first", "Ola!");
- }
- catch (ArgumentException^ e)
- {
- Console::WriteLine(e);
- }
- PrintKeysAndValues(mySL3);
-
- // Create a SortedList using the
- // StringComparer.InvariantCultureIgnoreCase value.
- SortedList^ mySL4 = gcnew SortedList( StringComparer::InvariantCultureIgnoreCase, 3 );
- Console::WriteLine( "mySL4 (InvariantCultureIgnoreCase):" );
- mySL4->Add( "FIRST", "Hello" );
- mySL4->Add( "SECOND", "World" );
- mySL4->Add( "THIRD", "!" );
- try
- {
- mySL4->Add( "first", "Ola!" );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- }
-
- PrintKeysAndValues( mySL4 );
-}
-
-/*
-This code produces the following output. Results vary depending on the system's culture settings.
-
-mySL1 (default):
- Capacity is 6.
- -KEY- -VALUE-
- first : Ola!
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-mySL2 (case-insensitive comparer):
-System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first'
- at System.Collections.SortedList.Add(Object key, Object value)
- at SamplesSortedList.Main()
- Capacity is 3.
- -KEY- -VALUE-
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-mySL3 (case-insensitive comparer, Turkish culture):
- Capacity is 6.
- -KEY- -VALUE-
- FIRST : Hello
- first : Ola!
- SECOND: World
- THIRD : !
-
-mySL4 (InvariantCultureIgnoreCase):
-System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first'
- at System.Collections.SortedList.Add(Object key, Object value)
- at SamplesSortedList.Main()
- Capacity is 3.
- -KEY- -VALUE-
- FIRST : Hello
- SECOND: World
- THIRD : !
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.CreateMasks/CPP/bitvector32_createmasks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.CreateMasks/CPP/bitvector32_createmasks.cpp
deleted file mode 100644
index a4aa7596eb9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.CreateMasks/CPP/bitvector32_createmasks.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-// The following code example shows how to create and use masks.
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Specialized;
-int main()
-{
- // Creates and initializes a BitVector32 with all bit flags set to FALSE.
- BitVector32 myBV;
-
- // Creates masks to isolate each of the first five bit flags.
- int myBit1 = BitVector32::CreateMask();
- int myBit2 = BitVector32::CreateMask( myBit1 );
- int myBit3 = BitVector32::CreateMask( myBit2 );
- int myBit4 = BitVector32::CreateMask( myBit3 );
- int myBit5 = BitVector32::CreateMask( myBit4 );
- Console::WriteLine( "Initial: \t {0}", myBV );
-
- // Sets the third bit to TRUE.
- myBV[ myBit3 ] = true;
- Console::WriteLine( "myBit3 = TRUE \t {0}", myBV );
-
- // Combines two masks to access multiple bits at a time.
- myBV[ myBit4 + myBit5 ] = true;
- Console::WriteLine( "myBit4 + myBit5 = TRUE \t {0}", myBV );
- myBV[ myBit1 | myBit2 ] = true;
- Console::WriteLine( "myBit1 | myBit2 = TRUE \t {0}", myBV );
-}
-
-/*
-This code produces the following output.
-
-Initial: BitVector32 {00000000000000000000000000000000}
-myBit3 = TRUE BitVector32 {00000000000000000000000000000100}
-myBit4 + myBit5 = TRUE BitVector32 {00000000000000000000000000011100}
-myBit1 | myBit2 = TRUE BitVector32 {00000000000000000000000000011111}
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp
deleted file mode 100644
index e3796e3bdc3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-// The following code example compares a BitVector32 with another BitVector32 and with an Int32.
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Specialized;
-
-int main()
-{
- // Creates and initializes a BitVector32 with the value 123.
- // This is the BitVector32 that will be compared to different types.
- BitVector32 myBV(123);
-
- // Creates and initializes a new BitVector32 which will be set up as sections.
- BitVector32 myBVsect(0);
-
- // Compares myBV and myBVsect.
- Console::WriteLine( "myBV : {0}", myBV );
- Console::WriteLine( "myBVsect : {0}", myBVsect );
- if ( myBV.Equals( myBVsect ) )
- Console::WriteLine( " myBV( {0}) equals myBVsect( {1}).", myBV.Data, myBVsect.Data );
- else
- Console::WriteLine( " myBV( {0}) does not equal myBVsect( {1}).", myBV.Data, myBVsect.Data );
-
- Console::WriteLine();
-
- // Assigns values to the sections of myBVsect.
- BitVector32::Section mySect1 = BitVector32::CreateSection( 5 );
- BitVector32::Section mySect2 = BitVector32::CreateSection( 1, mySect1 );
- BitVector32::Section mySect3 = BitVector32::CreateSection( 20, mySect2 );
- myBVsect[ mySect1 ] = 3;
- myBVsect[ mySect2 ] = 1;
- myBVsect[ mySect3 ] = 7;
-
- // Compares myBV and myBVsect.
- Console::WriteLine( "myBV : {0}", myBV );
- Console::WriteLine( "myBVsect with values : {0}", myBVsect );
- if ( myBV.Equals( myBVsect ) )
- Console::WriteLine( " myBV( {0}) equals myBVsect( {1}).", myBV.Data, myBVsect.Data );
- else
- Console::WriteLine( " myBV( {0}) does not equal myBVsect( {1}).", myBV.Data, myBVsect.Data );
-
- Console::WriteLine();
-
- // Compare myBV with an Int32.
- Console::WriteLine( "Comparing myBV with an Int32: " );
- Int32 myInt32 = 123;
-
- // Using Equals will fail because Int32 is not compatible with BitVector32.
- if ( myBV.Equals( myInt32 ) )
- Console::WriteLine( " Using BitVector32::Equals, myBV( {0}) equals myInt32( {1}).", myBV.Data, myInt32 );
- else
- Console::WriteLine( " Using BitVector32::Equals, myBV( {0}) does not equal myInt32( {1}).", myBV.Data, myInt32 );
-
- // To compare a BitVector32 with an Int32, use the "==" operator.
- if ( myBV.Data == myInt32 )
- Console::WriteLine( " Using the \"==\" operator, myBV.Data( {0}) equals myInt32( {1}).", myBV.Data, myInt32 );
- else
- Console::WriteLine( " Using the \"==\" operator, myBV.Data( {0}) does not equal myInt32( {1}).", myBV.Data, myInt32 );
-}
-
-/*
-This code produces the following output.
-
-myBV : BitVector32 {00000000000000000000000001111011}
-myBVsect : BitVector32 {00000000000000000000000000000000}
- myBV(123) does not equal myBVsect(0).
-
-myBV : BitVector32 {00000000000000000000000001111011}
-myBVsect with values : BitVector32 {00000000000000000000000001111011}
- myBV(123) equals myBVsect(123).
-
-Comparing myBV with an Int32:
- Using BitVector32::Equals, myBV(123) does not equal myInt32(123).
- Using the "==" operator, myBV.Data(123) equals myInt32(123).
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp
deleted file mode 100644
index 43f50a3e1db..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// The following code example uses a BitVector32 as a collection of bit flags.
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Specialized;
-int main()
-{
-
- // Creates and initializes a BitVector32 with all bit flags set to FALSE.
- BitVector32 myBV(0);
-
- // Creates masks to isolate each of the first five bit flags.
- int myBit1 = BitVector32::CreateMask();
- int myBit2 = BitVector32::CreateMask( myBit1 );
- int myBit3 = BitVector32::CreateMask( myBit2 );
- int myBit4 = BitVector32::CreateMask( myBit3 );
- int myBit5 = BitVector32::CreateMask( myBit4 );
-
- // Sets the alternating bits to TRUE.
- Console::WriteLine( "Setting alternating bits to TRUE:" );
- Console::WriteLine( " Initial: {0}", myBV );
- myBV[ myBit1 ] = true;
- Console::WriteLine( " myBit1 = TRUE: {0}", myBV );
- myBV[ myBit3 ] = true;
- Console::WriteLine( " myBit3 = TRUE: {0}", myBV );
- myBV[ myBit5 ] = true;
- Console::WriteLine( " myBit5 = TRUE: {0}", myBV );
-}
-
-/*
-This code produces the following output.
-
-Setting alternating bits to TRUE:
-Initial: BitVector32 {00000000000000000000000000000000}
-myBit1 = TRUE: BitVector32 {00000000000000000000000000000001}
-myBit3 = TRUE: BitVector32 {00000000000000000000000000000101}
-myBit5 = TRUE: BitVector32 {00000000000000000000000000010101}
-
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp
deleted file mode 100644
index 91d45f3f84b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// The following code example uses a BitVector32 as a collection of sections.
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Specialized;
-
-int main()
-{
- // Creates and initializes a BitVector32.
- BitVector32 myBV(0);
-
- // Creates four sections in the BitVector32 with maximum values 6, 3, 1, and 15.
- // mySect3, which uses exactly one bit, can also be used as a bit flag.
- BitVector32::Section mySect1 = BitVector32::CreateSection( 6 );
- BitVector32::Section mySect2 = BitVector32::CreateSection( 3, mySect1 );
- BitVector32::Section mySect3 = BitVector32::CreateSection( 1, mySect2 );
- BitVector32::Section mySect4 = BitVector32::CreateSection( 15, mySect3 );
-
- // Displays the values of the sections.
- Console::WriteLine( "Initial values:" );
- Console::WriteLine( "\tmySect1: {0}", myBV[ mySect1 ] );
- Console::WriteLine( "\tmySect2: {0}", myBV[ mySect2 ] );
- Console::WriteLine( "\tmySect3: {0}", myBV[ mySect3 ] );
- Console::WriteLine( "\tmySect4: {0}", myBV[ mySect4 ] );
-
- // Sets each section to a new value and displays the value of the BitVector32 at each step.
- Console::WriteLine( "Changing the values of each section:" );
- Console::WriteLine( "\tInitial: \t {0}", myBV );
- myBV[ mySect1 ] = 5;
- Console::WriteLine( "\tmySect1 = 5:\t {0}", myBV );
- myBV[ mySect2 ] = 3;
- Console::WriteLine( "\tmySect2 = 3:\t {0}", myBV );
- myBV[ mySect3 ] = 1;
- Console::WriteLine( "\tmySect3 = 1:\t {0}", myBV );
- myBV[ mySect4 ] = 9;
- Console::WriteLine( "\tmySect4 = 9:\t {0}", myBV );
-
- // Displays the values of the sections.
- Console::WriteLine( "New values:" );
- Console::WriteLine( "\tmySect1: {0}", myBV[ mySect1 ] );
- Console::WriteLine( "\tmySect2: {0}", myBV[ mySect2 ] );
- Console::WriteLine( "\tmySect3: {0}", myBV[ mySect3 ] );
- Console::WriteLine( "\tmySect4: {0}", myBV[ mySect4 ] );
-}
-
-/*
-This code produces the following output.
-
-Initial values:
- mySect1: 0
- mySect2: 0
- mySect3: 0
- mySect4: 0
-Changing the values of each section:
- Initial: BitVector32 {00000000000000000000000000000000}
- mySect1 = 5: BitVector32 {00000000000000000000000000000101}
- mySect2 = 3: BitVector32 {00000000000000000000000000011101}
- mySect3 = 1: BitVector32 {00000000000000000000000000111101}
- mySect4 = 9: BitVector32 {00000000000000000000001001111101}
-New values:
- mySect1: 5
- mySect2: 3
- mySect3: 1
- mySect4: 9
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp
deleted file mode 100644
index f4a12c16ce9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-// The following code example demonstrates several of the properties and methods of HybridDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintKeysAndValues1( IDictionary^ myCol );
-void PrintKeysAndValues2( IDictionary^ myCol );
-void PrintKeysAndValues3( HybridDictionary^ myCol );
-int main()
-{
-
- // Creates and initializes a new HybridDictionary.
- HybridDictionary^ myCol = gcnew HybridDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
- myCol->Add( "Plantain Bananas", "1.49" );
- myCol->Add( "Yellow Bananas", "0.79" );
- myCol->Add( "Strawberries", "3.33" );
- myCol->Add( "Cranberries", "5.98" );
- myCol->Add( "Navel Oranges", "1.29" );
- myCol->Add( "Grapes", "1.99" );
- myCol->Add( "Honeydew Melon", "0.59" );
- myCol->Add( "Seedless Watermelon", "0.49" );
- myCol->Add( "Pineapple", "1.49" );
- myCol->Add( "Nectarine", "1.99" );
- myCol->Add( "Plums", "1.69" );
- myCol->Add( "Peaches", "1.99" );
-
- // Display the contents of the collection using for each. This is the preferred method.
- Console::WriteLine( "Displays the elements using for each:" );
- PrintKeysAndValues1( myCol );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" );
- PrintKeysAndValues2( myCol );
-
- // Display the contents of the collection using the Keys, Values, Count, and Item properties.
- Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
- PrintKeysAndValues3( myCol );
-
- // Copies the HybridDictionary to an array with DictionaryEntry elements.
- array^myArr = gcnew array(myCol->Count);
- myCol->CopyTo( myArr, 0 );
-
- // Displays the values in the array.
- Console::WriteLine( "Displays the elements in the array:" );
- Console::WriteLine( " KEY VALUE" );
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value );
- Console::WriteLine();
-
- // Searches for a key.
- if ( myCol->Contains( "Kiwis" ) )
- Console::WriteLine( "The collection contains the key \"Kiwis\"." );
- else
- Console::WriteLine( "The collection does not contain the key \"Kiwis\"." );
-
- Console::WriteLine();
-
- // Deletes a key.
- myCol->Remove( "Plums" );
- Console::WriteLine( "The collection contains the following elements after removing \"Plums\":" );
- PrintKeysAndValues1( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues1( myCol );
-}
-
-// Uses the for each statement which hides the complexity of the enumerator.
-// NOTE: The for each statement is the preferred way of enumerating the contents of a collection.
-void PrintKeysAndValues1( IDictionary^ myCol ) {
- Console::WriteLine( " KEY VALUE" );
- for each ( DictionaryEntry^ de in myCol )
- Console::WriteLine( " {0,-25} {1}", de->Key, de->Value );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( IDictionary^ myCol )
-{
- IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator();
- Console::WriteLine( " KEY VALUE" );
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value );
-
- Console::WriteLine();
-}
-
-// Uses the Keys, Values, Count, and Item properties.
-void PrintKeysAndValues3( HybridDictionary^ myCol )
-{
- array^myKeys = gcnew array(myCol->Count);
- myCol->Keys->CopyTo( myKeys, 0 );
- Console::WriteLine( " INDEX KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] );
- Console::WriteLine();
-}
-
-/*
-This code produces output similar to the following:
-
-Displays the elements using for each:
- KEY VALUE
- Strawberries 3.33
- Yellow Bananas 0.79
- Cranberries 5.98
- Grapes 1.99
- Granny Smith Apples 0.89
- Seedless Watermelon 0.49
- Honeydew Melon 0.59
- Red Delicious Apples 0.99
- Navel Oranges 1.29
- Fuji Apples 1.29
- Plantain Bananas 1.49
- Gala Apples 1.49
- Pineapple 1.49
- Plums 1.69
- Braeburn Apples 1.49
- Peaches 1.99
- Golden Delicious Apples 1.29
- Nectarine 1.99
-
-Displays the elements using the IDictionaryEnumerator:
- KEY VALUE
- Strawberries 3.33
- Yellow Bananas 0.79
- Cranberries 5.98
- Grapes 1.99
- Granny Smith Apples 0.89
- Seedless Watermelon 0.49
- Honeydew Melon 0.59
- Red Delicious Apples 0.99
- Navel Oranges 1.29
- Fuji Apples 1.29
- Plantain Bananas 1.49
- Gala Apples 1.49
- Pineapple 1.49
- Plums 1.69
- Braeburn Apples 1.49
- Peaches 1.99
- Golden Delicious Apples 1.29
- Nectarine 1.99
-
-Displays the elements using the Keys, Values, Count, and Item properties:
- INDEX KEY VALUE
- 0 Strawberries 3.33
- 1 Yellow Bananas 0.79
- 2 Cranberries 5.98
- 3 Grapes 1.99
- 4 Granny Smith Apples 0.89
- 5 Seedless Watermelon 0.49
- 6 Honeydew Melon 0.59
- 7 Red Delicious Apples 0.99
- 8 Navel Oranges 1.29
- 9 Fuji Apples 1.29
- 10 Plantain Bananas 1.49
- 11 Gala Apples 1.49
- 12 Pineapple 1.49
- 13 Plums 1.69
- 14 Braeburn Apples 1.49
- 15 Peaches 1.99
- 16 Golden Delicious Apples 1.29
- 17 Nectarine 1.99
-
-Displays the elements in the array:
- KEY VALUE
- Strawberries 3.33
- Yellow Bananas 0.79
- Cranberries 5.98
- Grapes 1.99
- Granny Smith Apples 0.89
- Seedless Watermelon 0.49
- Honeydew Melon 0.59
- Red Delicious Apples 0.99
- Navel Oranges 1.29
- Fuji Apples 1.29
- Plantain Bananas 1.49
- Gala Apples 1.49
- Pineapple 1.49
- Plums 1.69
- Braeburn Apples 1.49
- Peaches 1.99
- Golden Delicious Apples 1.29
- Nectarine 1.99
-
-The collection does not contain the key "Kiwis".
-
-The collection contains the following elements after removing "Plums":
- KEY VALUE
- Strawberries 3.33
- Yellow Bananas 0.79
- Cranberries 5.98
- Grapes 1.99
- Granny Smith Apples 0.89
- Seedless Watermelon 0.49
- Honeydew Melon 0.59
- Red Delicious Apples 0.99
- Navel Oranges 1.29
- Fuji Apples 1.29
- Plantain Bananas 1.49
- Gala Apples 1.49
- Pineapple 1.49
- Braeburn Apples 1.49
- Peaches 1.99
- Golden Delicious Apples 1.29
- Nectarine 1.99
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp
deleted file mode 100644
index 5b82c8e92c1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Threading;
-
-public ref class HybridDictSample
-{
-public:
- static void Main()
- {
- // Creates and initializes a new HybridDictionary.
- HybridDictionary^ myHybridDictionary = gcnew HybridDictionary();
-
- //
- for each (DictionaryEntry^ de in myHybridDictionary)
- {
- //...
- }
- //
-
- //
- HybridDictionary^ myCollection = gcnew HybridDictionary();
- 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()
-{
- HybridDictSample::Main();
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp
deleted file mode 100644
index 1afdca2ae97..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-// The following code example adds to and removes elements from a HybridDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( IDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry de = safe_cast(myEnum->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new HybridDictionary.
- HybridDictionary^ myCol = gcnew HybridDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
- myCol->Add( "Plantain Bananas", "1.49" );
- myCol->Add( "Yellow Bananas", "0.79" );
- myCol->Add( "Strawberries", "3.33" );
- myCol->Add( "Cranberries", "5.98" );
- myCol->Add( "Navel Oranges", "1.29" );
- myCol->Add( "Grapes", "1.99" );
- myCol->Add( "Honeydew Melon", "0.59" );
- myCol->Add( "Seedless Watermelon", "0.49" );
- myCol->Add( "Pineapple", "1.49" );
- myCol->Add( "Nectarine", "1.99" );
- myCol->Add( "Plums", "1.69" );
- myCol->Add( "Peaches", "1.99" );
-
- // Displays the values in the HybridDictionary in three different ways.
- Console::WriteLine( "Initial contents of the HybridDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Deletes a key.
- myCol->Remove( "Plums" );
- Console::WriteLine( "The collection contains the following elements after removing \"Plums\":" );
- PrintKeysAndValues( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues( myCol );
-}
-
-/*
-This code produces output similar to the following:
-
-Initial contents of the HybridDictionary:
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Plums 1.69
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-The collection contains the following elements after removing "Plums":
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp
deleted file mode 100644
index 831a5749541..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-// The following code example searches for an element in a HybridDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( IDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry de = safe_cast(myEnum->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new HybridDictionary.
- HybridDictionary^ myCol = gcnew HybridDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
- myCol->Add( "Plantain Bananas", "1.49" );
- myCol->Add( "Yellow Bananas", "0.79" );
- myCol->Add( "Strawberries", "3.33" );
- myCol->Add( "Cranberries", "5.98" );
- myCol->Add( "Navel Oranges", "1.29" );
- myCol->Add( "Grapes", "1.99" );
- myCol->Add( "Honeydew Melon", "0.59" );
- myCol->Add( "Seedless Watermelon", "0.49" );
- myCol->Add( "Pineapple", "1.49" );
- myCol->Add( "Nectarine", "1.99" );
- myCol->Add( "Plums", "1.69" );
- myCol->Add( "Peaches", "1.99" );
-
- // Displays the values in the HybridDictionary in three different ways.
- Console::WriteLine( "Initial contents of the HybridDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Searches for a key.
- if ( myCol->Contains( "Kiwis" ) )
- Console::WriteLine( "The collection contains the key \"Kiwis\"." );
- else
- Console::WriteLine( "The collection does not contain the key \"Kiwis\"." );
-
- Console::WriteLine();
-}
-
-/*
-This code produces output similar to the following:
-
-Initial contents of the HybridDictionary:
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Plums 1.69
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-The collection does not contain the key "Kiwis".
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp
deleted file mode 100644
index b50664695a8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-// The following code example copies the elements of a HybridDictionary to an array.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( IDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry de = safe_cast(myEnum->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new HybridDictionary.
- HybridDictionary^ myCol = gcnew HybridDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
- myCol->Add( "Plantain Bananas", "1.49" );
- myCol->Add( "Yellow Bananas", "0.79" );
- myCol->Add( "Strawberries", "3.33" );
- myCol->Add( "Cranberries", "5.98" );
- myCol->Add( "Navel Oranges", "1.29" );
- myCol->Add( "Grapes", "1.99" );
- myCol->Add( "Honeydew Melon", "0.59" );
- myCol->Add( "Seedless Watermelon", "0.49" );
- myCol->Add( "Pineapple", "1.49" );
- myCol->Add( "Nectarine", "1.99" );
- myCol->Add( "Plums", "1.69" );
- myCol->Add( "Peaches", "1.99" );
-
- // Displays the values in the HybridDictionary in three different ways.
- Console::WriteLine( "Initial contents of the HybridDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Copies the HybridDictionary to an array with DictionaryEntry elements.
- array^myArr = gcnew array(myCol->Count);
- myCol->CopyTo( myArr, 0 );
-
- // Displays the values in the array.
- Console::WriteLine( "Displays the elements in the array:" );
- Console::WriteLine( " KEY VALUE" );
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value );
- Console::WriteLine();
-}
-
-/*
-This code produces output similar to the following:
-
-Initial contents of the HybridDictionary:
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Plums 1.69
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-Displays the elements in the array:
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Plums 1.69
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp
deleted file mode 100644
index 1966022fe36..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-// The following code example enumerates the elements of a HybridDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintKeysAndValues1( IDictionary^ myCol );
-void PrintKeysAndValues2( IDictionary^ myCol );
-void PrintKeysAndValues3( HybridDictionary^ myCol );
-
-int main()
-{
- // Creates and initializes a new HybridDictionary.
- HybridDictionary^ myCol = gcnew HybridDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
- myCol->Add( "Plantain Bananas", "1.49" );
- myCol->Add( "Yellow Bananas", "0.79" );
- myCol->Add( "Strawberries", "3.33" );
- myCol->Add( "Cranberries", "5.98" );
- myCol->Add( "Navel Oranges", "1.29" );
- myCol->Add( "Grapes", "1.99" );
- myCol->Add( "Honeydew Melon", "0.59" );
- myCol->Add( "Seedless Watermelon", "0.49" );
- myCol->Add( "Pineapple", "1.49" );
- myCol->Add( "Nectarine", "1.99" );
- myCol->Add( "Plums", "1.69" );
- myCol->Add( "Peaches", "1.99" );
-
- // Display the contents of the collection using for each. This is the preferred method.
- Console::WriteLine( "Displays the elements using for each:" );
- PrintKeysAndValues1( myCol );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" );
- PrintKeysAndValues2( myCol );
-
- // Display the contents of the collection using the Keys, Values, Count, and Item properties.
- Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
- PrintKeysAndValues3( myCol );
-}
-
-// Uses the foreach statement which hides the complexity of the enumerator.
-// NOTE: The foreach statement is the preferred way of enumerating the contents of a collection.
-void PrintKeysAndValues1( IDictionary^ myCol ) {
- Console::WriteLine( " KEY VALUE" );
- for each ( DictionaryEntry^ de in myCol )
- Console::WriteLine( " {0,-25} {1}", de->Key, de->Value );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( IDictionary^ myCol )
-{
- IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator();
- Console::WriteLine( " KEY VALUE" );
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value );
-
- Console::WriteLine();
-}
-
-// Uses the Keys, Values, Count, and Item properties.
-void PrintKeysAndValues3( HybridDictionary^ myCol )
-{
- array^myKeys = gcnew array(myCol->Count);
- myCol->Keys->CopyTo( myKeys, 0 );
- Console::WriteLine( " INDEX KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] );
- Console::WriteLine();
-}
-
-/*
-This code produces output similar to the following:
-
-Displays the elements using for each:
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Plums 1.69
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-Displays the elements using the IDictionaryEnumerator:
- KEY VALUE
- Seedless Watermelon 0.49
- Nectarine 1.99
- Cranberries 5.98
- Plantain Bananas 1.49
- Honeydew Melon 0.59
- Pineapple 1.49
- Strawberries 3.33
- Grapes 1.99
- Braeburn Apples 1.49
- Peaches 1.99
- Red Delicious Apples 0.99
- Golden Delicious Apples 1.29
- Yellow Bananas 0.79
- Granny Smith Apples 0.89
- Gala Apples 1.49
- Plums 1.69
- Navel Oranges 1.29
- Fuji Apples 1.29
-
-Displays the elements using the Keys, Values, Count, and Item properties:
- INDEX KEY VALUE
- 0 Seedless Watermelon 0.49
- 1 Nectarine 1.99
- 2 Cranberries 5.98
- 3 Plantain Bananas 1.49
- 4 Honeydew Melon 0.59
- 5 Pineapple 1.49
- 6 Strawberries 3.33
- 7 Grapes 1.99
- 8 Braeburn Apples 1.49
- 9 Peaches 1.99
- 10 Red Delicious Apples 0.99
- 11 Golden Delicious Apples 1.29
- 12 Yellow Bananas 0.79
- 13 Granny Smith Apples 0.89
- 14 Gala Apples 1.49
- 15 Plums 1.69
- 16 Navel Oranges 1.29
- 17 Fuji Apples 1.29
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp
deleted file mode 100644
index 641e2daadd9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-//
-
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-//
-public ref class PeopleEnum : IDictionaryEnumerator
-{
-private:
- // Enumerators are positioned before the first element
- // until the first MoveNext() call.
- int position;
- ArrayList^ _people;
-
-public:
- PeopleEnum(ArrayList^ list)
- {
- this->Reset();
- _people = list;
- }
-
- virtual bool MoveNext()
- {
- position++;
- return (position < _people->Count);
- }
-
- virtual void Reset()
- {
- position = -1;
- }
-
- virtual property Object^ Current
- {
- Object^ get()
- {
- try
- {
- return _people[position];
- }
- catch (IndexOutOfRangeException^)
- {
- throw gcnew InvalidOperationException();
- }
- }
- }
-
- virtual property DictionaryEntry Entry
- {
- DictionaryEntry get()
- {
- return (DictionaryEntry)(Current);
- }
- }
-
- virtual property Object^ Key
- {
- Object^ get()
- {
- try
- {
- return ((DictionaryEntry^)_people[position])->Key;
- }
- catch (IndexOutOfRangeException^)
- {
- throw gcnew InvalidOperationException();
- }
- }
- }
-
- virtual property Object^ Value
- {
- Object^ get()
- {
- try
- {
- return ((DictionaryEntry^)_people[position])->Value;
- }
- catch (IndexOutOfRangeException^)
- {
- throw gcnew InvalidOperationException();
- }
- }
- }
-};
-
-public ref class People : IOrderedDictionary
-{
-private:
- ArrayList^ _people;
-
-public:
- People(int numItems)
- {
- _people = gcnew ArrayList(numItems);
- }
-
- int IndexOfKey(Object^ key)
- {
- for (int i = 0; i < _people->Count; i++)
- {
- if (((DictionaryEntry^)_people[i])->Key == key)
- return i;
- }
-
- // key not found, return -1.
- return -1;
- }
-
- virtual property Object^ default[Object^]
- {
- Object^ get(Object^ key)
- {
- return ((DictionaryEntry^)_people[IndexOfKey(key)])->Value;
- }
- void set(Object^ key, Object^ value)
- {
- _people[IndexOfKey(key)] = gcnew DictionaryEntry(key, value);
- }
- }
-
- // IOrderedDictionary Members
- virtual IDictionaryEnumerator^ GetEnumerator()
- {
- return gcnew PeopleEnum(_people);
- }
-
- virtual void Insert(int index, Object^ key, Object^ value)
- {
- if (IndexOfKey(key) != -1)
- {
- throw gcnew ArgumentException("An element with the same key already exists in the collection.");
- }
- _people->Insert(index, gcnew DictionaryEntry(key, value));
- }
-
- virtual void RemoveAt(int index)
- {
- _people->RemoveAt(index);
- }
-
- virtual property Object^ default[int]
- {
- Object^ get(int index)
- {
- return ((DictionaryEntry^)_people[index])->Value;
- }
- void set(int index, Object^ value)
- {
- Object^ key = ((DictionaryEntry^)_people[index])->Key;
- _people[index] = gcnew DictionaryEntry(key, value);
- }
- }
-
- // IDictionary Members
-
- virtual void Add(Object^ key, Object^ value)
- {
- if (IndexOfKey(key) != -1)
- {
- throw gcnew ArgumentException("An element with the same key already exists in the collection.");
- }
- _people->Add(gcnew DictionaryEntry(key, value));
- }
-
- virtual void Clear()
- {
- _people->Clear();
- }
-
- virtual bool Contains(Object^ key)
- {
- if (IndexOfKey(key) == -1)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- virtual property bool IsFixedSize
- {
- bool get()
- {
- return false;
- }
- }
-
- virtual property bool IsReadOnly
- {
- bool get()
- {
- return false;
- }
- }
-
- virtual property ICollection^ Keys
- {
- ICollection^ get()
- {
- ArrayList^ KeyCollection = gcnew ArrayList(_people->Count);
- for (int i = 0; i < _people->Count; i++)
- {
- KeyCollection->Add( ((DictionaryEntry^)_people[i])->Key );
- }
- return KeyCollection;
- }
- }
-
- virtual void Remove(Object^ key)
- {
- _people->RemoveAt(IndexOfKey(key));
- }
-
- virtual property ICollection^ Values
- {
- ICollection ^get()
- {
- ArrayList^ ValueCollection = gcnew ArrayList(_people->Count);
- for (int i = 0; i < _people->Count; i++)
- {
- ValueCollection->Add( ((DictionaryEntry^)_people[i])->Value );
- }
- return ValueCollection;
- }
- }
-
- // ICollection Members
-
- virtual void CopyTo(Array^ array, int index)
- {
- _people->CopyTo(array, index);
- }
-
- virtual property int Count
- {
- int get()
- {
- return _people->Count;
- }
- }
-
- virtual property bool IsSynchronized
- {
- bool get()
- {
- return _people->IsSynchronized;
- }
- }
-
- virtual property Object^ SyncRoot
- {
- Object^ get()
- {
- return _people->SyncRoot;
- }
- }
-
- // IEnumerable Members
-
- virtual IEnumerator^ IfcGetEnumerator() = IEnumerable::GetEnumerator
- {
- return (IEnumerator^) gcnew PeopleEnum(_people);
- }
-};
-//
-
-class App
-{
-public:
- static void Main()
- {
- People^ peopleCollection = gcnew People(3);
- peopleCollection->Add("John", "Smith");
- peopleCollection->Add("Jim", "Johnson");
- peopleCollection->Add("Sue", "Rabon");
-
- Console::WriteLine("Displaying the entries in peopleCollection:");
- for each (DictionaryEntry^ de in peopleCollection)
- {
- Console::WriteLine("{0} {1}", de->Key, de->Value);
- }
- Console::WriteLine();
- Console::WriteLine("Displaying the entries in the modified peopleCollection:");
- peopleCollection["Jim"] = "Jackson";
- peopleCollection->Remove("Sue");
- peopleCollection->Insert(0, "Fred", "Anderson");
-
- for each (DictionaryEntry^ de in peopleCollection)
- {
- Console::WriteLine("{0} {1}", de->Key, de->Value);
- }
-
- }
-};
-
-int main()
-{
- App::Main();
-}
-/* This code produces output similar to the following:
- *
- * Displaying the entries in peopleCollection:
- * John Smith
- * Jim Johnson
- * Sue Rabon
- *
- * Displaying the entries in the modified peopleCollection:
- * Fred Anderson
- * John Smith
- * Jim Jackson
- */
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp
deleted file mode 100644
index 05fe0cdd917..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class ODEnum : IDictionaryEnumerator
-{
-private:
- // Enumerators are positioned before the first element
- // until the first MoveNext() call.
- int position;
- ArrayList^ itemlist;
-
-public:
- ODEnum(ArrayList^ list)
- {
- this->Reset();
- itemlist = list;
- }
-
- virtual bool MoveNext()
- {
- position++;
- return (position < itemlist->Count);
- }
-
- virtual void Reset()
- {
- position = -1;
- }
-
- virtual property Object^ Current
- {
- Object^ get()
- {
- try
- {
- return itemlist[position];
- }
- catch (IndexOutOfRangeException^)
- {
- throw gcnew InvalidOperationException();
- }
- }
- }
-
- virtual property DictionaryEntry Entry
- {
- DictionaryEntry get()
- {
- return (DictionaryEntry)(Current);
- }
- }
-
- virtual property Object^ Key
- {
- Object^ get()
- {
- try
- {
- return ((DictionaryEntry^)itemlist[position])->Key;
- }
- catch (IndexOutOfRangeException^)
- {
- throw gcnew InvalidOperationException();
- }
- }
- }
-
- virtual property Object^ Value
- {
- Object^ get()
- {
- try
- {
- return ((DictionaryEntry^)itemlist[position])->Value;
- }
- catch (IndexOutOfRangeException^)
- {
- throw gcnew InvalidOperationException();
- }
- }
- }
-};
-
-public ref class SimpleOD : IOrderedDictionary
-{
-private:
- ArrayList^ itemlist;
-
-public:
- SimpleOD(int numItems)
- {
- itemlist = gcnew ArrayList(numItems);
- }
-
- int IndexOfKey(Object^ key)
- {
- for (int i = 0; i < itemlist->Count; i++)
- {
- if (((DictionaryEntry^)itemlist[i])->Key == key)
- return i;
- }
-
- // key not found, return -1.
- return -1;
- }
-
- virtual property Object^ default[Object^]
- {
- Object^ get(Object^ key)
- {
- return ((DictionaryEntry^)itemlist[IndexOfKey(key)])->Value;
- }
- void set(Object^ key, Object^ value)
- {
- itemlist[IndexOfKey(key)] = gcnew DictionaryEntry(key, value);
- }
- }
-
- // IOrderedDictionary Members
- virtual IDictionaryEnumerator^ GetEnumerator()
- {
- return gcnew ODEnum(itemlist);
- }
-
- virtual void Insert(int index, Object^ key, Object^ value)
- {
- if (IndexOfKey(key) != -1)
- {
- throw gcnew ArgumentException("An element with the same key already exists in the collection.");
- }
- itemlist->Insert(index, gcnew DictionaryEntry(key, value));
- }
-
- virtual void RemoveAt(int index)
- {
- itemlist->RemoveAt(index);
- }
-
- virtual property Object^ default[int]
- {
- Object^ get(int index)
- {
- return ((DictionaryEntry^)itemlist[index])->Value;
- }
- void set(int index, Object^ value)
- {
- Object^ key = ((DictionaryEntry^)itemlist[index])->Key;
- itemlist[index] = gcnew DictionaryEntry(Keys, value);
- }
- }
-
- // IDictionary Members
-
- virtual void Add(Object^ key, Object^ value)
- {
- if (IndexOfKey(key) != -1)
- {
- throw gcnew ArgumentException("An element with the same key already exists in the collection.");
- }
- itemlist->Add(gcnew DictionaryEntry(key, value));
- }
-
- virtual void Clear()
- {
- itemlist->Clear();
- }
-
- virtual bool Contains(Object^ key)
- {
- if (IndexOfKey(key) == -1)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- virtual property bool IsFixedSize
- {
- bool get()
- {
- return false;
- }
- }
-
- virtual property bool IsReadOnly
- {
- bool get()
- {
- return false;
- }
- }
-
- virtual property ICollection^ Keys
- {
- ICollection^ get()
- {
- ArrayList^ KeyCollection = gcnew ArrayList(itemlist->Count);
- for (int i = 0; i < itemlist->Count; i++)
- {
- KeyCollection[i] = ((DictionaryEntry^)itemlist[i])->Key;
- }
- return KeyCollection;
- }
- }
-
- virtual void Remove(Object^ key)
- {
- itemlist->RemoveAt(IndexOfKey(key));
- }
-
- virtual property ICollection^ Values
- {
- ICollection ^get()
- {
- ArrayList^ ValueCollection = gcnew ArrayList(itemlist->Count);
- for (int i = 0; i < itemlist->Count; i++)
- {
- ValueCollection[i] = ((DictionaryEntry^)itemlist[i])->Value;
- }
- return ValueCollection;
- }
- }
-
- // ICollection Members
-
- virtual void CopyTo(Array^ array, int index)
- {
- itemlist->CopyTo(array, index);
- }
-
- virtual property int Count
- {
- int get()
- {
- return itemlist->Count;
- }
- }
-
- virtual property bool IsSynchronized
- {
- bool get()
- {
- return itemlist->IsSynchronized;
- }
- }
-
- virtual property Object^ SyncRoot
- {
- Object^ get()
- {
- return itemlist->SyncRoot;
- }
- }
-
- // IEnumerable Members
-
- virtual IEnumerator^ IfcGetEnumerator() = IEnumerable::GetEnumerator
- {
- return (IEnumerator^) gcnew ODEnum(itemlist);
- }
-};
-
-class App
-{
-public:
- static void Main()
- {
- int index = 1;
-
- SimpleOD^ myOrderedDictionary = gcnew SimpleOD(2);
- myOrderedDictionary->Add("Way", "ToGo");
- myOrderedDictionary->Add("Far", "Out");
-
- Object^ obj;
- //
- obj = myOrderedDictionary[index];
- //
- //
- for each (DictionaryEntry de in myOrderedDictionary)
- {
- //...
- }
- //
- }
-};
-
-int main()
-{
- App::Main();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp
deleted file mode 100644
index d1760135b98..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-// The following code example demonstrates several of the properties and methods of ListDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintKeysAndValues1( IDictionary^ myCol );
-void PrintKeysAndValues2( IDictionary^ myCol );
-void PrintKeysAndValues3( ListDictionary^ myCol );
-
-int main()
-{
- // Creates and initializes a new ListDictionary.
- ListDictionary^ myCol = gcnew ListDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
-
- // Display the contents of the collection using for each. This is the preferred method.
- Console::WriteLine( "Displays the elements using for each:" );
- PrintKeysAndValues1( myCol );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" );
- PrintKeysAndValues2( myCol );
-
- // Display the contents of the collection using the Keys, Values, Count, and Item properties.
- Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
- PrintKeysAndValues3( myCol );
-
- // Copies the ListDictionary to an array with DictionaryEntry elements.
- array^myArr = gcnew array(myCol->Count);
- myCol->CopyTo( myArr, 0 );
-
- // Displays the values in the array.
- Console::WriteLine( "Displays the elements in the array:" );
- Console::WriteLine( " KEY VALUE" );
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value );
- Console::WriteLine();
-
- // Searches for a key.
- if ( myCol->Contains( "Kiwis" ) )
- Console::WriteLine( "The collection contains the key \"Kiwis\"." );
- else
- Console::WriteLine( "The collection does not contain the key \"Kiwis\"." );
-
- Console::WriteLine();
-
- // Deletes a key.
- myCol->Remove( "Plums" );
- Console::WriteLine( "The collection contains the following elements after removing \"Plums\":" );
- PrintKeysAndValues2( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues2( myCol );
-}
-
-// Uses the for each statement which hides the complexity of the enumerator.
-// NOTE: The for each statement is the preferred way of enumerating the contents of a collection.
-void PrintKeysAndValues1( IDictionary^ myCol ) {
- Console::WriteLine( " KEY VALUE" );
- for each ( DictionaryEntry^ de in myCol )
- Console::WriteLine( " {0,-25} {1}", de->Key, de->Value );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( IDictionary^ myCol )
-{
- IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator();
- Console::WriteLine( " KEY VALUE" );
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value );
- Console::WriteLine();
-}
-
-// Uses the Keys, Values, Count, and Item properties.
-void PrintKeysAndValues3( ListDictionary^ myCol )
-{
- array^myKeys = gcnew array(myCol->Count);
- myCol->Keys->CopyTo( myKeys, 0 );
- Console::WriteLine( " INDEX KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] );
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Displays the elements using for each:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-Displays the elements using the IDictionaryEnumerator:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-Displays the elements using the Keys, Values, Count, and Item properties:
- INDEX KEY VALUE
- 0 Braeburn Apples 1.49
- 1 Fuji Apples 1.29
- 2 Gala Apples 1.49
- 3 Golden Delicious Apples 1.29
- 4 Granny Smith Apples 0.89
- 5 Red Delicious Apples 0.99
-
-Displays the elements in the array:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-The collection does not contain the key "Kiwis".
-
-The collection contains the following elements after removing "Plums":
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp
deleted file mode 100644
index 0f3452dcd52..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Threading;
-
-public ref class SamplesListDictionary
-{
-public:
- static void Main()
- {
- //
- ListDictionary^ myCollection = gcnew ListDictionary();
- 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);
- }
- }
- //
- }
-
- static void Dummy()
- {
- ListDictionary^ myListDictionary = gcnew ListDictionary();
- //
- for each (DictionaryEntry de in myListDictionary)
- {
- //...
- }
- //
- }
-};
-
-int main()
-{
- SamplesListDictionary::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp
deleted file mode 100644
index ef13cdd9540..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-// The following code example adds to and removes elements from a ListDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( IDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry de = safe_cast(myEnum->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new ListDictionary.
- ListDictionary^ myCol = gcnew ListDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
-
- // Displays the values in the ListDictionary in three different ways.
- Console::WriteLine( "Initial contents of the ListDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Deletes a key.
- myCol->Remove( "Gala Apples" );
- Console::WriteLine( "The collection contains the following elements after removing \"Gala Apples\":" );
- PrintKeysAndValues( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues( myCol );
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the ListDictionary:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-The collection contains the following elements after removing "Gala Apples":
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp
deleted file mode 100644
index ba69388921b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-// The following code example searches for an element in a ListDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( IDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry de = safe_cast(myEnum->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new ListDictionary.
- ListDictionary^ myCol = gcnew ListDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
-
- // Displays the values in the ListDictionary in three different ways.
- Console::WriteLine( "Initial contents of the ListDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Searches for a key.
- if ( myCol->Contains( "Kiwis" ) )
- Console::WriteLine( "The collection contains the key \"Kiwis\"." );
- else
- Console::WriteLine( "The collection does not contain the key \"Kiwis\"." );
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the ListDictionary:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-The collection does not contain the key "Kiwis".
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp
deleted file mode 100644
index 772edf629f0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-// The following code example copies the elements of a ListDictionary to an array.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintKeysAndValues( IDictionary^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry de = safe_cast(myEnum->Current);
- Console::WriteLine( " {0,-25} {1}", de.Key, de.Value );
- }
-
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Creates and initializes a new ListDictionary.
- ListDictionary^ myCol = gcnew ListDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
-
- // Displays the values in the ListDictionary in three different ways.
- Console::WriteLine( "Initial contents of the ListDictionary:" );
- PrintKeysAndValues( myCol );
-
- // Copies the ListDictionary to an array with DictionaryEntry elements.
- array^myArr = gcnew array(myCol->Count);
- myCol->CopyTo( myArr, 0 );
-
- // Displays the values in the array.
- Console::WriteLine( "Displays the elements in the array:" );
- Console::WriteLine( " KEY VALUE" );
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value );
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the ListDictionary:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-Displays the elements in the array:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp
deleted file mode 100644
index 2a525d94ac8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-// The following code example enumerates the elements of a ListDictionary.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintKeysAndValues1( IDictionary^ myCol );
-void PrintKeysAndValues2( IDictionary^ myCol );
-void PrintKeysAndValues3( ListDictionary^ myCol );
-
-int main()
-{
- // Creates and initializes a new ListDictionary.
- ListDictionary^ myCol = gcnew ListDictionary;
- myCol->Add( "Braeburn Apples", "1.49" );
- myCol->Add( "Fuji Apples", "1.29" );
- myCol->Add( "Gala Apples", "1.49" );
- myCol->Add( "Golden Delicious Apples", "1.29" );
- myCol->Add( "Granny Smith Apples", "0.89" );
- myCol->Add( "Red Delicious Apples", "0.99" );
-
- // Display the contents of the collection using for each. This is the preferred method.
- Console::WriteLine( "Displays the elements using for each:" );
- PrintKeysAndValues1( myCol );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" );
- PrintKeysAndValues2( myCol );
-
- // Display the contents of the collection using the Keys, Values, Count, and Item properties.
- Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
- PrintKeysAndValues3( myCol );
-}
-
-// Uses the for each statement which hides the complexity of the enumerator.
-// NOTE: The for each statement is the preferred way of enumerating the contents of a collection.
-void PrintKeysAndValues1( IDictionary^ myCol ) {
- Console::WriteLine( " KEY VALUE" );
- for each ( DictionaryEntry^ de in myCol )
- Console::WriteLine( " {0,-25} {1}", de->Key, de->Value );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintKeysAndValues2( IDictionary^ myCol )
-{
- IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator();
- Console::WriteLine( " KEY VALUE" );
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value );
-
- Console::WriteLine();
-}
-
-// Uses the Keys, Values, Count, and Item properties.
-void PrintKeysAndValues3( ListDictionary^ myCol )
-{
- array^myKeys = gcnew array(myCol->Count);
- myCol->Keys->CopyTo( myKeys, 0 );
- Console::WriteLine( " INDEX KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] );
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Displays the elements using for each:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-Displays the elements using the IDictionaryEnumerator:
- KEY VALUE
- Braeburn Apples 1.49
- Fuji Apples 1.29
- Gala Apples 1.49
- Golden Delicious Apples 1.29
- Granny Smith Apples 0.89
- Red Delicious Apples 0.99
-
-Displays the elements using the Keys, Values, Count, and Item properties:
- INDEX KEY VALUE
- 0 Braeburn Apples 1.49
- 1 Fuji Apples 1.29
- 2 Gala Apples 1.49
- 3 Golden Delicious Apples 1.29
- 4 Granny Smith Apples 0.89
- 5 Red Delicious Apples 0.99
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp
deleted file mode 100644
index e3a242ae17f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-// The following example uses BaseAdd to create a new NameObjectCollectionBase with elements from another dictionary.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-public ref class MyCollection: public NameObjectCollectionBase
-{
-private:
- DictionaryEntry _de;
-
-public:
-
- property DictionaryEntry Item [ int ]
- {
- // Gets a key-and-value pair (DictionaryEntry) using an index.
- DictionaryEntry get( int index )
- {
- _de.Key = this->BaseGetKey( index );
- _de.Value = this->BaseGet( index );
- return (_de);
- }
- }
-
- // Adds elements from an IDictionary* into the new collection.
- MyCollection( IDictionary^ d )
- {
- IEnumerator^ myEnum = d->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry^ de = safe_cast(myEnum->Current);
- this->BaseAdd( safe_cast(de->Key), de->Value );
- }
- }
-};
-
-int main()
-{
- // Creates and initializes a new MyCollection instance.
- IDictionary^ d = gcnew ListDictionary;
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myCol = gcnew MyCollection( d );
-
- // Displays the keys and values of the MyCollection instance.
- for ( int i = 0; i < myCol->Count; i++ )
- {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol->Item[ i ].Key, myCol->Item[ i ].Value );
- }
-}
-
-/*
-This code produces the following output.
-
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp
deleted file mode 100644
index 7dfd2cf7f8b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-// The following example uses BaseClear to remove all elements from a NameObjectCollectionBase.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-public ref class MyCollection: public NameObjectCollectionBase
-{
-private:
- DictionaryEntry _de;
-
-public:
-
- property DictionaryEntry Item [ int ]
- {
- // Gets a key-and-value pair (DictionaryEntry) using an index.
- DictionaryEntry get( int index )
- {
- _de.Key = this->BaseGetKey( index );
- _de.Value = this->BaseGet( index );
- return (_de);
- }
- }
-
- // Adds elements from an IDictionary* into the new collection.
- MyCollection( IDictionary^ d )
- {
- IEnumerator^ myEnum = d->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry^ de = safe_cast(myEnum->Current);
- this->BaseAdd( safe_cast(de->Key), de->Value );
- }
- }
-
- // Clears all the elements in the collection.
- void Clear()
- {
- this->BaseClear();
- }
-};
-
-static void PrintKeysAndValues( MyCollection^ myCol )
-{
- for ( int i = 0; i < myCol->Count; i++ )
- {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol->Item[ i ].Key, myCol->Item[ i ].Value );
-
- }
-}
-
-int main()
-{
- // Creates and initializes a new MyCollection instance.
- IDictionary^ d = gcnew ListDictionary;
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myCol = gcnew MyCollection( d );
- Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-
- // Removes all elements from the collection.
- myCol->Clear();
- Console::WriteLine( "After clearing the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-}
-
-/*
-This code produces the following output.
-
-Initial state of the collection (Count = 3):
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-After clearing the collection (Count = 0):
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp
deleted file mode 100644
index d7954215945..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-
-// The following example uses BaseGetKey and BaseGet to get specific keys and values.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
-public:
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get( int index ) {
- _de->Key = this->BaseGetKey( index );
- _de->Value = this->BaseGet( index );
- return( _de );
- }
- }
-
- // Gets or sets the value associated with the specified key.
- property Object^ default[ String^ ] {
- Object^ get(String^ key) {
- return( this->BaseGet( key ) );
- }
- void set( String^ key, Object^ value ) {
- this->BaseSet( key, value );
- }
- }
-
- // Adds elements from an IDictionary into the new collection.
- MyCollection( IDictionary^ d ) {
-
- _de = gcnew DictionaryEntry();
-
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- }
-};
-
-public ref class SamplesNameObjectCollectionBase {
-
-public:
- static void Main() {
-
- // Creates and initializes a new MyCollection instance.
- IDictionary^ d = gcnew ListDictionary();
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myCol = gcnew MyCollection( d );
- Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-
- // Gets specific keys and values.
- Console::WriteLine( "The key at index 0 is {0}.", myCol[0]->Key );
- Console::WriteLine( "The value at index 0 is {0}.", myCol[0]->Value );
- Console::WriteLine( "The value associated with the key \"green\" is {0}.", myCol["green"] );
-
- }
-
- static void PrintKeysAndValues( MyCollection^ myCol ) {
- for ( int i = 0; i < myCol->Count; i++ ) {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
- }
- }
-};
-
-int main()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
-/*
-This code produces the following output.
-
-Initial state of the collection (Count = 3):
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-The key at index 0 is red.
-The value at index 0 is apple.
-The value associated with the key "green" is pear.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp
deleted file mode 100644
index c96322f4cfa..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-// The following example uses BaseGetAllKeys and BaseGetAllValues to get an array of the keys or an array of the values.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
-public:
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get(int index) {
- _de->Key = this->BaseGetKey( index );
- _de->Value = this->BaseGet( index );
- return( _de );
- }
- }
-
- // Adds elements from an IDictionary into the new collection.
- MyCollection( IDictionary^ d ) {
-
- _de = gcnew DictionaryEntry();
-
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- }
-
- // Gets a String array that contains all the keys in the collection.
- property array^ AllKeys {
- array^ get() {
- return( this->BaseGetAllKeys() );
- }
- }
-
- // Gets an Object array that contains all the values in the collection.
- property Array^ AllValues {
- Array^ get() {
- return( this->BaseGetAllValues() );
- }
- }
-
- // Gets a String array that contains all the values in the collection.
- property array^ AllStringValues {
- array^ get() {
- return( (array^) this->BaseGetAllValues( System::String::typeid ) );
- }
- }
-};
-
-public ref class SamplesNameObjectCollectionBase {
-
-public:
- static void Main() {
-
- // Creates and initializes a new MyCollection instance.
- IDictionary^ d = gcnew ListDictionary();
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myCol = gcnew MyCollection( d );
- Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-
- // Displays the list of keys.
- Console::WriteLine( "The list of keys:" );
- for each ( String^ s in myCol->AllKeys ) {
- Console::WriteLine( " {0}", s );
- }
-
- // Displays the list of values of type Object.
- Console::WriteLine( "The list of values (Object):" );
- for each ( Object^ o in myCol->AllValues ) {
- Console::WriteLine( " {0}", o->ToString() );
- }
-
- // Displays the list of values of type String.
- Console::WriteLine( "The list of values (String):" );
- for each ( String^ s in myCol->AllValues ) {
- Console::WriteLine( " {0}", s );
- }
- }
-
-public:
- static void PrintKeysAndValues( MyCollection^ myCol ) {
- for ( int i = 0; i < myCol->Count; i++ ) {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
- }
- }
-};
-
-int main()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
-/*
-This code produces the following output.
-
-Initial state of the collection (Count = 3):
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-The list of keys:
- red
- yellow
- green
-The list of values (Object):
- apple
- banana
- pear
-The list of values (String):
- apple
- banana
- pear
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp
deleted file mode 100644
index 663a6cd5536..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-// The following example uses BaseHasKeys to determine if the collection contains keys that are not a null reference.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
-public:
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get(int index) {
- _de->Key = this->BaseGetKey( index );
- _de->Value = this->BaseGet( index );
- return( _de );
- }
- }
-
- // Creates an empty collection.
- MyCollection() {
- _de = gcnew DictionaryEntry();
- }
-
- // Adds an entry to the collection.
- void Add( String^ key, Object^ value ) {
- this->BaseAdd( key, value );
- }
-
- // Gets a value indicating whether the collection contains keys that are not a null reference.
- property Boolean HasKeys {
- Boolean get() {
- return( this->BaseHasKeys() );
- }
- }
-};
-
-void PrintKeysAndValues( MyCollection^ myCol ) {
- for ( int i = 0; i < myCol->Count; i++ ) {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
- }
-}
-
-int main() {
-
- // Creates an empty MyCollection instance.
- MyCollection^ myCol = gcnew MyCollection();
- Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
- Console::WriteLine( "HasKeys? {0}", myCol->HasKeys );
-
- Console::WriteLine();
-
- // Adds an item to the collection.
- myCol->Add( "blue", "sky" );
- Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
- Console::WriteLine( "HasKeys? {0}", myCol->HasKeys );
-
-}
-
-/*
-This code produces the following output.
-
-Initial state of the collection (Count = 0):
-HasKeys? False
-
-Initial state of the collection (Count = 1):
-[0] : blue, sky
-HasKeys? True
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp
deleted file mode 100644
index de50b6634e1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-// The following example uses BaseRemove and BaseRemoveAt to remove elements from a NameObjectCollectionBase.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
-public:
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get(int index) {
- _de->Key = this->BaseGetKey( index );
- _de->Value = this->BaseGet( index );
- return( _de );
- }
- }
-
- // Adds elements from an IDictionary into the new collection.
- MyCollection( IDictionary^ d ) {
-
- _de = gcnew DictionaryEntry();
-
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- }
-
- // Removes an entry with the specified key from the collection.
- void Remove( String^ key ) {
- this->BaseRemove( key );
- }
-
- // Removes an entry in the specified index from the collection.
- void Remove( int index ) {
- this->BaseRemoveAt( index );
- }
-};
-
-public ref class SamplesNameObjectCollectionBase {
-
-public:
- static void Main() {
-
- // Creates and initializes a new MyCollection instance.
- IDictionary^ d = gcnew ListDictionary();
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myCol = gcnew MyCollection( d );
- Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-
- // Removes an element at a specific index.
- myCol->Remove( 1 );
- Console::WriteLine( "After removing the element at index 1 (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-
- // Removes an element with a specific key.
- myCol->Remove( "red" );
- Console::WriteLine( "After removing the element with the key \"red\" (Count = {0}):", myCol->Count );
- PrintKeysAndValues( myCol );
-
- }
-
- static void PrintKeysAndValues( MyCollection^ myCol ) {
- for ( int i = 0; i < myCol->Count; i++ ) {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
- }
- }
-};
-
-int main()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
-/*
-This code produces the following output.
-
-Initial state of the collection (Count = 3):
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-After removing the element at index 1 (Count = 2):
-[0] : red, apple
-[1] : green, pear
-After removing the element with the key "red" (Count = 1):
-[0] : green, pear
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp
deleted file mode 100644
index e9c37f870ef..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// The following example uses BaseSet to set the value of a specific element.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
- // Gets or sets the value at the specified index.
-public:
- property Object^ default[ int ] {
- Object^ get(int index) {
- return( this->BaseGet( index ) );
- }
- void set( int index, Object^ value ) {
- this->BaseSet( index, value );
- }
- }
-
- // Gets or sets the value associated with the specified key.
- property Object^ default[ String^ ] {
- Object^ get(String^ key) {
- return( this->BaseGet( key ) );
- }
- void set( String^ key, Object^ value ) {
- this->BaseSet( key, value );
- }
- }
-
- // Gets a String array that contains all the keys in the collection.
- property array^ AllKeys {
- array^ get() {
- return( this->BaseGetAllKeys() );
- }
- }
-
- // Adds elements from an IDictionary into the new collection.
- MyCollection( IDictionary^ d ) {
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- }
-
-};
-
-public ref class SamplesNameObjectCollectionBase {
-
-public:
- static void Main() {
-
- // Creates and initializes a new MyCollection instance.
- IDictionary^ d = gcnew ListDictionary();
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myCol = gcnew MyCollection( d );
- Console::WriteLine( "Initial state of the collection:" );
- PrintKeysAndValues2( myCol );
- Console::WriteLine();
-
- // Sets the value at index 1.
- myCol[1] = "sunflower";
- Console::WriteLine( "After setting the value at index 1:" );
- PrintKeysAndValues2( myCol );
- Console::WriteLine();
-
- // Sets the value associated with the key "red".
- myCol["red"] = "tulip";
- Console::WriteLine( "After setting the value associated with the key \"red\":" );
- PrintKeysAndValues2( myCol );
-
- }
-
- static void PrintKeysAndValues2( MyCollection^ myCol ) {
- for each ( String^ s in myCol->AllKeys ) {
- Console::WriteLine( "{0}, {1}", s, myCol[s] );
- }
- }
-};
-
-int main()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
-/*
-This code produces the following output.
-
-Initial state of the collection:
-red, apple
-yellow, banana
-green, pear
-
-After setting the value at index 1:
-red, apple
-yellow, sunflower
-green, pear
-
-After setting the value associated with the key "red":
-red, tulip
-yellow, sunflower
-green, pear
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp
deleted file mode 100644
index c7f2f6f2036..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-// The following example creates a read-only collection.
-// For an expanded version of this example, see the NameObjectCollectionBase class topic.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
-public:
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get( int index ) {
- _de->Key = this->BaseGetKey( index );
- _de->Value = this->BaseGet( index );
- return( _de );
- }
- }
-
- // Adds elements from an IDictionary into the new collection.
- MyCollection( IDictionary^ d, Boolean bReadOnly ) {
-
- _de = gcnew DictionaryEntry();
-
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- this->IsReadOnly = bReadOnly;
- }
-
- // Adds an entry to the collection.
- void Add( String^ key, Object^ value ) {
- this->BaseAdd( key, value );
- }
-};
-
-public ref class SamplesNameObjectCollectionBase {
-
-public:
- static void Main() {
-
- // Creates and initializes a new MyCollection that is read-only.
- IDictionary^ d = gcnew ListDictionary();
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myROCol = gcnew MyCollection( d, true );
-
- // Tries to add a new item.
- try {
- myROCol->Add( "blue", "sky" );
- }
- catch ( NotSupportedException^ e ) {
- Console::WriteLine( e->ToString() );
- }
-
- // Displays the keys and values of the MyCollection.
- Console::WriteLine( "Read-Only Collection:" );
- PrintKeysAndValues( myROCol );
- }
-
- static void PrintKeysAndValues( MyCollection^ myCol ) {
- for ( int i = 0; i < myCol->Count; i++ ) {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
- }
- }
-};
-
-int main()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
-/*
-This code produces the following output.
-
-System.NotSupportedException: Collection is read-only.
- at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
- at SamplesNameObjectCollectionBase.Main()
-Read-Only Collection:
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp
deleted file mode 100644
index 8f68c652453..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-// The following example shows how to implement and use the NameObjectCollectionBase class.
-
-//
-#using
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class MyCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Creates an empty collection.
-public:
- MyCollection() {
- _de = gcnew DictionaryEntry();
- }
-
- // Adds elements from an IDictionary into the new collection.
- MyCollection( IDictionary^ d, Boolean bReadOnly ) {
-
- _de = gcnew DictionaryEntry();
-
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- this->IsReadOnly = bReadOnly;
- }
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get(int index) {
- _de->Key = this->BaseGetKey(index);
- _de->Value = this->BaseGet(index);
- return( _de );
- }
- }
-
- // Gets or sets the value associated with the specified key.
- property Object^ default[ String^ ] {
- Object^ get(String^ key) {
- return( this->BaseGet( key ) );
- }
- void set( String^ key, Object^ value ) {
- this->BaseSet( key, value );
- }
- }
-
- // Gets a String array that contains all the keys in the collection.
- property array^ AllKeys {
- array^ get() {
- return( (array^)this->BaseGetAllKeys() );
- }
- }
-
- // Gets an Object array that contains all the values in the collection.
- property Array^ AllValues {
- Array^ get() {
- return( this->BaseGetAllValues() );
- }
- }
-
- // Gets a String array that contains all the values in the collection.
- property array^ AllStringValues {
- array^ get() {
- return( (array^) this->BaseGetAllValues( String ::typeid ));
- }
- }
-
- // Gets a value indicating if the collection contains keys that are not null.
- property Boolean HasKeys {
- Boolean get() {
- return( this->BaseHasKeys() );
- }
- }
-
- // Adds an entry to the collection.
- void Add( String^ key, Object^ value ) {
- this->BaseAdd( key, value );
- }
-
- // Removes an entry with the specified key from the collection.
- void Remove( String^ key ) {
- this->BaseRemove( key );
- }
-
- // Removes an entry in the specified index from the collection.
- void Remove( int index ) {
- this->BaseRemoveAt( index );
- }
-
- // Clears all the elements in the collection.
- void Clear() {
- this->BaseClear();
- }
-};
-
-public ref class SamplesNameObjectCollectionBase {
-
-public:
- static void Main() {
- // Creates and initializes a new MyCollection that is read-only.
- IDictionary^ d = gcnew ListDictionary();
- d->Add( "red", "apple" );
- d->Add( "yellow", "banana" );
- d->Add( "green", "pear" );
- MyCollection^ myROCol = gcnew MyCollection( d, true );
-
- // Tries to add a new item.
- try {
- myROCol->Add( "blue", "sky" );
- }
- catch ( NotSupportedException^ e ) {
- Console::WriteLine( e->ToString() );
- }
-
- // Displays the keys and values of the MyCollection.
- Console::WriteLine( "Read-Only Collection:" );
- PrintKeysAndValues( myROCol );
-
- // Creates and initializes an empty MyCollection that is writable.
- MyCollection^ myRWCol = gcnew MyCollection();
-
- // Adds new items to the collection.
- myRWCol->Add( "purple", "grape" );
- myRWCol->Add( "orange", "tangerine" );
- myRWCol->Add( "black", "berries" );
- Console::WriteLine( "Writable Collection (after adding values):" );
- PrintKeysAndValues( myRWCol );
-
- // Changes the value of one element.
- myRWCol["orange"] = "grapefruit";
- Console::WriteLine( "Writable Collection (after changing one value):" );
- PrintKeysAndValues( myRWCol );
-
- // Removes one item from the collection.
- myRWCol->Remove( "black" );
- Console::WriteLine( "Writable Collection (after removing one value):" );
- PrintKeysAndValues( myRWCol );
-
- // Removes all elements from the collection.
- myRWCol->Clear();
- Console::WriteLine( "Writable Collection (after clearing the collection):" );
- PrintKeysAndValues( myRWCol );
- }
-
- // Prints the indexes, keys, and values.
- static void PrintKeysAndValues( MyCollection^ myCol ) {
- for ( int i = 0; i < myCol->Count; i++ ) {
- Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
- }
- }
-
- // Prints the keys and values using AllKeys.
- static void PrintKeysAndValues2( MyCollection^ myCol ) {
- for each ( String^ s in myCol->AllKeys ) {
- Console::WriteLine( "{0}, {1}", s, myCol[s] );
- }
- }
-};
-
-int main()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
-/*
-This code produces the following output.
-
-System.NotSupportedException: Collection is read-only.
- at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
- at SamplesNameObjectCollectionBase.Main()
-Read-Only Collection:
-[0] : red, apple
-[1] : yellow, banana
-[2] : green, pear
-Writable Collection (after adding values):
-[0] : purple, grape
-[1] : orange, tangerine
-[2] : black, berries
-Writable Collection (after changing one value):
-[0] : purple, grape
-[1] : orange, grapefruit
-[2] : black, berries
-Writable Collection (after removing one value):
-[0] : purple, grape
-[1] : orange, grapefruit
-Writable Collection (after clearing the collection):
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp
deleted file mode 100644
index 7865c4fe20e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Threading;
-
-public ref class DerivedCollection : public NameObjectCollectionBase {
-
-private:
- DictionaryEntry^ _de;
-
- // Creates an empty collection.
-public:
- DerivedCollection() {
- _de = gcnew DictionaryEntry();
- }
-
- // Adds elements from an IDictionary into the new collection.
- DerivedCollection( IDictionary^ d, Boolean bReadOnly ) {
-
- _de = gcnew DictionaryEntry();
-
- for each ( DictionaryEntry^ de in d ) {
- this->BaseAdd( (String^) de->Key, de->Value );
- }
- this->IsReadOnly = bReadOnly;
- }
-
- // Gets a key-and-value pair (DictionaryEntry) using an index.
- property DictionaryEntry^ default[ int ] {
- DictionaryEntry^ get(int index) {
- _de->Key = this->BaseGetKey(index);
- _de->Value = this->BaseGet(index);
- return( _de );
- }
- }
-
- // Gets or sets the value associated with the specified key.
- property Object^ default[ String^ ] {
- Object^ get(String^ key) {
- return( this->BaseGet( key ) );
- }
- void set( String^ key, Object^ value ) {
- this->BaseSet( key, value );
- }
- }
-
- // Gets a String array that contains all the keys in the collection.
- property array^ AllKeys {
- array^ get() {
- return( (array^)this->BaseGetAllKeys() );
- }
- }
-
- // Gets an Object array that contains all the values in the collection.
- property Array^ AllValues {
- Array^ get() {
- return( this->BaseGetAllValues() );
- }
- }
-
- // Gets a String array that contains all the values in the collection.
- property array^ AllStringValues {
- array^ get() {
- return( (array^) this->BaseGetAllValues( String ::typeid ));
- }
- }
-
- // Gets a value indicating if the collection contains keys that are not null.
- property Boolean HasKeys {
- Boolean get() {
- return( this->BaseHasKeys() );
- }
- }
-
- // Adds an entry to the collection.
- void Add( String^ key, Object^ value ) {
- this->BaseAdd( key, value );
- }
-
- // Removes an entry with the specified key from the collection.
- void Remove( String^ key ) {
- this->BaseRemove( key );
- }
-
- // Removes an entry in the specified index from the collection.
- void Remove( int index ) {
- this->BaseRemoveAt( index );
- }
-
- // Clears all the elements in the collection.
- void Clear() {
- this->BaseClear();
- }
-};
-
-public ref class SamplesNameObjectCollectionBase
-{
-public:
- static void Main()
- {
- //
- // Create a collection derived from NameObjectCollectionBase
- ICollection^ myCollection = gcnew DerivedCollection();
- 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()
-{
- SamplesNameObjectCollectionBase::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp
deleted file mode 100644
index 6d13a5bf9be..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-// The following code example demonstrates several of the properties and methods of NameValueCollection.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintKeysAndValues( NameValueCollection^ myCol );
-void PrintKeysAndValues2( NameValueCollection^ myCol );
-
-int main()
-{
- // Creates and initializes a new NameValueCollection.
- NameValueCollection^ myCol = gcnew NameValueCollection;
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
- myCol->Add( "red", "rouge" );
-
- // Displays the values in the NameValueCollection in two different ways.
- Console::WriteLine( "Displays the elements using the AllKeys property and the Item (indexer) property:" );
- PrintKeysAndValues( myCol );
- Console::WriteLine( "Displays the elements using GetKey and Get:" );
- PrintKeysAndValues2( myCol );
-
- // Gets a value either by index or by key.
- Console::WriteLine( "Index 1 contains the value {0}.", myCol[ 1 ] );
- Console::WriteLine( "Key \"red\" has the value {0}.", myCol[ "red" ] );
- Console::WriteLine();
-
- // Copies the values to a string array and displays the string array.
- array^myStrArr = gcnew array(myCol->Count);
- myCol->CopyTo( myStrArr, 0 );
- Console::WriteLine( "The string array contains:" );
- for each ( String^ s in myStrArr )
- Console::WriteLine( " {0}", s );
- Console::WriteLine();
-
- // Searches for a key and deletes it.
- myCol->Remove( "green" );
- Console::WriteLine( "The collection contains the following elements after removing \"green\":" );
- PrintKeysAndValues( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "The collection contains the following elements after it is cleared:" );
- PrintKeysAndValues( myCol );
-}
-
-void PrintKeysAndValues( NameValueCollection^ myCol )
-{
- Console::WriteLine( " KEY VALUE" );
- for each ( String^ s in myCol->AllKeys )
- Console::WriteLine( " {0,-10} {1}", s, myCol[s] );
- Console::WriteLine();
-}
-
-void PrintKeysAndValues2( NameValueCollection^ myCol )
-{
- Console::WriteLine( " [INDEX] KEY VALUE" );
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " [{0}] {1,-10} {2}", i, myCol->GetKey( i ), myCol->Get( i ) );
- Console::WriteLine();
-}
-
-/*
-
-This code produces the following output.
-
-Displays the elements using the AllKeys property and the Item (indexer) property:
- KEY VALUE
- red rojo,rouge
- green verde
- blue azul
-
-Displays the elements using GetKey and Get:
- [INDEX] KEY VALUE
- [0] red rojo,rouge
- [1] green verde
- [2] blue azul
-
-Index 1 contains the value verde.
-Key "red" has the value rojo,rouge.
-
-The string array contains:
- rojo,rouge
- verde
- azul
-
-The collection contains the following elements after removing "green":
- KEY VALUE
- red rojo,rouge
- blue azul
-
-The collection contains the following elements after it is cleared:
- KEY VALUE
-
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp
deleted file mode 100644
index c59ed515e67..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// The following code example enumerates the elements of a OrderedDictionary.
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class OrderedDictionarySample
-{
-public:
- static void Main()
- {
- //
- // Creates and initializes a OrderedDictionary.
- OrderedDictionary^ myOrderedDictionary = gcnew OrderedDictionary();
- myOrderedDictionary->Add("testKey1", "testValue1");
- myOrderedDictionary->Add("testKey2", "testValue2");
- myOrderedDictionary->Add("keyToDelete", "valueToDelete");
- myOrderedDictionary->Add("testKey3", "testValue3");
-
- ICollection^ keyCollection = myOrderedDictionary->Keys;
- ICollection^ valueCollection = myOrderedDictionary->Values;
-
- // Display the contents using the key and value collections
- DisplayContents(keyCollection, valueCollection, myOrderedDictionary->Count);
- //
-
- //
- // Modifying the OrderedDictionary
- if (!myOrderedDictionary->IsReadOnly)
- {
- // Insert a new key to the beginning of the OrderedDictionary
- myOrderedDictionary->Insert(0, "insertedKey1", "insertedValue1");
-
- // Modify the value of the entry with the key "testKey2"
- myOrderedDictionary["testKey2"] = "modifiedValue";
-
- // Remove the last entry from the OrderedDictionary: "testKey3"
- myOrderedDictionary->RemoveAt(myOrderedDictionary->Count - 1);
-
- // Remove the "keyToDelete" entry, if it exists
- if (myOrderedDictionary->Contains("keyToDelete"))
- {
- myOrderedDictionary->Remove("keyToDelete");
- }
- }
- //
-
- Console::WriteLine(
- "{0}Displaying the entries of a modified OrderedDictionary.",
- Environment::NewLine);
- DisplayContents(keyCollection, valueCollection, myOrderedDictionary->Count);
-
- //
- // Clear the OrderedDictionary and add new values
- myOrderedDictionary->Clear();
- myOrderedDictionary->Add("newKey1", "newValue1");
- myOrderedDictionary->Add("newKey2", "newValue2");
- myOrderedDictionary->Add("newKey3", "newValue3");
-
- // Display the contents of the "new" Dictionary using an enumerator
- IDictionaryEnumerator^ myEnumerator =
- myOrderedDictionary->GetEnumerator();
-
- Console::WriteLine(
- "{0}Displaying the entries of a \"new\" OrderedDictionary.",
- Environment::NewLine);
-
- DisplayEnumerator(myEnumerator);
- //
- }
-
- //
- // Displays the contents of the OrderedDictionary from its keys and values
- static void DisplayContents(
- ICollection^ keyCollection, ICollection^ valueCollection, int dictionarySize)
- {
- array^ myKeys = gcnew array(dictionarySize);
- array^ myValues = gcnew array(dictionarySize);
- keyCollection->CopyTo(myKeys, 0);
- valueCollection->CopyTo(myValues, 0);
-
- // Displays the contents of the OrderedDictionary
- Console::WriteLine(" INDEX KEY VALUE");
- for (int i = 0; i < dictionarySize; i++)
- {
- Console::WriteLine(" {0,-5} {1,-25} {2}",
- i, myKeys[i], myValues[i]);
- }
- Console::WriteLine();
- }
- //
-
- //
- // Displays the contents of the OrderedDictionary using its enumerator
- static void DisplayEnumerator(IDictionaryEnumerator^ myEnumerator)
- {
- Console::WriteLine(" KEY VALUE");
- while (myEnumerator->MoveNext())
- {
- Console::WriteLine(" {0,-25} {1}",
- myEnumerator->Key, myEnumerator->Value);
- }
- }
- //
-};
-
-int main()
-{
- OrderedDictionarySample::Main();
-}
-
-/*
-This code produces the following output.
-
- INDEX KEY VALUE
- 0 testKey1 testValue1
- 1 testKey2 testValue2
- 2 keyToDelete valueToDelete
- 3 testKey3 testValue3
-
-
-Displaying the entries of a modified OrderedDictionary.
- INDEX KEY VALUE
- 0 insertedKey1 insertedValue1
- 1 testKey1 testValue1
- 2 testKey2 modifiedValue
-
-
-Displaying the entries of a "new" OrderedDictionary.
- KEY VALUE
- newKey1 newValue1
- newKey2 newValue2
- newKey3 newValue3
-
-*/
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp
deleted file mode 100644
index 42c6ceb624c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-public ref class OrderedDictionarySample
-{
-public:
- static void Main()
- {
- OrderedDictionary^ myOrderedDictionary = gcnew OrderedDictionary();
- //
- for each (DictionaryEntry de in myOrderedDictionary)
- {
- //...
- }
- //
- }
-};
-
-int main()
-{
- OrderedDictionarySample::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp
deleted file mode 100644
index 427029d212e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-using namespace System::Threading;
-
-public ref class SamplesStringCollection
-{
-public:
- static void Main()
- {
- //
- StringCollection^ myCollection = gcnew StringCollection();
- 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()
-{
- SamplesStringCollection::Main();
-}
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp
deleted file mode 100644
index c05a22e2367..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-// The following code example demonstrates several of the properties and methods of StringCollection.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-
-void PrintValues1( StringCollection^ myCol );
-void PrintValues2( StringCollection^ myCol );
-void PrintValues3( StringCollection^ myCol );
-
-int main()
-{
-
- // Create and initializes a new StringCollection.
- StringCollection^ myCol = gcnew StringCollection;
-
- // Add a range of elements from an array to the end of the StringCollection.
- array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"};
- myCol->AddRange( myArr );
-
- // Display the contents of the collection using for each. This is the preferred method.
- Console::WriteLine( "Displays the elements using for each:" );
- PrintValues1( myCol );
-
- // Display the contents of the collection using the enumerator.
- Console::WriteLine( "Displays the elements using the IEnumerator:" );
- PrintValues2( myCol );
-
- // Display the contents of the collection using the Count and Item properties.
- Console::WriteLine( "Displays the elements using the Count and Item properties:" );
- PrintValues3( myCol );
-
- // Add one element to the end of the StringCollection and insert another at index 3.
- myCol->Add( "* white" );
- myCol->Insert( 3, "* gray" );
- Console::WriteLine( "After adding \"* white\" to the end and inserting \"* gray\" at index 3:" );
- PrintValues1( myCol );
-
- // Remove one element from the StringCollection.
- myCol->Remove( "yellow" );
- Console::WriteLine( "After removing \"yellow\":" );
- PrintValues1( myCol );
-
- // Remove all occurrences of a value from the StringCollection.
- int i = myCol->IndexOf( "RED" );
- while ( i > -1 )
- {
- myCol->RemoveAt( i );
- i = myCol->IndexOf( "RED" );
- }
-
-
- // Verify that all occurrences of "RED" are gone.
- if ( myCol->Contains( "RED" ) )
- Console::WriteLine( "*** The collection still contains \"RED\"." );
-
- Console::WriteLine( "After removing all occurrences of \"RED\":" );
- PrintValues1( myCol );
-
- // Copy the collection to a new array starting at index 0.
- array^myArr2 = gcnew array(myCol->Count);
- myCol->CopyTo( myArr2, 0 );
- Console::WriteLine( "The new array contains:" );
- for ( i = 0; i < myArr2->Length; i++ )
- {
- Console::WriteLine( " [{0}] {1}", i, myArr2[ i ] );
-
- }
- Console::WriteLine();
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "After clearing the collection:" );
- PrintValues1( myCol );
-}
-
-
-// Uses the for each statement which hides the complexity of the enumerator.
-// NOTE: The for each statement is the preferred way of enumerating the contents of a collection.
-void PrintValues1( StringCollection^ myCol ) {
- for each ( Object^ obj in myCol )
- Console::WriteLine( " {0}", obj );
- Console::WriteLine();
-}
-
-// Uses the enumerator.
-void PrintValues2( StringCollection^ myCol )
-{
- StringEnumerator^ myEnumerator = myCol->GetEnumerator();
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( " {0}", myEnumerator->Current );
-
- Console::WriteLine();
-}
-
-
-// Uses the Count and Item properties.
-void PrintValues3( StringCollection^ myCol )
-{
- for ( int i = 0; i < myCol->Count; i++ )
- Console::WriteLine( " {0}", myCol[ i ] );
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Displays the elements using the IEnumerator:
- RED
- orange
- yellow
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-Displays the elements using the Count and Item properties:
- RED
- orange
- yellow
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-After adding "* white" to the end and inserting "* gray" at index 3:
- RED
- orange
- yellow
- * gray
- RED
- green
- blue
- RED
- indigo
- violet
- RED
- * white
-
-After removing "yellow":
- RED
- orange
- * gray
- RED
- green
- blue
- RED
- indigo
- violet
- RED
- * white
-
-After removing all occurrences of "RED":
- orange
- * gray
- green
- blue
- indigo
- violet
- * white
-
-The new array contains:
- [0] orange
- [1] * gray
- [2] green
- [3] blue
- [4] indigo
- [5] violet
- [6] * white
-
-After clearing the collection:
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp
deleted file mode 100644
index 841b997b1e1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-// The following code example adds new elements to the StringCollection.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintValues( IEnumerable^ myCol );
-int main()
-{
-
- // Creates and initializes a new StringCollection.
- StringCollection^ myCol = gcnew StringCollection;
- Console::WriteLine( "Initial contents of the StringCollection:" );
- PrintValues( myCol );
-
- // Adds a range of elements from an array to the end of the StringCollection.
- array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"};
- myCol->AddRange( myArr );
- Console::WriteLine( "After adding a range of elements:" );
- PrintValues( myCol );
-
- // Adds one element to the end of the StringCollection and inserts another at index 3.
- myCol->Add( "* white" );
- myCol->Insert( 3, "* gray" );
- Console::WriteLine( "After adding \"* white\" to the end and inserting \"* gray\" at index 3:" );
- PrintValues( myCol );
-}
-
-void PrintValues( IEnumerable^ myCol )
-{
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ obj = safe_cast(myEnum->Current);
- Console::WriteLine( " {0}", obj );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the StringCollection:
-
-After adding a range of elements:
- RED
- orange
- yellow
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-After adding "* white" to the end and inserting "* gray" at index 3:
- RED
- orange
- yellow
- * gray
- RED
- green
- blue
- RED
- indigo
- violet
- RED
- * white
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp
deleted file mode 100644
index 9d9a32b8e90..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-// The following code example searches the StringCollection for an element.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintValues( IEnumerable^ myCol );
-int main()
-{
-
- // Creates and initializes a new StringCollection.
- StringCollection^ myCol = gcnew StringCollection;
- array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"};
- myCol->AddRange( myArr );
- Console::WriteLine( "Initial contents of the StringCollection:" );
- PrintValues( myCol );
-
- // Checks whether the collection contains "orange" and, if so, displays its index.
- if ( myCol->Contains( "orange" ) )
- Console::WriteLine( "The collection contains \"orange\" at index {0}.", myCol->IndexOf( "orange" ) );
- else
- Console::WriteLine( "The collection does not contain \"orange\"." );
-}
-
-void PrintValues( IEnumerable^ myCol )
-{
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ obj = safe_cast(myEnum->Current);
- Console::WriteLine( " {0}", obj );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the StringCollection:
- RED
- orange
- yellow
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-The collection contains "orange" at index 1.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp
deleted file mode 100644
index f90440e4676..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-// The following code example copies a StringCollection to an array.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintValues( IEnumerable^ myCol );
-int main()
-{
-
- // Creates and initializes a new StringCollection.
- StringCollection^ myCol = gcnew StringCollection;
- array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"};
- myCol->AddRange( myArr );
- Console::WriteLine( "Initial contents of the StringCollection:" );
- PrintValues( myCol );
-
- // Copies the collection to a new array starting at index 0.
- array^myArr2 = gcnew array(myCol->Count);
- myCol->CopyTo( myArr2, 0 );
- Console::WriteLine( "The new array contains:" );
- for ( int i = 0; i < myArr2->Length; i++ )
- {
- Console::WriteLine( " [{0}] {1}", i, myArr2[ i ] );
-
- }
- Console::WriteLine();
-}
-
-void PrintValues( IEnumerable^ myCol )
-{
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ obj = safe_cast(myEnum->Current);
- Console::WriteLine( " {0}", obj );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the StringCollection:
- RED
- orange
- yellow
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-The new array contains:
- [0] RED
- [1] orange
- [2] yellow
- [3] RED
- [4] green
- [5] blue
- [6] RED
- [7] indigo
- [8] violet
- [9] RED
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp
deleted file mode 100644
index 98e049d1393..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-// The following code example removes elements from the StringCollection.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void PrintValues( IEnumerable^ myCol );
-int main()
-{
-
- // Creates and initializes a new StringCollection.
- StringCollection^ myCol = gcnew StringCollection;
- array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"};
- myCol->AddRange( myArr );
- Console::WriteLine( "Initial contents of the StringCollection:" );
- PrintValues( myCol );
-
- // Removes one element from the StringCollection.
- myCol->Remove( "yellow" );
- Console::WriteLine( "After removing \"yellow\":" );
- PrintValues( myCol );
-
- // Removes all occurrences of a value from the StringCollection.
- int i = myCol->IndexOf( "RED" );
- while ( i > -1 )
- {
- myCol->RemoveAt( i );
- i = myCol->IndexOf( "RED" );
- }
-
- Console::WriteLine( "After removing all occurrences of \"RED\":" );
- PrintValues( myCol );
-
- // Clears the entire collection.
- myCol->Clear();
- Console::WriteLine( "After clearing the collection:" );
- PrintValues( myCol );
-}
-
-void PrintValues( IEnumerable^ myCol )
-{
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Object^ obj = safe_cast(myEnum->Current);
- Console::WriteLine( " {0}", obj );
- }
-
- Console::WriteLine();
-}
-
-/*
-This code produces the following output.
-
-Initial contents of the StringCollection:
- RED
- orange
- yellow
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-After removing "yellow":
- RED
- orange
- RED
- green
- blue
- RED
- indigo
- violet
- RED
-
-After removing all occurrences of "RED":
- orange
- green
- blue
- indigo
- violet
-
-After clearing the collection:
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp
deleted file mode 100644
index 5bf34579a7f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-// The following code example shows how a StringDictionary can be copied to an array.
-//
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Collections::Specialized;
-void main()
-{
-
- // Creates and initializes a new StringDictionary.
- StringDictionary^ myCol = gcnew StringDictionary;
- myCol->Add( "red", "rojo" );
- myCol->Add( "green", "verde" );
- myCol->Add( "blue", "azul" );
-
- // Displays the values in the StringDictionary.
- Console::WriteLine( "KEYS\tVALUES in the StringDictionary" );
- IEnumerator^ myEnum = myCol->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry^ myDE = safe_cast(myEnum->Current);
- Console::WriteLine( "{0}\t{1}", myDE->Key, myDE->Value );
- Console::WriteLine();
-
- // Creates an array with DictionaryEntry elements.
- array^myArr = gcnew array(3);
-
- // Copies the StringDictionary to the array.
- myCol->CopyTo( myArr, 0 );
-
- // Displays the values in the array.
- Console::WriteLine( "KEYS\tVALUES in the array" );
- for ( int i = 0; i < myArr->Length; i++ )
- Console::WriteLine( "{0}\t{1}", myArr[ i ].Key, myArr[ i ].Value );
- Console::WriteLine();
- }
-}
-
-/*
-This code produces the following output.
-
-KEYS VALUES in the StringDictionary
-green verde
-red rojo
-blue azul
-
-KEYS VALUES in the array
-green verde
-red rojo
-blue azul
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp
deleted file mode 100644
index c6cea926c77..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-// The following code example demonstrates several of the properties and methods of StringEnumerator.
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Specialized;
-int main()
-{
-
- // Creates and initializes a StringCollection.
- StringCollection^ myCol = gcnew StringCollection;
- array^myArr = {"red","orange","yellow","green","blue","indigo","violet"};
- myCol->AddRange( myArr );
-
- // Enumerates the elements in the StringCollection.
- StringEnumerator^ myEnumerator = myCol->GetEnumerator();
- while ( myEnumerator->MoveNext() )
- Console::WriteLine( "{0}", myEnumerator->Current );
-
- Console::WriteLine();
-
- // Resets the enumerator and displays the first element again.
- myEnumerator->Reset();
- if ( myEnumerator->MoveNext() )
- Console::WriteLine( "The first element is {0}.", myEnumerator->Current );
-}
-
-/*
-This code produces the following output.
-
-red
-orange
-yellow
-green
-blue
-indigo
-violet
-
-The first element is red.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp
deleted file mode 100644
index 5c947137978..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// CorrelationManager.cpp : main project file.
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Collections::Generic;
-using namespace System::Text;
-using namespace System::Diagnostics;
-using namespace System::Threading;
-
-void ThreadProc()
-{
- TraceSource^ ts = gcnew TraceSource("MyApp");
- int i = ts->Listeners->Add(gcnew ConsoleTraceListener());
- ts->Listeners[i]->TraceOutputOptions = TraceOptions::LogicalOperationStack;
- ts->Switch = gcnew SourceSwitch("MyAPP", "Verbose");
- // Add another logical operation.
- Trace::CorrelationManager->StartLogicalOperation("WorkerThread");
-
- ts->TraceEvent(TraceEventType::Error, 1, "Trace an error event.");
- Trace::CorrelationManager->StopLogicalOperation();
-}
-
-void main()
-{
- TraceSource^ ts = gcnew TraceSource("MyApp");
- int i = ts->Listeners->Add(gcnew ConsoleTraceListener());
- ts->Listeners[i]->TraceOutputOptions = TraceOptions::LogicalOperationStack;
- ts->Switch = gcnew SourceSwitch("MyAPP", "Verbose");
- // Start the logical operation on the Main thread.
- Trace::CorrelationManager->StartLogicalOperation("MainThread");
-
- ts->TraceEvent(TraceEventType::Error, 1, "Trace an error event.");
- Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc));
-// Start the worker thread.
- t->Start();
-// Give the worker thread a chance to execute.
- Thread::Sleep(1000);
- Trace::CorrelationManager->StopLogicalOperation();}
-
-
-
-// This sample generates the following output:
-//MyApp Error: 1 : Trace an error event.
-// LogicalOperationStack=MainThread
-//MyApp Error: 1 : Trace an error event.
-// LogicalOperationStack=WorkerThread, MainThread
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp
deleted file mode 100644
index 519ff58fbcd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Diagnostics;
-using namespace System::Reflection;
-
-ref class HashtableDebugView;
-
-//
-[DebuggerDisplay("{value}", Name = "{key}")]
-ref class KeyValuePairs
-{
-private:
- IDictionary^ dictionary;
- Object^ key;
- Object^ value;
-
-public:
- KeyValuePairs(IDictionary^ dictionary, Object^ key, Object^ value)
- {
- this->value = value;
- this->key = key;
- this->dictionary = dictionary;
- }
-};
-//
-
-//
-[DebuggerDisplay("Count = {Count}")]
-//
-[DebuggerTypeProxy(HashtableDebugView::typeid)]
-ref class MyHashtable : Hashtable
-//
-{
-private:
- static const String^ TestString = "This should not appear in the debug window.";
-
-internal:
- ref class HashtableDebugView
- {
- private:
- Hashtable^ hashtable;
- public:
- static const String^ TestString = "This should appear in the debug window.";
- HashtableDebugView(Hashtable^ hashtable)
- {
- this->hashtable = hashtable;
- }
-
- //
- [DebuggerBrowsable(DebuggerBrowsableState::RootHidden)]
- property array^ Keys
- {
- array^ get()
- {
- array^ keys = gcnew array(hashtable->Count);
-
- IEnumerator^ ie = hashtable->Keys->GetEnumerator();
- int i = 0;
- Object^ key;
- while (ie->MoveNext())
- {
- key = ie->Current;
- keys[i] = gcnew KeyValuePairs(hashtable, key, hashtable[key]);
- i++;
- }
- return keys;
- }
- }
- //
- };
-};
-//
-
-public ref class DebugViewTest
-{
-private:
- // The following constant will appear in the debug window for DebugViewTest.
- static const String^ TabString = " ";
-public:
- //
- // The following DebuggerBrowsableAttribute prevents the property following it
- // from appearing in the debug window for the class.
- [DebuggerBrowsable(DebuggerBrowsableState::Never)]
- static String^ y = "Test String";
- //
-
- static void Main()
- {
- MyHashtable^ myHashTable = gcnew MyHashtable();
- myHashTable->Add("one", 1);
- myHashTable->Add("two", 2);
- Console::WriteLine(myHashTable->ToString());
- Console::WriteLine("In Main.");
- }
-};
-
-int main()
-{
- DebugViewTest::Main();
-}
-//
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp
deleted file mode 100644
index 6ac933cf809..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-
-///////////////////////////////////////////////////////////////////////
-//
-// EventSchemaTraceListener.cpp : main project file.
-// Expected Output:
-// 1)
-// EventSchemaTraceListener CPP Sample
-//
-// IsThreadSafe? True
-// BufferSize = 65536
-// MaximumFileSize = 20480000
-// MaximumNumberOfFiles = 2
-// Name = eventListener
-// TraceLogRetentionOption = LimitedCircularFiles
-// TraceOutputOptions = DateTime, Timestamp, ProcessId
-//
-// Press the enter key to exit
-//
-// 2) An output file is created named TraceOutput.xml. It will be
-// opened and displayed in Microsoft Notepad.
-//
-// NOTE 1:
-// Under certain circumstances, the VS C++ compiler will treat
-// Console::WriteLine("MyText = " + MyVar);
-// differently then the VS CSharp compiler.
-// The C++ compiler will produce error C3063, whereas the
-// CSharp compiler accepts the statement.
-// This occurs when the VS C++ compiler cannot determine the
-// datatype of "MyVar" because it is an enumeration type.
-// The solution is:
-// Use either of the following two methods:
-// Console::WriteLine("MyText = {0} " , MyVar);
-// Console::WriteLine("MyText = " + MyVar.ToString());
-//
-// Although not specific to this particular pieces of code,
-// this is demonstrated below in the Display function: The
-// last two members, TraceLogRetentionOption, and
-// TraceOutputOptions, are enumerations, and cannot simply be
-// concatenated into Console::WriteLine.
-//
-///////////////////////////////////////////////////////////////////////
-#using
-#using
-
-#define NOCONFIGFILE 1
-using namespace System;
-using namespace System::IO;
-using namespace System::Diagnostics;
-
-
-[STAThreadAttribute]
-void main()
-{
- Console::WriteLine("EventSchemaTraceListener CPP Sample\n");
-
- File::Delete("TraceOutput.xml");
- TraceSource ^ ts = gcnew TraceSource("TestSource");
-
-
-#if NOCONFIGFILE
- ts->Listeners->Add(gcnew EventSchemaTraceListener("TraceOutput.xml",
- "eventListener", 65536,
- TraceLogRetentionOption::LimitedCircularFiles,
- 20480000, 2));
- ts->Listeners["eventListener"]->TraceOutputOptions =
- TraceOptions::DateTime |
- TraceOptions::ProcessId |
- TraceOptions::Timestamp;
-#endif
-
- EventSchemaTraceListener ^ ESTL =
- (EventSchemaTraceListener^)(ts->Listeners["eventListener"]);
-
-
- Console::WriteLine("IsThreadSafe? = " + ESTL->IsThreadSafe);
- Console::WriteLine("BufferSize = " + ESTL->BufferSize);
- Console::WriteLine("MaximumFileSize = " + ESTL->MaximumFileSize);
- Console::WriteLine("MaximumNumberOfFiles = " + ESTL->MaximumNumberOfFiles);
- Console::WriteLine("Name = " + ESTL->Name);
- Console::WriteLine("TraceLogRetentionOption = " + ESTL->TraceLogRetentionOption.ToString());
- Console::WriteLine("TraceOutputOptions = {0}\n", ESTL->TraceOutputOptions);
-
- ts->Switch->Level = SourceLevels::All;
- String ^ testString = ""
- + ""
- + "11";
-
- UnescapedXmlDiagnosticData ^ unXData = gcnew UnescapedXmlDiagnosticData(testString);
- ts->TraceData(TraceEventType::Error, 38, unXData);
- ts->TraceEvent(TraceEventType::Error, 38, testString);
- ts->Flush();
- ts->Close();
-
- Process::Start("notepad.exe", "TraceOutput.xml");
- Console::WriteLine("\nPress the enter key to exit");
- Console::ReadLine();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp
deleted file mode 100644
index 07d517d64ac..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-//
-// InstanceData_CopyTo.cpp : main project file.
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-
-///////////////////////////////////////////////////////////////////////
-//
-// FORWARD DECLARATIONS
-//
-///////////////////////////////////////////////////////////////////////
-
-// Console Utility Functions:
-void InitConsole(); // Init console size
-void TitleBlock(); // Write the title block
-void CW(String^strText , // Write a colored string
- String^ C = "", int LF = 1);
-
-
-// InstanceData subroutines
-// Display the contents of an InstanceData object.
-void ProcessInstanceDataObject(String^ name, CounterSample CSRef);
-
-// Display the contents of an InstanceDataCollection.
-void ProcessInstanceDataCollection(InstanceDataCollection^ idCol);
-
-
-
-
-///////////////////////////////////////////////////////////////////////
-//
-// MAIN PROGRAM
-//
-///////////////////////////////////////////////////////////////////////
-
-void main()
-{
- InitConsole();
- TitleBlock();
-
- String^ categoryName;
- String^ catNumStr;
- int categoryNum;
-
-
- array^ categories =
- PerformanceCounterCategory::GetCategories();
-
- // Create and sort an array of category names.
- array^ categoryNames = gcnew array(categories->Length);
- int catX;
- for(catX=0; catX < categories->Length; catX++)
- categoryNames[catX] = categories[catX]->CategoryName;
- Array::Sort(categoryNames);
-
- while(1)
- {
- CW("These PerformanceCounterCategory categories are registered \n"
- +"on this computer:","Red");
-
- for(catX=0; catX < categories->Length; catX++)
- Console::WriteLine("{0,4} - {1}", catX+1, categoryNames[catX]);
-
- // Ask the user to choose a category.
- Console::Write("\nEnter a category number from the above list: ");
- catNumStr = Console::ReadLine();
-
- // Validate the entered category number.
- try {
- categoryNum = int::Parse(catNumStr);
- if (categoryNum < 1 || categoryNum > categories->Length)
- throw gcnew Exception(String::Format("The category number "+
- " must be in the range 1..{0}.", categories->Length));
- categoryName = categoryNames[(categoryNum-1)];
-
- // Process the InstanceDataCollectionCollection for this category.
- PerformanceCounterCategory^ pcc =
- gcnew PerformanceCounterCategory(categoryName);
- InstanceDataCollectionCollection^ idColCol = pcc->ReadCategory();
- array^ idColArray =
- gcnew array(idColCol->Count);
-
- CW("\nInstanceDataCollectionCollection for \"" +categoryName+"\" "
- +"has "+idColCol->Count+" elements.","Blue");
-
- idColCol->CopyTo(idColArray, 0);
-
- for each ( InstanceDataCollection ^ idCol in idColArray )
- ProcessInstanceDataCollection(idCol);
- }
- catch(Exception^ ex)
- {
- Console::WriteLine("\"{0}\" is not a valid category number." +
- "\n{1}", catNumStr, ex->Message);
- }
-
- CW("\n\nRun again (Y,N)?","Yellow");
- catNumStr = Console::ReadLine();
- if ("Y" != catNumStr && "y" != catNumStr) break;
- }
-}
-
-
-///////////////////////////////////////////////////////////////////////
-//
-// SUBROUTINES
-//
-///////////////////////////////////////////////////////////////////////
-
-void InitConsole()
-{
- Console::BufferHeight = 4000;
- Console::WindowHeight = 40;
-}
-
-void TitleBlock()
-{
-Console::Title = "InstDataCopyTo.cpp Sample";
-
-CW(
- "///////////////////////////////////////////////////////////////////\n"
-+"//\n"
-+"// PROGRAM instdatacopyto.cpp\n"
-+"// PURPOSE Show how to use InstanceData objects\n"
-+"// OUTPUT 1) Displays a numbered list of PerformanceCounter\n"
-+"// categories that exist on the local computer.\n"
-+"// 2) Prompts the user to select a category.\n"
-+"// 3) Displays the instance data associated with each\n"
-+"// instance of the PerformanceCounter in the\n"
-+"// selected PerformanceCounterCategory\n"
-+"//\n"
-+ "///////////////////////////////////////////////////////////////////\n"
-,"Yellow");
-}
-
-
-// Utility function: ConsoleWrite: Write a colored string
-void CW(String^ strText , String^ C, int LF)
-{
- if (C != "") Console::ForegroundColor = *dynamic_cast
- (Enum::Parse(ConsoleColor::typeid, C));
- Console::Write(strText);
- Console::ResetColor();
- Console::Write("\n{0}",LF?"\n":"");
-}
-
-// Display the contents of an InstanceDataCollection.
-void ProcessInstanceDataCollection(InstanceDataCollection ^ idCol)
-{
- array^ instDataArray = gcnew array(idCol->Count);
-
- CW("\n InstanceDataCollection for \""
- + idCol->CounterName + "\" has " + idCol->Count + " elements.", "Red");
-
- // Copy and process the InstanceData array.
- idCol->CopyTo(instDataArray, 0);
-
- int idX;
- for(idX=0; idX < instDataArray->Length; idX++)
- ProcessInstanceDataObject(instDataArray[idX]->InstanceName,
- instDataArray[idX]->Sample);
-}
-
-
-// Display the contents of an InstanceData object.
-void ProcessInstanceDataObject(String ^ name, CounterSample CSRef)
-{
- InstanceData ^ instData = gcnew InstanceData(name, CSRef);
- CW(" Data from InstanceData object:","Red",0);
-
- CW(" InstanceName: "+instData->InstanceName,"Green",0);
- CW(" RawValue: " + instData->RawValue);
-
- CounterSample sample = instData->Sample;
- Console::Write(" Data from CounterSample object:\n" +
- " CounterType: {0,-27} SystemFrequency: {1}\n" +
- " BaseValue: {2,-27} RawValue: {3}\n" +
- " CounterFrequency: {4,-27} CounterTimeStamp: {5}\n" +
- " TimeStamp: {6,-27} TimeStamp100nSec: {7}\n\n",
- sample.CounterType, sample.SystemFrequency, sample.BaseValue,
- sample.RawValue, sample.CounterFrequency, sample.CounterTimeStamp,
- sample.TimeStamp, sample.TimeStamp100nSec);
-}
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp
deleted file mode 100644
index 63ae0eabe00..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-ref class PerfCounterCatGetCountMod
-{
- //
-public:
- static void Main(array^ args)
- {
- String^ categoryName = "";
- String^ machineName = "";
- String^ instanceName = "";
- PerformanceCounterCategory^ pcc;
- array^ counters;
-
- // Copy the supplied arguments into the local variables.
- try
- {
- categoryName = args[1];
- machineName = args[2]=="."? "": args[2];
- instanceName = args[3];
- }
- catch (...)
- {
- // Ignore the exception from non-supplied arguments.
- }
-
- try
- {
- // Create the appropriate PerformanceCounterCategory object.
- if (machineName->Length>0)
- {
- pcc = gcnew PerformanceCounterCategory(categoryName, machineName);
- }
- else
- {
- pcc = gcnew PerformanceCounterCategory(categoryName);
- }
-
- // Get the counters for this instance or a single instance
- // of the selected category.
- if (instanceName->Length > 0)
- {
- counters = pcc->GetCounters(instanceName);
- }
- else
- {
- counters = pcc->GetCounters();
- }
-
- }
- catch (Exception^ ex)
- {
- Console::WriteLine("Unable to get counter information for " +
- (instanceName->Length>0? "instance \"{2}\" in ": "single-instance ") +
- "category \"{0}\" on " + (machineName->Length>0? "computer \"{1}\":": "this computer:"),
- categoryName, machineName, instanceName);
- Console::WriteLine(ex->Message);
- return;
- }
-
- // Display the counter names if GetCounters was successful.
- if (counters != nullptr)
- {
- Console::WriteLine("These counters exist in " +
- (instanceName->Length > 0 ? "instance \"{1}\" of" : "single instance") +
- " category {0} on " + (machineName->Length > 0 ? "computer \"{2}\":": "this computer:"),
- categoryName, instanceName, machineName);
-
- // Display a numbered list of the counter names.
- int objX;
- for(objX = 0; objX < counters->Length; objX++)
- {
- Console::WriteLine("{0,4} - {1}", objX + 1, counters[objX]->CounterName);
- }
- }
- }
- //
-};
-
-int main()
-{
- PerfCounterCatGetCountMod::Main(Environment::GetCommandLineArgs());
-}
-//
-
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp
deleted file mode 100644
index 3a2934fc5ec..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-ref class PerfCounterCatGetInstMod
-{
- //
-public:
- static void Main(array^ args)
- {
- String^ categoryName = "";
- String^ machineName = "";
- PerformanceCounterCategory^ pcc;
- array^ instances;
-
- // Copy the supplied arguments into the local variables.
- try
- {
- categoryName = args[1];
- machineName = args[2]=="."? "": args[2];
- }
- catch (...)
- {
- // Ignore the exception from non-supplied arguments.
- }
-
- try
- {
- // Create the appropriate PerformanceCounterCategory object.
- if (machineName->Length > 0)
- {
- pcc = gcnew PerformanceCounterCategory(categoryName, machineName);
- }
- else
- {
- pcc = gcnew PerformanceCounterCategory(categoryName);
- }
-
- // Get the instances associated with this category.
- instances = pcc->GetInstanceNames();
-
- }
- catch (Exception^ ex)
- {
- Console::WriteLine("Unable to get instance information for " +
- "category \"{0}\" on " +
- (machineName->Length>0? "computer \"{1}\":": "this computer:"),
- categoryName, machineName);
- Console::WriteLine(ex->Message);
- return;
- }
-
- //If an empty array is returned, the category has a single instance.
- if (instances->Length==0)
- {
- Console::WriteLine("Category \"{0}\" on " +
- (machineName->Length>0? "computer \"{1}\"": "this computer") +
- " is single-instance.", pcc->CategoryName, pcc->MachineName);
- }
- else
- {
- // Otherwise, display the instances.
- Console::WriteLine("These instances exist in category \"{0}\" on " +
- (machineName->Length>0? "computer \"{1}\".": "this computer:"),
- pcc->CategoryName, pcc->MachineName);
-
- Array::Sort(instances);
- int objX;
- for (objX = 0; objX < instances->Length; objX++)
- {
- Console::WriteLine("{0,4} - {1}", objX+1, instances[objX]);
- }
- }
- }
- //
-};
-
-int main()
-{
- PerfCounterCatGetInstMod::Main(Environment::GetCommandLineArgs());
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp
deleted file mode 100644
index 598438b1a46..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Diagnostics;
-
-ref class PerfCounterCatGetCatMod
-{
- //
-public:
- static void Main(array^ args)
- {
- String^ machineName = "";
- array^ categories;
-
- // Copy the machine name argument into the local variable.
- try
- {
- machineName = args[1]=="."? "": args[1];
- }
- catch (...)
- {
- }
-
- // Generate a list of categories registered on the specified computer.
- try
- {
- if (machineName->Length > 0)
- {
- categories = PerformanceCounterCategory::GetCategories(machineName);
- }
- else
- {
- categories = PerformanceCounterCategory::GetCategories();
- }
- }
- catch(Exception^ ex)
- {
- Console::WriteLine("Unable to get categories on " +
- (machineName->Length > 0 ? "computer \"{0}\":": "this computer:"), machineName);
- Console::WriteLine(ex->Message);
- return;
- }
-
- Console::WriteLine("These categories are registered on " +
- (machineName->Length > 0 ? "computer \"{0}\":": "this computer:"), machineName);
-
- // Create and sort an array of category names.
- array^ categoryNames = gcnew array(categories->Length);
- int objX;
- for (objX = 0; objX < categories->Length; objX++)
- {
- categoryNames[objX] = categories[objX]->CategoryName;
- }
- Array::Sort(categoryNames);
-
- for (objX = 0; objX < categories->Length; objX++)
- {
- Console::WriteLine("{0,4} - {1}", objX + 1, categoryNames[objX]);
- }
- }
- //
-};
-
-int main()
-{
- PerfCounterCatGetCatMod::Main(Environment::GetCommandLineArgs());
-}
-//
-
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp
deleted file mode 100644
index 43756bed5b8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-//
-/////////////////////////////////////////////////////////////////////////////////
-//
-// NAME TraceSource2.cpp : main project file
-//
-/////////////////////////////////////////////////////////////////////////////////
-
-
-
-// The following configuration file can be used with this sample.
-// When using a configuration file #define ConfigFile.
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-
-#define TRACE
-//#define ConfigFile
-
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Diagnostics;
-using namespace System::Reflection;
-using namespace System::IO;
-using namespace System::Security::Permissions;
-
-void DisplayProperties(TraceSource^ ts); // Forward Declaration
-
-
-int main()
-{
- TraceSource^ ts = gcnew TraceSource("TraceTest");
-
- try
- {
- // Initialize trace switches.
-#if(!ConfigFile)
- SourceSwitch^ sourceSwitch = gcnew SourceSwitch("SourceSwitch", "Verbose");
- ts->Switch = sourceSwitch;
- int idxConsole = ts->Listeners->Add(gcnew System::Diagnostics::ConsoleTraceListener());
- ts->Listeners[idxConsole]->Name = "console";
-#endif
- DisplayProperties(ts);
- ts->Listeners["console"]->TraceOutputOptions |= TraceOptions::Callstack;
- ts->TraceEvent(TraceEventType::Warning, 1);
- ts->Listeners["console"]->TraceOutputOptions = TraceOptions::DateTime;
- // Issue file not found message as a warning.
- ts->TraceEvent(TraceEventType::Warning, 2, "File Test not found");
- // Issue file not found message as a verbose event using a formatted string.
- ts->TraceEvent(TraceEventType::Verbose, 3, "File {0} not found.", "test");
- // Issue file not found message as information.
- ts->TraceInformation("File {0} not found.", "test");
- ts->Listeners["console"]->TraceOutputOptions |= TraceOptions::LogicalOperationStack;
- // Issue file not found message as an error event.
- ts->TraceEvent(TraceEventType::Error, 4, "File {0} not found.", "test");
-
- // Test the filter on the ConsoleTraceListener.
- ts->Listeners["console"]->Filter = gcnew SourceFilter("No match");
- ts->TraceData(TraceEventType::Error, 5,
- "SourceFilter should reject this message for the console trace listener.");
- ts->Listeners["console"]->Filter = gcnew SourceFilter("TraceTest");
- ts->TraceData(TraceEventType::Error, 6,
- "SourceFilter should let this message through on the console trace listener.");
- ts->Listeners["console"]->Filter = nullptr;
-
- // Use the TraceData method.
- ts->TraceData(TraceEventType::Warning, 7, gcnew array{ "Message 1", "Message 2" });
-
- // Activity tests.
- ts->TraceEvent(TraceEventType::Start, 9, "Will not appear until the switch is changed.");
- ts->Switch->Level = SourceLevels::ActivityTracing | SourceLevels::Critical;
- ts->TraceEvent(TraceEventType::Suspend, 10, "Switch includes ActivityTracing, this should appear");
- ts->TraceEvent(TraceEventType::Critical, 11, "Switch includes Critical, this should appear");
- ts->Flush();
- ts->Close();
- Console::WriteLine("Press enter key to exit.");
- Console::Read();
- }
- catch (Exception ^e)
- {
- // Catch any unexpected exception.
- Console::WriteLine("Unexpected exception: " + e->ToString());
- Console::Read();
- }
-}
-
-
-void DisplayProperties(TraceSource^ ts)
-{
- Console::WriteLine("TraceSource name = " + ts->Name);
-// Console::WriteLine("TraceSource switch level = " + ts->Switch->Level); // error C3063: operator '+': all operands must have the same enumeration type
- Console::WriteLine("TraceSource switch level = {0}", ts->Switch->Level); // SUCCESS: does compile. Weird
- Console::WriteLine("TraceSource Attributes Count " + ts->Attributes->Count); // SUCCESS: also compiles. Really weird
- Console::WriteLine("TraceSource Attributes Count = {0}", ts->Attributes->Count); // SUCCESS: okay, I give up. Somebody call me a cab.
-
- Console::WriteLine("TraceSource switch = " + ts->Switch->DisplayName);
- array^ switches = SwitchAttribute::GetAll(TraceSource::typeid->Assembly);
-
- for (int i = 0; i < switches->Length; i++)
- {
- Console::WriteLine("Switch name = " + switches[i]->SwitchName);
- Console::WriteLine("Switch type = " + switches[i]->SwitchType);
- }
-
-#if(ConfigFile)
- // Get the custom attributes for the TraceSource.
- Console::WriteLine("Number of custom trace source attributes = "
- + ts.Attributes.Count);
- foreach (DictionaryEntry de in ts.Attributes)
- Console::WriteLine("Custom trace source attribute = "
- + de.Key + " " + de.Value);
- // Get the custom attributes for the trace source switch.
- foreach (DictionaryEntry de in ts.Switch.Attributes)
- Console::WriteLine("Custom switch attribute = "
- + de.Key + " " + de.Value);
-#endif
- Console::WriteLine("Number of listeners = " + ts->Listeners->Count);
- for each (TraceListener ^ traceListener in ts->Listeners)
- {
- Console::Write("TraceListener: " + traceListener->Name + "\t");
- // The following output can be used to update the configuration file.
- Console::WriteLine("AssemblyQualifiedName = " +
- (traceListener->GetType()->AssemblyQualifiedName));
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp
deleted file mode 100644
index 4e3179203c5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-// The following code example shows how the result of GetWeekOfYear varies depending on the
-// FirstDayOfWeek and the CalendarWeekRule used.
-// If the specified date is the last day of the year, GetWeekOfYear returns the total number of weeks in that year.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Gets the Calendar instance associated with a CultureInfo.
- CultureInfo^ myCI = gcnew CultureInfo( "en-US" );
- Calendar^ myCal = myCI->Calendar;
-
- // Gets the DTFI properties required by GetWeekOfYear.
- CalendarWeekRule myCWR = myCI->DateTimeFormat->CalendarWeekRule;
- DayOfWeek myFirstDOW = myCI->DateTimeFormat->FirstDayOfWeek;
-
- // Displays the number of the current week relative to the beginning of the year.
- Console::WriteLine( "The CalendarWeekRule used for the en-US culture is {0}.", myCWR );
- Console::WriteLine( "The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW );
- Console::WriteLine( "Therefore, the current week is Week {0} of the current year.", myCal->GetWeekOfYear( DateTime::Now, myCWR, myFirstDOW ) );
-
- // Displays the total number of weeks in the current year.
- DateTime LastDay = System::DateTime( DateTime::Now.Year, 12, 31 );
- Console::WriteLine( "There are {0} weeks in the current year ( {1}).", myCal->GetWeekOfYear( LastDay, myCWR, myFirstDOW ), LastDay.Year );
-}
-
-/*
-This code produces the following output. Results vary depending on the system date.
-
-The CalendarWeekRule used for the en-US culture is FirstDay.
-The FirstDayOfWeek used for the en-US culture is Sunday.
-Therefore, the current week is Week 1 of the current year.
-There are 53 weeks in the current year (2001).
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp
deleted file mode 100644
index 0df7a5a06b3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-
-// The following code example demonstrates the members of the Calendar class.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine( " Hour: {0}", myCal->GetHour( myDT ) );
- Console::WriteLine( " Minute: {0}", myCal->GetMinute( myDT ) );
- Console::WriteLine( " Second: {0}", myCal->GetSecond( myDT ) );
- Console::WriteLine( " Milliseconds: {0}", myCal->GetMilliseconds( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Uses the default calendar of the InvariantCulture.
- Calendar^ myCal = CultureInfo::InvariantCulture->Calendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds 5 to every component of the DateTime.
- myDT = myCal->AddYears( myDT, 5 );
- myDT = myCal->AddMonths( myDT, 5 );
- myDT = myCal->AddWeeks( myDT, 5 );
- myDT = myCal->AddDays( myDT, 5 );
- myDT = myCal->AddHours( myDT, 5 );
- myDT = myCal->AddMinutes( myDT, 5 );
- myDT = myCal->AddSeconds( myDT, 5 );
- myDT = myCal->AddMilliseconds( myDT, 5 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding 5 to each component of the DateTime:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar:
-Era: 1
-Year: 2002
-Month: 4
-DayOfYear: 93
-DayOfMonth: 3
-DayOfWeek: Wednesday
-Hour: 0
-Minute: 0
-Second: 0
-Milliseconds: 0
-
-After adding 5 to each component of the DateTime:
-Era: 1
-Year: 2007
-Month: 10
-DayOfYear: 286
-DayOfMonth: 13
-DayOfWeek: Saturday
-Hour: 5
-Minute: 5
-Second: 5
-Milliseconds: 5
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp
deleted file mode 100644
index 865e7a9526e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-
-// The following code example compares different implementations of the Calendar class.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates an instance of every Calendar type.
- array^myCals = gcnew array(8);
- myCals[ 0 ] = gcnew GregorianCalendar;
- myCals[ 1 ] = gcnew HebrewCalendar;
- myCals[ 2 ] = gcnew HijriCalendar;
- myCals[ 3 ] = gcnew JapaneseCalendar;
- myCals[ 4 ] = gcnew JulianCalendar;
- myCals[ 5 ] = gcnew KoreanCalendar;
- myCals[ 6 ] = gcnew TaiwanCalendar;
- myCals[ 7 ] = gcnew ThaiBuddhistCalendar;
-
- // For each calendar, displays the current year, the number of months in that year,
- // and the number of days in each month of that year.
- int i;
- int j;
- int iYear;
- int iMonth;
- int iDay;
- DateTime myDT = DateTime::Today;
- for ( i = 0; i < myCals->Length; i++ )
- {
- iYear = myCals[ i ]->GetYear( myDT );
- Console::WriteLine();
- Console::WriteLine( " {0}, Year: {1}", myCals[ i ]->GetType(), myCals[ i ]->GetYear( myDT ) );
- Console::WriteLine( " MonthsInYear: {0}", myCals[ i ]->GetMonthsInYear( iYear ) );
- Console::WriteLine( " DaysInYear: {0}", myCals[ i ]->GetDaysInYear( iYear ) );
- Console::WriteLine( " Days in each month:" );
- Console::Write( " " );
- for ( j = 1; j <= myCals[ i ]->GetMonthsInYear( iYear ); j++ )
- Console::Write( " {0, -5}", myCals[ i ]->GetDaysInMonth( iYear, j ) );
- Console::WriteLine();
- iMonth = myCals[ i ]->GetMonth( myDT );
- iDay = myCals[ i ]->GetDayOfMonth( myDT );
- Console::WriteLine( " IsLeapDay: {0}", myCals[ i ]->IsLeapDay( iYear, iMonth, iDay ) );
- Console::WriteLine( " IsLeapMonth: {0}", myCals[ i ]->IsLeapMonth( iYear, iMonth ) );
- Console::WriteLine( " IsLeapYear: {0}", myCals[ i ]->IsLeapYear( iYear ) );
-
- }
-}
-
-/*
-This code produces the following output. The results vary depending on the date.
-
-System::Globalization::GregorianCalendar, Year: 2002
-MonthsInYear: 12
-DaysInYear: 365
-Days in each month:
-31 28 31 30 31 30 31 31 30 31 30 31
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: False
-
-System::Globalization::HebrewCalendar, Year: 5763
-MonthsInYear: 13
-DaysInYear: 385
-Days in each month:
-30 30 30 29 30 30 29 30 29 30 29 30 29
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: True
-
-System::Globalization::HijriCalendar, Year: 1423
-MonthsInYear: 12
-DaysInYear: 355
-Days in each month:
-30 29 30 29 30 29 30 29 30 29 30 30
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: True
-
-System::Globalization::JapaneseCalendar, Year: 14
-MonthsInYear: 12
-DaysInYear: 365
-Days in each month:
-31 28 31 30 31 30 31 31 30 31 30 31
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: False
-
-System::Globalization::JulianCalendar, Year: 2002
-MonthsInYear: 12
-DaysInYear: 365
-Days in each month:
-31 28 31 30 31 30 31 31 30 31 30 31
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: False
-
-System::Globalization::KoreanCalendar, Year: 4335
-MonthsInYear: 12
-DaysInYear: 365
-Days in each month:
-31 28 31 30 31 30 31 31 30 31 30 31
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: False
-
-System::Globalization::TaiwanCalendar, Year: 91
-MonthsInYear: 12
-DaysInYear: 365
-Days in each month:
-31 28 31 30 31 30 31 31 30 31 30 31
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: False
-
-System::Globalization::ThaiBuddhistCalendar, Year: 2545
-MonthsInYear: 12
-DaysInYear: 365
-Days in each month:
-31 28 31 30 31 30 31 31 30 31 30 31
-IsLeapDay: False
-IsLeapMonth: False
-IsLeapYear: False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp
deleted file mode 100644
index 868fb637de7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-
-// The following code example shows the values returned by each method for different types of characters.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintProperties( Char c );
-int main()
-{
- Console::WriteLine( " c Num Dig Dec UnicodeCategory" );
- Console::Write( "U+0061 LATIN SMALL LETTER A " );
- PrintProperties( L'a' );
- Console::Write( "U+0393 GREEK CAPITAL LETTER GAMMA " );
- PrintProperties( L'\u0393' );
- Console::Write( "U+0039 DIGIT NINE " );
- PrintProperties( L'9' );
- Console::Write( "U+00B2 SUPERSCRIPT TWO " );
- PrintProperties( L'\u00B2' );
- Console::Write( "U+00BC VULGAR FRACTION ONE QUARTER " );
- PrintProperties( L'\u00BC' );
- Console::Write( "U+0BEF TAMIL DIGIT NINE " );
- PrintProperties( L'\u0BEF' );
- Console::Write( "U+0BF0 TAMIL NUMBER TEN " );
- PrintProperties( L'\u0BF0' );
- Console::Write( "U+0F33 TIBETAN DIGIT HALF ZERO " );
- PrintProperties( L'\u0F33' );
- Console::Write( "U+2788 CIRCLED SANS-SERIF DIGIT NINE " );
- PrintProperties( L'\u2788' );
-}
-
-void PrintProperties( Char c )
-{
- Console::Write( " {0,-3}", c );
- Console::Write( " {0,-5}", CharUnicodeInfo::GetNumericValue( c ) );
- Console::Write( " {0,-5}", CharUnicodeInfo::GetDigitValue( c ) );
- Console::Write( " {0,-5}", CharUnicodeInfo::GetDecimalDigitValue( c ) );
- Console::WriteLine( "{0}", CharUnicodeInfo::GetUnicodeCategory( c ) );
-}
-
-/*
-This code produces the following output. Some characters might not display at the console.
-
- c Num Dig Dec UnicodeCategory
-U+0061 LATIN SMALL LETTER A a -1 -1 -1 LowercaseLetter
-U+0393 GREEK CAPITAL LETTER GAMMA Γ -1 -1 -1 UppercaseLetter
-U+0039 DIGIT NINE 9 9 9 9 DecimalDigitNumber
-U+00B2 SUPERSCRIPT TWO ² 2 2 -1 OtherNumber
-U+00BC VULGAR FRACTION ONE QUARTER ¼ 0.25 -1 -1 OtherNumber
-U+0BEF TAMIL DIGIT NINE ௯ 9 9 9 DecimalDigitNumber
-U+0BF0 TAMIL NUMBER TEN ௰ 10 -1 -1 OtherNumber
-U+0F33 TIBETAN DIGIT HALF ZERO ༳ -0.5 -1 -1 OtherNumber
-U+2788 CIRCLED SANS-SERIF DIGIT NINE ➈ 9 9 -1 OtherNumber
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp
deleted file mode 100644
index 1ff91fb5a7e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-
-// The following code example shows the values returned by each method for different types of characters.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // The String to get information for.
- String^ s = "a9\u0393\u00B2\u00BC\u0BEF\u0BF0\u2788";
- Console::WriteLine( "String: {0}", s );
-
- // Print the values for each of the characters in the string.
- Console::WriteLine( "index c Num Dig Dec UnicodeCategory" );
- for ( int i = 0; i < s->Length; i++ )
- {
- Console::Write( "{0,-5} {1,-3}", i, s[ i ] );
- Console::Write( " {0,-5}", CharUnicodeInfo::GetNumericValue( s, i ) );
- Console::Write( " {0,-5}", CharUnicodeInfo::GetDigitValue( s, i ) );
- Console::Write( " {0,-5}", CharUnicodeInfo::GetDecimalDigitValue( s, i ) );
- Console::WriteLine( "{0}", CharUnicodeInfo::GetUnicodeCategory( s, i ) );
-
- }
-}
-
-/*
-This code produces the following output. Some characters might not display at the console.
-
-String: a9Γ²¼௯௰➈
-index c Num Dig Dec UnicodeCategory
-0 a -1 -1 -1 LowercaseLetter
-1 9 9 9 9 DecimalDigitNumber
-2 Γ -1 -1 -1 UppercaseLetter
-3 ² 2 2 -1 OtherNumber
-4 ¼ 0.25 -1 -1 OtherNumber
-5 ௯ 9 9 9 DecimalDigitNumber
-6 ௰ 10 -1 -1 OtherNumber
-7 ➈ 9 9 -1 OtherNumber
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp
deleted file mode 100644
index 96de17a4d52..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-
-// The following code example compares portions of two strings using the different CompareInfo instances:
-// a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort,
-// a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and
-// a CompareInfo instance associated with the InvariantCulture.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "calle";
- String^ myStr2 = "calor";
-
- // Uses GetCompareInfo to create the CompareInfo that uses the S"es-ES" culture with international sort.
- CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" );
-
- // Uses GetCompareInfo to create the CompareInfo that uses the S"es-ES" culture with traditional sort.
- CompareInfo^ myCompTrad = CompareInfo::GetCompareInfo( 0x040A );
-
- // Uses the CompareInfo property of the InvariantCulture.
- CompareInfo^ myCompInva = CultureInfo::InvariantCulture->CompareInfo;
-
- // Compares two strings using myCompIntl.
- Console::WriteLine( "Comparing \" {0}\" and \" {1}\"", myStr1->Substring( 2, 2 ), myStr2->Substring( 2, 2 ) );
- Console::WriteLine( " With myCompIntl->Compare: {0}", myCompIntl->Compare( myStr1, 2, 2, myStr2, 2, 2 ) );
- Console::WriteLine( " With myCompTrad->Compare: {0}", myCompTrad->Compare( myStr1, 2, 2, myStr2, 2, 2 ) );
- Console::WriteLine( " With myCompInva->Compare: {0}", myCompInva->Compare( myStr1, 2, 2, myStr2, 2, 2 ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing S"ll" and S"lo"
-With myCompIntl.Compare: -1
-With myCompTrad.Compare: 1
-With myCompInva.Compare: -1
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp
deleted file mode 100644
index 4c7273f97da..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-
-// The following code example compares portions of two strings using different CompareOptions settings.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "My Uncle Bill's clients";
- String^ myStr2 = "My uncle bills clients";
-
- // Creates a CompareInfo that uses the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // Compares two strings using myComp.
- Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1->Substring( 3, 10 ), myStr2->Substring( 3, 10 ) );
- Console::WriteLine( " With no CompareOptions : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10 ) );
- Console::WriteLine( " With None : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::None ) );
- Console::WriteLine( " With Ordinal : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::Ordinal ) );
- Console::WriteLine( " With StringSort : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::StringSort ) );
- Console::WriteLine( " With IgnoreCase : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::IgnoreCase ) );
- Console::WriteLine( " With IgnoreSymbols : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::IgnoreSymbols ) );
- Console::WriteLine( " With IgnoreCase and IgnoreSymbols : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, static_cast(CompareOptions::IgnoreCase | CompareOptions::IgnoreSymbols) ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing "Uncle Bill" and "uncle bill"
- With no CompareOptions : 1
- With None : 1
- With Ordinal : -32
- With StringSort : 1
- With IgnoreCase : 0
- With IgnoreSymbols : 1
- With IgnoreCase and IgnoreSymbols : 0
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp
deleted file mode 100644
index 678b54b5912..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-
-// The following code example compares portions of two strings using the different CompareInfo instances:
-// a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort,
-// a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and
-// a CompareInfo instance associated with the InvariantCulture.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "calle";
- String^ myStr2 = "calor";
-
- // Uses GetCompareInfo to create the CompareInfo that
- // uses the S"es-ES" culture with international sort.
- CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" );
-
- // Uses GetCompareInfo to create the CompareInfo that
- // uses the S"es-ES" culture with traditional sort.
- CompareInfo^ myCompTrad = CompareInfo::GetCompareInfo( 0x040A );
-
- // Uses the CompareInfo property of the InvariantCulture.
- CompareInfo^ myCompInva = CultureInfo::InvariantCulture->CompareInfo;
-
- // Compares two strings using myCompIntl.
- Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1->Substring( 2 ), myStr2->Substring( 2 ) );
- Console::WriteLine( " With myCompIntl::Compare: {0}", myCompIntl->Compare( myStr1, 2, myStr2, 2 ) );
- Console::WriteLine( " With myCompTrad::Compare: {0}", myCompTrad->Compare( myStr1, 2, myStr2, 2 ) );
- Console::WriteLine( " With myCompInva::Compare: {0}", myCompInva->Compare( myStr1, 2, myStr2, 2 ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing "lle" and "lor"
- With myCompIntl::Compare: -1
- With myCompTrad::Compare: 1
- With myCompInva::Compare: -1
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp
deleted file mode 100644
index b180520da7d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-// The following code example compares portions of two strings using different CompareOptions settings.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "My Uncle Bill's clients";
- String^ myStr2 = "My uncle bills clients";
-
- // Creates a CompareInfo that uses the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // Compares two strings using myComp.
- Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1->Substring( 10 ), myStr2->Substring( 10 ) );
- Console::WriteLine( " With no CompareOptions : {0}", myComp->Compare( myStr1, 10, myStr2, 10 ) );
- Console::WriteLine( " With None : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::None ) );
- Console::WriteLine( " With Ordinal : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::Ordinal ) );
- Console::WriteLine( " With StringSort : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::StringSort ) );
- Console::WriteLine( " With IgnoreCase : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::IgnoreCase ) );
- Console::WriteLine( " With IgnoreSymbols : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::IgnoreSymbols ) );
- Console::WriteLine( " With IgnoreCase and IgnoreSymbols : {0}", myComp->Compare( myStr1, 10, myStr2, 10, static_cast(CompareOptions::IgnoreCase | CompareOptions::IgnoreSymbols) ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing "ill's clients" and "ills clients"
- With no CompareOptions : 1
- With None : 1
- With Ordinal : -76
- With StringSort : -1
- With IgnoreCase : 1
- With IgnoreSymbols : 0
- With IgnoreCase and IgnoreSymbols : 0
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp
deleted file mode 100644
index f479b4c5433..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// The following code example compares two strings using the different CompareInfo instances:
-// a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort,
-// a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and
-// a CompareInfo instance associated with the InvariantCulture.
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "calle";
- String^ myStr2 = "calor";
-
- // Uses GetCompareInfo to create the CompareInfo that
- // uses the S"es-ES" culture with international sort.
- CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" );
-
- // Uses GetCompareInfo to create the CompareInfo that
- // uses the S"es-ES" culture with traditional sort.
- CompareInfo^ myCompTrad = CompareInfo::GetCompareInfo( 0x040A );
-
- // Uses the CompareInfo property of the InvariantCulture.
- CompareInfo^ myCompInva = CultureInfo::InvariantCulture->CompareInfo;
-
- // Compares two strings using myCompIntl.
- Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1, myStr2 );
- Console::WriteLine( " With myCompIntl::Compare: {0}", myCompIntl->Compare( myStr1, myStr2 ) );
- Console::WriteLine( " With myCompTrad::Compare: {0}", myCompTrad->Compare( myStr1, myStr2 ) );
- Console::WriteLine( " With myCompInva::Compare: {0}", myCompInva->Compare( myStr1, myStr2 ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing "calle" and "calor"
- With myCompIntl::Compare: -1
- With myCompTrad::Compare: 1
- With myCompInva::Compare: -1
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp
deleted file mode 100644
index 2e1193e0288..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-// The following code example compares two strings using different CompareOptions settings.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "My Uncle Bill's clients";
- String^ myStr2 = "My uncle bills clients";
-
- // Creates a CompareInfo which uses the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // Compares two strings using myComp.
- Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1, myStr2 );
- Console::WriteLine( " With no CompareOptions : {0}", myComp->Compare( myStr1, myStr2 ) );
- Console::WriteLine( " With None : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::None ) );
- Console::WriteLine( " With Ordinal : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::Ordinal ) );
- Console::WriteLine( " With StringSort : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::StringSort ) );
- Console::WriteLine( " With IgnoreCase : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::IgnoreCase ) );
- Console::WriteLine( " With IgnoreSymbols : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::IgnoreSymbols ) );
- Console::WriteLine( " With IgnoreCase and IgnoreSymbols : {0}", myComp->Compare( myStr1, myStr2, static_cast(CompareOptions::IgnoreCase | CompareOptions::IgnoreSymbols) ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing "My Uncle Bill's clients" and "My uncle bills clients"
- With no CompareOptions : 1
- With None : 1
- With Ordinal : -32
- With StringSort : -1
- With IgnoreCase : 1
- With IgnoreSymbols : 1
- With IgnoreCase and IgnoreSymbols : 0
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOf/CPP/indexof.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOf/CPP/indexof.cpp
deleted file mode 100644
index b82a9f2e5ef..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOf/CPP/indexof.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-
-// The following code example determines the indexes of the first and last occurrences of a character or a substring within a string.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintMarker( String^ Prefix, int First, int Last )
-{
-
- // Determines the size of the array to create.
- int mySize;
- if ( Last > First )
- mySize = Last;
- else
- mySize = First;
-
- if ( mySize > -1 )
- {
-
- // Creates an array of Char to hold the markers.
- array^myCharArr = gcnew array(mySize + 1);
-
- // Inserts the appropriate markers.
- if ( First > -1 )
- myCharArr[ First ] = 'f';
- if ( Last > -1 )
- myCharArr[ Last ] = 'l';
- if ( First == Last )
- myCharArr[ First ] = 'b';
-
- // Displays the array of Char as a String.
- Console::WriteLine( "{0}{1}", Prefix, gcnew String( myCharArr ) );
- }
- else
- Console::WriteLine( Prefix );
-}
-
-int main()
-{
-
- // Creates CompareInfo for the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // Searches for the ligature Æ.
- String^ myStr = "Is AE or ae the same as Æ or æ?";
- Console::WriteLine();
- Console::WriteLine( "No options : {0}", myStr );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE" ), myComp->LastIndexOf( myStr, "AE" ) );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae" ), myComp->LastIndexOf( myStr, "ae" ) );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ' ), myComp->LastIndexOf( myStr, L'Æ' ) );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ' ), myComp->LastIndexOf( myStr, L'æ' ) );
- Console::WriteLine( "Ordinal : {0}", myStr );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "AE", CompareOptions::Ordinal ) );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "ae", CompareOptions::Ordinal ) );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Æ', CompareOptions::Ordinal ) );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'æ', CompareOptions::Ordinal ) );
- Console::WriteLine( "IgnoreCase : {0}", myStr );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "AE", CompareOptions::IgnoreCase ) );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "ae", CompareOptions::IgnoreCase ) );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Æ', CompareOptions::IgnoreCase ) );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'æ', CompareOptions::IgnoreCase ) );
-
- // Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis.
- myStr = "Is U\u0308 or u\u0308 the same as \u00DC or \u00FC?";
- Console::WriteLine();
- Console::WriteLine( "No options : {0}", myStr );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308" ), myComp->LastIndexOf( myStr, "U\u0308" ) );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308" ), myComp->LastIndexOf( myStr, "u\u0308" ) );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü' ), myComp->LastIndexOf( myStr, L'Ü' ) );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü' ), myComp->LastIndexOf( myStr, L'ü' ) );
- Console::WriteLine( "Ordinal : {0}", myStr );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "U\u0308", CompareOptions::Ordinal ) );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "u\u0308", CompareOptions::Ordinal ) );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Ü', CompareOptions::Ordinal ) );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'ü', CompareOptions::Ordinal ) );
- Console::WriteLine( "IgnoreCase : {0}", myStr );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "U\u0308", CompareOptions::IgnoreCase ) );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "u\u0308", CompareOptions::IgnoreCase ) );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Ü', CompareOptions::IgnoreCase ) );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'ü', CompareOptions::IgnoreCase ) );
-}
-
-/*
-This code produces the following output.
-
-No options : Is AE or ae the same as Æ or æ?
- AE : f l
- ae : f l
- Æ : f l
- æ : f l
-Ordinal : Is AE or ae the same as Æ or æ?
- AE : b
- ae : b
- Æ : b
- æ : b
-IgnoreCase : Is AE or ae the same as Æ or æ?
- AE : f l
- ae : f l
- Æ : f l
- æ : f l
-
-No options : Is U" or u" the same as Ü or ü?
- U" : f l
- u" : f l
- Ü : f l
- ü : f l
-Ordinal : Is U" or u" the same as Ü or ü?
- U" : b
- u" : b
- Ü : b
- ü : b
-IgnoreCase : Is U" or u" the same as Ü or ü?
- U" : f l
- u" : f l
- Ü : f l
- ü : f l
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp
deleted file mode 100644
index f5d3d8ae905..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-
-// The following code example determines the indexes of the first and last occurrences of a character or a substring within a portion of a string.
-// Note that IndexOf and LastIndexOf are searching in different portions of the string, even with the same StartIndex parameter.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintMarker( String^ Prefix, int First, int Last )
-{
-
- // Determines the size of the array to create.
- int mySize;
- if ( Last > First )
- mySize = Last;
- else
- mySize = First;
-
- if ( mySize > -1 )
- {
-
- // Creates an array of Char to hold the markers.
- array^myCharArr = gcnew array(mySize + 1);
-
- // Inserts the appropriate markers.
- if ( First > -1 )
- myCharArr[ First ] = 'f';
- if ( Last > -1 )
- myCharArr[ Last ] = 'l';
- if ( First == Last )
- myCharArr[ First ] = 'b';
-
- // Displays the array of Char as a String.
- Console::WriteLine( "{0}{1}", Prefix, gcnew String( myCharArr ) );
- }
- else
- Console::WriteLine( Prefix );
-}
-
-int main()
-{
-
- // Creates CompareInfo for the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // iS is the starting index of the substring.
- int iS = 20;
-
- // myT1 is the string used for padding.
- String^ myT1;
-
- // Searches for the ligature Æ.
- String^ myStr = "Is AE or ae the same as Æ or æ?";
- Console::WriteLine();
- myT1 = gcnew String( '-',iS );
- Console::WriteLine( "IndexOf( String, *, {0}, * )", iS );
- Console::WriteLine( "Original : {0}", myStr );
- Console::WriteLine( "No options : {0}{1}", myT1, myStr->Substring( iS ) );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS ), -1 );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS ), -1 );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS ), -1 );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS ), -1 );
- Console::WriteLine( "Ordinal : {0}{1}", myT1, myStr->Substring( iS ) );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, CompareOptions::Ordinal ), -1 );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, CompareOptions::Ordinal ), -1 );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, CompareOptions::Ordinal ), -1 );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, CompareOptions::Ordinal ), -1 );
- Console::WriteLine( "IgnoreCase : {0}{1}", myT1, myStr->Substring( iS ) );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, CompareOptions::IgnoreCase ), -1 );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, CompareOptions::IgnoreCase ), -1 );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, CompareOptions::IgnoreCase ), -1 );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, CompareOptions::IgnoreCase ), -1 );
- myT1 = gcnew String( '-',myStr->Length - iS - 1 );
- Console::WriteLine( "LastIndexOf( String, *, {0}, * )", iS );
- Console::WriteLine( "Original : {0}", myStr );
- Console::WriteLine( "No options : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 );
- PrintMarker( " AE : ", -1, myComp->LastIndexOf( myStr, "AE", iS ) );
- PrintMarker( " ae : ", -1, myComp->LastIndexOf( myStr, "ae", iS ) );
- PrintMarker( " Æ : ", -1, myComp->LastIndexOf( myStr, L'Æ', iS ) );
- PrintMarker( " æ : ", -1, myComp->LastIndexOf( myStr, L'æ', iS ) );
- Console::WriteLine( "Ordinal : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 );
- PrintMarker( " AE : ", -1, myComp->LastIndexOf( myStr, "AE", iS, CompareOptions::Ordinal ) );
- PrintMarker( " ae : ", -1, myComp->LastIndexOf( myStr, "ae", iS, CompareOptions::Ordinal ) );
- PrintMarker( " Æ : ", -1, myComp->LastIndexOf( myStr, L'Æ', iS, CompareOptions::Ordinal ) );
- PrintMarker( " æ : ", -1, myComp->LastIndexOf( myStr, L'æ', iS, CompareOptions::Ordinal ) );
- Console::WriteLine( "IgnoreCase : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 );
- PrintMarker( " AE : ", -1, myComp->LastIndexOf( myStr, "AE", iS, CompareOptions::IgnoreCase ) );
- PrintMarker( " ae : ", -1, myComp->LastIndexOf( myStr, "ae", iS, CompareOptions::IgnoreCase ) );
- PrintMarker( " Æ : ", -1, myComp->LastIndexOf( myStr, L'Æ', iS, CompareOptions::IgnoreCase ) );
- PrintMarker( " æ : ", -1, myComp->LastIndexOf( myStr, L'æ', iS, CompareOptions::IgnoreCase ) );
-
- // Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis.
- myStr = "Is U\u0308 or u\u0308 the same as \u00DC or \u00FC?";
- Console::WriteLine();
- myT1 = gcnew String( '-',iS );
- Console::WriteLine( "IndexOf( String, *, {0}, * )", iS );
- Console::WriteLine( "Original : {0}", myStr );
- Console::WriteLine( "No options : {0}{1}", myT1, myStr->Substring( iS ) );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS ), -1 );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS ), -1 );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS ), -1 );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS ), -1 );
- Console::WriteLine( "Ordinal : {0}{1}", myT1, myStr->Substring( iS ) );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, CompareOptions::Ordinal ), -1 );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, CompareOptions::Ordinal ), -1 );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, CompareOptions::Ordinal ), -1 );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, CompareOptions::Ordinal ), -1 );
- Console::WriteLine( "IgnoreCase : {0}{1}", myT1, myStr->Substring( iS ) );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, CompareOptions::IgnoreCase ), -1 );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, CompareOptions::IgnoreCase ), -1 );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, CompareOptions::IgnoreCase ), -1 );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, CompareOptions::IgnoreCase ), -1 );
- myT1 = gcnew String( '-',myStr->Length - iS - 1 );
- Console::WriteLine( "LastIndexOf( String, *, {0}, * )", iS );
- Console::WriteLine( "Original : {0}", myStr );
- Console::WriteLine( "No options : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 );
- PrintMarker( " U\u0308 : ", -1, myComp->LastIndexOf( myStr, "U\u0308", iS ) );
- PrintMarker( " u\u0308 : ", -1, myComp->LastIndexOf( myStr, "u\u0308", iS ) );
- PrintMarker( " Ü : ", -1, myComp->LastIndexOf( myStr, L'Ü', iS ) );
- PrintMarker( " ü : ", -1, myComp->LastIndexOf( myStr, L'ü', iS ) );
- Console::WriteLine( "Ordinal : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 );
- PrintMarker( " U\u0308 : ", -1, myComp->LastIndexOf( myStr, "U\u0308", iS, CompareOptions::Ordinal ) );
- PrintMarker( " u\u0308 : ", -1, myComp->LastIndexOf( myStr, "u\u0308", iS, CompareOptions::Ordinal ) );
- PrintMarker( " Ü : ", -1, myComp->LastIndexOf( myStr, L'Ü', iS, CompareOptions::Ordinal ) );
- PrintMarker( " ü : ", -1, myComp->LastIndexOf( myStr, L'ü', iS, CompareOptions::Ordinal ) );
- Console::WriteLine( "IgnoreCase : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 );
- PrintMarker( " U\u0308 : ", -1, myComp->LastIndexOf( myStr, "U\u0308", iS, CompareOptions::IgnoreCase ) );
- PrintMarker( " u\u0308 : ", -1, myComp->LastIndexOf( myStr, "u\u0308", iS, CompareOptions::IgnoreCase ) );
- PrintMarker( " Ü : ", -1, myComp->LastIndexOf( myStr, L'Ü', iS, CompareOptions::IgnoreCase ) );
- PrintMarker( " ü : ", -1, myComp->LastIndexOf( myStr, L'ü', iS, CompareOptions::IgnoreCase ) );
-}
-
-/*
-This code produces the following output.
-
-IndexOf( String, *, 20, * )
-Original : Is AE or ae the same as Æ or æ?
-No options : -------------------- as Æ or æ?
- AE : f
- ae : f
- Æ : f
- æ : f
-Ordinal : -------------------- as Æ or æ?
- AE :
- ae :
- Æ : f
- æ : f
-IgnoreCase : -------------------- as Æ or æ?
- AE : f
- ae : f
- Æ : f
- æ : f
-LastIndexOf( String, *, 20, * )
-Original : Is AE or ae the same as Æ or æ?
-No options : Is AE or ae the same ----------
- AE : l
- ae : l
- Æ : l
- æ : l
-Ordinal : Is AE or ae the same ----------
- AE : l
- ae : l
- Æ :
- æ :
-IgnoreCase : Is AE or ae the same ----------
- AE : l
- ae : l
- Æ : l
- æ : l
-
-IndexOf( String, *, 20, * )
-Original : Is U" or u" the same as Ü or ü?
-No options : -------------------- as Ü or ü?
- U" : f
- u" : f
- Ü : f
- ü : f
-Ordinal : -------------------- as Ü or ü?
- U" :
- u" :
- Ü : f
- ü : f
-IgnoreCase : -------------------- as Ü or ü?
- U" : f
- u" : f
- Ü : f
- ü : f
-LastIndexOf( String, *, 20, * )
-Original : Is U" or u" the same as Ü or ü?
-No options : Is U" or u" the same ----------
- U" : l
- u" : l
- Ü : l
- ü : l
-Ordinal : Is U" or u" the same ----------
- U" : l
- u" : l
- Ü :
- ü :
-IgnoreCase : Is U" or u" the same ----------
- U" : l
- u" : l
- Ü : l
- ü : l
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfIntInt/CPP/indexofintint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfIntInt/CPP/indexofintint.cpp
deleted file mode 100644
index 381970926e1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfIntInt/CPP/indexofintint.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-
-// The following code example determines the indexes of the first and last occurrences of a character or a substring within a portion of a string.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintMarker( String^ Prefix, int First, int Last )
-{
-
- // Determines the size of the array to create.
- int mySize;
- if ( Last > First )
- mySize = Last;
- else
- mySize = First;
-
- if ( mySize > -1 )
- {
-
- // Creates an array of Char to hold the markers.
- array^myCharArr = gcnew array(mySize + 1);
-
- // Inserts the appropriate markers.
- if ( First > -1 )
- myCharArr[ First ] = 'f';
- if ( Last > -1 )
- myCharArr[ Last ] = 'l';
- if ( First == Last )
- myCharArr[ First ] = 'b';
-
- // Displays the array of Char as a String.
- Console::WriteLine( "{0}{1}", Prefix, gcnew String( myCharArr ) );
- }
- else
- Console::WriteLine( Prefix );
-}
-
-int main()
-{
-
- // Creates CompareInfo for the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // iS is the starting index of the substring.
- int iS = 8;
-
- // iL is the length of the substring.
- int iL = 18;
-
- // myT1 and myT2 are the strings used for padding.
- String^ myT1 = gcnew String( '-',iS );
- String^ myT2;
-
- // Searches for the ligature Æ.
- String^ myStr = "Is AE or ae the same as Æ or æ?";
- myT2 = gcnew String( '-',myStr->Length - iS - iL );
- Console::WriteLine();
- Console::WriteLine( "Original : {0}", myStr );
- Console::WriteLine( "No options : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, iL ), myComp->LastIndexOf( myStr, "AE", iS + iL - 1, iL ) );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, iL ), myComp->LastIndexOf( myStr, "ae", iS + iL - 1, iL ) );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, iL ), myComp->LastIndexOf( myStr, L'Æ', iS + iL - 1, iL ) );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, iL ), myComp->LastIndexOf( myStr, L'æ', iS + iL - 1, iL ) );
- Console::WriteLine( "Ordinal : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "AE", iS + iL - 1, iL, CompareOptions::Ordinal ) );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "ae", iS + iL - 1, iL, CompareOptions::Ordinal ) );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Æ', iS + iL - 1, iL, CompareOptions::Ordinal ) );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'æ', iS + iL - 1, iL, CompareOptions::Ordinal ) );
- Console::WriteLine( "IgnoreCase : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 );
- PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "AE", iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
- PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "ae", iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
- PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Æ', iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
- PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'æ', iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
-
- // Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis.
- myStr = "Is U\u0308 or u\u0308 the same as \u00DC or \u00FC?";
- myT2 = gcnew String( '-',myStr->Length - iS - iL );
- Console::WriteLine();
- Console::WriteLine( "Original : {0}", myStr );
- Console::WriteLine( "No options : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, iL ), myComp->LastIndexOf( myStr, "U\u0308", iS + iL - 1, iL ) );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, iL ), myComp->LastIndexOf( myStr, "u\u0308", iS + iL - 1, iL ) );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, iL ), myComp->LastIndexOf( myStr, L'Ü', iS + iL - 1, iL ) );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, iL ), myComp->LastIndexOf( myStr, L'ü', iS + iL - 1, iL ) );
- Console::WriteLine( "Ordinal : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "U\u0308", iS + iL - 1, iL, CompareOptions::Ordinal ) );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "u\u0308", iS + iL - 1, iL, CompareOptions::Ordinal ) );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Ü', iS + iL - 1, iL, CompareOptions::Ordinal ) );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'ü', iS + iL - 1, iL, CompareOptions::Ordinal ) );
- Console::WriteLine( "IgnoreCase : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 );
- PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "U\u0308", iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
- PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "u\u0308", iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
- PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Ü', iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
- PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'ü', iS + iL - 1, iL, CompareOptions::IgnoreCase ) );
-}
-
-/*
-This code produces the following output.
-
-Original : Is AE or ae the same as Æ or æ?
-No options : -------- ae the same as Æ -----
- AE : b
- ae : b
- Æ : b
- æ : b
-Ordinal : -------- ae the same as Æ -----
- AE :
- ae : b
- Æ : b
- æ :
-IgnoreCase : -------- ae the same as Æ -----
- AE : f l
- ae : f l
- Æ : f l
- æ : f l
-
-Original : Is U" or u" the same as Ü or ü?
-No options : -------- u" the same as Ü -----
- U" : b
- u" : b
- Ü : b
- ü : b
-Ordinal : -------- u" the same as Ü -----
- U" :
- u" : b
- Ü : b
- ü :
-IgnoreCase : -------- u" the same as Ü -----
- U" : f l
- u" : f l
- Ü : f l
- ü : f l
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffix/CPP/isprefixsuffix.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffix/CPP/isprefixsuffix.cpp
deleted file mode 100644
index 67bd06172ff..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffix/CPP/isprefixsuffix.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-// The following code example determines whether a String* is the prefix or suffix of another String*.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "calle";
- String^ myStr2 = "llegar";
- String^ myXfix = "lle";
-
- // Uses the CompareInfo property of the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
-
- // Determines whether myXfix is a prefix of S"calle" and S"llegar".
- Console::WriteLine( "IsPrefix( {0}, {1}) : {2}", myStr1, myXfix, myComp->IsPrefix( myStr1, myXfix ) );
- Console::WriteLine( "IsPrefix( {0}, {1}) : {2}", myStr2, myXfix, myComp->IsPrefix( myStr2, myXfix ) );
-
- // Determines whether myXfix is a suffix of S"calle" and S"llegar".
- Console::WriteLine( "IsSuffix( {0}, {1}) : {2}", myStr1, myXfix, myComp->IsSuffix( myStr1, myXfix ) );
- Console::WriteLine( "IsSuffix( {0}, {1}) : {2}", myStr2, myXfix, myComp->IsSuffix( myStr2, myXfix ) );
-}
-
-/*
-This code produces the following output.
-
-IsPrefix(calle, lle) : False
-IsPrefix(llegar, lle) : True
-IsSuffix(calle, lle) : True
-IsSuffix(llegar, lle) : False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp
deleted file mode 100644
index 4873c4342d0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-
-// The following code example determines whether a String* is the prefix or suffix of another String* using CompareOptions.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the strings to compare.
- String^ myStr1 = "calle";
- String^ myStr2 = "llegar";
- String^ myXfix = "LLE";
-
- // Uses the CompareInfo property of the InvariantCulture.
- CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
- Console::WriteLine( "IsSuffix \"{0}\", \"{1}\"", myStr1, myXfix );
- Console::WriteLine( " With no CompareOptions : {0}", myComp->IsSuffix( myStr1, myXfix ) );
- Console::WriteLine( " With None : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::None ) );
- Console::WriteLine( " With Ordinal : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::Ordinal ) );
- Console::WriteLine( " With IgnoreCase : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::IgnoreCase ) );
- Console::WriteLine( "IsPrefix \"{0}\", \"{1}\"", myStr2, myXfix );
- Console::WriteLine( " With no CompareOptions : {0}", myComp->IsPrefix( myStr2, myXfix ) );
- Console::WriteLine( " With None : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::None ) );
- Console::WriteLine( " With Ordinal : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::Ordinal ) );
- Console::WriteLine( " With IgnoreCase : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::IgnoreCase ) );
-}
-
-/*
-This code produces the following output.
-
-IsSuffix "calle", "LLE"
- With no CompareOptions : False
- With None : False
- With Ordinal : False
- With IgnoreCase : True
-IsPrefix "llegar", "LLE"
- With no CompareOptions : False
- With None : False
- With Ordinal : False
- With IgnoreCase : True
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp
deleted file mode 100644
index 36c0e20d3fc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-// The following code example shows that CultureInfo::Clone also clones the DateTimeFormatInfo and
-// NumberFormatInfo instances associated with the CultureInfo.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a CultureInfo.
- CultureInfo^ myCI = gcnew CultureInfo( "en-US",false );
-
- // Clones myCI and modifies the DTFI and NFI instances associated with the clone.
- CultureInfo^ myCIclone = dynamic_cast(myCI->Clone());
- myCIclone->DateTimeFormat->AMDesignator = "a.m.";
- myCIclone->DateTimeFormat->DateSeparator = "-";
- myCIclone->NumberFormat->CurrencySymbol = "USD";
- myCIclone->NumberFormat->NumberDecimalDigits = 4;
-
- // Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
- Console::WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
- Console::WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI->DateTimeFormat->AMDesignator, myCIclone->DateTimeFormat->AMDesignator );
- Console::WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI->DateTimeFormat->DateSeparator, myCIclone->DateTimeFormat->DateSeparator );
- Console::WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI->NumberFormat->CurrencySymbol, myCIclone->NumberFormat->CurrencySymbol );
- Console::WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI->NumberFormat->NumberDecimalDigits, myCIclone->NumberFormat->NumberDecimalDigits );
-}
-
-/*
-This code produces the following output.
-
-DTFI/NFI PROPERTY ORIGINAL MODIFIED CLONE
-DTFI.AMDesignator AM a.m.
-DTFI.DateSeparator / -
-NFI.CurrencySymbol $ USD
-NFI.NumberDecimalDigits 2 4
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp
deleted file mode 100644
index 39d0500f201..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Threading;
-
-int main()
-{
- // Display the name of the current thread culture.
- Console::WriteLine("CurrentCulture is {0}.", CultureInfo::CurrentCulture->Name);
-
- // Change the current culture to th-TH.
- CultureInfo::CurrentCulture = gcnew CultureInfo("th-TH",false);
- Console::WriteLine("CurrentCulture is now {0}.", CultureInfo::CurrentCulture->Name);
-
- // Displays the name of the CurrentUICulture of the current thread.
- Console::WriteLine("CurrentUICulture is {0}.", CultureInfo::CurrentCulture->Name);
-
- // Changes the CurrentUICulture of the current thread to ja-JP.
- CultureInfo::CurrentUICulture = gcnew CultureInfo("ja-JP",false);
- Console::WriteLine("CurrentUICulture is now {0}.", CultureInfo::CurrentCulture->Name);
-}
-// The example displays the following output:
-// CurrentCulture is en-US.
-// CurrentCulture is now th-TH.
-// CurrentUICulture is en-US.
-// CurrentUICulture is now ja-JP.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp
deleted file mode 100644
index 895e3754d36..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-
-// The following code example displays several properties of the neutral cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Displays several properties of the neutral cultures.
- Console::WriteLine( "CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME" );
- System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::NeutralCultures )->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- CultureInfo^ ci = safe_cast(enum0->Current);
- Console::Write( "{0,-7}", ci->Name );
- Console::Write( " {0,-3}", ci->TwoLetterISOLanguageName );
- Console::Write( " {0,-3}", ci->ThreeLetterISOLanguageName );
- Console::Write( " {0,-3}", ci->ThreeLetterWindowsLanguageName );
- Console::Write( " {0,-40}", ci->DisplayName );
- Console::WriteLine( " {0,-40}", ci->EnglishName );
- }
-}
-
-/*
-This code produces the following output. This output has been cropped for brevity.
-
-CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
-ar ar ara ARA Arabic Arabic
-bg bg bul BGR Bulgarian Bulgarian
-ca ca cat CAT Catalan Catalan
-zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
-cs cs ces CSY Czech Czech
-da da dan DAN Danish Danish
-de de deu DEU German German
-el el ell ELL Greek Greek
-en en eng ENU English English
-es es spa ESP Spanish Spanish
-fi fi fin FIN Finnish Finnish
-zh zh zho CHS Chinese Chinese
-zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional)
-zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy
-zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp
deleted file mode 100644
index c7d200f5865..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example determines which cultures using the Chinese language are neutral cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Lists the cultures that use the Chinese language and determines if each is a neutral culture.
- System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::AllCultures )->GetEnumerator();
- while ( enum0->MoveNext() )
- {
- CultureInfo^ ci = safe_cast(enum0->Current);
- if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) )
- {
- Console::Write( "{0,-7} {1,-40}", ci->Name, ci->EnglishName );
- if ( ci->IsNeutralCulture )
- {
- Console::WriteLine( ": neutral" );
- }
- else
- {
- Console::WriteLine( ": specific" );
- }
- }
- }
-}
-
-/*
-This code produces the following output.
-
-zh-Hans Chinese (Simplified) : neutral
-zh-TW Chinese (Traditional, Taiwan) : specific
-zh-CN Chinese (Simplified, PRC) : specific
-zh-HK Chinese (Traditional, Hong Kong S.A.R.) : specific
-zh-SG Chinese (Simplified, Singapore) : specific
-zh-MO Chinese (Traditional, Macao S.A.R.) : specific
-zh Chinese : neutral
-zh-Hant Chinese (Traditional) : neutral
-zh-CHS Chinese (Simplified) Legacy : neutral
-zh-CHT Chinese (Traditional) Legacy : neutral
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp
deleted file mode 100644
index bc3ff941693..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-// The following code example displays the parent culture of each specific
-// culture using the Chinese language.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Prints the header.
- Console::WriteLine( "SPECIFIC CULTURE PARENT CULTURE" );
-
- // Determines the specific cultures that use the Chinese language,
- // and displays the parent culture.
- System::Collections::IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator();
- while ( en->MoveNext() )
- {
- CultureInfo^ ci = safe_cast(en->Current);
- if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) )
- {
- Console::Write( "0x{0} {1} {2,-40}", ci->LCID.ToString( "X4" ), ci->Name, ci->EnglishName );
- Console::WriteLine( "0x{0} {1} {2}", ci->Parent->LCID.ToString( "X4" ), ci->Parent->Name, ci->Parent->EnglishName );
- }
- }
-}
-
-/*
-This code produces the following output.
-
-SPECIFIC CULTURE PARENT CULTURE
-0x0404 zh-TW Chinese (Traditional, Taiwan) 0x7C04 zh-CHT Chinese (Traditional) Legacy
-0x0804 zh-CN Chinese (Simplified, PRC) 0x0004 zh-CHS Chinese (Simplified) Legacy
-0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
-0x1004 zh-SG Chinese (Simplified, Singapore) 0x0004 zh-CHS Chinese (Simplified) Legacy
-0x1404 zh-MO Chinese (Traditional, Macao S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp
deleted file mode 100644
index c2e98b06394..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-// The following code example shows that CultureInfo::ReadOnly also protects the
-// DateTimeFormatInfo and NumberFormatInfo instances associated with the CultureInfo.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates a CultureInfo.
- CultureInfo^ myCI = gcnew CultureInfo( "en-US" );
-
- // Creates a read-only CultureInfo based on myCI ->
- CultureInfo^ myReadOnlyCI = CultureInfo::ReadOnly( myCI );
-
- // Display the read-only status of each CultureInfo and their DateTimeFormat and NumberFormat properties.
- Console::WriteLine( "myCI is {0}.", myCI->IsReadOnly ? (String^)"read only" : "writable" );
- Console::WriteLine( "myCI -> DateTimeFormat is {0}.", myCI->DateTimeFormat->IsReadOnly ? (String^)"read only" : "writable" );
- Console::WriteLine( "myCI -> NumberFormat is {0}.", myCI->NumberFormat->IsReadOnly ? (String^)"read only" : "writable" );
- Console::WriteLine( "myReadOnlyCI is {0}.", myReadOnlyCI->IsReadOnly ? (String^)"read only" : "writable" );
- Console::WriteLine( "myReadOnlyCI -> DateTimeFormat is {0}.", myReadOnlyCI->DateTimeFormat->IsReadOnly ? (String^)"read only" : "writable" );
- Console::WriteLine( "myReadOnlyCI -> NumberFormat is {0}.", myReadOnlyCI->NumberFormat->IsReadOnly ? (String^)"read only" : "writable" );
-}
-
-/*
-This code produces the following output.
-
-myCI is writable.
-myCI -> DateTimeFormat is writable.
-myCI -> NumberFormat is writable.
-myReadOnlyCI is read only.
-myReadOnlyCI -> DateTimeFormat is read only.
-myReadOnlyCI -> NumberFormat is read only.
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp
deleted file mode 100644
index 5a683e17740..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-
-// The following code example shows how to create a CultureInfo for S"Spanish - Spain"
-// with the international sort and another with the traditional sort.
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes the CultureInfo which uses the international sort.
- CultureInfo^ myCIintl = gcnew CultureInfo( "es-ES",false );
-
- // Creates and initializes the CultureInfo which uses the traditional sort.
- CultureInfo^ myCItrad = gcnew CultureInfo( 0x040A,false );
-
- // Displays the properties of each culture.
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL" );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "CompareInfo", myCIintl->CompareInfo, myCItrad->CompareInfo );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "DisplayName", myCIintl->DisplayName, myCItrad->DisplayName );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "EnglishName", myCIintl->EnglishName, myCItrad->EnglishName );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "IsNeutralCulture", myCIintl->IsNeutralCulture, myCItrad->IsNeutralCulture );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "IsReadOnly", myCIintl->IsReadOnly, myCItrad->IsReadOnly );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "LCID", myCIintl->LCID, myCItrad->LCID );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "Name", myCIintl->Name, myCItrad->Name );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "NativeName", myCIintl->NativeName, myCItrad->NativeName );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "Parent", myCIintl->Parent, myCItrad->Parent );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "TextInfo", myCIintl->TextInfo, myCItrad->TextInfo );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "ThreeLetterISOLanguageName", myCIintl->ThreeLetterISOLanguageName, myCItrad->ThreeLetterISOLanguageName );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl->ThreeLetterWindowsLanguageName, myCItrad->ThreeLetterWindowsLanguageName );
- Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "TwoLetterISOLanguageName", myCIintl->TwoLetterISOLanguageName, myCItrad->TwoLetterISOLanguageName );
- Console::WriteLine();
-
- // Compare two strings using myCIintl ->
- Console::WriteLine( "Comparing \"llegar\" and \"lugar\"" );
- Console::WriteLine( " With myCIintl -> CompareInfo -> Compare: {0}", myCIintl->CompareInfo->Compare( "llegar", "lugar" ) );
- Console::WriteLine( " With myCItrad -> CompareInfo -> Compare: {0}", myCItrad->CompareInfo->Compare( "llegar", "lugar" ) );
-}
-
-/*
-This code produces the following output.
-
-PROPERTY INTERNATIONAL TRADITIONAL
-CompareInfo CompareInfo - es-ES CompareInfo - es-ES_tradnl
-DisplayName Spanish (Spain) Spanish (Spain)
-EnglishName Spanish (Spain, International Sort) Spanish (Spain, Traditional Sort)
-IsNeutralCulture False False
-IsReadOnly False False
-LCID 3082 1034
-Name es-ES es-ES
-NativeName Español (España, alfabetización internacional) Español (España, alfabetización tradicional)
-Parent es es
-TextInfo TextInfo - es-ES TextInfo - es-ES_tradnl
-ThreeLetterISOLanguageName spa spa
-ThreeLetterWindowsLanguageName ESN ESP
-TwoLetterISOLanguageName es es
-
-Comparing "llegar" and "lugar"
- With myCIintl -> CompareInfo -> Compare: -1
- With myCItrad -> CompareInfo -> Compare: 1
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp
deleted file mode 100644
index c9f0bdb0a61..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of FullDateTimePattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->FullDateTimePattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output. The question marks take the place of native script characters.
-
-CULTURE PROPERTY VALUE
-en-US dddd, MMMM dd, yyyy h:mm:ss tt
-ja-JP yyyy'年'M'月'd'日' H:mm:ss
-fr-FR dddd d MMMM yyyy HH:mm:ss
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp
deleted file mode 100644
index 64fb0d7708a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of LongDatePattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->LongDatePattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output:
-
-CULTURE PROPERTY VALUE
-en-US dddd, MMMM dd, yyyy
-ja-JP yyyy'年'M'月'd'日'
-fr-FR dddd d MMMM yyyy
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp
deleted file mode 100644
index 035bc98e2a0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of LongTimePattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->LongTimePattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output.
-
-CULTURE PROPERTY VALUE
-en-US h:mm:ss tt
-ja-JP H:mm:ss
-fr-FR HH:mm:ss
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp
deleted file mode 100644
index 29e0b173c0f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of MonthDayPattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->MonthDayPattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output. The question marks take the place of native script characters.
-
-CULTURE PROPERTY VALUE
-en-US MMMM dd
-ja-JP M'?'d'?'
-fr-FR d MMMM
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.RFC1123Pattern/CPP/dtfi_rfc1123pattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.RFC1123Pattern/CPP/dtfi_rfc1123pattern.cpp
deleted file mode 100644
index 6f5088a4914..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.RFC1123Pattern/CPP/dtfi_rfc1123pattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of RFC1123Pattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->RFC1123Pattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output.
-
-CULTURE PROPERTY VALUE
-en-US ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
-ja-JP ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
-fr-FR ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp
deleted file mode 100644
index 7bc1dc8a065..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of ShortTimePattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->ShortTimePattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output.
-
-CULTURE PROPERTY VALUE
-en-US h:mm tt
-ja-JP H:mm
-fr-FR HH:mm
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp
deleted file mode 100644
index e49b6b214a2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of SortableDateTimePattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->SortableDateTimePattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output.
-
-CULTURE PROPERTY VALUE
-en-US yyyy'-'MM'-'dd'T'HH':'mm':'ss
-ja-JP yyyy'-'MM'-'dd'T'HH':'mm':'ss
-fr-FR yyyy'-'MM'-'dd'T'HH':'mm':'ss
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp
deleted file mode 100644
index f3e77ca4e46..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-
-// The following code example displays the value of UniversalSortableDateTimePattern
-// for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->UniversalSortableDateTimePattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output.
-
-CULTURE PROPERTY VALUE
-en-US yyyy'-'MM'-'dd HH':'mm':'ss'Z'
-ja-JP yyyy'-'MM'-'dd HH':'mm':'ss'Z'
-fr-FR yyyy'-'MM'-'dd HH':'mm':'ss'Z'
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp
deleted file mode 100644
index 549fe6aecfd..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// The following code example displays the value of YearMonthPattern for selected cultures.
-//
-using namespace System;
-using namespace System::Globalization;
-void PrintPattern( String^ myCulture )
-{
- CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
- DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
- Console::WriteLine( " {0} {1}", myCulture, myDTFI->YearMonthPattern );
-}
-
-int main()
-{
-
- // Displays the values of the pattern properties.
- Console::WriteLine( " CULTURE PROPERTY VALUE" );
- PrintPattern( "en-US" );
- PrintPattern( "ja-JP" );
- PrintPattern( "fr-FR" );
-}
-
-/*
-This code produces the following output. The question marks take the place of native script characters.
-
- CULTURE PROPERTY VALUE
- en-US MMMM yyyy
- ja-JP yyyy年M月
- fr-FR MMMM yyyy
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInMonth/CPP/gregoriancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInMonth/CPP/gregoriancalendar_getdaysinmonth.cpp
deleted file mode 100644
index cde0e811c88..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInMonth/CPP/gregoriancalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month in each of
-// 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, GregorianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: 28 28 28 29 28
-Era 1: 28 28 28 29 28
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInYear/CPP/gregoriancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInYear/CPP/gregoriancalendar_getdaysinyear.cpp
deleted file mode 100644
index a15e780eff2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInYear/CPP/gregoriancalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, GregorianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: 365 365 365 366 365
-Era 1: 365 365 365 366 365
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp
deleted file mode 100644
index 990c729f21e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-
-// The following code example shows that DTFI ignores the punctuation in the
-// era name only if the calendar is Gregorian and the culture uses the era name "A.D.".
-//
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Collections;
-int main()
-{
-
- // Creates strings with punctuation and without.
- String^ strADPunc = "A.D.";
- String^ strADNoPunc = "AD";
- String^ strCEPunc = "C.E.";
- String^ strCENoPunc = "CE";
-
- // Calls DTFI::GetEra for each culture that uses GregorianCalendar as the default calendar.
- Console::WriteLine( " ----- AD ----- ----- CE -----" );
- Console::WriteLine( "CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR" );
- IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator();
- while ( en->MoveNext() )
- {
- CultureInfo^ myCI = safe_cast(en->Current);
- Console::Write( "{0, -12}", myCI );
- Console::Write( "{0,-7}{1,-9}", myCI->DateTimeFormat->GetEra( strADPunc ), myCI->DateTimeFormat->GetEra( strADNoPunc ) );
- Console::Write( "{0, -7}{1, -9}", myCI->DateTimeFormat->GetEra( strCEPunc ), myCI->DateTimeFormat->GetEra( strCENoPunc ) );
- Console::Write( "{0}", myCI->Calendar );
- Console::WriteLine();
- }
-}
-
-/*
-This code produces the following output. This output has been cropped for brevity.
-
- ----- AD ----- ----- CE -----
-CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR
-ar-SA -1 -1 -1 -1 System.Globalization.HijriCalendar
-ar-IQ 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-EG 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-LY 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-DZ 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-MA 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-TN 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-OM 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-YE 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-SY 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-JO 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-LB 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-KW 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-AE 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-BH 1 1 -1 -1 System.Globalization.GregorianCalendar
-ar-QA 1 1 -1 -1 System.Globalization.GregorianCalendar
-bg-BG 1 1 -1 -1 System.Globalization.GregorianCalendar
-ca-ES -1 -1 -1 -1 System.Globalization.GregorianCalendar
-zh-TW -1 -1 -1 -1 System.Globalization.GregorianCalendar
-zh-CN -1 -1 -1 -1 System.Globalization.GregorianCalendar
-zh-HK 1 1 -1 -1 System.Globalization.GregorianCalendar
-zh-SG 1 1 -1 -1 System.Globalization.GregorianCalendar
-zh-MO 1 1 -1 -1 System.Globalization.GregorianCalendar
-cs-CZ -1 -1 -1 -1 System.Globalization.GregorianCalendar
-da-DK 1 1 -1 -1 System.Globalization.GregorianCalendar
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetMonthsInYear/CPP/gregoriancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetMonthsInYear/CPP/gregoriancalendar_getmonthsinyear.cpp
deleted file mode 100644
index dfe3801afab..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetMonthsInYear/CPP/gregoriancalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, GregorianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: 12 12 12 12 12
-Era 1: 12 12 12 12 12
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapDay/CPP/gregoriancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapDay/CPP/gregoriancalendar_isleapday.cpp
deleted file mode 100644
index e69e21eeaba..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapDay/CPP/gregoriancalendar_isleapday.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the second
-// month (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, GregorianCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, GregorianCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapMonth/CPP/gregoriancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapMonth/CPP/gregoriancalendar_isleapmonth.cpp
deleted file mode 100644
index 140956b9f7f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapMonth/CPP/gregoriancalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in five years
-// in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 2001; y <= 2005; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, GregorianCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, GregorianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-2001: False False False False False False False False False False False False
-2002: False False False False False False False False False False False False
-2003: False False False False False False False False False False False False
-2004: False False False False False False False False False False False False
-2005: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapYear/CPP/gregoriancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapYear/CPP/gregoriancalendar_isleapyear.cpp
deleted file mode 100644
index 6331dd01784..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapYear/CPP/gregoriancalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, GregorianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp
deleted file mode 100644
index 1a0b6a1e910..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-
-// The following code example prints a DateTime using a GregorianCalendar that is localized.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes three different CultureInfo.
- CultureInfo^ myCIdeDE = gcnew CultureInfo( "de-DE",false );
- CultureInfo^ myCIenUS = gcnew CultureInfo( "en-US",false );
- CultureInfo^ myCIfrFR = gcnew CultureInfo( "fr-FR",false );
- CultureInfo^ myCIruRU = gcnew CultureInfo( "ru-RU",false );
-
- // Creates a Localized GregorianCalendar.
- // GregorianCalendarTypes::Localized is the default when using the GregorianCalendar constructor with->Item[Out] parameters.
- Calendar^ myCal = gcnew GregorianCalendar;
-
- // Sets the DateTimeFormatInfo::Calendar property to a Localized GregorianCalendar.
- // Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
- myCIruRU->DateTimeFormat->Calendar = myCal;
-
- // Creates a DateTime.
- DateTime myDT = DateTime(2002,1,3,13,30,45);
-
- // Displays the DateTime.
- Console::WriteLine( "de-DE: {0}", myDT.ToString( "F", myCIdeDE ) );
- Console::WriteLine( "en-US: {0}", myDT.ToString( "F", myCIenUS ) );
- Console::WriteLine( "fr-FR: {0}", myDT.ToString( "F", myCIfrFR ) );
- Console::WriteLine( "ru-RU: {0}", myDT.ToString( "F", myCIruRU ) );
-}
-
-/*
-The example displays the following output:
- de-DE: Donnerstag, 3. Januar 2002 13:30:45
- en-US: Thursday, January 03, 2002 1:30:45 PM
- fr-FR: jeudi 3 janvier 2002 13:30:45
- ru-RU: 3 января 2002 г. 13:30:45
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp
deleted file mode 100644
index 698b5b3e06f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example demonstrates how to determine the GregorianCalendar
-// version supported by the culture.
-//
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Collections;
-int main()
-{
-
- // Calendar* myOptCals[] = new CultureInfo(S"ar-SA") -> OptionalCalendars;
- CultureInfo^ MyCI = gcnew CultureInfo( "ar-SA" );
- array^myOptCals = MyCI->OptionalCalendars;
-
- // Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
- Console::WriteLine( "The ar-SA culture supports the following calendars:" );
- IEnumerator^ myEnum = myOptCals->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Calendar^ cal = safe_cast(myEnum->Current);
- if ( cal->GetType() == GregorianCalendar::typeid )
- {
- GregorianCalendar^ myGreCal = dynamic_cast(cal);
- GregorianCalendarTypes calType = myGreCal->CalendarType;
- Console::WriteLine( " {0} ( {1})", cal, calType );
- }
- else
- Console::WriteLine( " {0}", cal );
- }
-}
-
-/*
-This code produces the following output.
-
-The ar-SA culture supports the following calendars:
- System.Globalization.HijriCalendar
- System.Globalization.GregorianCalendar ( USEnglish)
- System.Globalization.GregorianCalendar ( MiddleEastFrench)
- System.Globalization.GregorianCalendar ( Arabic)
- System.Globalization.GregorianCalendar ( Localized)
- System.Globalization.GregorianCalendar ( TransliteratedFrench)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp
deleted file mode 100644
index 372b38993c5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Gregorian calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the GregorianCalendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar:
- Era: 1
- Year: 2002
- Month: 4
- DayOfYear: 93
- DayOfMonth: 3
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 2005
- Month: 2
- DayOfYear: 34
- DayOfMonth: 3
- DayOfWeek: Thursday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp
deleted file mode 100644
index f3640634df9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Create an instance of the calendar.
- GregorianCalendar^ myCal = gcnew GregorianCalendar;
- Console::WriteLine( myCal );
-
- // Display the MinSupportedDateTime.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::WriteLine( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::WriteLine( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.GregorianCalendar
-MinSupportedDateTime: 01/01/0001
-MaxSupportedDateTime: 12/31/9999
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp
deleted file mode 100644
index bc4213e8f2e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month in each of
-// 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, HebrewCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 5761 5762 5763 5764 5765
-CurrentEra: 29 29 30 30 29
-Era 1: 29 29 30 30 29
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp
deleted file mode 100644
index 57e2ea00d8c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, HebrewCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 5761 5762 5763 5764 5765
-CurrentEra: 12 12 13 12 13
-Era 1: 12 12 13 12 13
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp
deleted file mode 100644
index 9c1c73168c4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the second month
-// (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 5761; y <= 5765; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, HebrewCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, HebrewCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 5761; y <= 5765; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 5761 5762 5763 5764 5765
-CurrentEra: False False False False False
-Era 1: False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp
deleted file mode 100644
index 1da1268009b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in five years
-// in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 5761; y <= 5765; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, HebrewCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, HebrewCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-5761: False False False False False False False False False False False False
-5762: False False False False False False False False False False False False
-5763: False False False False False False True False False False False False False
-5764: False False False False False False False False False False False False
-5765: False False False False False False True False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp
deleted file mode 100644
index f7458927a3b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, HebrewCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 5761 5762 5763 5764 5765
-CurrentEra: False False True False True
-Era 1: False False True False True
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp
deleted file mode 100644
index cadc36701b1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Hebrew calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Hebrew calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the Hebrew calendar:
- Era: 1
- Year: 5762
- Month: 7
- DayOfYear: 198
- DayOfMonth: 21
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 5765
- Month: 5
- DayOfYear: 138
- DayOfMonth: 21
- DayOfWeek: Monday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp
deleted file mode 100644
index d739184677c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HebrewCalendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, HebrewCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 5761; y <= 5765; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 5761 5762 5763 5764 5765
-CurrentEra: 353 354 385 355 383
-Era 1: 353 354 385 355 383
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp
deleted file mode 100644
index 6355880b6f4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Create an instance of the calendar.
- HebrewCalendar^ myCal = gcnew HebrewCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.HebrewCalendar
-MinSupportedDateTime: 04/07/5343 (in Gregorian, 01/01/1583)
-MaxSupportedDateTime: 13/29/5999 (in Gregorian, 09/29/2239)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInMonth/CPP/hijricalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInMonth/CPP/hijricalendar_getdaysinmonth.cpp
deleted file mode 100644
index b31c1af503b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInMonth/CPP/hijricalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the twelfth month in
-// each of 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 12, HijriCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 12, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output. The results might vary depending on
-the settings in Regional and Language Options (or Regional Options or Regional Settings).
-
-YEAR 1421 1422 1423 1424 1425
-CurrentEra: 29 29 30 29 29
-Era 1: 29 29 30 29 29
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInYear/CPP/hijricalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInYear/CPP/hijricalendar_getdaysinyear.cpp
deleted file mode 100644
index 036e38f6962..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInYear/CPP/hijricalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, HijriCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output. The results might vary depending on
-the settings in Regional and Language Options (or Regional Options or Regional Settings).
-
-YEAR 1421 1422 1423 1424 1425
-CurrentEra: 354 354 355 354 354
-Era 1: 354 354 355 354 354
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetMonthsInYear/CPP/hijricalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetMonthsInYear/CPP/hijricalendar_getmonthsinyear.cpp
deleted file mode 100644
index f922542fad0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetMonthsInYear/CPP/hijricalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, HijriCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output. The results might vary depending on
-the settings in Regional and Language Options (or Regional Options or Regional Settings).
-
-YEAR 1421 1422 1423 1424 1425
-CurrentEra: 12 12 12 12 12
-Era 1: 12 12 12 12 12
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp
deleted file mode 100644
index 8ad91079056..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-
-// The following code example shows how HijriAdjustment affects the date.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Creates a DateTime and initializes it to the second day of the first month of the year 1422.
- DateTime myDT = DateTime(1422,1,2,myCal);
-
- // Displays the current values of the DateTime.
- Console::WriteLine( "HijriAdjustment is {0}.", myCal->HijriAdjustment );
- Console::WriteLine( " Year is {0}.", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month is {0}.", myCal->GetMonth( myDT ) );
- Console::WriteLine( " Day is {0}.", myCal->GetDayOfMonth( myDT ) );
-
- // Sets the HijriAdjustment property to 2.
- myCal->HijriAdjustment = 2;
- Console::WriteLine( "HijriAdjustment is {0}.", myCal->HijriAdjustment );
- Console::WriteLine( " Year is {0}.", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month is {0}.", myCal->GetMonth( myDT ) );
- Console::WriteLine( " Day is {0}.", myCal->GetDayOfMonth( myDT ) );
-
- // Sets the HijriAdjustment property to -2.
- myCal->HijriAdjustment = -2;
- Console::WriteLine( "HijriAdjustment is {0}.", myCal->HijriAdjustment );
- Console::WriteLine( " Year is {0}.", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month is {0}.", myCal->GetMonth( myDT ) );
- Console::WriteLine( " Day is {0}.", myCal->GetDayOfMonth( myDT ) );
-}
-
-/*
-This code produces the following output. Results vary depending on the registry settings.
-
-HijriAdjustment is 0.
-Year is 1422.
-Month is 1.
-Day is 2.
-HijriAdjustment is 2.
-Year is 1422.
-Month is 1.
-Day is 4.
-HijriAdjustment is -2.
-Year is 1421.
-Month is 12.
-Day is 29.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp
deleted file mode 100644
index 374dfbf3d96..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the second
-// month (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 1421; y <= 1425; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, HijriCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, HijriCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1421; y <= 1425; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 1421 1422 1423 1424 1425
-CurrentEra: False False False False False
-Era 1: False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapMonth/CPP/hijricalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapMonth/CPP/hijricalendar_isleapmonth.cpp
deleted file mode 100644
index aa01d2f822d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapMonth/CPP/hijricalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in
-// five years in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 1421; y <= 1425; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, HijriCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, HijriCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-1421: False False False False False False False False False False False False
-1422: False False False False False False False False False False False False
-1423: False False False False False False False False False False False False
-1424: False False False False False False False False False False False False
-1425: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapYear/CPP/hijricalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapYear/CPP/hijricalendar_isleapyear.cpp
deleted file mode 100644
index e3896e85af1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapYear/CPP/hijricalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, HijriCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1421; y <= 1425; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 1421 1422 1423 1424 1425
-CurrentEra: False False True False False
-Era 1: False False True False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp
deleted file mode 100644
index 8585d7966f6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Hijri calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the HijriCalendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Hijri calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the Hijri calendar:
- Era: 1
- Year: 1423
- Month: 1
- DayOfYear: 21
- DayOfMonth: 21
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 1425
- Month: 11
- DayOfYear: 316
- DayOfMonth: 21
- DayOfWeek: Saturday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp
deleted file mode 100644
index 4c8f361ea5f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Create an instance of the calendar.
- HijriCalendar^ myCal = gcnew HijriCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.HijriCalendar
-MinSupportedDateTime: 01/01/0001 (in Gregorian, 07/18/0622)
-MaxSupportedDateTime: 04/03/9666 (in Gregorian, 12/31/9999)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp
deleted file mode 100644
index 41a3f5fffa3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-// The following code example displays the values contained in the Eras property.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::WriteLine( "Eras[ {0}] = {1}", i, myCal->Eras[ i ] );
-
- }
-}
-
-/*
-This code produces the following output.
-
-Eras->Item[0] = 4
-Eras->Item[1] = 3
-Eras->Item[2] = 2
-Eras->Item[3] = 1
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp
deleted file mode 100644
index 18dc3f18f24..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month in each
-// of 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, JapaneseCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 1 2 3 4 5
-CurrentEra: 28 28 28 29 28
-Era 4: 28 28 28 29 28
-Era 3: 28 28 29 28 28
-Era 2: 29 28 28 28 29
-Era 1: 29 28 28 28 29
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp
deleted file mode 100644
index b7c757179f0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, JapaneseCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 1 2 3 4 5
-CurrentEra: 365 365 365 366 365
-Era 4: 365 365 365 366 365
-Era 3: 365 365 366 365 365
-Era 2: 366 365 365 365 366
-Era 1: 366 365 365 365 366
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp
deleted file mode 100644
index 8fff71ba264..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, JapaneseCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
- }
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp
deleted file mode 100644
index 085173db873..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Creates a holder for the last day of the second month (February)->
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 1; y <= 5; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, JapaneseCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, JapaneseCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1; y <= 5; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
- }
- Console::WriteLine();
- }
-}
-/*
-This code produces the following output.
-
-YEAR 1 2 3 4 5
-CurrentEra: False True False False False
-Era 5: False True False False False
-Era 4: False False False True False
-Era 3: False False True False False
-Era 2: True False False False True
-Era 1: True False False False True
-
-*/
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp
deleted file mode 100644
index de254b59da9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months
-// in five years in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 1; y <= 5; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, JapaneseCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, JapaneseCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-1: False False False False False False False False False False False False
-2: False False False False False False False False False False False False
-3: False False False False False False False False False False False False
-4: False False False False False False False False False False False False
-5: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp
deleted file mode 100644
index 5a922425510..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Creates and initializes a JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, JapaneseCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 1; y <= 5; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
- }
-}
-/*
-This code produces the following output.
-
-YEAR 1 2 3 4 5
-CurrentEra: False True False False False
-Era 5: False True False False False
-Era 4: False False False True False
-Era 3: False False True False False
-Era 2: True False False False True
-Era 1: True False False False True
-
-*/
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp
deleted file mode 100644
index b5ce5f316e5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Japanese calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the JapaneseCalendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Japanese calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the Japanese calendar:
- Era: 4
- Year: 14
- Month: 4
- DayOfYear: 93
- DayOfMonth: 3
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 4
- Year: 17
- Month: 2
- DayOfYear: 34
- DayOfMonth: 3
- DayOfWeek: Thursday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp
deleted file mode 100644
index d982671caed..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Create an instance of the calendar.
- JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.JapaneseCalendar
-MinSupportedDateTime: 09/08/0001 (in Gregorian, 09/08/1868)
-MaxSupportedDateTime: 12/31/8011 (in Gregorian, 12/31/9999)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp
deleted file mode 100644
index 34d49e99fe2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month in
-// each of 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, JulianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: 28 28 28 29 28
-Era 1: 28 28 28 29 28
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp
deleted file mode 100644
index 3e36971f4c5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, JulianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: 365 365 365 366 365
-Era 1: 365 365 365 366 365
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp
deleted file mode 100644
index 113ce8b1c77..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, JulianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: 12 12 12 12 12
-Era 1: 12 12 12 12 12
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp
deleted file mode 100644
index b8036ac7e05..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the
-// second month (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, JulianCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, JulianCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp
deleted file mode 100644
index b2d0997f2f8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in
-// five years in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 2001; y <= 2005; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, JulianCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, JulianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-2001: False False False False False False False False False False False False
-2002: False False False False False False False False False False False False
-2003: False False False False False False False False False False False False
-2004: False False False False False False False False False False False False
-2005: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp
deleted file mode 100644
index 5436dfbd8b5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, JulianCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2001; y <= 2005; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2001 2002 2003 2004 2005
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp
deleted file mode 100644
index e14dd6e99a2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Julian calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the JulianCalendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Julian calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the Julian calendar:
- Era: 1
- Year: 2002
- Month: 3
- DayOfYear: 80
- DayOfMonth: 21
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 2005
- Month: 1
- DayOfYear: 21
- DayOfMonth: 21
- DayOfWeek: Thursday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_MinMax/CPP/juliancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_MinMax/CPP/juliancalendar_minmax.cpp
deleted file mode 100644
index 5aa56fb4924..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_MinMax/CPP/juliancalendar_minmax.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Create an instance of the calendar.
- JulianCalendar^ myCal = gcnew JulianCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.JulianCalendar
-MinSupportedDateTime: 01/03/0001 (in Gregorian, 01/01/0001)
-MaxSupportedDateTime: 10/19/9999 (in Gregorian, 12/31/9999)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInMonth/CPP/koreancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInMonth/CPP/koreancalendar_getdaysinmonth.cpp
deleted file mode 100644
index 6b3c77a66da..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInMonth/CPP/koreancalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month
-// in each of 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, KoreanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 4334 4335 4336 4337 4338
-CurrentEra: 28 28 28 29 28
-Era 1: 28 28 28 29 28
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp
deleted file mode 100644
index 5211726ccf0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, KoreanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 4334 4335 4336 4337 4338
-CurrentEra: 365 365 365 366 365
-Era 1: 365 365 365 366 365
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp
deleted file mode 100644
index 33b5c948bd3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, KoreanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 4334 4335 4336 4337 4338
-CurrentEra: 12 12 12 12 12
-Era 1: 12 12 12 12 12
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp
deleted file mode 100644
index d973b468e66..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the second
-// month (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 4334; y <= 4338; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, KoreanCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, KoreanCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 4334; y <= 4338; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 4334 4335 4336 4337 4338
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp
deleted file mode 100644
index 3446270064d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in five years in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 4334; y <= 4338; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, KoreanCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, KoreanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-4334: False False False False False False False False False False False False
-4335: False False False False False False False False False False False False
-4336: False False False False False False False False False False False False
-4337: False False False False False False False False False False False False
-4338: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp
deleted file mode 100644
index 5e2e16c671d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, KoreanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 4334; y <= 4338; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 4334 4335 4336 4337 4338
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp
deleted file mode 100644
index 0af45b0db54..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Korean calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the KoreanCalendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Korean calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the Korean calendar:
- Era: 1
- Year: 4335
- Month: 4
- DayOfYear: 93
- DayOfMonth: 3
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 4338
- Month: 2
- DayOfYear: 34
- DayOfMonth: 3
- DayOfWeek: Thursday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_MinMax/CPP/koreancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_MinMax/CPP/koreancalendar_minmax.cpp
deleted file mode 100644
index 00de6b90a65..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_MinMax/CPP/koreancalendar_minmax.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
-
- // Create an instance of the calendar.
- KoreanCalendar^ myCal = gcnew KoreanCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.KoreanCalendar
-MinSupportedDateTime: 01/01/2334 (in Gregorian, 01/01/0001)
-MaxSupportedDateTime: 12/31/12332 (in Gregorian, 12/31/9999)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp
deleted file mode 100644
index 0725c178ee9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Globalization;
-using namespace System::Text;
-int main()
-{
-
- // Gets the InvariantInfo.
- NumberFormatInfo^ myInv = NumberFormatInfo::InvariantInfo;
-
- // Gets a UnicodeEncoding to display the Unicode value of symbols.
- UnicodeEncoding^ myUE = gcnew UnicodeEncoding( true,false );
- array^myCodes;
-
- // Displays the default values for each of the properties.
- Console::WriteLine( "InvariantInfo:\nNote: Symbols might not display correctly on the console, \ntherefore, Unicode values are included." );
- Console::WriteLine( "\tCurrencyDecimalDigits\t\t {0}", myInv->CurrencyDecimalDigits );
- Console::WriteLine( "\tCurrencyDecimalSeparator\t {0}", myInv->CurrencyDecimalSeparator );
- Console::WriteLine( "\tCurrencyGroupSeparator\t\t {0}", myInv->CurrencyGroupSeparator );
- Console::WriteLine( "\tCurrencyGroupSizes\t\t {0}", myInv->CurrencyGroupSizes[ 0 ] );
- Console::WriteLine( "\tCurrencyNegativePattern\t\t {0}", myInv->CurrencyNegativePattern );
- Console::WriteLine( "\tCurrencyPositivePattern\t\t {0}", myInv->CurrencyPositivePattern );
- myCodes = myUE->GetBytes( myInv->CurrencySymbol );
- Console::WriteLine( "\tCurrencySymbol\t\t\t {0}\t(U+ {1:x2} {2:x2})", myInv->CurrencySymbol, myCodes[ 0 ], myCodes[ 1 ] );
- Console::WriteLine( "\tNaNSymbol\t\t\t {0}", myInv->NaNSymbol );
- Console::WriteLine( "\tNegativeInfinitySymbol\t\t {0}", myInv->NegativeInfinitySymbol );
- Console::WriteLine( "\tNegativeSign\t\t\t {0}", myInv->NegativeSign );
- Console::WriteLine( "\tNumberDecimalDigits\t\t {0}", myInv->NumberDecimalDigits );
- Console::WriteLine( "\tNumberDecimalSeparator\t\t {0}", myInv->NumberDecimalSeparator );
- Console::WriteLine( "\tNumberGroupSeparator\t\t {0}", myInv->NumberGroupSeparator );
- Console::WriteLine( "\tNumberGroupSizes\t\t {0}", myInv->NumberGroupSizes[ 0 ] );
- Console::WriteLine( "\tNumberNegativePattern\t\t {0}", myInv->NumberNegativePattern );
- Console::WriteLine( "\tPercentDecimalDigits\t\t {0}", myInv->PercentDecimalDigits );
- Console::WriteLine( "\tPercentDecimalSeparator\t\t {0}", myInv->PercentDecimalSeparator );
- Console::WriteLine( "\tPercentGroupSeparator\t\t {0}", myInv->PercentGroupSeparator );
- Console::WriteLine( "\tPercentGroupSizes\t\t {0}", myInv->PercentGroupSizes[ 0 ] );
- Console::WriteLine( "\tPercentNegativePattern\t\t {0}", myInv->PercentNegativePattern );
- Console::WriteLine( "\tPercentPositivePattern\t\t {0}", myInv->PercentPositivePattern );
- myCodes = myUE->GetBytes( myInv->PercentSymbol );
- Console::WriteLine( "\tPercentSymbol\t\t\t {0}\t(U+ {1:x2} {2:x2})", myInv->PercentSymbol, myCodes[ 0 ], myCodes[ 1 ] );
- myCodes = myUE->GetBytes( myInv->PerMilleSymbol );
- Console::WriteLine( "\tPerMilleSymbol\t\t\t {0}\t(U+ {1:x2} {2:x2})", myInv->PerMilleSymbol, myCodes[ 0 ], myCodes[ 1 ] );
- Console::WriteLine( "\tPositiveInfinitySymbol\t\t {0}", myInv->PositiveInfinitySymbol );
- Console::WriteLine( "\tPositiveSign\t\t\t {0}", myInv->PositiveSign );
-}
-
-/*
-
-This code produces the following output.
-
-InvariantInfo:
-Note: Symbols might not display correctly on the console,
-therefore, Unicode values are included.
-CurrencyDecimalDigits 2
-CurrencyDecimalSeparator .
-CurrencyGroupSeparator ,
-CurrencyGroupSizes 3
-CurrencyNegativePattern 0
-CurrencyPositivePattern 0
-CurrencySymbol (U+00a4)
-NaNSymbol NaN
-NegativeInfinitySymbol -Infinity
-NegativeSign -
-NumberDecimalDigits 2
-NumberDecimalSeparator .
-NumberGroupSeparator ,
-NumberGroupSizes 3
-NumberNegativePattern 1
-PercentDecimalDigits 2
-PercentDecimalSeparator .
-PercentGroupSeparator ,
-PercentGroupSizes 3
-PercentNegativePattern 0
-PercentPositivePattern 0
-PercentSymbol % (U+0025)
-PerMilleSymbol % (U+2030)
-PositiveInfinitySymbol Infinity
-PositiveSign +
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp
deleted file mode 100644
index 1a0bf689d64..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// The following code example creates instances of
-// T:System.Globalization.RegionInfo using culture names.
-
-//
-using namespace System;
-using namespace System::Collections;
-using namespace System::Globalization;
-
-namespace Sample
-{
- public ref class SamplesRegionInfo
- {
- public:
- static void Work()
- {
-
- // Creates an array containing culture names.
- array ^ commonCultures =
- {"", "ar", "ar-DZ", "en", "en-US"};
-
- // Creates a RegionInfo for each of the culture names.
- // Note that "ar" is the culture name for the neutral
- // culture "Arabic", but it is also the region name for
- // the country/region "Argentina"; therefore, it does not
- // fail as expected.
- Console::WriteLine("Without checks...");
- for each (String^ cultureID in commonCultures)
- {
- try
- {
- RegionInfo^ region =
- gcnew RegionInfo(cultureID);
- }
-
- catch (ArgumentException^ ex)
- {
- Console::WriteLine(ex);
- }
- }
-
- Console::WriteLine();
-
- Console::WriteLine("Checking the culture"
- " names first...");
-
- for each (String^ cultureID in commonCultures)
- {
- if (cultureID->Length == 0)
- {
- Console::WriteLine(
- "The culture is the invariant culture.");
- }
- else
- {
- CultureInfo^ culture =
- gcnew CultureInfo(cultureID, false);
- if (culture->IsNeutralCulture)
- {
- Console::WriteLine("The culture {0} is "
- "a neutral culture.", cultureID);
- }
- else
- {
- Console::WriteLine("The culture {0} is "
- "a specific culture.", cultureID);
- try
- {
- RegionInfo^ region =
- gcnew RegionInfo(cultureID);
- }
- catch (ArgumentException^ ex)
- {
- Console::WriteLine(ex);
- }
- }
- }
- }
- Console::ReadLine();
- }
- };
-}
-
-int main()
-{
- Sample::SamplesRegionInfo::Work();
- return 0;
-}
-
-/*
-This code produces the following output.
-
-Without checks...
-System.ArgumentException: Region name '' is not supported.
-Parameter name: name
-at System.Globalization.RegionInfo..ctor(String name)
-at SamplesRegionInfo.Main()
-System.ArgumentException: Region name 'en' is not supported.
-Parameter name: name
-at System.Globalization.CultureTableRecord..ctor(String regionName,
- Boolean useUserOverride)
-at System.Globalization.RegionInfo..ctor(String name)
-at SamplesRegionInfo.Main()
-
-Checking the culture names first...
-The culture is the invariant culture.
-The culture ar is a neutral culture.
-The culture ar-DZ is a specific culture.
-The culture en is a neutral culture.
-The culture en-US is a specific culture.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp
deleted file mode 100644
index afae697de7f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-// The following code example demonstrates several members of the RegionInfo class.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Displays the property values of the RegionInfo for "US".
- RegionInfo^ myRI1 = gcnew RegionInfo( "US" );
- Console::WriteLine( " Name: {0}", myRI1->Name );
- Console::WriteLine( " DisplayName: {0}", myRI1->DisplayName );
- Console::WriteLine( " EnglishName: {0}", myRI1->EnglishName );
- Console::WriteLine( " IsMetric: {0}", myRI1->IsMetric );
- Console::WriteLine( " ThreeLetterISORegionName: {0}", myRI1->ThreeLetterISORegionName );
- Console::WriteLine( " ThreeLetterWindowsRegionName: {0}", myRI1->ThreeLetterWindowsRegionName );
- Console::WriteLine( " TwoLetterISORegionName: {0}", myRI1->TwoLetterISORegionName );
- Console::WriteLine( " CurrencySymbol: {0}", myRI1->CurrencySymbol );
- Console::WriteLine( " ISOCurrencySymbol: {0}", myRI1->ISOCurrencySymbol );
- Console::WriteLine();
-
- // Compares the RegionInfo above with another RegionInfo created using CultureInfo.
- RegionInfo^ myRI2 = gcnew RegionInfo( (gcnew CultureInfo( "en-US",false ))->LCID );
- if ( myRI1->Equals( myRI2 ) )
- Console::WriteLine( "The two RegionInfo instances are equal." );
- else
- Console::WriteLine( "The two RegionInfo instances are NOT equal." );
-}
-
-/*
-This code produces the following output.
-
- Name: US
- DisplayName: United States
- EnglishName: United States
- IsMetric: False
- ThreeLetterISORegionName: USA
- ThreeLetterWindowsRegionName: USA
- TwoLetterISORegionName: US
- CurrencySymbol: $
- ISOCurrencySymbol: USD
-
-The two RegionInfo instances are equal.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp
deleted file mode 100644
index 59f19db370c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-// The following code example compares two instances of RegionInfo that were created differently.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates a RegionInfo using the ISO 3166 two-letter code.
- RegionInfo^ myRI1 = gcnew RegionInfo( "US" );
-
- // Creates a RegionInfo using a CultureInfo.LCID.
- RegionInfo^ myRI2 = gcnew RegionInfo( (gcnew CultureInfo( "en-US",false ))->LCID );
-
- // Compares the two instances.
- if ( myRI1->Equals( myRI2 ) )
- Console::WriteLine( "The two RegionInfo instances are equal." );
- else
- Console::WriteLine( "The two RegionInfo instances are NOT equal." );
-}
-
-/*
-This code produces the following output.
-
-The two RegionInfo instances are equal.
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp
deleted file mode 100644
index b61096e79cc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example displays the properties of the RegionInfo class.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Displays the property values of the RegionInfo for "US".
- RegionInfo^ myRI1 = gcnew RegionInfo( "US" );
- Console::WriteLine( " Name: {0}", myRI1->Name );
- Console::WriteLine( " DisplayName: {0}", myRI1->DisplayName );
- Console::WriteLine( " EnglishName: {0}", myRI1->EnglishName );
- Console::WriteLine( " IsMetric: {0}", myRI1->IsMetric );
- Console::WriteLine( " ThreeLetterISORegionName: {0}", myRI1->ThreeLetterISORegionName );
- Console::WriteLine( " ThreeLetterWindowsRegionName: {0}", myRI1->ThreeLetterWindowsRegionName );
- Console::WriteLine( " TwoLetterISORegionName: {0}", myRI1->TwoLetterISORegionName );
- Console::WriteLine( " CurrencySymbol: {0}", myRI1->CurrencySymbol );
- Console::WriteLine( " ISOCurrencySymbol: {0}", myRI1->ISOCurrencySymbol );
-}
-
-/*
-This code produces the following output.
-
- Name: US
- DisplayName: United States
- EnglishName: United States
- IsMetric: False
- ThreeLetterISORegionName: USA
- ThreeLetterWindowsRegionName: USA
- TwoLetterISORegionName: US
- CurrencySymbol: $
- ISOCurrencySymbol: USD
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Compare/CPP/sortkey_compare.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Compare/CPP/sortkey_compare.cpp
deleted file mode 100644
index 1b59bd014bf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Compare/CPP/sortkey_compare.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example compares SortKey objects created with
-// cultures that have different sort orders.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates a SortKey using the en-US culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- CompareInfo^ myComp_enUS = MyCI->CompareInfo;
- SortKey^ mySK1 = myComp_enUS->GetSortKey( "llama" );
-
- // Creates a SortKey using the es-ES culture with international sort.
- MyCI = gcnew CultureInfo( "es-ES",false );
- CompareInfo^ myComp_esES = MyCI->CompareInfo;
- SortKey^ mySK2 = myComp_esES->GetSortKey( "llama" );
-
- // Creates a SortKey using the es-ES culture with traditional sort.
- MyCI = gcnew CultureInfo( 0x040A,false );
- CompareInfo^ myComp_es = MyCI->CompareInfo;
- SortKey^ mySK3 = myComp_es->GetSortKey( "llama" );
-
- // Compares the en-US SortKey with each of the es-ES SortKey objects.
- Console::WriteLine( "Comparing \"llama\" in en-US and in es-ES with international sort : {0}", SortKey::Compare( mySK1, mySK2 ) );
- Console::WriteLine( "Comparing \"llama\" in en-US and in es-ES with traditional sort : {0}", SortKey::Compare( mySK1, mySK3 ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing S"llama" in en-US and in es-ES with international sort : 0
-Comparing S"llama" in en-US and in es-ES with traditional sort : -1
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp
deleted file mode 100644
index 3f300f6813f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-
-// The following code example shows the results of SortKey->Equals
-// when compared with different SortKey objects.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates two identical en-US cultures and one de-DE culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- CompareInfo^ myComp_enUS1 = MyCI->CompareInfo;
- MyCI = gcnew CultureInfo( "en-US",false );
- CompareInfo^ myComp_enUS2 = MyCI->CompareInfo;
- MyCI = gcnew CultureInfo( "de-DE",false );
- CompareInfo^ myComp_deDE = MyCI->CompareInfo;
-
- // Creates the base SortKey to compare with all the others.
- SortKey^ mySK1 = myComp_enUS1->GetSortKey( "cant", CompareOptions::StringSort );
-
- // Creates a SortKey that is derived exactly the same way as the base SortKey.
- SortKey^ mySK2 = myComp_enUS1->GetSortKey( "cant", CompareOptions::StringSort );
-
- // Creates a SortKey that uses word sort, which is the default sort.
- SortKey^ mySK3 = myComp_enUS1->GetSortKey( "cant" );
-
- // Creates a SortKey for a different String*.
- SortKey^ mySK4 = myComp_enUS1->GetSortKey( "can't", CompareOptions::StringSort );
-
- // Creates a SortKey from a different CompareInfo with the same culture.
- SortKey^ mySK5 = myComp_enUS2->GetSortKey( "cant", CompareOptions::StringSort );
-
- // Creates a SortKey from a different CompareInfo with a different culture.
- SortKey^ mySK6 = myComp_deDE->GetSortKey( "cant", CompareOptions::StringSort );
-
- // Compares the base SortKey with itself.
- Console::WriteLine( "Comparing the base SortKey with itself: {0}", mySK1->Equals( mySK1 ) );
- Console::WriteLine();
-
- // Prints the header for the table.
- Console::WriteLine( "CompareInfo Culture OriginalString CompareOptions Equals()" );
-
- // Compares the base SortKey with a SortKey that is
- // created from the same CompareInfo with the same String* and the same CompareOptions.
- Console::WriteLine( "same same same same {0}", mySK1->Equals( mySK2 ) );
-
- // Compares the base SortKey with a SortKey that is
- // created from the same CompareInfo with the same String* but with different CompareOptions.
- Console::WriteLine( "same same same different {0}", mySK1->Equals( mySK3 ) );
-
- // Compares the base SortKey with a SortKey that is
- // created from the same CompareInfo with the different String*
- // but with the same CompareOptions.
- Console::WriteLine( "same same different same {0}", mySK1->Equals( mySK4 ) );
-
- // Compares the base SortKey with a SortKey that is
- // created from a different CompareInfo (same culture)
- // with the same String* and the same CompareOptions.
- Console::WriteLine( "different same same same {0}", mySK1->Equals( mySK5 ) );
-
- // Compares the base SortKey with a SortKey that is
- // created from a different CompareInfo (different culture)
- // with the same String* and the same CompareOptions.
- Console::WriteLine( "different different same same {0}", mySK1->Equals( mySK6 ) );
-}
-
-/*
-This code produces the following output.
-
-Comparing the base SortKey with itself: True
-
-CompareInfo Culture OriginalString CompareOptions Equals()
-same same same same True
-same same same different False
-same same different same False
-different same same same True
-different different same same False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp
deleted file mode 100644
index 59e7fbd6cec..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month in each
-// of 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, TaiwanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 90 91 92 93 94
-CurrentEra: 28 28 28 29 28
-Era 1: 28 28 28 29 28
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp
deleted file mode 100644
index be31d941d3e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, TaiwanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 90 91 92 93 94
-CurrentEra: 365 365 365 366 365
-Era 1: 365 365 365 366 365
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp
deleted file mode 100644
index 5dd8e46be7e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, TaiwanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 90 91 92 93 94
-CurrentEra: 12 12 12 12 12
-Era 1: 12 12 12 12 12
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp
deleted file mode 100644
index 89fc7fb7e6f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the second month (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t{0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 90; y <= 94; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, TaiwanCalendar::CurrentEra );
- Console::Write( "\t{0}", myCal->IsLeapDay( y, 2, iLastDay, TaiwanCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 90; y <= 94; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t{0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 90 91 92 93 94
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp
deleted file mode 100644
index 914453cabe8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in five years in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 90; y <= 94; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, TaiwanCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, TaiwanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-90: False False False False False False False False False False False False
-91: False False False False False False False False False False False False
-92: False False False False False False False False False False False False
-93: False False False False False False False False False False False False
-94: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp
deleted file mode 100644
index dc8bffdcf80..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, TaiwanCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 90; y <= 94; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 90 91 92 93 94
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp
deleted file mode 100644
index 99c84b107ab..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the Taiwan calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the TaiwanCalendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Taiwan calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the Taiwan calendar:
- Era: 1
- Year: 91
- Month: 4
- DayOfYear: 93
- DayOfMonth: 3
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 94
- Month: 2
- DayOfYear: 34
- DayOfMonth: 3
- DayOfWeek: Thursday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp
deleted file mode 100644
index 3deda76056f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-// The following code example gets the minimum value and the maximum value of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Create an instance of the calendar.
- TaiwanCalendar^ myCal = gcnew TaiwanCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.TaiwanCalendar
-MinSupportedDateTime: 01/01/0001 (in Gregorian, 01/01/1912)
-MaxSupportedDateTime: 12/31/8088 (in Gregorian, 12/31/9999)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp
deleted file mode 100644
index 9e73e264824..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// The following code example shows the values returned by TextElementEnumerator.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a String containing the following:
- // - a surrogate pair (high surrogate U+D800 and low surrogate U+DC00)
- // - a combining character sequence (the Latin small letter S"a" followed by the combining grave accent)
- // - a base character (the ligature S"")
- String^ myString = L"\xD800\xDC00"
- L"a\u0300\u00C6";
-
- // Creates and initializes a TextElementEnumerator for myString.
- TextElementEnumerator^ myTEE = StringInfo::GetTextElementEnumerator( myString );
-
- // Displays the values returned by ElementIndex, Current and GetTextElement.
- // Current and GetTextElement return a String* containing the entire text element.
- Console::WriteLine( "Index\tCurrent\tGetTextElement" );
- myTEE->Reset();
- while ( myTEE->MoveNext() )
- Console::WriteLine( "[{0}]:\t {1}\t {2}", myTEE->ElementIndex, myTEE->Current, myTEE->GetTextElement() );
-}
-
-/*
-This code produces the following output. The question marks take the place of high and low surrogates.
-
-Index Current GetTextElement
-[0]: 𐀀 𐀀
-[2]: à à
-[4]: Æ Æ
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp
deleted file mode 100644
index c77a0736012..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-
-// The following code example changes the casing of a String*.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Defines the String* with mixed casing.
- String^ myString = "wAr aNd pEaCe";
-
- // Creates a TextInfo based on the S"en-US" culture.
- CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
- TextInfo^ myTI = MyCI->TextInfo;
-
- // Changes a String* to lowercase.
- Console::WriteLine( "\"{0}\" to lowercase: {1}", myString, myTI->ToLower( myString ) );
-
- // Changes a String* to uppercase.
- Console::WriteLine( "\"{0}\" to uppercase: {1}", myString, myTI->ToUpper( myString ) );
-
- // Changes a String* to titlecase.
- Console::WriteLine( "\"{0}\" to titlecase: {1}", myString, myTI->ToTitleCase( myString ) );
-}
-
-/*
-This code produces the following output.
-
-S"wAr aNd pEaCe" to lowercase: war and peace
-S"wAr aNd pEaCe" to uppercase: WAR AND PEACE
-S"wAr aNd pEaCe" to titlecase: War And Peace
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp
deleted file mode 100644
index 88271b26c94..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// The following code example calls GetDaysInMonth for the second month in each of 5
-// years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, ThaiBuddhistCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2544 2545 2546 2547 2548
-CurrentEra: 28 28 28 29 28
-Era 1: 28 28 28 29 28
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp
deleted file mode 100644
index 9aa2d9d8dee..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetDaysInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, ThaiBuddhistCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2544 2545 2546 2547 2548
-CurrentEra: 365 365 365 366 365
-Era 1: 365 365 365 366 365
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp
deleted file mode 100644
index 3a8a6d35a73..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls GetMonthsInYear for 5 years in each era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Displays the value of the CurrentEra property.
- Console::Write( "CurrentEra:" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, ThaiBuddhistCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Displays the values in the Eras property.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2544 2545 2546 2547 2548
-CurrentEra: 12 12 12 12 12
-Era 1: 12 12 12 12 12
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp
deleted file mode 100644
index 356591167c0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// The following code example calls IsLeapDay for the last day of the
-// second month (February) for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Creates a holder for the last day of the second month (February).
- int iLastDay;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 2544; y <= 2548; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, ThaiBuddhistCalendar::CurrentEra );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, ThaiBuddhistCalendar::CurrentEra ) );
-
- }
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2544; y <= 2548; y++ )
- {
- iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] );
- Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) );
-
- }
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2544 2545 2546 2547 2548
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp
deleted file mode 100644
index 23dd963fa16..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-// The following code example calls IsLeapMonth for all the months in five years in the current era.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Checks all the months in five years in the current era.
- int iMonthsInYear;
- for ( int y = 2544; y <= 2548; y++ )
- {
- Console::Write( " {0}:\t", y );
- iMonthsInYear = myCal->GetMonthsInYear( y, ThaiBuddhistCalendar::CurrentEra );
- for ( int m = 1; m <= iMonthsInYear; m++ )
- Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, ThaiBuddhistCalendar::CurrentEra ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-2544: False False False False False False False False False False False False
-2545: False False False False False False False False False False False False
-2546: False False False False False False False False False False False False
-2547: False False False False False False False False False False False False
-2548: False False False False False False False False False False False False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp
deleted file mode 100644
index f8db76f0cbb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// The following code example calls IsLeapYear for five years in each of the eras.
-//
-using namespace System;
-using namespace System::Globalization;
-int main()
-{
-
- // Creates and initializes a ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Displays the header.
- Console::Write( "YEAR\t" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", y );
- Console::WriteLine();
-
- // Checks five years in the current era.
- Console::Write( "CurrentEra:" );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, ThaiBuddhistCalendar::CurrentEra ) );
- Console::WriteLine();
-
- // Checks five years in each of the eras.
- for ( int i = 0; i < myCal->Eras->Length; i++ )
- {
- Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
- for ( int y = 2544; y <= 2548; y++ )
- Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
- Console::WriteLine();
-
- }
-}
-
-/*
-This code produces the following output.
-
-YEAR 2544 2545 2546 2547 2548
-CurrentEra: False False False True False
-Era 1: False False False True False
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp
deleted file mode 100644
index 814657e163c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-
-// The following code example displays the values of several components of a DateTime in terms of the ThaiBuddhist calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-void DisplayValues( Calendar^ myCal, DateTime myDT )
-{
- Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) );
- Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) );
- Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) );
- Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) );
- Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) );
- Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) );
- Console::WriteLine();
-}
-
-int main()
-{
-
- // Sets a DateTime to April 3, 2002 of the Gregorian calendar.
- DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar);
-
- // Creates an instance of the ThaiBuddhistCalendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
-
- // Displays the values of the DateTime.
- Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the ThaiBuddhist calendar:" );
- DisplayValues( myCal, myDT );
-
- // Adds two years and ten months.
- myDT = myCal->AddYears( myDT, 2 );
- myDT = myCal->AddMonths( myDT, 10 );
-
- // Displays the values of the DateTime.
- Console::WriteLine( "After adding two years and ten months:" );
- DisplayValues( myCal, myDT );
-}
-
-/*
-This code produces the following output.
-
-April 3, 2002 of the Gregorian calendar equals the following in the ThaiBuddhist calendar:
- Era: 1
- Year: 2545
- Month: 4
- DayOfYear: 93
- DayOfMonth: 3
- DayOfWeek: Wednesday
-
-After adding two years and ten months:
- Era: 1
- Year: 2548
- Month: 2
- DayOfYear: 34
- DayOfMonth: 3
- DayOfWeek: Thursday
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_MinMax/CPP/thaibuddhistcalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_MinMax/CPP/thaibuddhistcalendar_minmax.cpp
deleted file mode 100644
index a3628cd7019..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_MinMax/CPP/thaibuddhistcalendar_minmax.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// The following code example gets the minimum date and the maximum date of the calendar.
-//
-using namespace System;
-using namespace System::Globalization;
-
-int main()
-{
- // Create an instance of the calendar.
- ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar;
- Console::WriteLine( myCal );
-
- // Create an instance of the GregorianCalendar.
- GregorianCalendar^ myGre = gcnew GregorianCalendar;
-
- // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMin = myCal->MinSupportedDateTime;
- Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) );
-
- // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar.
- DateTime myMax = myCal->MaxSupportedDateTime;
- Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) );
- Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) );
-}
-
-/*
-This code produces the following output.
-
-System.Globalization.ThaiBuddhistCalendar
-MinSupportedDateTime: 01/01/0544 (in Gregorian, 01/01/0001)
-MaxSupportedDateTime: 12/31/10542 (in Gregorian, 12/31/9999)
-
-*/
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp
deleted file mode 100644
index f1c0b919c12..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- int i = 0;
-
- // Create random data to write to the stream.
- array^writeArray = gcnew array(1000);
- (gcnew Random)->NextBytes( writeArray );
- BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream );
- BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream );
- try
- {
-
- // Write the data to the stream.
- Console::WriteLine( "Writing the data." );
- for ( i = 0; i < writeArray->Length; i++ )
- {
- binWriter->Write( writeArray[ i ] );
-
- }
-
- // Set the stream position to the beginning of the stream.
- binReader->BaseStream->Position = 0;
-
- // Read and verify the data from the stream.
- for ( i = 0; i < writeArray->Length; i++ )
- {
- if ( binReader->ReadByte() != writeArray[ i ] )
- {
- Console::WriteLine( "Error writing the data." );
- return -1;
- }
-
- }
- Console::WriteLine( "The data was written and verified." );
- }
- // Catch the EndOfStreamException and write an error message.
- catch ( EndOfStreamException^ e )
- {
- Console::WriteLine( "Error writing the data.\n{0}", e->GetType()->Name );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp
deleted file mode 100644
index a47e5998074..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- const int arrayLength = 1000;
-
- // Create random data to write to the stream.
- array^dataArray = gcnew array(arrayLength);
- (gcnew Random)->NextBytes( dataArray );
- BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream );
-
- // Write the data to the stream.
- Console::WriteLine( "Writing the data." );
- binWriter->Write( dataArray );
-
- // Create the reader using the stream from the writer.
- BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream );
-
- // Set the stream position to the beginning of the stream.
- binReader->BaseStream->Position = 0;
-
- // Read and verify the data.
- array^verifyArray = binReader->ReadBytes( arrayLength );
- if ( verifyArray->Length != arrayLength )
- {
- Console::WriteLine( "Error writing the data." );
- return -1;
- }
-
- for ( int i = 0; i < arrayLength; i++ )
- {
- if ( verifyArray[ i ] != dataArray[ i ] )
- {
- Console::WriteLine( "Error writing the data." );
- return -1;
- }
-
- }
- Console::WriteLine( "The data was written and verified." );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp
deleted file mode 100644
index f77f117e2d3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- int i;
- array^invalidPathChars = Path::InvalidPathChars;
- MemoryStream^ memStream = gcnew MemoryStream;
- BinaryWriter^ binWriter = gcnew BinaryWriter( memStream );
-
- // Write to memory.
- binWriter->Write( "Invalid file path characters are: " );
- for ( i = 0; i < invalidPathChars->Length; i++ )
- {
- binWriter->Write( invalidPathChars[ i ] );
-
- }
-
- // Create the reader using the same MemoryStream
- // as used with the writer.
- BinaryReader^ binReader = gcnew BinaryReader( memStream );
-
- // Set Position to the beginning of the stream.
- binReader->BaseStream->Position = 0;
-
- // Read the data from memory and write it to the console.
- Console::Write( binReader->ReadString() );
- array^memoryData = gcnew array(memStream->Length - memStream->Position);
- for ( i = 0; i < memoryData->Length; i++ )
- {
- memoryData[ i ] = binReader->ReadChar();
-
- }
- Console::WriteLine( memoryData );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp
deleted file mode 100644
index 1e60a82c46f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- int i;
- array^invalidPathChars = Path::InvalidPathChars;
- MemoryStream^ memStream = gcnew MemoryStream;
- BinaryWriter^ binWriter = gcnew BinaryWriter( memStream );
-
- // Write to memory.
- binWriter->Write( "Invalid file path characters are: " );
- for ( i = 0; i < invalidPathChars->Length; i++ )
- {
- binWriter->Write( invalidPathChars[ i ] );
-
- }
-
- // Create the reader using the same MemoryStream
- // as used with the writer.
- BinaryReader^ binReader = gcnew BinaryReader( memStream );
-
- // Set Position to the beginning of the stream.
- binReader->BaseStream->Position = 0;
-
- // Read the data from memory and write it to the console.
- Console::Write( binReader->ReadString() );
- array^memoryData = gcnew array(memStream->Length - memStream->Position);
- for ( i = 0; i < memoryData->Length; i++ )
- {
- memoryData[ i ] = Convert::ToChar( binReader->Read() );
-
- }
- Console::WriteLine( memoryData );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp
deleted file mode 100644
index 18e3d52cf62..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- array^invalidPathChars = Path::InvalidPathChars;
- MemoryStream^ memStream = gcnew MemoryStream;
- BinaryWriter^ binWriter = gcnew BinaryWriter( memStream );
-
- // Write to memory.
- binWriter->Write( "Invalid file path characters are: " );
- binWriter->Write( Path::InvalidPathChars );
-
- // Create the reader using the same MemoryStream
- // as used with the writer.
- BinaryReader^ binReader = gcnew BinaryReader( memStream );
-
- // Set Position to the beginning of the stream.
- binReader->BaseStream->Position = 0;
-
- // Read the data from memory and write it to the console.
- Console::Write( binReader->ReadString() );
- Console::WriteLine( binReader->ReadChars( (int)(memStream->Length - memStream->Position) ) );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp
deleted file mode 100644
index 591906554cb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- array^invalidPathChars = Path::InvalidPathChars;
- MemoryStream^ memStream = gcnew MemoryStream;
- BinaryWriter^ binWriter = gcnew BinaryWriter( memStream );
-
- // Write to memory.
- binWriter->Write( "Invalid file path characters are: " );
- binWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
-
- // Create the reader using the same MemoryStream
- // as used with the writer.
- BinaryReader^ binReader = gcnew BinaryReader( memStream );
-
- // Set Position to the beginning of the stream.
- binReader->BaseStream->Position = 0;
-
- // Read the data from memory and write it to the console.
- Console::Write( binReader->ReadString() );
- int arraySize = (int)(memStream->Length - memStream->Position);
- array^memoryData = gcnew array(arraySize);
- binReader->Read( memoryData, 0, arraySize );
- Console::WriteLine( memoryData );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp
deleted file mode 100644
index 68e90396c8a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- int i;
- const int arrayLength = 1000;
-
- // Create random data to write to the stream.
- array^dataArray = gcnew array(arrayLength);
- Random^ randomGenerator = gcnew Random;
- for ( i = 0; i < arrayLength; i++ )
- {
- dataArray[ i ] = 100.1 * randomGenerator->NextDouble();
-
- }
- BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream );
- try
- {
-
- // Write data to the stream.
- Console::WriteLine( "Writing data to the stream." );
- i = 0;
- for ( i = 0; i < arrayLength; i++ )
- {
- binWriter->Write( dataArray[ i ] );
-
- }
-
- // Create a reader using the stream from the writer.
- BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream );
-
- // Return to the beginning of the stream.
- binReader->BaseStream->Position = 0;
- try
- {
-
- // Read and verify the data.
- i = 0;
- Console::WriteLine( "Verifying the written data." );
- for ( i = 0; i < arrayLength; i++ )
- {
- if ( binReader->ReadDouble() != dataArray[ i ] )
- {
- Console::WriteLine( "Error writing data." );
- break;
- }
-
- }
- Console::WriteLine( "The data was written and verified." );
- }
- catch ( EndOfStreamException^ e )
- {
- Console::WriteLine( "Error writing data: {0}.", e->GetType()->Name );
- }
-
- }
- finally
- {
- binWriter->Close();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp
deleted file mode 100644
index 432c26e3d9c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-public ref class BinReadWrite
-{
-public:
- static void Main()
- {
- String^ testfile = "C:\\temp\\testfile.bin";
-
- // create a test file using BinaryWriter
- FileStream^ fs = File::Create(testfile);
- UTF8Encoding^ utf8 = gcnew UTF8Encoding();
-
- BinaryWriter^ bw = gcnew BinaryWriter(fs, utf8);
- // write a series of bytes to the file, each time incrementing
- // the value from 0 - 127
- int pos;
-
- for (pos = 0; pos < 128; pos++)
- {
- bw->Write((Byte)pos);
- }
-
- // reset the stream position for the next write pass
- bw->Seek(0, SeekOrigin::Begin);
- // write marks in file with the value of 255 going forward
- for (pos = 0; pos < 120; pos += 8)
- {
- bw->Seek(7, SeekOrigin::Current);
- bw->Write((Byte)255);
- }
-
- // reset the stream position for the next write pass
- bw->Seek(0, SeekOrigin::End);
- // write marks in file with the value of 254 going backward
- for (pos = 128; pos > 6; pos -= 6)
- {
- bw->Seek(-6, SeekOrigin::Current);
- bw->Write((Byte)254);
- bw->Seek(-1, SeekOrigin::Current);
- }
-
- // now dump the contents of the file using the original file stream
- fs->Seek(0, SeekOrigin::Begin);
- array^ rawbytes = gcnew array(fs->Length);
- fs->Read(rawbytes, 0, (int)fs->Length);
-
- int i = 0;
- for each (Byte b in rawbytes)
- {
- switch (b)
- {
- case 254:
- {
- Console::Write("-%- ");
- }
- break;
-
- case 255:
- {
- Console::Write("-*- ");
- }
- break;
-
- default:
- {
- Console::Write("{0:d3} ", b);
- }
- break;
- }
- i++;
- if (i == 16)
- {
- Console::WriteLine();
- i = 0;
- }
- }
- fs->Close();
- }
-};
-
-int main()
-{
- BinReadWrite::Main();
-}
-
-//The output from the program is this:
-//
-// 000 001 -%- 003 004 005 006 -*- -%- 009 010 011 012 013 -%- -*-
-// 016 017 018 019 -%- 021 022 -*- 024 025 -%- 027 028 029 030 -*-
-// -%- 033 034 035 036 037 -%- -*- 040 041 042 043 -%- 045 046 -*-
-// 048 049 -%- 051 052 053 054 -*- -%- 057 058 059 060 061 -%- -*-
-// 064 065 066 067 -%- 069 070 -*- 072 073 -%- 075 076 077 078 -*-
-// -%- 081 082 083 084 085 -%- -*- 088 089 090 091 -%- 093 094 -*-
-// 096 097 -%- 099 100 101 102 -*- -%- 105 106 107 108 109 -%- -*-
-// 112 113 114 115 -%- 117 118 -*- 120 121 -%- 123 124 125 126 127
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp
deleted file mode 100644
index c0d99cbb370..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Globalization;
-using namespace System::Net;
-using namespace System::Net::Sockets;
-static const int streamBufferSize = 1000;
-public ref class Client
-{
-private:
- literal int dataArraySize = 100;
- literal int numberOfLoops = 10000;
- Client(){}
-
-
-public:
- static void ReceiveData( Stream^ netStream, Stream^ bufStream )
- {
- DateTime startTime;
- Double networkTime;
- Double bufferedTime = 0;
- int bytesReceived = 0;
- array^receivedData = gcnew array(dataArraySize);
-
- // Receive data using the NetworkStream.
- Console::WriteLine( "Receiving data using NetworkStream." );
- startTime = DateTime::Now;
- while ( bytesReceived < numberOfLoops * receivedData->Length )
- {
- bytesReceived += netStream->Read( receivedData, 0, receivedData->Length );
- }
-
- networkTime = (DateTime::Now - startTime).TotalSeconds;
- Console::WriteLine( "{0} bytes received in {1} seconds.\n", bytesReceived.ToString(), networkTime.ToString( "F1" ) );
-
- //
- // Receive data using the BufferedStream.
- Console::WriteLine( "Receiving data using BufferedStream." );
- bytesReceived = 0;
- startTime = DateTime::Now;
- while ( bytesReceived < numberOfLoops * receivedData->Length )
- {
- bytesReceived += bufStream->Read( receivedData, 0, receivedData->Length );
- }
-
- bufferedTime = (DateTime::Now - startTime).TotalSeconds;
- Console::WriteLine( "{0} bytes received in {1} seconds.\n", bytesReceived.ToString(), bufferedTime.ToString( "F1" ) );
-
- //
- // Print the ratio of read times.
- Console::WriteLine( "Receiving data using the buffered "
- "network stream was {0} {1} than using the network "
- "stream alone.", (networkTime / bufferedTime).ToString( "P0" ), bufferedTime < networkTime ? (String^)"faster" : "slower" );
- }
-
- static void SendData( Stream^ netStream, Stream^ bufStream )
- {
- DateTime startTime;
- Double networkTime;
- Double bufferedTime;
-
- // Create random data to send to the server.
- array^dataToSend = gcnew array(dataArraySize);
- (gcnew Random)->NextBytes( dataToSend );
-
- // Send the data using the NetworkStream.
- Console::WriteLine( "Sending data using NetworkStream." );
- startTime = DateTime::Now;
- for ( int i = 0; i < numberOfLoops; i++ )
- {
- netStream->Write( dataToSend, 0, dataToSend->Length );
-
- }
- networkTime = (DateTime::Now - startTime).TotalSeconds;
- Console::WriteLine( "{0} bytes sent in {1} seconds.\n", (numberOfLoops * dataToSend->Length).ToString(), networkTime.ToString( "F1" ) );
-
- //
- // Send the data using the BufferedStream.
- Console::WriteLine( "Sending data using BufferedStream." );
- startTime = DateTime::Now;
- for ( int i = 0; i < numberOfLoops; i++ )
- {
- bufStream->Write( dataToSend, 0, dataToSend->Length );
-
- }
- bufStream->Flush();
- bufferedTime = (DateTime::Now - startTime).TotalSeconds;
- Console::WriteLine( "{0} bytes sent in {1} seconds.\n", (numberOfLoops * dataToSend->Length).ToString(), bufferedTime.ToString( "F1" ) );
-
- //
- // Print the ratio of write times.
- Console::WriteLine( "Sending data using the buffered "
- "network stream was {0} {1} than using the network "
- "stream alone.\n", (networkTime / bufferedTime).ToString( "P0" ), bufferedTime < networkTime ? (String^)"faster" : "slower" );
- }
-
-};
-
-int main( int argc, char *argv[] )
-{
-
- // Check that an argument was specified when the
- // program was invoked.
- if ( argc == 1 )
- {
- Console::WriteLine( "Error: The name of the host computer"
- " must be specified when the program is invoked." );
- return -1;
- }
-
- String^ remoteName = gcnew String( argv[ 1 ] );
-
- // Create the underlying socket and connect to the server.
- Socket^ clientSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp );
- clientSocket->Connect( gcnew IPEndPoint( Dns::Resolve( remoteName )->AddressList[ 0 ],1800 ) );
- Console::WriteLine( "Client is connected.\n" );
-
- //
- // Create a NetworkStream that owns clientSocket and
- // then create a BufferedStream on top of the NetworkStream.
- NetworkStream^ netStream = gcnew NetworkStream( clientSocket,true );
- BufferedStream^ bufStream = gcnew BufferedStream( netStream,streamBufferSize );
-
- //
- try
- {
-
- //
- // Check whether the underlying stream supports seeking.
- Console::WriteLine( "NetworkStream {0} seeking.\n", bufStream->CanSeek ? (String^)"supports" : "does not support" );
-
- //
- // Send and receive data.
- //
- if ( bufStream->CanWrite )
- {
- Client::SendData( netStream, bufStream );
- }
-
- //
- //
- if ( bufStream->CanRead )
- {
- Client::ReceiveData( netStream, bufStream );
- }
-
- //
- }
- finally
- {
-
- //
- // When bufStream is closed, netStream is in turn closed,
- // which in turn shuts down the connection and closes
- // clientSocket.
- Console::WriteLine( "\nShutting down connection." );
- bufStream->Close();
-
- //
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp
deleted file mode 100644
index fef12f4fa47..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Net;
-using namespace System::Net::Sockets;
-int main()
-{
-
- // This is a Windows Sockets 2 error code.
- const int WSAETIMEDOUT = 10060;
- Socket^ serverSocket;
- int bytesReceived;
- int totalReceived = 0;
- array^receivedData = gcnew array(2000000);
-
- // Create random data to send to the client.
- array^dataToSend = gcnew array(2000000);
- (gcnew Random)->NextBytes( dataToSend );
- IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ];
- IPEndPoint^ ipEndpoint = gcnew IPEndPoint( ipAddress,1800 );
-
- // Create a socket and listen for incoming connections.
- Socket^ listenSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp );
- try
- {
- listenSocket->Bind( ipEndpoint );
- listenSocket->Listen( 1 );
-
- // Accept a connection and create a socket to handle it.
- serverSocket = listenSocket->Accept();
- Console::WriteLine( "Server is connected.\n" );
- }
- finally
- {
- listenSocket->Close();
- }
-
- try
- {
-
- // Send data to the client.
- Console::Write( "Sending data ... " );
- int bytesSent = serverSocket->Send( dataToSend, 0, dataToSend->Length, SocketFlags::None );
- Console::WriteLine( "{0} bytes sent.\n", bytesSent.ToString() );
-
- // Set the timeout for receiving data to 2 seconds.
- serverSocket->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::ReceiveTimeout, 2000 );
-
- // Receive data from the client.
- Console::Write( "Receiving data ... " );
- try
- {
- do
- {
- bytesReceived = serverSocket->Receive( receivedData, 0, receivedData->Length, SocketFlags::None );
- totalReceived += bytesReceived;
- }
- while ( bytesReceived != 0 );
- }
- catch ( SocketException^ e )
- {
- if ( e->ErrorCode == WSAETIMEDOUT )
- {
-
- // Data was not received within the given time.
- // Assume that the transmission has ended.
- }
- else
- {
- Console::WriteLine( "{0}: {1}\n", e->GetType()->Name, e->Message );
- }
- }
- finally
- {
- Console::WriteLine( "{0} bytes received.\n", totalReceived.ToString() );
- }
-
- }
- finally
- {
- serverSocket->Shutdown( SocketShutdown::Both );
- Console::WriteLine( "Connection shut down." );
- serverSocket->Close();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp
deleted file mode 100644
index c11186b5225..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-
-//
-//
-//
-//
-//
-using namespace System;
-class Class1
-{
-public:
- void PrintFileSystemEntries( String^ path )
- {
- try
- {
-
- // Obtain the file system entries in the directory path.
- array^directoryEntries = System::IO::Directory::GetFileSystemEntries( path );
- for ( int i = 0; i < directoryEntries->Length; i++ )
- {
- System::Console::WriteLine( directoryEntries[ i ] );
-
- }
- }
- catch ( ArgumentNullException^ )
- {
- System::Console::WriteLine( "Path is a null reference." );
- }
- catch ( System::Security::SecurityException^ )
- {
- System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." );
- }
- catch ( ArgumentException^ )
- {
- System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, \HelloServer' or contains invalid characters." );
- }
- catch ( System::IO::DirectoryNotFoundException^ )
- {
- System::Console::WriteLine( "The path encapsulated in the \HelloServer' Directory object does not exist." );
- }
-
- }
-
- void PrintFileSystemEntries( String^ path, String^ pattern )
- {
- try
- {
-
- // Obtain the file system entries in the directory
- // path that match the pattern.
- array^directoryEntries = System::IO::Directory::GetFileSystemEntries( path, pattern );
- for ( int i = 0; i < directoryEntries->Length; i++ )
- {
- System::Console::WriteLine( directoryEntries[ i ] );
-
- }
- }
- catch ( ArgumentNullException^ )
- {
- System::Console::WriteLine( "Path is a null reference." );
- }
- catch ( System::Security::SecurityException^ )
- {
- System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." );
- }
- catch ( ArgumentException^ )
- {
- System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, \HelloServer' or contains invalid characters." );
- }
- catch ( System::IO::DirectoryNotFoundException^ )
- {
- System::Console::WriteLine( "The path encapsulated in the \HelloServer' Directory object does not exist." );
- }
-
- }
-
-
- // Print out all logical drives on the system.
- void GetLogicalDrives()
- {
- try
- {
- array^drives = System::IO::Directory::GetLogicalDrives();
- for ( int i = 0; i < drives->Length; i++ )
- {
- System::Console::WriteLine( drives[ i ] );
-
- }
- }
- catch ( System::IO::IOException^ )
- {
- System::Console::WriteLine( "An I/O error occurs." );
- }
- catch ( System::Security::SecurityException^ )
- {
- System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." );
- }
-
- }
-
- void GetParent( String^ path )
- {
- try
- {
- System::IO::DirectoryInfo^ directoryInfo = System::IO::Directory::GetParent( path );
- System::Console::WriteLine( directoryInfo->FullName );
- }
- catch ( ArgumentNullException^ )
- {
- System::Console::WriteLine( "Path is a null reference." );
- }
- catch ( ArgumentException^ )
- {
- System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, or \HelloServer' contains invalid characters." );
- }
-
- }
-
- void Move( String^ sourcePath, String^ destinationPath )
- {
- try
- {
- System::IO::Directory::Move( sourcePath, destinationPath );
- System::Console::WriteLine( "The directory move is complete." );
- }
- catch ( ArgumentNullException^ )
- {
- System::Console::WriteLine( "Path is a null reference." );
- }
- catch ( System::Security::SecurityException^ )
- {
- System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." );
- }
- catch ( ArgumentException^ )
- {
- System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, \HelloServer' or contains invalid characters." );
- }
- catch ( System::IO::IOException^ )
- {
- System::Console::WriteLine( "An attempt was made to move a \HelloServer' directory to a different \HelloServer' volume, or destDirName \HelloServer' already exists." );
- }
-
- }
-
-};
-
-int main()
-{
- Class1 * snippets = new Class1;
- String^ path = System::IO::Directory::GetCurrentDirectory();
- String^ filter = "*.exe";
- snippets->PrintFileSystemEntries( path );
- snippets->PrintFileSystemEntries( path, filter );
- snippets->GetLogicalDrives();
- snippets->GetParent( path );
- snippets->Move( "C:\\proof", "C:\\Temp" );
- return 0;
-}
-
-//
-//
-//
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp
deleted file mode 100644
index 4223289ec56..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-
-ref class App
-{
-public:
- static void Main()
- {
- // Specify the directory you want to manipulate.
- String^ path = "c:\\";
- String^ searchPattern = "c*";
-
- DirectoryInfo^ di = gcnew DirectoryInfo(path);
- array^ directories =
- di->GetDirectories(searchPattern, SearchOption::TopDirectoryOnly);
-
- array^ files =
- di->GetFiles(searchPattern, SearchOption::TopDirectoryOnly);
-
- Console::WriteLine(
- "Directories that begin with the letter \"c\" in {0}", path);
- for each (DirectoryInfo^ dir in directories)
- {
- Console::WriteLine(
- "{0,-25} {1,25}", dir->FullName, dir->LastWriteTime);
- }
-
- Console::WriteLine();
- Console::WriteLine(
- "Files that begin with the letter \"c\" in {0}", path);
- for each (FileInfo^ file in files)
- {
- Console::WriteLine(
- "{0,-25} {1,25}", file->Name, file->LastWriteTime);
- }
- } // Main()
-}; // App()
-
-int main()
-{
- App::Main();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp
deleted file mode 100644
index 5bae2a921c4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-
-//
-// This sample shows how to set the current directory and how to determine
-// the root directory.
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Create string for a directory. This value should be an existing directory
- // or the sample will throw a DirectoryNotFoundException.
- String^ dir = "C:\\test";
- try
- {
-
- //Set the current directory.
- Directory::SetCurrentDirectory( dir );
- }
- catch ( DirectoryNotFoundException^ e )
- {
- Console::WriteLine( "The specified directory does not exist. {0}", e );
- }
-
-
- // Print to console the results.
- Console::WriteLine( "Root directory: {0}", Directory::GetDirectoryRoot( dir ) );
- Console::WriteLine( "Current directory: {0}", Directory::GetCurrentDirectory() );
-}
-
-// The output of this sample depends on what value you assign to the variable dir.
-// If the directory c:\test exists, the output for this sample is:
-// Root directory: C:\
-// Current directory: C:\test
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp
deleted file mode 100644
index fc1124722e1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ fileName = "Test@##@.dat";
-
- // Create random data to write to the file.
- array^dataArray = gcnew array(100000);
- (gcnew Random)->NextBytes( dataArray );
- FileStream^ fileStream = gcnew FileStream( fileName,FileMode::Create );
- try
- {
-
- // Write the data to the file, byte by byte.
- for ( int i = 0; i < dataArray->Length; i++ )
- {
- fileStream->WriteByte( dataArray[ i ] );
-
- }
-
- // Set the stream position to the beginning of the file.
- fileStream->Seek( 0, SeekOrigin::Begin );
-
- // Read and verify the data.
- for ( int i = 0; i < fileStream->Length; i++ )
- {
- if ( dataArray[ i ] != fileStream->ReadByte() )
- {
- Console::WriteLine( "Error writing data." );
- return -1;
- }
-
- }
- Console::WriteLine( "The data was written to {0} "
- "and verified.", fileStream->Name );
- }
- finally
- {
- fileStream->Close();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp
deleted file mode 100644
index e6d0b8b59b5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Threading;
-
-// Maintain state information to be passed to
-// EndWriteCallback and EndReadCallback.
-ref class State
-{
-private:
-
- // fStream is used to read and write to the file.
- FileStream^ fStream;
-
- // writeArray stores data that is written to the file.
- array^writeArray;
-
- // readArray stores data that is read from the file.
- array^readArray;
-
- // manualEvent signals the main thread
- // when verification is complete.
- ManualResetEvent^ manualEvent;
-
-public:
- State( FileStream^ fStream, array^writeArray, ManualResetEvent^ manualEvent )
- {
- this->fStream = fStream;
- this->writeArray = writeArray;
- this->manualEvent = manualEvent;
- readArray = gcnew array(writeArray->Length);
- }
-
-
- property FileStream^ FStream
- {
- FileStream^ get()
- {
- return fStream;
- }
-
- }
-
- property array^ WriteArray
- {
- array^ get()
- {
- return writeArray;
- }
-
- }
-
- property array^ ReadArray
- {
- array^ get()
- {
- return readArray;
- }
-
- }
-
- property ManualResetEvent^ ManualEvent
- {
- ManualResetEvent^ get()
- {
- return manualEvent;
- }
-
- }
-
-};
-
-ref class FStream
-{
-private:
-
- // When BeginRead is finished reading data from the file, the
- // EndReadCallback method is called to end the asynchronous
- // read operation and then verify the data.
- //
- static void EndReadCallback( IAsyncResult^ asyncResult )
- {
- State^ tempState = dynamic_cast(asyncResult->AsyncState);
- int readCount = tempState->FStream->EndRead( asyncResult );
- int i = 0;
- while ( i < readCount )
- {
- if ( tempState->ReadArray[ i ] != tempState->WriteArray[ i++ ] )
- {
- Console::WriteLine( "Error writing data." );
- tempState->FStream->Close();
- return;
- }
- }
-
- Console::WriteLine( "The data was written to {0} "
- "and verified.", tempState->FStream->Name );
- tempState->FStream->Close();
-
- // Signal the main thread that the verification is finished.
- tempState->ManualEvent->Set();
- }
-
-
-public:
-
- //
- // When BeginWrite is finished writing data to the file, the
- // EndWriteCallback method is called to end the asynchronous
- // write operation and then read back and verify the data.
- //
- static void EndWriteCallback( IAsyncResult^ asyncResult )
- {
- State^ tempState = dynamic_cast(asyncResult->AsyncState);
- FileStream^ fStream = tempState->FStream;
- fStream->EndWrite( asyncResult );
-
- // Asynchronously read back the written data.
- fStream->Position = 0;
- asyncResult = fStream->BeginRead( tempState->ReadArray, 0, tempState->ReadArray->Length, gcnew AsyncCallback( &FStream::EndReadCallback ), tempState );
-
- // Concurrently do other work, such as
- // logging the write operation.
- }
-
-};
-
-
-//
-//
-int main()
-{
-
- // Create a synchronization object that gets
- // signaled when verification is complete.
- ManualResetEvent^ manualEvent = gcnew ManualResetEvent( false );
-
- // Create the data to write to the file.
- array^writeArray = gcnew array(100000);
- (gcnew Random)->NextBytes( writeArray );
- FileStream^ fStream = gcnew FileStream( "Test#@@#.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::None,4096,true );
-
- // Check that the FileStream was opened asynchronously.
- Console::WriteLine( "fStream was {0}opened asynchronously.", fStream->IsAsync ? (String^)"" : "not " );
-
- // Asynchronously write to the file.
- IAsyncResult^ asyncResult = fStream->BeginWrite( writeArray, 0, writeArray->Length, gcnew AsyncCallback( &FStream::EndWriteCallback ), gcnew State( fStream,writeArray,manualEvent ) );
-
- // Concurrently do other work and then wait
- // for the data to be written and verified.
- manualEvent->WaitOne( 5000, false );
-}
-
-//
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp
deleted file mode 100644
index c9d04e24506..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-int main()
-{
- UnicodeEncoding^ uniEncoding = gcnew UnicodeEncoding;
- String^ lastRecordText = "The last processed record number was: ";
- int textLength = uniEncoding->GetByteCount( lastRecordText );
- int recordNumber = 13;
- int byteCount = uniEncoding->GetByteCount( recordNumber.ToString() );
- String^ tempString;
-
- //
- FileStream^ fileStream = gcnew FileStream( "Test#@@#.dat",FileMode::OpenOrCreate,FileAccess::ReadWrite,FileShare::ReadWrite );
-
- //
- try
- {
-
- //
- // Write the original file data.
- if ( fileStream->Length == 0 )
- {
- tempString = String::Concat( lastRecordText, recordNumber.ToString() );
- fileStream->Write( uniEncoding->GetBytes( tempString ), 0, uniEncoding->GetByteCount( tempString ) );
- }
-
- //
- // Allow the user to choose the operation.
- Char consoleInput = 'R';
- array^readText = gcnew array(fileStream->Length);
- while ( consoleInput != 'X' )
- {
- Console::Write( "\nEnter 'R' to read, 'W' to write, 'L' to "
- "lock, 'U' to unlock, anything else to exit: " );
- if ( (tempString = Console::ReadLine())->Length == 0 )
- {
- break;
- }
- consoleInput = Char::ToUpper( tempString[0] );
- switch ( consoleInput )
- {
- case 'R':
- try
- {
- fileStream->Seek( 0, SeekOrigin::Begin );
- fileStream->Read( readText, 0, (int)fileStream->Length );
- tempString = gcnew String( uniEncoding->GetChars( readText, 0, readText->Length ) );
- Console::WriteLine( tempString );
- recordNumber = Int32::Parse( tempString->Substring( tempString->IndexOf( ':' ) + 2 ) );
- }
- // Catch the IOException generated if the
- // specified part of the file is locked.
- catch ( IOException^ e )
- {
- Console::WriteLine( "{0}: The read "
- "operation could not be performed "
- "because the specified part of the "
- "file is locked.", e->GetType()->Name );
- }
-
- break;
-
- //
- // Update the file.
- case 'W':
- try
- {
- fileStream->Seek( textLength, SeekOrigin::Begin );
- fileStream->Read( readText, textLength - 1, byteCount );
- tempString = gcnew String( uniEncoding->GetChars( readText, textLength - 1, byteCount ) );
- recordNumber = Int32::Parse( tempString ) + 1;
- fileStream->Seek( textLength, SeekOrigin::Begin );
- fileStream->Write( uniEncoding->GetBytes( recordNumber.ToString() ), 0, byteCount );
- fileStream->Flush();
- Console::WriteLine( "Record has been updated." );
- }
- //
- //
- // Catch the IOException generated if the
- // specified part of the file is locked.
- catch ( IOException^ e )
- {
- Console::WriteLine( "{0}: The write operation could not "
- "be performed because the specified "
- "part of the file is locked.", e->GetType()->Name );
- }
-
-
- //
- break;
-
- // Lock the specified part of the file.
- case 'L':
- try
- {
- fileStream->Lock( textLength - 1, byteCount );
- Console::WriteLine( "The specified part "
- "of file has been locked." );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( "{0}: The specified part of file is"
- " already locked.", e->GetType()->Name );
- }
-
- break;
-
- //
- // Unlock the specified part of the file.
- case 'U':
- try
- {
- fileStream->Unlock( textLength - 1, byteCount );
- Console::WriteLine( "The specified part "
- "of file has been unlocked." );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( "{0}: The specified part of file is "
- "not locked by the current process.", e->GetType()->Name );
- }
-
- break;
-
- default:
-
- //
- // Exit the program.
- consoleInput = 'X';
- break;
- }
- }
- }
- finally
- {
- fileStream->Close();
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp
deleted file mode 100644
index af3bee22a32..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-using namespace System;
-using namespace System::IO;
-using namespace System::IO::IsolatedStorage;
-
-public ref class IsoFileGetStoreSample
-{
-public:
- static void Main()
- {
- IsolatedStorageFile^ isoFile;
-
- // remarks for GetMachineStoreForApplication()
- //
- isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Application |
- IsolatedStorageScope::Machine, (Type^)nullptr);
- //
- isoFile->Close();
-
- // remarks for GetMachineStoreForAssembly()
- //
- isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly |
- IsolatedStorageScope::Machine, (Type^)nullptr, (Type^)nullptr);
- //
- isoFile->Close();
-
- // remarks for GetMachineStoreForDomain()
- //
- isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly |
- IsolatedStorageScope::Domain | IsolatedStorageScope::Machine,
- (Type^)nullptr, (Type^)nullptr);
- //
- isoFile->Close();
-
- // remarks for GetUserStoreForApplication()
- //
- isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Application |
- IsolatedStorageScope::User, (Type^)nullptr);
- //
- isoFile->Close();
-
- // remarks for GetUserStoreForAssembly()
- //
- isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly |
- IsolatedStorageScope::User, (Type^)nullptr, (Type^)nullptr);
- //
- isoFile->Close();
-
- // remarks for GetUserStoreForDomain()
- //
- isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly |
- IsolatedStorageScope::Domain | IsolatedStorageScope::User,
- (Type^)nullptr, (Type^)nullptr);
- //
- isoFile->Close();
- }
-};
-
-int main()
-{
- IsoFileGetStoreSample::Main();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp
deleted file mode 100644
index daaf6e6e7ea..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-
-//
-// This sample demonstrates methods of classes found in the System.IO IsolatedStorage namespace.
-using namespace System;
-using namespace System::IO;
-using namespace System::IO::IsolatedStorage;
-using namespace System::Security::Policy;
-using namespace System::Security::Permissions;
-
-public ref class LoginPrefs
-{
-private:
- String^ userName;
- String^ newsUrl;
- String^ sportsUrl;
- bool newPrefs;
-
-public:
-
- //
- [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
- bool GetPrefsForUser()
- {
- try
- {
-
- //
- // Retrieve an IsolatedStorageFile for the current Domain and Assembly.
- IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr );
- IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile );
-
- //
- // farThe code executes to this point only if a file corresponding to the username exists.
- // Though you can perform operations on the stream, you cannot get a handle to the file.
- try
- {
- IntPtr aFileHandle = isoStream->Handle;
- Console::WriteLine( "A pointer to a file handle has been obtained. {0} {1}", aFileHandle, aFileHandle.GetHashCode() );
- }
- catch ( Exception^ e )
- {
-
- // Handle the exception.
- Console::WriteLine( "Expected exception" );
- Console::WriteLine( e->ToString() );
- }
-
- StreamReader^ reader = gcnew StreamReader( isoStream );
-
- // Read the data.
- this->NewsUrl = reader->ReadLine();
- this->SportsUrl = reader->ReadLine();
- reader->Close();
- isoFile->Close();
- isoStream->Close();
- return false;
- }
- catch ( Exception^ e )
- {
-
- // Expected exception if a file cannot be found. This indicates that we have a new user.
- String^ errorMessage = e->ToString();
- return true;
- }
-
- }
-
-
- //
- //
- bool GetIsoStoreInfo()
- {
-
- // Get a User store with type evidence for the current Domain and the Assembly.
- IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
-
- //
- array^dirNames = isoFile->GetDirectoryNames( "*" );
- array^fileNames = isoFile->GetFileNames( "*" );
-
- // List directories currently in this Isolated Storage.
- if ( dirNames->Length > 0 )
- {
- for ( int i = 0; i < dirNames->Length; ++i )
- {
- Console::WriteLine( "Directory Name: {0}", dirNames[ i ] );
-
- }
- }
-
-
- // List the files currently in this Isolated Storage.
- // The list represents all users who have personal preferences stored for this application.
- if ( fileNames->Length > 0 )
- {
- for ( int i = 0; i < fileNames->Length; ++i )
- {
- Console::WriteLine( "File Name: {0}", fileNames[ i ] );
-
- }
- }
-
-
- //
- isoFile->Close();
- return true;
- }
-
-
- //
- //
- double SetPrefsForUser()
- {
- try
- {
-
- //
- IsolatedStorageFile^ isoFile;
- isoFile = IsolatedStorageFile::GetUserStoreForDomain();
-
- // Open or create a writable file.
- IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,isoFile );
- StreamWriter^ writer = gcnew StreamWriter( isoStream );
- writer->WriteLine( this->NewsUrl );
- writer->WriteLine( this->SportsUrl );
-
- // Calculate the amount of space used to record the user's preferences.
- double d = isoFile->CurrentSize / isoFile->MaximumSize;
- Console::WriteLine( "CurrentSize = {0}", isoFile->CurrentSize.ToString() );
- Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() );
- writer->Close();
- isoFile->Close();
- isoStream->Close();
- return d;
-
- //
- }
- catch ( Exception^ e )
- {
- // Add code here to handle the exception.
- Console::WriteLine( e->ToString() );
- return 0.0;
- }
-
- }
-
-
- //
- //
- void DeleteFiles()
- {
-
- //
- try
- {
- IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
- array^dirNames = isoFile->GetDirectoryNames( "*" );
- array^fileNames = isoFile->GetFileNames( "*" );
-
- //
- // List the files currently in this Isolated Storage.
- // The list represents all users who have personal
- // preferences stored for this application.
- if ( fileNames->Length > 0 )
- {
- for ( int i = 0; i < fileNames->Length; ++i )
- {
-
- //Delete the files.
- isoFile->DeleteFile( fileNames[ i ] );
-
- }
- fileNames = isoFile->GetFileNames( "*" );
- }
- isoFile->Close();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->ToString() );
- }
-
- }
-
-
- //
- //
- // This method deletes directories in the specified Isolated Storage, after first
- // deleting the files they contain. In this example, the Archive directory is deleted.
- // There should be no other directories in this Isolated Storage.
- void DeleteDirectories()
- {
- try
- {
- IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
- array^dirNames = isoFile->GetDirectoryNames( "*" );
- array^fileNames = isoFile->GetFileNames( "Archive\\*" );
-
- // Delete the current files within the Archive directory.
- if ( fileNames->Length > 0 )
- {
- for ( int i = 0; i < fileNames->Length; ++i )
- {
-
- //delete files
- isoFile->DeleteFile( String::Concat("Archive\\", fileNames[ i ]) );
-
- }
- fileNames = isoFile->GetFileNames( "Archive\\*" );
- }
- if ( dirNames->Length > 0 )
- {
- for ( int i = 0; i < dirNames->Length; ++i )
- {
-
- // Delete the Archive directory.
- isoFile->DeleteDirectory( dirNames[ i ] );
-
- }
- }
- dirNames = isoFile->GetDirectoryNames( "*" );
- isoFile->Remove();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->ToString() );
- }
-
- }
-
-
- //
- //
- double SetNewPrefsForUser()
- {
- try
- {
- Byte inputChar;
- IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
-
- // If this is not a new user, archive the old preferences and
- // overwrite them using the new preferences.
- if ( !this->NewPrefs )
- {
- if ( isoFile->GetDirectoryNames( "Archive" )->Length == 0 )
- isoFile->CreateDirectory( "Archive" );
- else
- {
-
- //
- // This is the stream to which data will be written.
- IsolatedStorageFileStream^ source = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,isoFile );
-
- // This is the stream from which data will be read.
- Console::WriteLine( "Is the source file readable? {0}", (source->CanRead ? (String^)"true" : "false") );
- Console::WriteLine( "Creating new IsolatedStorageFileStream for Archive." );
-
- // Open or create a writable file.
- IsolatedStorageFileStream^ target = gcnew IsolatedStorageFileStream( String::Concat("Archive\\",this->userName),FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,isoFile );
-
- //
- //
- Console::WriteLine( "Is the target file writable? {0}", (target->CanWrite ? (String^)"true" : "false") );
-
- //
- // Stream the old file to a new file in the Archive directory.
- if ( source->IsAsync && target->IsAsync )
- {
-
- // IsolatedStorageFileStreams cannot be asynchronous. However, you
- // can use the asynchronous BeginRead and BeginWrite functions
- // with some possible performance penalty.
- Console::WriteLine( "IsolatedStorageFileStreams cannot be asynchronous." );
- }
- else
- {
-
- //
- Console::WriteLine( "Writing data to the new file." );
- while ( source->Position < source->Length )
- {
- inputChar = (Byte)source->ReadByte();
- target->WriteByte( (Byte)source->ReadByte() );
- }
-
- // Determine the size of the IsolatedStorageFileStream
- // by checking its Length property.
- Console::WriteLine( "Total Bytes Read: {0}", source->Length.ToString() );
-
- //
- }
-
- // After you have read and written to the streams, close them.
- target->Close();
- source->Close();
- }
- }
-
- //
- // Open or create a writable file, no larger than 10k
- IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,10240,isoFile );
-
- //
- isoStream->Position = 0; // Position to overwrite the old data.
-
- //
- //
- StreamWriter^ writer = gcnew StreamWriter( isoStream );
-
- // Update the data based on the new inputs.
- writer->WriteLine( this->NewsUrl );
- writer->WriteLine( this->SportsUrl );
-
- // Calculate the amount of space used to record this user's preferences.
- double d = isoFile->CurrentSize / isoFile->MaximumSize;
- Console::WriteLine( "CurrentSize = {0}", isoFile->CurrentSize.ToString() );
- Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() );
-
- //
- // StreamWriter.Close implicitly closes isoStream.
- writer->Close();
- isoFile->Close();
- return d;
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->ToString() );
- return 0.0;
- }
-
- }
-
- LoginPrefs( String^ aUserName )
- {
- userName = aUserName;
- newPrefs = GetPrefsForUser();
- }
-
-
- property String^ NewsUrl
- {
- String^ get()
- {
- return newsUrl;
- }
-
- void set( String^ value )
- {
- newsUrl = value;
- }
-
- }
-
- property String^ SportsUrl
- {
- String^ get()
- {
- return sportsUrl;
- }
-
- void set( String^ value )
- {
- sportsUrl = value;
- }
-
- }
-
- property bool NewPrefs
- {
- bool get()
- {
- return newPrefs;
- }
-
- }
-
-};
-
-void GatherInfoFromUser( LoginPrefs^ lp )
-{
- Console::WriteLine( "Please enter the URL of your news site." );
- lp->NewsUrl = Console::ReadLine();
- Console::WriteLine( "Please enter the URL of your sports site." );
- lp->SportsUrl = Console::ReadLine();
-}
-
-int main()
-{
-
- // Prompt the user for their username.
- Console::WriteLine( "Enter your login ID:" );
-
- // Does no error checking.
- LoginPrefs^ lp = gcnew LoginPrefs( Console::ReadLine() );
- if ( lp->NewPrefs )
- {
- Console::WriteLine( "Please set preferences for a new user." );
- GatherInfoFromUser( lp );
-
- // Write the new preferences to storage.
- double percentUsed = lp->SetPrefsForUser();
- Console::WriteLine( "Your preferences have been written. Current space used is {0}%", percentUsed );
- }
- else
- {
- Console::WriteLine( "Welcome back." );
- Console::WriteLine( "Your preferences have expired, please reset them." );
- GatherInfoFromUser( lp );
- lp->SetNewPrefsForUser();
- Console::WriteLine( "Your news site has been set to {0}\n and your sports site has been set to {1}.", lp->NewsUrl, lp->SportsUrl );
- }
-
- lp->GetIsoStoreInfo();
- Console::WriteLine( "Enter 'd' to delete the IsolatedStorage files and exit, or press any other key to exit without deleting files." );
- String^ consoleInput = Console::ReadLine();
- if ( consoleInput->Equals( "d" ) )
- {
- lp->DeleteFiles();
- lp->DeleteDirectories();
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp
deleted file mode 100644
index 6d60f8f19f3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-
-int main()
-{
- int count;
- array^byteArray;
- array^charArray;
- UnicodeEncoding^ uniEncoding = gcnew UnicodeEncoding;
-
- // Create the data to write to the stream.
- array^firstString = uniEncoding->GetBytes( "Invalid file path characters are: " );
- array^secondString = uniEncoding->GetBytes( Path::InvalidPathChars );
-
- //
- MemoryStream^ memStream = gcnew MemoryStream( 100 );
- //
- try
- {
- //
- // Write the first string to the stream.
- memStream->Write( firstString, 0, firstString->Length );
- //
-
- //
- // Write the second string to the stream, byte by byte.
- count = 0;
- while ( count < secondString->Length )
- {
- memStream->WriteByte( secondString[ count++ ] );
- }
- //
-
-
- //
- // Write the stream properties to the console.
- Console::WriteLine( "Capacity = {0}, Length = {1}, "
- "Position = {2}\n", memStream->Capacity.ToString(), memStream->Length.ToString(), memStream->Position.ToString() );
- //
-
- //
- // Set the stream position to the beginning of the stream.
- memStream->Seek( 0, SeekOrigin::Begin );
- //
-
- //
- // Read the first 20 bytes from the stream.
- byteArray = gcnew array(memStream->Length);
- count = memStream->Read( byteArray, 0, 20 );
- //
-
- //
- // Read the remaining bytes, byte by byte.
- while ( count < memStream->Length )
- {
- byteArray[ count++ ] = Convert::ToByte( memStream->ReadByte() );
- }
- //
-
- // Decode the Byte array into a Char array
- // and write it to the console.
- charArray = gcnew array(uniEncoding->GetCharCount( byteArray, 0, count ));
- uniEncoding->GetDecoder()->GetChars( byteArray, 0, count, charArray, 0 );
- Console::WriteLine( charArray );
- }
- finally
- {
- memStream->Close();
- }
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp
deleted file mode 100644
index ea4a47ab8ca..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-void ChangeExtension()
-{
- String^ goodFileName = "C:\\mydir\\myfile.com.extension";
- String^ badFileName = "C:\\mydir\\";
- String^ result;
- result = Path::ChangeExtension( goodFileName, ".old" );
- Console::WriteLine( "ChangeExtension({0}, '.old') returns '{1}'", goodFileName, result );
- result = Path::ChangeExtension( goodFileName, "" );
- Console::WriteLine( "ChangeExtension({0}, '') returns '{1}'", goodFileName, result );
- result = Path::ChangeExtension( badFileName, ".old" );
- Console::WriteLine( "ChangeExtension({0}, '.old') returns '{1}'", badFileName, result );
-
- // This code produces output similar to the following:
- //
- // ChangeExtension(C:\mydir\myfile.com.extension, '.old') returns 'C:\mydir\myfile.com.old'
- // ChangeExtension(C:\mydir\myfile.com.extension, '') returns 'C:\mydir\myfile.com.'
- // ChangeExtension(C:\mydir\, '.old') returns 'C:\mydir\.old'
- //
- Console::WriteLine();
-}
-
-void Combine()
-{
- //
- String^ path1 = " C:\\mydir1";
- String^ path2 = "mydir2";
- String^ path3 = " mydir3";
- String^ combinedPaths;
- combinedPaths = Path::Combine( path1, path2 );
- Console::WriteLine( "Combine('{0}', '{1}') returns '{2}'", path1, path2, combinedPaths );
- combinedPaths = Path::Combine( path1, path3 );
- Console::WriteLine( "Combine('{0}', '{1}') returns '{2}'", path1, path3, combinedPaths );
-
- // This code produces output similar to the following:
- //
- // Combine(' C:\mydir1', 'mydir2') returns ' C:\mydir1\mydir2'
- // Combine(' C:\mydir1', ' mydir3') returns ' C:\mydir1\ mydir3'
- //
- Console::WriteLine();
-}
-
-void GetDirectoryName()
-{
- //
- String^ filePath = "C:\\MyDir\\MySubDir\\myfile.ext";
- String^ directoryName;
- int i = 0;
-
- while (filePath != nullptr)
- {
- directoryName = Path::GetDirectoryName(filePath);
- Console::WriteLine("GetDirectoryName('{0}') returns '{1}'",
- filePath, directoryName);
- filePath = directoryName;
- if (i == 1)
- {
- filePath = directoryName + "\\"; // this will preserve the previous path
- }
- i++;
- }
- /*
- This code produces the following output:
-
- GetDirectoryName('C:\MyDir\MySubDir\myfile.ext') returns 'C:\MyDir\MySubDir'
- GetDirectoryName('C:\MyDir\MySubDir') returns 'C:\MyDir'
- GetDirectoryName('C:\MyDir\') returns 'C:\MyDir'
- GetDirectoryName('C:\MyDir') returns 'C:\'
- GetDirectoryName('C:\') returns ''
- */
- //
- Console::WriteLine();
-}
-
-void GetExtension()
-{
- //
- String^ fileName = "C:\\mydir.old\\myfile.ext";
- String^ path = "C:\\mydir.old\\";
- String^ extension;
- extension = Path::GetExtension( fileName );
- Console::WriteLine( "GetExtension('{0}') returns '{1}'", fileName, extension );
- extension = Path::GetExtension( path );
- Console::WriteLine( "GetExtension('{0}') returns '{1}'", path, extension );
-
- // This code produces output similar to the following:
- //
- // GetExtension('C:\mydir.old\myfile.ext') returns '.ext'
- // GetExtension('C:\mydir.old\') returns ''
- //
- Console::WriteLine();
-}
-
-void GetFileName()
-{
- //
- String^ fileName = "C:\\mydir\\myfile.ext";
- String^ path = "C:\\mydir\\";
- String^ result;
- result = Path::GetFileName( fileName );
- Console::WriteLine( "GetFileName('{0}') returns '{1}'", fileName, result );
- result = Path::GetFileName( path );
- Console::WriteLine( "GetFileName('{0}') returns '{1}'", path, result );
-
- // This code produces output similar to the following:
- //
- // GetFileName('C:\mydir\myfile.ext') returns 'myfile.ext'
- // GetFileName('C:\mydir\') returns ''
- //
- Console::WriteLine();
-}
-
-void GetFileNameWithoutExtension()
-{
- //
- String^ fileName = "C:\\mydir\\myfile.ext";
- String^ path = "C:\\mydir\\";
- String^ result;
- result = Path::GetFileNameWithoutExtension( fileName );
- Console::WriteLine( "GetFileNameWithoutExtension('{0}') returns '{1}'", fileName, result );
- result = Path::GetFileName( path );
- Console::WriteLine( "GetFileName('{0}') returns '{1}'", path, result );
-
- // This code produces output similar to the following:
- //
- // GetFileNameWithoutExtension('C:\mydir\myfile.ext') returns 'myfile'
- // GetFileName('C:\mydir\') returns ''
- //
- Console::WriteLine();
-}
-
-void GetFullPath()
-{
- //
- String^ fileName = "myfile.ext";
- String^ path = "\\mydir\\";
- String^ fullPath;
- fullPath = Path::GetFullPath( path );
- Console::WriteLine( "GetFullPath('{0}') returns '{1}'", path, fullPath );
- fullPath = Path::GetFullPath( fileName );
- Console::WriteLine( "GetFullPath('{0}') returns '{1}'", fileName, fullPath );
-
- // Output is based on your current directory, except
- // in the last case, where it is based on the root drive
- // GetFullPath('mydir') returns 'C:\temp\Demo\mydir'
- // GetFullPath('myfile.ext') returns 'C:\temp\Demo\myfile.ext'
- // GetFullPath('\mydir') returns 'C:\mydir'
- //
- Console::WriteLine();
-}
-
-void GetPathRoot()
-{
- //
- String^ path = "\\mydir\\";
- String^ fileName = "myfile.ext";
- String^ fullPath = "C:\\mydir\\myfile.ext";
- String^ pathRoot;
- pathRoot = Path::GetPathRoot( path );
- Console::WriteLine( "GetPathRoot('{0}') returns '{1}'", path, pathRoot );
- pathRoot = Path::GetPathRoot( fileName );
- Console::WriteLine( "GetPathRoot('{0}') returns '{1}'", fileName, pathRoot );
- pathRoot = Path::GetPathRoot( fullPath );
- Console::WriteLine( "GetPathRoot('{0}') returns '{1}'", fullPath, pathRoot );
-
- // This code produces output similar to the following:
- //
- // GetPathRoot('\mydir\') returns '\'
- // GetPathRoot('myfile.ext') returns ''
- // GetPathRoot('C:\mydir\myfile.ext') returns 'C:\'
- //
- Console::WriteLine();
-}
-
-void GetTempFileName()
-{
- //
- String^ fileName = Path::GetTempFileName();
- FileInfo^ fileInfo = gcnew FileInfo( fileName );
- Console::WriteLine( "File '{0}' created of size {1} bytes", fileName, (fileInfo->Length).ToString() );
-
- // Write some text to the file.
- FileStream^ f = gcnew FileStream( fileName,FileMode::Open );
- StreamWriter^ s = gcnew StreamWriter( f );
- s->WriteLine( "Output to the file" );
- s->Close();
- f->Close();
- fileInfo->Refresh();
- Console::WriteLine( "File '{0}' now has size {1} bytes", fileName, (fileInfo->Length).ToString() );
-
- // This code produces output similar to the following:
- //
- // File 'D:\Documents and Settings\cliffc\Local Settings\Temp\8\tmp38.tmp' created of size 0 bytes
- // File 'D:\Documents and Settings\cliffc\Local Settings\Temp\8\tmp38.tmp' now has size 20 bytes
- //
- Console::WriteLine();
-}
-
-void GetTempPath()
-{
- //
- String^ tempPath = Path::GetTempPath();
- Console::WriteLine( "Temporary path is '{0}'", tempPath );
- DirectoryInfo^ tempDir = gcnew DirectoryInfo( tempPath );
- Console::WriteLine( "{0} contains {1} files", tempPath, (tempDir->GetFiles()->Length).ToString() );
-
- // This code produces output similar to the following:
- //
- // Temporary path is 'D:\Documents and Settings\cliffc\Local Settings\Temp\8\'
- // D:\Documents and Settings\cliffc\Local Settings\Temp\8\ contains 6 files
- //
- Console::WriteLine();
-}
-
-void HasExtension()
-{
- //
- String^ fileName1 = "myfile.ext";
- String^ fileName2 = "mydir\\myfile";
- String^ path = "C:\\mydir.ext\\";
- bool result;
- result = Path::HasExtension( fileName1 );
- Console::WriteLine( "HasExtension('{0}') returns {1}", fileName1, result.ToString() );
- result = Path::HasExtension( fileName2 );
- Console::WriteLine( "HasExtension('{0}') returns {1}", fileName2, result.ToString() );
- result = Path::HasExtension( path );
- Console::WriteLine( "HasExtension('{0}') returns {1}", path, result.ToString() );
-
- // This code produces output similar to the following:
- //
- // HasExtension('myfile.ext') returns True
- // HasExtension('mydir\myfile') returns False
- // HasExtension('C:\mydir.ext\') returns False
- //
- Console::WriteLine();
-}
-
-void IsPathRooted()
-{
- //
- String^ fileName = "C:\\mydir\\myfile.ext";
- String^ UncPath = "\\\\myPc\\mydir\\myfile";
- String^ relativePath = "mydir\\sudir\\";
- bool result;
- result = Path::IsPathRooted( fileName );
- Console::WriteLine( "IsPathRooted('{0}') returns {1}", fileName, result.ToString() );
- result = Path::IsPathRooted( UncPath );
- Console::WriteLine( "IsPathRooted('{0}') returns {1}", UncPath, result.ToString() );
- result = Path::IsPathRooted( relativePath );
- Console::WriteLine( "IsPathRooted('{0}') returns {1}", relativePath, result.ToString() );
-
- // This code produces output similar to the following:
- //
- // IsPathRooted('C:\mydir\myfile.ext') returns True
- // IsPathRooted('\\myPc\mydir\myfile') returns True
- // IsPathRooted('mydir\sudir\') returns False
- //
- Console::WriteLine();
-}
-
-void StaticProperties()
-{
- //
- Console::WriteLine( "Path::AltDirectorySeparatorChar={0}", (Path::AltDirectorySeparatorChar).ToString() );
- Console::WriteLine( "Path::DirectorySeparatorChar={0}", (Path::DirectorySeparatorChar).ToString() );
- Console::WriteLine( "Path::PathSeparator={0}", (Path::PathSeparator).ToString() );
- Console::WriteLine( "Path::VolumeSeparatorChar={0}", (Path::VolumeSeparatorChar).ToString() );
- Console::Write( "Path::InvalidPathChars=" );
- for ( int i = 0; i < Path::InvalidPathChars->Length; i++ )
- Console::Write( Path::InvalidPathChars[ i ] );
- Console::WriteLine();
-
- // This code produces output similar to the following:
- // Note that the InvalidPathCharacters contain characters
- // outside of the printable character set.
- //
- // Path.AltDirectorySeparatorChar=/
- // Path.DirectorySeparatorChar=\
- // Path.PathSeparator=;
- // Path.VolumeSeparatorChar=:
- //
- Console::WriteLine();
-}
-
-int main( void )
-{
- Console::WriteLine();
- StaticProperties();
- ChangeExtension();
- Combine();
- GetDirectoryName();
- GetExtension();
- GetFileName();
- GetFileNameWithoutExtension();
- GetFullPath();
- GetPathRoot();
- GetTempFileName();
- GetTempPath();
- HasExtension();
- IsPathRooted();
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp
deleted file mode 100644
index 2aed9679b07..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::IO::Pipes;
-
-ref class PipeClient
-{
-public:
- static void Main(array^ args)
- {
- if (args->Length > 1)
- {
- PipeStream^ pipeClient = gcnew AnonymousPipeClientStream(PipeDirection::In, args[1]);
-
- Console::WriteLine("[CLIENT] Current TransmissionMode: {0}.",
- pipeClient->TransmissionMode);
-
- StreamReader^ sr = gcnew StreamReader(pipeClient);
-
- // Display the read text to the console
- String^ temp;
-
- // Wait for 'sync message' from the server.
- do
- {
- Console::WriteLine("[CLIENT] Wait for sync...");
- temp = sr->ReadLine();
- }
- while (!temp->StartsWith("SYNC"));
-
- // Read the server data and echo to the console.
- while ((temp = sr->ReadLine()) != nullptr)
- {
- Console::WriteLine("[CLIENT] Echo: " + temp);
- }
- sr->Close();
- pipeClient->Close();
- }
- Console::Write("[CLIENT] Press Enter to continue...");
- Console::ReadLine();
- }
-};
-
-int main()
-{
- array^ args = Environment::GetCommandLineArgs();
- PipeClient::Main(args);
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp
deleted file mode 100644
index 26174ff6fe9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-#using
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::IO::Pipes;
-using namespace System::Diagnostics;
-
-ref class PipeServer
-{
-public:
- static void Main()
- {
- Process^ pipeClient = gcnew Process();
-
- pipeClient->StartInfo->FileName = "pipeClient.exe";
-
- AnonymousPipeServerStream^ pipeServer =
- gcnew AnonymousPipeServerStream(PipeDirection::Out,
- HandleInheritability::Inheritable);
-
- Console::WriteLine("[SERVER] Current TransmissionMode: {0}.",
- pipeServer->TransmissionMode);
-
- // Pass the client process a handle to the server.
- pipeClient->StartInfo->Arguments =
- pipeServer->GetClientHandleAsString();
- pipeClient->StartInfo->UseShellExecute = false;
- pipeClient->Start();
-
- pipeServer->DisposeLocalCopyOfClientHandle();
-
- try
- {
- // Read user input and send that to the client process.
- StreamWriter^ sw = gcnew StreamWriter(pipeServer);
-
- sw->AutoFlush = true;
- // Send a 'sync message' and wait for client to receive it.
- sw->WriteLine("SYNC");
- pipeServer->WaitForPipeDrain();
- // Send the console input to the client process.
- Console::Write("[SERVER] Enter text: ");
- sw->WriteLine(Console::ReadLine());
- sw->Close();
- }
- // Catch the IOException that is raised if the pipe is broken
- // or disconnected.
- catch (IOException^ e)
- {
- Console::WriteLine("[SERVER] Error: {0}", e->Message);
- }
- pipeServer->Close();
- pipeClient->WaitForExit();
- pipeClient->Close();
- Console::WriteLine("[SERVER] Client quit. Server terminating.");
- }
-};
-
-int main()
-{
- PipeServer::Main();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp
deleted file mode 100644
index 8908a781218..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::IO::Pipes;
-using namespace System::Text;
-using namespace System::Threading;
-
-// Defines the data protocol for reading and writing strings on our stream
-public ref class StreamString
-{
-private:
- Stream^ ioStream;
- UnicodeEncoding^ streamEncoding;
-
-public:
- StreamString(Stream^ ioStream)
- {
- this->ioStream = ioStream;
- streamEncoding = gcnew UnicodeEncoding();
- }
-
- String^ ReadString()
- {
- int len;
-
- len = ioStream->ReadByte() * 256;
- len += ioStream->ReadByte();
- array^ inBuffer = gcnew array(len);
- ioStream->Read(inBuffer, 0, len);
-
- return streamEncoding->GetString(inBuffer);
- }
-
- int WriteString(String^ outString)
- {
- array^ outBuffer = streamEncoding->GetBytes(outString);
- int len = outBuffer->Length;
- if (len > UInt16::MaxValue)
- {
- len = (int)UInt16::MaxValue;
- }
- ioStream->WriteByte((Byte)(len / 256));
- ioStream->WriteByte((Byte)(len & 255));
- ioStream->Write(outBuffer, 0, len);
- ioStream->Flush();
-
- return outBuffer->Length + 2;
- }
-};
-
-// Contains the method executed in the context of the impersonated user
-public ref class ReadFileToStream
-{
-private:
- String^ fn;
- StreamString ^ss;
-
-public:
- ReadFileToStream(StreamString^ str, String^ filename)
- {
- fn = filename;
- ss = str;
- }
-
- void Start()
- {
- String^ contents = File::ReadAllText(fn);
- ss->WriteString(contents);
- }
-};
-
-public ref class PipeServer
-{
-private:
- static int numThreads = 4;
-
-public:
- static void Main()
- {
- int i;
- array^ servers = gcnew array(numThreads);
-
- Console::WriteLine("\n*** Named pipe server stream with impersonation example ***\n");
- Console::WriteLine("Waiting for client connect...\n");
- for (i = 0; i < numThreads; i++)
- {
- servers[i] = gcnew Thread(gcnew ThreadStart(&ServerThread));
- servers[i]->Start();
- }
- Thread::Sleep(250);
- while (i > 0)
- {
- for (int j = 0; j < numThreads; j++)
- {
- if (servers[j] != nullptr)
- {
- if (servers[j]->Join(250))
- {
- Console::WriteLine("Server thread[{0}] finished.", servers[j]->ManagedThreadId);
- servers[j] = nullptr;
- i--; // decrement the thread watch count
- }
- }
- }
- }
- Console::WriteLine("\nServer threads exhausted, exiting.");
- }
-
-private:
- static void ServerThread()
- {
- NamedPipeServerStream^ pipeServer =
- gcnew NamedPipeServerStream("testpipe", PipeDirection::InOut, numThreads);
-
- int threadId = Thread::CurrentThread->ManagedThreadId;
-
- // Wait for a client to connect
- pipeServer->WaitForConnection();
-
- Console::WriteLine("Client connected on thread[{0}].", threadId);
- try
- {
- //
- // Read the request from the client. Once the client has
- // written to the pipe its security token will be available.
-
- StreamString^ ss = gcnew StreamString(pipeServer);
-
- // Verify our identity to the connected client using a
- // string that the client anticipates.
-
- ss->WriteString("I am the one true server!");
- String^ filename = ss->ReadString();
-
- // Read in the contents of the file while impersonating the client.
- ReadFileToStream^ fileReader = gcnew ReadFileToStream(ss, filename);
-
- // Display the name of the user we are impersonating.
- Console::WriteLine("Reading file: {0} on thread[{1}] as user: {2}.",
- filename, threadId, pipeServer->GetImpersonationUserName());
- pipeServer->RunAsClient(gcnew PipeStreamImpersonationWorker(fileReader, &ReadFileToStream::Start));
- //
- }
- // Catch the IOException that is raised if the pipe is broken
- // or disconnected.
- catch (IOException^ e)
- {
- Console::WriteLine("ERROR: {0}", e->Message);
- }
- pipeServer->Close();
- }
-};
-
-int main()
-{
- PipeServer::Main();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp
deleted file mode 100644
index 17fffe2f8bb..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO::Ports;
-
-ref class PortDataReceived
-{
-public:
- static void Main()
- {
- //
- SerialPort^ mySerialPort = gcnew SerialPort("COM1");
-
- mySerialPort->BaudRate = 9600;
- mySerialPort->Parity = Parity::None;
- mySerialPort->StopBits = StopBits::One;
- mySerialPort->DataBits = 8;
- mySerialPort->Handshake = Handshake::None;
- mySerialPort->RtsEnable = true;
- //
-
- mySerialPort->DataReceived += gcnew SerialDataReceivedEventHandler(DataReceivedHandler);
-
- mySerialPort->Open();
-
- Console::WriteLine("Press any key to continue...");
- Console::WriteLine();
- Console::ReadKey();
- mySerialPort->Close();
- }
-
-private:
- static void DataReceivedHandler(
- Object^ sender,
- SerialDataReceivedEventArgs^ e)
- {
- SerialPort^ sp = (SerialPort^)sender;
- String^ indata = sp->ReadExisting();
- Console::WriteLine("Data Received:");
- Console::Write(indata);
- }
-};
-
-int main()
-{
- PortDataReceived::Main();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp
deleted file mode 100644
index 86631d9ff20..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::IO::Ports;
-using namespace System::Threading;
-
-public ref class PortChat
-{
-private:
- static bool _continue;
- static SerialPort^ _serialPort;
-
- //
-public:
- static void Main()
- {
- String^ name;
- String^ message;
- StringComparer^ stringComparer = StringComparer::OrdinalIgnoreCase;
- Thread^ readThread = gcnew Thread(gcnew ThreadStart(PortChat::Read));
-
- // Create a new SerialPort object with default settings.
- _serialPort = gcnew SerialPort();
-
- // Allow the user to set the appropriate properties.
- _serialPort->PortName = SetPortName(_serialPort->PortName);
- _serialPort->BaudRate = SetPortBaudRate(_serialPort->BaudRate);
- _serialPort->Parity = SetPortParity(_serialPort->Parity);
- _serialPort->DataBits = SetPortDataBits(_serialPort->DataBits);
- _serialPort->StopBits = SetPortStopBits(_serialPort->StopBits);
- _serialPort->Handshake = SetPortHandshake(_serialPort->Handshake);
-
- // Set the read/write timeouts
- _serialPort->ReadTimeout = 500;
- _serialPort->WriteTimeout = 500;
-
- _serialPort->Open();
- _continue = true;
- readThread->Start();
-
- Console::Write("Name: ");
- name = Console::ReadLine();
-
- Console::WriteLine("Type QUIT to exit");
-
- while (_continue)
- {
- message = Console::ReadLine();
-
- if (stringComparer->Equals("quit", message))
- {
- _continue = false;
- }
- else
- {
- _serialPort->WriteLine(
- String::Format("<{0}>: {1}", name, message) );
- }
- }
-
- readThread->Join();
- _serialPort->Close();
- }
-
- static void Read()
- {
- while (_continue)
- {
- try
- {
- String^ message = _serialPort->ReadLine();
- Console::WriteLine(message);
- }
- catch (TimeoutException ^) { }
- }
- }
- //
-
- //
- static String^ SetPortName(String^ defaultPortName)
- {
- String^ portName;
-
- Console::WriteLine("Available Ports:");
- for each (String^ s in SerialPort::GetPortNames())
- {
- Console::WriteLine(" {0}", s);
- }
-
- Console::Write("Enter COM port value (Default: {0}): ", defaultPortName);
- portName = Console::ReadLine();
-
- if (portName == "")
- {
- portName = defaultPortName;
- }
- return portName;
- }
- //
-
- static Int32 SetPortBaudRate(Int32 defaultPortBaudRate)
- {
- String^ baudRate;
-
- Console::Write("Baud Rate(default:{0}): ", defaultPortBaudRate);
- baudRate = Console::ReadLine();
-
- if (baudRate == "")
- {
- baudRate = defaultPortBaudRate.ToString();
- }
-
- return Int32::Parse(baudRate);
- }
-
- //
- static Parity SetPortParity(Parity defaultPortParity)
- {
- String^ parity;
-
- Console::WriteLine("Available Parity options:");
- for each (String^ s in Enum::GetNames(Parity::typeid))
- {
- Console::WriteLine(" {0}", s);
- }
-
- Console::Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString());
- parity = Console::ReadLine();
-
- if (parity == "")
- {
- parity = defaultPortParity.ToString();
- }
-
- return (Parity)Enum::Parse(Parity::typeid, parity);
- }
- //
-
- static Int32 SetPortDataBits(Int32 defaultPortDataBits)
- {
- String^ dataBits;
-
- Console::Write("Enter DataBits value (Default: {0}): ", defaultPortDataBits);
- dataBits = Console::ReadLine();
-
- if (dataBits == "")
- {
- dataBits = defaultPortDataBits.ToString();
- }
-
- return Int32::Parse(dataBits);
- }
-
- //
- static StopBits SetPortStopBits(StopBits defaultPortStopBits)
- {
- String^ stopBits;
-
- Console::WriteLine("Available Stop Bits options:");
- for each (String^ s in Enum::GetNames(StopBits::typeid))
- {
- Console::WriteLine(" {0}", s);
- }
-
- Console::Write("Enter StopBits value (None is not supported and \n" +
- "raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
- stopBits = Console::ReadLine();
-
- if (stopBits == "")
- {
- stopBits = defaultPortStopBits.ToString();
- }
-
- return (StopBits)Enum::Parse(StopBits::typeid, stopBits);
- }
- //
-
- //
- static Handshake SetPortHandshake(Handshake defaultPortHandshake)
- {
- String^ handshake;
-
- Console::WriteLine("Available Handshake options:");
- for each (String^ s in Enum::GetNames(Handshake::typeid))
- {
- Console::WriteLine(" {0}", s);
- }
-
- Console::Write("Enter Handshake value (Default: {0}):", defaultPortHandshake.ToString());
- handshake = Console::ReadLine();
-
- if (handshake == "")
- {
- handshake = defaultPortHandshake.ToString();
- }
-
- return (Handshake)Enum::Parse(Handshake::typeid, handshake);
- }
- //
-};
-
-int main()
-{
- PortChat::Main();
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp
deleted file mode 100644
index a1f9f662b60..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-ref class StreamReaderSample: public TextReader
-{
-public:
-
- //
- StreamReaderSample()
- {
- printInfo();
- usePeek();
- usePosition();
- useNull();
- useReadLine();
- useReadToEnd();
- }
-
-
-private:
-
- //All Overloaded Constructors for StreamReader
- //
- void getNewStreamReader()
- {
-
- //Get a new StreamReader in ASCII format from a
- //file using a buffer and byte order mark detection
- StreamReader^ srAsciiFromFileFalse512 = gcnew StreamReader( "C:\\Temp\\Test.txt",System::Text::Encoding::ASCII,false,512 );
-
- //Get a new StreamReader in ASCII format from a
- //file with byte order mark detection = false
- StreamReader^ srAsciiFromFileFalse = gcnew StreamReader( "C:\\Temp\\Test.txt",System::Text::Encoding::ASCII,false );
-
- //Get a new StreamReader in ASCII format from a file
- StreamReader^ srAsciiFromFile = gcnew StreamReader( "C:\\Temp\\Test.txt",System::Text::Encoding::ASCII );
-
- //Get a new StreamReader from a
- //file with byte order mark detection = false
- StreamReader^ srFromFileFalse = gcnew StreamReader( "C:\\Temp\\Test.txt",false );
-
- //Get a new StreamReader from a file
- StreamReader^ srFromFile = gcnew StreamReader( "C:\\Temp\\Test.txt" );
-
- //Get a new StreamReader in ASCII format from a
- //FileStream with byte order mark detection = false and a buffer
- StreamReader^ srAsciiFromStreamFalse512 = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII,false,512 );
-
- //Get a new StreamReader in ASCII format from a
- //FileStream with byte order mark detection = false
- StreamReader^ srAsciiFromStreamFalse = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII,false );
-
- //Get a new StreamReader in ASCII format from a FileStream
- StreamReader^ srAsciiFromStream = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
-
- //Get a new StreamReader from a
- //FileStream with byte order mark detection = false
- StreamReader^ srFromStreamFalse = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),false );
-
- //Get a new StreamReader from a FileStream
- StreamReader^ srFromStream = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ) );
- }
-
-
- //
- //
- void printInfo()
- {
-
- //
- //
- StreamReader^ srEncoding = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
- Console::WriteLine( "Encoding: {0}", srEncoding->CurrentEncoding->EncodingName );
- srEncoding->Close();
-
- //
- }
-
- void usePeek()
- {
-
- //
- StreamReader^ srPeek = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
-
- // set the file pointer to the beginning
- srPeek->BaseStream->Seek( 0, SeekOrigin::Begin );
-
- // cycle while there is a next char
- while ( srPeek->Peek() > -1 )
- {
- Console::Write( srPeek->ReadLine() );
- }
-
- srPeek->Close();
-
- //
- }
-
- void usePosition()
- {
-
- //
- StreamReader^ srRead = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
-
- // set the file pointer to the beginning
- srRead->BaseStream->Seek( 0, SeekOrigin::Begin );
- srRead->BaseStream->Position = 0;
- while ( srRead->BaseStream->Position < srRead->BaseStream->Length )
- {
- array<__wchar_t>^buffer = gcnew array<__wchar_t>(1);
- srRead->Read( buffer, 0, 1 );
- Console::Write( buffer[ 0 ].ToString() );
- srRead->BaseStream->Position = srRead->BaseStream->Position + 1;
- }
-
- srRead->DiscardBufferedData();
- srRead->Close();
-
- //
- }
-
- void useNull()
- {
-
- //
- StreamReader^ srNull = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
- if ( !srNull->Equals( StreamReader::Null ) )
- {
- srNull->BaseStream->Seek( 0, SeekOrigin::Begin );
- Console::WriteLine( srNull->ReadToEnd() );
- }
-
- srNull->Close();
-
- //
- }
-
- void useReadLine()
- {
-
- //
- StreamReader^ srReadLine = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
- srReadLine->BaseStream->Seek( 0, SeekOrigin::Begin );
- while ( srReadLine->Peek() > -1 )
- {
- Console::WriteLine( srReadLine->ReadLine() );
- }
-
- srReadLine->Close();
-
- //
- }
-
- void useReadToEnd()
- {
-
- //
- StreamReader^ srReadToEnd = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII );
- srReadToEnd->BaseStream->Seek( 0, SeekOrigin::Begin );
- Console::WriteLine( srReadToEnd->ReadToEnd() );
- srReadToEnd->Close();
-
- //
- //
- }
-
- //
- //
-};
-
-
-//
-void main( int argc )
-{
- StreamReaderSample^ srs = gcnew StreamReaderSample;
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp
deleted file mode 100644
index a901e502b87..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Runtime;
-using namespace System::Reflection;
-using namespace System::Runtime::Remoting::Lifetime;
-using namespace System::Security::Permissions;
-
-namespace StreamWriterSample
-{
- public ref class Logger
- {
-//
- public:
- //Constructors
- Logger()
- {
- BeginWrite();
- }
-
- Logger( String^ logFile )
- {
- BeginWrite( logFile );
- }
-
- //Destructor
- ~Logger()
- {
- EndWrite();
- }
-
- //
- void CreateTextFile( String^ fileName, String^ textToAdd )
- {
- String^ logFile = String::Concat( DateTime::Now.ToShortDateString()
- ->Replace( "/", "-" )->Replace( "\\", "-" ), ".log" );
-
- FileStream^ fs = gcnew FileStream( fileName,
- FileMode::CreateNew, FileAccess::Write, FileShare::None );
-
- StreamWriter^ swFromFile = gcnew StreamWriter( logFile );
- swFromFile->Write( textToAdd );
- swFromFile->Flush();
- swFromFile->Close();
-
- StreamWriter^ swFromFileStream = gcnew StreamWriter( fs );
- swFromFileStream->Write( textToAdd );
- swFromFileStream->Flush();
- swFromFileStream->Close();
-
- StreamWriter^ swFromFileStreamDefaultEnc =
- gcnew System::IO::StreamWriter( fs,
- System::Text::Encoding::Default );
- swFromFileStreamDefaultEnc->Write( textToAdd );
- swFromFileStreamDefaultEnc->Flush();
- swFromFileStreamDefaultEnc->Close();
-
- StreamWriter^ swFromFileTrue =
- gcnew StreamWriter( fileName,true );
- swFromFileTrue->Write( textToAdd );
- swFromFileTrue->Flush();
- swFromFileTrue->Close();
-
- StreamWriter^ swFromFileTrueUTF8Buffer =
- gcnew StreamWriter( fileName,
- true, System::Text::Encoding::UTF8, 512 );
- swFromFileTrueUTF8Buffer->Write( textToAdd );
- swFromFileTrueUTF8Buffer->Flush();
- swFromFileTrueUTF8Buffer->Close();
-
- StreamWriter^ swFromFileTrueUTF8 =
- gcnew StreamWriter( fileName, true,
- System::Text::Encoding::UTF8 );
- swFromFileTrueUTF8->Write( textToAdd );
- swFromFileTrueUTF8->Flush();
- swFromFileTrueUTF8->Close();
-
- StreamWriter^ swFromFileStreamUTF8Buffer =
- gcnew StreamWriter( fs, System::Text::Encoding::UTF8, 512 );
- swFromFileStreamUTF8Buffer->Write( textToAdd );
- swFromFileStreamUTF8Buffer->Flush();
- swFromFileStreamUTF8Buffer->Close();
- }
- //
-
- //
- private:
- [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)]
- void BeginWrite( String^ logFile )
- {
- //
- //
- StreamWriter^ sw = gcnew StreamWriter( logFile,true );
-
- //
- //
- // Gets or sets a value indicating whether the StreamWriter
- // will flush its buffer to the underlying stream after every
- // call to StreamWriter.Write.
- sw->AutoFlush = true;
- //
- //
- if ( sw->Equals( StreamWriter::Null ) )
- {
- sw->WriteLine( "The store can be written to, but not read from." );
- }
- //
- //
- sw->Write( Char::Parse( " " ) );
- //
- //
- String^ hello = "Hellow World!";
- array^ buffer = hello->ToCharArray();
- sw->Write( buffer );
- //
- //
- String^ helloWorld = "Hellow World!";
- // writes out "low World"
- sw->Write( helloWorld );
- //
- //
- sw->WriteLine( "---Begin Log Entry---" );
- //
- //
- // Write out the current text encoding
- sw->WriteLine( "Encoding: {0}",
- sw->Encoding->ToString() );
- //
- //
- // Display the Format Provider
- sw->WriteLine( "Format Provider: {0} ",
- sw->FormatProvider->ToString() );
- //
- //
- // Set the characters you would like to designate a new line
- sw->NewLine = "\r\n";
- //
- //
- ILease^ obj = dynamic_cast(sw->InitializeLifetimeService());
- if ( obj != nullptr )
- {
- sw->WriteLine( "Object initialized lease " +
- "time remaining: {0}.",
- obj->CurrentLeaseTime.ToString() );
- }
- //
- //
- ILease^ lease = dynamic_cast(sw->GetLifetimeService());
- if ( lease != nullptr )
- {
- sw->WriteLine( "Object lease time remaining: {0}.",
- lease->CurrentLeaseTime.ToString() );
- }
- //
-
- //
- // update underlying file
- sw->Flush();
- //
- //
- // close the file by closing the writer
- sw->Close();
- //
- //
- }
- //
-
- void BeginWrite()
- {
- BeginWrite( String::Concat( DateTime::Now.ToShortDateString()
- ->Replace( "/", "-" )->Replace( "\\", "-" ), ".log" ) );
- }
-
- void EndWrite( String^ logFile )
- {
- StreamWriter^ sw = gcnew StreamWriter( logFile,true );
-
- // Set the file pointer to the end of file.
- sw->BaseStream->Seek( 0, SeekOrigin::End );
- // Write text to the file.
- sw->WriteLine( "---End Log Entry---\r\n" );
- // Update the underlying file.
- sw->Flush();
- // Close the file by closing the writer.
- sw->Close();
- }
-
- void EndWrite()
- {
- EndWrite( String::Concat( DateTime::Now.ToShortDateString()
- ->Replace( "/", "-" )->Replace( "\\", "-" ), ".log" ) );
- }
- //
- };
-}
-//
-
-int main()
-{
- StreamWriterSample::Logger^ l = gcnew StreamWriterSample::Logger;
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp
deleted file mode 100644
index 0e1c9ac1f5b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-int main()
-{
- String^ textReaderText = "TextReader is the abstract base "
- "class of StreamReader and StringReader, which read "
- "characters from streams and strings, respectively.\n\n"
- "Create an instance of TextReader to open a text file "
- "for reading a specified range of characters, or to "
- "create a reader based on an existing stream.\n\n"
- "You can also use an instance of TextReader to read "
- "text from a custom backing store using the same "
- "APIs you would use for a string or a stream.\n\n";
- Console::WriteLine( "Original text:\n\n{0}", textReaderText );
-
- //
- // From textReaderText, create a continuous paragraph
- // with two spaces between each sentence.
- String^ aLine;
- String^ aParagraph;
- StringReader^ strReader = gcnew StringReader( textReaderText );
- while ( true )
- {
- aLine = strReader->ReadLine();
- if ( aLine != nullptr )
- {
- aParagraph = String::Concat( aParagraph, aLine, " " );
- }
- else
- {
- aParagraph = String::Concat( aParagraph, "\n" );
- break;
- }
- }
-
- Console::WriteLine( "Modified text:\n\n{0}", aParagraph );
-
- //
- // Re-create textReaderText from aParagraph.
- int intCharacter;
- Char convertedCharacter;
- StringWriter^ strWriter = gcnew StringWriter;
- strReader = gcnew StringReader( aParagraph );
- while ( true )
- {
- intCharacter = strReader->Read();
-
- // Check for the end of the string
- // before converting to a character.
- if ( intCharacter == -1 )
- break;
-
-
- //
- convertedCharacter = Convert::ToChar( intCharacter );
- if ( convertedCharacter == '.' )
- {
- strWriter->Write( ".\n\n" );
-
- // Bypass the spaces between sentences.
- strReader->Read();
- strReader->Read();
- }
- //
- else
- {
- strWriter->Write( convertedCharacter );
- }
- }
-
- Console::WriteLine( "\nOriginal text:\n\n{0}", strWriter->ToString() );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp
deleted file mode 100644
index 8c1ec78fa24..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-int main()
-{
- StringWriter^ strWriter = gcnew StringWriter;
-
- //
- // Use the three overloads of the Write method that are
- // overridden by the StringWriter class.
- strWriter->Write( "file path characters are: " );
- strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
- strWriter->Write( Char::Parse( "." ) );
-
- //
- //
- // Use the underlying StringBuilder for more complex
- // manipulations of the string.
- strWriter->GetStringBuilder()->Insert( 0, "Invalid " );
-
- //
- //
- Console::WriteLine( "The following string is {0} encoded.\n{1}", strWriter->Encoding->EncodingName, strWriter->ToString() );
-
- //
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp
deleted file mode 100644
index 3314eaac96a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Globalization;
-using namespace System::IO;
-int main()
-{
- StringWriter^ strWriter = gcnew StringWriter( gcnew CultureInfo( "ar-DZ" ) );
- strWriter->Write( DateTime::Now );
-
- //
- Console::WriteLine( "Current date and time using the invariant culture: {0}\n"
- "Current date and time using the Algerian culture: {1}", DateTime::Now.ToString(), strWriter->ToString() );
-
- //
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp
deleted file mode 100644
index 10ced5c03d7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Text;
-int main()
-{
- StringBuilder^ strBuilder = gcnew StringBuilder( "file path characters are: " );
- StringWriter^ strWriter = gcnew StringWriter( strBuilder );
- strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
-
- //
- strWriter->Close();
-
- // Since the StringWriter is closed, an exception will
- // be thrown if the Write method is called. However,
- // the StringBuilder can still manipulate the string.
- strBuilder->Insert( 0, "Invalid " );
- Console::WriteLine( strWriter->ToString() );
-
- //
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp
deleted file mode 100644
index e9352f717a0..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-
-//
-void WriteText( TextWriter^ textWriter )
-{
- textWriter->Write( "Invalid file path characters are: " );
- textWriter->Write( Path::InvalidPathChars );
- textWriter->Write( Char::Parse( "." ) );
-}
-
-
-//
-//
-void ReadText( TextReader^ textReader )
-{
- Console::WriteLine( "From {0} - {1}", textReader->GetType()->Name, textReader->ReadToEnd() );
-}
-
-
-//
-int main()
-{
-
- //
- TextWriter^ stringWriter = gcnew StringWriter;
- TextWriter^ streamWriter = gcnew StreamWriter( "InvalidPathChars.txt" );
-
- //
- WriteText( stringWriter );
- WriteText( streamWriter );
- streamWriter->Close();
-
- //
- TextReader^ stringReader = gcnew StringReader( stringWriter->ToString() );
- TextReader^ streamReader = gcnew StreamReader( "InvalidPathChars.txt" );
-
- //
- ReadText( stringReader );
- ReadText( streamReader );
- streamReader->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp
deleted file mode 100644
index bcc6eb8fc3a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-
-//
-// This sample shows the differences between dates from methods that use
-//coordinated universal time (UTC) format and those that do not.
-using namespace System;
-using namespace System::IO;
-int main()
-{
-
- // Set the directory.
- String^ n = "C:\\test\\newdir";
-
- //Create two variables to use to set the time.
- DateTime dtime1 = DateTime(2002,1,3);
- DateTime dtime2 = DateTime(1999,1,1);
-
- //Create the directory.
- try
- {
- Directory::CreateDirectory( n );
- }
- catch ( IOException^ e )
- {
- Console::WriteLine( e );
- }
-
-
- //Set the creation and last access times to a variable DateTime value.
- Directory::SetCreationTime( n, dtime1 );
- Directory::SetLastAccessTimeUtc( n, dtime1 );
-
- // Print to console the results.
- Console::WriteLine( "Creation Date: {0}", Directory::GetCreationTime( n ) );
- Console::WriteLine( "UTC creation Date: {0}", Directory::GetCreationTimeUtc( n ) );
- Console::WriteLine( "Last write time: {0}", Directory::GetLastWriteTime( n ) );
- Console::WriteLine( "UTC last write time: {0}", Directory::GetLastWriteTimeUtc( n ) );
- Console::WriteLine( "Last access time: {0}", Directory::GetLastAccessTime( n ) );
- Console::WriteLine( "UTC last access time: {0}", Directory::GetLastAccessTimeUtc( n ) );
-
- //Set the last write time to a different value.
- Directory::SetLastWriteTimeUtc( n, dtime2 );
- Console::WriteLine( "Changed last write time: {0}", Directory::GetLastWriteTimeUtc( n ) );
-}
-
-// Obviously, since this sample deals with dates and times, the output will vary
-// depending on when you run the executable. Here is one example of the output:
-//Creation Date: 1/3/2002 12:00:00 AM
-//UTC creation Date: 1/3/2002 8:00:00 AM
-//Last write time: 12/31/1998 4:00:00 PM
-//UTC last write time: 1/1/1999 12:00:00 AM
-//Last access time: 1/2/2002 4:00:00 PM
-//UTC last access time: 1/3/2002 12:00:00 AM
-//Changed last write time: 1/1/1999 12:00:00 AM
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp
deleted file mode 100644
index c07a0a5476f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Resources;
-using namespace System::Collections;
-void main()
-{
-
- // Create a ResXResourceReader for the file items.resx.
- ResXResourceReader^ rsxr = gcnew ResXResourceReader( "items.resx" );
-
-
- // Iterate through the resources and display the contents to the console.
- IEnumerator^ myEnum = rsxr->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- DictionaryEntry^ d = safe_cast(myEnum->Current);
- Console::WriteLine( "{0}:\t {1}", d->Key, d->Value );
- }
-
-
- //Close the reader.
- rsxr->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp
deleted file mode 100644
index d1d5faf2d6d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::Resources;
-using namespace System::ComponentModel::Design;
-
-namespace UseDataNodesExample
-{
- public ref class Program
- {
- public:
- static void Main()
- {
- Console::WriteLine("\nEnumerating as data items...");
- EnumResourceItems("Resource1.resx", false);
-
- Console::WriteLine("\nEnumerating as data nodes...");
- EnumResourceItems("Resource1.resx", true);
- }
-
- static void EnumResourceItems(String^ resxFile, bool useDataNodes)
- {
- ResXResourceReader^ reader = gcnew ResXResourceReader(resxFile);
-
- reader->UseResXDataNodes = useDataNodes;
-
- //
- // Enumerate using IEnumerable.GetEnumerator().
- Console::WriteLine("\n Default enumerator:");
- for each (DictionaryEntry entry in reader)
- {
- ShowResourceItem(entry, useDataNodes);
- }
- //
-
- //
- // Enumerate using GetMetadataEnumerator()
- IDictionaryEnumerator^ metadataEnumerator = reader->GetMetadataEnumerator();
-
- Console::WriteLine("\n MetadataEnumerator:");
- while (metadataEnumerator->MoveNext())
- {
- ShowResourceItem(metadataEnumerator->Entry, useDataNodes);
- }
- //
-
- //
- // Enumerate using GetEnumerator()
- IDictionaryEnumerator^ enumerator = reader->GetEnumerator();
-
- Console::WriteLine("\n Enumerator:");
- while (enumerator->MoveNext())
- {
- ShowResourceItem(enumerator->Entry, useDataNodes);
- }
- //
- delete reader;
- }
-
- static void ShowResourceItem(DictionaryEntry entry, bool isDataNode)
- {
- // Use a nullptr type resolver.
- ITypeResolutionService^ typeres = nullptr;
- ResXDataNode^ dnode;
-
- if (isDataNode)
- {
- // Display from node info.
- dnode = (ResXDataNode^)entry.Value;
- Console::WriteLine(" {0}={1}", dnode->Name, dnode->GetValue(typeres));
- }
- else
- {
- // Display as DictionaryEntry info.
- Console::WriteLine(" {0}={1}", entry.Key, entry.Value);
- }
- }
- };
-}
-
-int main()
-{
- UseDataNodesExample::Program::Main();
-}
-// The example program will have the following output:
-//
-// Enumerating as data items...
-//
-// Default enumerator:
-// DataSample=Sample DATA value
-//
-// MetadataEnumerator:
-// MetadataSample=Sample METADATA value
-//
-// Enumerator:
-// DataSample=Sample DATA value
-//
-// Enumerating as data nodes...
-//
-// Default enumerator:
-// DataSample=Sample DATA value
-// MetadataSample=Sample METADATA value
-//
-// MetadataEnumerator:
-//
-// Enumerator:
-// DataSample=Sample DATA value
-// MetadataSample=Sample METADATA value
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp
deleted file mode 100644
index 07b62bf13b4..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Resources;
-using namespace System::Collections;
-int main()
-{
-
- // Create a ResourceReader for the file items.resources.
- ResourceReader^ rr = gcnew ResourceReader( "items.resources" );
-
- // Create an IDictionaryEnumerator* to iterate through the resources.
- IDictionaryEnumerator^ id = rr->GetEnumerator();
-
- // Iterate through the resources and display the contents to the console.
- while ( id->MoveNext() )
- Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value );
-
- rr->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp
deleted file mode 100644
index 8f81922ead1..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Resources;
-using namespace System::Collections;
-int main()
-{
-
- // Create a ResourceSet for the file items.resources.
- ResourceSet^ rs = gcnew ResourceSet( "items.resources" );
-
- // Create an IDictionaryEnumerator* to read the data in the ResourceSet.
- IDictionaryEnumerator^ id = rs->GetEnumerator();
-
- // Iterate through the ResourceSet and display the contents to the console.
- while ( id->MoveNext() )
- Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value );
-
- rs->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp
deleted file mode 100644
index b782b33e9ef..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Resources;
-using namespace System::IO;
-int main()
-{
-
- // Create a file stream to encapsulate items.resources.
- FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write );
-
- // Open a resource writer to write from the stream.
- IResourceWriter^ writer = gcnew ResourceWriter( fs );
-
- // Add resources to the resource writer.
- writer->AddResource( "String 1", "First String" );
- writer->AddResource( "String 2", "Second String" );
- writer->AddResource( "String 3", "Third String" );
-
- // Write the resources to the stream, and close it.
- writer->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp
deleted file mode 100644
index f96fb6c9ed2..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Resources;
-using namespace System::IO;
-int main()
-{
- // Create a file stream to encapsulate items.resources.
- FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write );
-
- // Open a resource writer to write from the stream.
- IResourceWriter^ writer = gcnew ResourceWriter( fs );
-
- // Add resources to the resource writer.
- writer->AddResource( "String 1", "First String" );
- writer->AddResource( "String 2", "Second String" );
- writer->AddResource( "String 3", "Third String" );
-
- // Write the resources to the stream,
- // and clean up all resources associated with the writer.
- // Calling Dispose is equivalent to calling Close.
- writer->~IResourceWriter();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp
deleted file mode 100644
index ae4c0f1b512..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Resources;
-using namespace System::IO;
-int main()
-{
-
- // Create a file stream to encapsulate items.resources.
- FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write );
-
- // Open a resource writer to write from the stream.
- IResourceWriter^ writer = gcnew ResourceWriter( fs );
-
- // Add resources to the resource writer.
- writer->AddResource( "String 1", "First String" );
- writer->AddResource( "String 2", "Second String" );
- writer->AddResource( "String 3", "Third String" );
-
- // Generate the resources, and close the writer.
- writer->Generate();
- writer->Close();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp
deleted file mode 100644
index 08370f3519c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-
-//#pragma comment(linker, "/CLRUNMANAGEDCODECHECK:NO")
-//
-// The following HTML code can be used to call the user control in this sample.
-//
-//
-//
-//
-//
-//
-//
-//
-// To run this test control you must create a strong name key, snkey.snk, and
-// a code group that gives full trust to assemblies signed with snkey.snk.
-// The user control displays an OpenFileDialog box, then displays a text box containing the name of
-// the file selected and a list box that displays the contents of the file. The selected file must
-// contain text in order for the control to display the data properly.
-// Caution This sample demonstrates the use of the Assert method. Calling Assert removes the
-// requirement that all code in the call chain must be granted permission to access the specified
-// resource, it can open up security vulnerabilities if used incorrectly or inappropriately. Therefore,
-// it should be used with great caution. Assert should always be followed with a RevertAssert
-// command to restore the security settings.
-#using
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Collections;
-using namespace System::ComponentModel;
-using namespace System::Drawing;
-using namespace System::Data;
-using namespace System::Windows::Forms;
-using namespace System::IO;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Reflection;
-using namespace System::Runtime::CompilerServices;
-
-// This strong name key is used to create a code group that gives permissions to this assembly.
-// The AllowPartiallyTrustedCallersAttribute requires the assembly to be signed with a strong name key.
-// This attribute is necessary since the control is called by either an intranet or Internet
-// Web page that should be running under restricted permissions.
-// The userControl1 displays an OpenFileDialog box, then displays a text box containing the name of
-// the file selected and a list box that displays the contents of the file. The selected file must
-// contain text in order for the control to display the data properly.
-
-[assembly:AssemblyKeyFile("snKey.snk")];
-[assembly:AssemblyVersion("1.0.0.0")];
-[assembly:AllowPartiallyTrustedCallers];
-public ref class UserControl1: public System::Windows::Forms::UserControl
-{
-private:
- System::Windows::Forms::TextBox^ textBox1;
- System::Windows::Forms::ListBox^ listBox1;
-
- // Required designer variable.
- System::ComponentModel::Container^ components;
-
-public:
-// Demand the zone requirement for the calling application.
-[ZoneIdentityPermission(SecurityAction::Demand, Zone = SecurityZone::Intranet)]
- UserControl1()
- {
-
- // This call is required by the Windows.Forms Form Designer.
- InitializeComponent();
-
- // The OpenFileDialog box should not require any special permissions.
- OpenFileDialog^ fileDialog = gcnew OpenFileDialog;
- if ( fileDialog->ShowDialog() == DialogResult::OK )
- {
-
- // Reading the name of the selected file from the OpenFileDialog box
- // and reading the file requires FileIOPermission. The user control should
- // have this permission granted through its code group; the Web page that calls the
- // control should not have this permission. The Assert command prevents a stack walk
- // that would fail because the caller does not have the required FileIOPermission.
- // The use of Assert can open up security vulnerabilities if used incorrectly or
- // inappropriately. Therefore, it should be used with great caution.
- // The Assert command should be followed by a RevertAssert as soon as the file operation
- // is completed.
- (gcnew FileIOPermission( PermissionState::Unrestricted ))->Assert();
- textBox1->Text = fileDialog->FileName;
-
- // Display the contents of the file in the text box.
- FileStream^ fsIn = gcnew FileStream( textBox1->Text,FileMode::Open,FileAccess::Read,FileShare::Read );
- StreamReader^ sr = gcnew StreamReader( fsIn );
-
- // Process every line in the file
- for ( String ^ Line = sr->ReadLine(); Line != nullptr; Line = sr->ReadLine() )
- {
- listBox1->Items->Add( Line );
-
- }
-
- // file operations.
- FileIOPermission::RevertAssert();
- }
- }
-
-private:
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- void InitializeComponent()
- {
- this->textBox1 = gcnew System::Windows::Forms::TextBox;
- this->listBox1 = gcnew System::Windows::Forms::ListBox;
- this->SuspendLayout();
-
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point( 208, 112 );
- this->textBox1->Name = "textBox1";
- this->textBox1->Size = System::Drawing::Size( 320, 20 );
- this->textBox1->TabIndex = 0;
- this->textBox1->Text = "textBox1";
- this->textBox1->TextChanged += gcnew System::EventHandler( this,&UserControl1::textBox1_TextChanged );
-
- //
- // listBox1
- //
- this->listBox1->Location = System::Drawing::Point( 200, 184 );
- this->listBox1->Name = "listBox1";
- this->listBox1->Size = System::Drawing::Size( 336, 108 );
- this->listBox1->TabIndex = 1;
-
- //
- // UserControl1
- //
- this->Controls->Add( this->listBox1 );
- this->Controls->Add( this->textBox1 );
- this->Name = "UserControl1";
- this->Size = System::Drawing::Size( 592, 400 );
- this->Load += gcnew System::EventHandler( this,&UserControl1::UserControl1_Load );
- this->ResumeLayout( false );
- }
-
- void UserControl1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ ){}
-
- void textBox1_TextChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ){}
-
-};
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp
deleted file mode 100644
index 5a67133635d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-// This class creates a custom crytographic object based on the asymmetric
-// algorithm by extending the abstract base class AsymmetricAlgorithm.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-using namespace System::Reflection;
-
-[assembly: AssemblyKeyFile("CustomCrypto.snk")];
-[assembly: AssemblyVersion("1.0.0.0")];
-[assembly: CLSCompliant(true)];
-namespace Contoso
-{
- // Define a CustomCrypto class that inherits from the AsymmetricAlgorithm
- // class.
- public ref class CustomCrypto :
- public System::Security::Cryptography::AsymmetricAlgorithm
- {
- // Declare local member variables.
- private:
- CspParameters^ cryptoServiceParameters;
- array^ customValidKeySizes;
-
- // Initialize a CustomCrypto with the default key size of 8.
- public:
- CustomCrypto()
- {
- customValidKeySizes =
- gcnew array{gcnew KeySizes(8, 64, 8)};
- this->KeySize = 8;
- }
-
- // Initialize a CustomCrypto with the specified key size.
- public:
- CustomCrypto(int keySize)
- {
- customValidKeySizes =
- gcnew array{gcnew KeySizes(8, 64, 8)};
- this->KeySize = keySize;
- }
-
- // Accessor function for keySizes member variable.
- public:
- property array^ LegalKeySizes
- {
- virtual array^ get() override
- {
- return (array^)customValidKeySizes->Clone();
- }
- }
-
- // Modify the KeySizeValue property inherited from the Asymmetric
- // class. Prior to setting the value, ensure it falls within the
- // range identified in the local keySizes member variable.
- //
- public:
- property int KeySize
- {
- virtual int get() override
- {
- return KeySizeValue;
- }
-
- virtual void set(int value) override
- {
- for (int i = 0; i < customValidKeySizes->Length; i++)
- {
- if (customValidKeySizes[i]->SkipSize == 0)
- {
- if (customValidKeySizes[i]->MinSize == value)
- {
- KeySizeValue = value;
- return;
- }
- }
- else
- {
- for (int j = customValidKeySizes[i]->MinSize;
- j <= customValidKeySizes[i]->MaxSize;
- j += customValidKeySizes[i]->SkipSize)
- {
- if (j == value)
- {
- KeySizeValue = value;
- return;
- }
- }
- }
- }
-
- // If the key does not fall within the range identified
- // in the keySizes member variable, throw an exception.
- throw gcnew CryptographicException("Invalid key size.");
- }
- }
- //
-
- // Initialize the parameters with default values.
- public:
- void InitializeParameters()
- {
- cryptoServiceParameters = gcnew CspParameters();
- cryptoServiceParameters->ProviderName = "Contoso";
- cryptoServiceParameters->KeyContainerName = "SecurityBin1";
- cryptoServiceParameters->KeyNumber = 1;
- cryptoServiceParameters->ProviderType = 2;
- }
-
- // Parse specified xmlString for values to populate the CspParams
- //
- // Expected XML schema:
- //
- //
- //
- //
- //
- //
- public:
- virtual void FromXmlString(String^ xmlString) override
- {
- if (xmlString != nullptr)
- {
- XmlDocument^ document = gcnew XmlDocument();
- document->LoadXml(xmlString);
- XmlNode^ firstNode = document->FirstChild;
- XmlNodeList^ nodeList;
-
- // Assemble parameters from values in each XML element.
- cryptoServiceParameters = gcnew CspParameters();
-
- // KeyContainerName is optional.
- nodeList =
- document->GetElementsByTagName("KeyContainerName");
- if (nodeList->Count > 0)
- {
- cryptoServiceParameters->KeyContainerName =
- nodeList->Item(0)->InnerText;
- }
-
- // KeyNumber is optional.
- nodeList = document->GetElementsByTagName("KeyNumber");
- if (nodeList->Count > 0)
- {
- cryptoServiceParameters->KeyNumber =
- Int32::Parse(nodeList->Item(0)->InnerText);
- }
-
- // ProviderName is optional.
- nodeList = document->GetElementsByTagName("ProviderName");
- if (nodeList->Count > 0)
- {
- cryptoServiceParameters->ProviderName =
- nodeList->Item(0)->InnerText;
- }
-
- // ProviderType is optional.
- nodeList = document->GetElementsByTagName("ProviderType");
- if (nodeList->Count > 0)
- {
- cryptoServiceParameters->ProviderType =
- Int32::Parse(nodeList->Item(0)->InnerText);
- }
- }
- else
- {
- throw gcnew ArgumentNullException("xmlString");
- }
- }
- //
-
- // Create an XML string representation of the parameters in the
- // current customCrypto object.
- //
- public:
- virtual String^ ToXmlString(bool includePrivateParameters) override
- {
- String^ keyContainerName = "";
- String^ keyNumber = "";
- String^ providerName = "";
- String^ providerType = "";
-
- if (cryptoServiceParameters != nullptr)
- {
- keyContainerName =
- cryptoServiceParameters->KeyContainerName;
- keyNumber = cryptoServiceParameters->KeyNumber.ToString();
- providerName = cryptoServiceParameters->ProviderName;
- providerType =
- cryptoServiceParameters->ProviderType.ToString();
- }
-
- StringBuilder^ sb = gcnew StringBuilder();
- sb->Append("");
-
- sb->Append("");
- sb->Append(keyContainerName);
- sb->Append("");
-
- sb->Append("");
- sb->Append(keyNumber);
- sb->Append("");
-
- sb->Append("");
- sb->Append(providerName);
- sb->Append("");
-
- sb->Append("");
- sb->Append(providerType);
- sb->Append("");
-
- sb->Append("");
- return(sb->ToString());
- }
- //
-
- // Return the name for the key exchange algorithm.
- //
- public:
- property String^ KeyExchangeAlgorithm
- {
- virtual String^ get() override
- {
- return "RSA-PKCS1-KeyEx";
- }
- }
- //
-
- // Retrieves the name of the signature alogrithm.
- //
- // This example uses the SHA1 algorithm.
- // Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
-
- public:
- property String^ SignatureAlgorithm
- {
- virtual String^ get() override
- {
- return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
- }
- }
- //
-
- // Required member for implementing the AsymmetricAlgorithm class.
- protected:
- virtual ~CustomCrypto()
- {
- }
-
- // Call the Create method using the CustomCrypto assembly name.
- //
- // The create function attempts to create a CustomCrypto
- // object using the assembly name. This functionality requires
- // modification of the machine.config file. Add the following
- // section to the configuration element and modify the values
- // of the cryptoClass to reflect what isinstalled
- // in your machines GAC.
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
-
- public:
- static CustomCrypto^ Create()
- {
- return Create("CustomCrypto");
- }
- //
-
- // Create a CustomCrypto object by calling CrytoConfig's
- // CreateFromName method and casting the type to CustomCrypto.
- //
- // The create function attempts to create a CustomCrypto object
- // using the assembly name. This functionality requires
- // modification of the machine.config file. Add the following
- // section to the configuration element and modify the values
- // of the cryptoClass to reflect what is installed
- // in your machines GAC.
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
-
- public:
- static CustomCrypto^ Create(String^ algorithmName)
- {
- return (CustomCrypto^)
- CryptoConfig::CreateFromName(algorithmName);
- }
- //
- };
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp
deleted file mode 100644
index 0de4308d5f7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-
-// This sample demonstrates how to implement a custom asymmetric algorithm
-// inherited from the AsymmetricAlgorithm base class.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Xml;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-
-// Display the properties of the specified CustomCrypto object to the
-// console.
-static void DisplayProperties(Contoso::CustomCrypto^ customCryptoAlgorithm)
-{
- // Retrieve the class description for the customCrypto object.
- //
- String^ classDescription = customCryptoAlgorithm->ToString();
- //
-
- Console::WriteLine(classDescription);
- Console::WriteLine("KeyExchangeAlgorithm: {0}",
- customCryptoAlgorithm->KeyExchangeAlgorithm);
- Console::WriteLine("SignatureAlgorithm: {0}",
- customCryptoAlgorithm->SignatureAlgorithm);
- Console::WriteLine("KeySize: {0}",
- customCryptoAlgorithm->KeySize);
- Console::WriteLine("Parameters described in Xml format:");
- Console::WriteLine(customCryptoAlgorithm->ToXmlString(true));
-
- // Display the MinSize, MaxSize, and SkipSize properties of
- // each KeySize item in the local keySizes member variable.
- //
- array^ legalKeySizes = customCryptoAlgorithm->LegalKeySizes;
- for (int i = 0; i < legalKeySizes->Length; i++)
- {
- Console::WriteLine(
- "Keysize{0} min, max, step: {1}, {2}, {3}, ", i,
- legalKeySizes[i]->MinSize,
- legalKeySizes[i]->MaxSize,
- legalKeySizes[i]->SkipSize);
- }
- //
-}
-
-[STAThread]
-int main()
-{
- // Construct a CustomCrypto object and initialize its
- // CspParameters.
- Contoso::CustomCrypto^ customCryptoAlgorithm = gcnew Contoso::CustomCrypto();
- customCryptoAlgorithm->InitializeParameters();
-
- // Display properties of the current customCrypto object.
- Console::WriteLine(
- "*** CustomCrypto created with default parameters:");
- DisplayProperties(customCryptoAlgorithm);
-
- // Release all the resources used by this instance of
- // CustomCrypto.
- //
- customCryptoAlgorithm->Clear();
- //
-
- customCryptoAlgorithm = gcnew Contoso::CustomCrypto(64);
- // Create new parameters and set them by using the FromXmlString
- // method.
- String^ parameterXml = "" +
- "Contoso" +
- "SecurityBin2" +
- "1" +
- "2" +
- "";
- customCryptoAlgorithm->FromXmlString(parameterXml);
-
- // Display the properties of a customCrypto object created with
- // custom parameters.
- Console::WriteLine(
- "{0}*** CustomCrypto created with custom parameters:", Environment::NewLine);
- DisplayProperties(customCryptoAlgorithm);
-
- // Create an object by using the assembly name.
- Contoso::CustomCrypto^ cryptoFromAssembly =
- Contoso::CustomCrypto::Create("CustomCrypto");
- if (cryptoFromAssembly != nullptr)
- {
- Console::WriteLine("{0}*** Successfully created " +
- "CustomCrypto from the Create method.", Environment::NewLine);
- DisplayProperties(cryptoFromAssembly);
- }
- else
- {
- Console::WriteLine("Unable to create CustomCrypto from " +
- "the Create method.");
- }
-
- Console::WriteLine(
- "This sample completed successfully; press Enter to exit.");
- Console::ReadLine();
-}
-
-//
-// This sample produces the following output:
-//
-// *** CustomCrypto created with default parameters:
-// Contoso.vbCustomCrypto
-// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx
-// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
-// KeySize: 8
-// Parameters described in Xml format:
-// SecurityBin1
-// 1Contoso
-// 2
-// Keysize0 min, max, step: 8, 64, 8,
-//
-// *** CustomCrypto created with custom parameters:
-// Contoso.vbCustomCrypto
-// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx
-// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
-// KeySize: 64
-// Parameters described in Xml format:
-// SecurityBin2
-// 1Contoso
-// 2
-// Keysize0 min, max, step: 8, 64, 8,
-// Unable to create CustomCrypto from the Create method
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp
deleted file mode 100644
index 49ba079bd65..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-// This sample demonstrates how to use each member of the CryptoConfig class.
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-
-int main()
-{
- // Create a CryptoConfig object to store configuration information.
- //
- CryptoConfig^ cryptoConfig = gcnew CryptoConfig;
- //
-
- // Retrieve the class path for CryptoConfig.
- //
- String^ classDescription = cryptoConfig->ToString();
- //
-
- // Create a new SHA1 provider.
- //
- SHA1CryptoServiceProvider^ SHA1alg =
- dynamic_cast(
- CryptoConfig::CreateFromName( L"SHA1" ));
- //
-
- // Create an RSAParameters with the TestContainer key container.
- //
- CspParameters^ parameters = gcnew CspParameters;
- parameters->KeyContainerName = L"TestContainer";
- array^argsArray = gcnew array(1){
- parameters
- };
-
- // Instantiate the RSA provider instance accessing the TestContainer
- // key container.
- RSACryptoServiceProvider^ rsaProvider =
- static_cast(
- CryptoConfig::CreateFromName( L"RSA", argsArray ));
- //
-
- // Use the MapNameToOID method to get an object identifier
- // (OID) from the string name of the SHA1 algorithm.
- //
- String^ sha1Oid = CryptoConfig::MapNameToOID( L"SHA1" );
- //
-
- // Encode the specified object identifier.
- //
- array^encodedMessage = CryptoConfig::EncodeOID( sha1Oid );
-
- //
- // Display the results to the console.
- Console::WriteLine( L"** {0} **", classDescription );
- Console::WriteLine( L"Created an RSA provider with a KeyContainerName called {0}.",
- parameters->KeyContainerName );
- Console::WriteLine( L"Object identifier from the SHA1 name:{0}",
- sha1Oid );
- Console::WriteLine( L"The object identifier encoded: {0}",
- System::Text::Encoding::ASCII->GetString( encodedMessage ) );
- Console::WriteLine( L"This sample completed successfully; press Enter to exit." );
- Console::ReadLine();
-}
-
-//
-// This sample produces the following output:
-//
-// ** System.Security.Cryptography.CryptoConfig **
-// Created an RSA provider with a KeyContainerName called TestContainer.
-// Object identifier from the SHA1 name:1.3.14.3.2.26
-// The object identifier encoded: HH*((*H9
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp
deleted file mode 100644
index fc83f952401..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-// This sample demonstrates how to use each member of the
-// CryptographicException class.
-//
-using namespace System;
-using namespace System::Text;
-using namespace System::Security::Cryptography;
-using namespace System::Runtime::Serialization;
-
-ref class CryptographicExceptionMembers
-{
-public:
-
- static void Run()
- {
- CryptographicExceptionMembers^ testRun = gcnew CryptographicExceptionMembers;
- testRun->TestConstructors();
- testRun->ShowProperties();
- Console::WriteLine( L"This sample ended successfully; "
- L" press Enter to exit." );
- Console::ReadLine();
- }
-
-private:
- // Test each public implementation of the CryptographicException
- // constructors.
- void TestConstructors()
- {
- EmptyConstructor();
- IntConstructor();
- StringConstructor();
- StringExceptionConstructor();
- StringStringConstructor();
- }
-
- void EmptyConstructor()
- {
- // Construct a CryptographicException with no parameters.
- //
- CryptographicException^ cryptographicException = gcnew CryptographicException;
-
- //
- Console::WriteLine( L"Created an empty CryptographicException." );
- }
-
- void IntConstructor()
- {
- // Construct a CryptographicException using the error code for an
- // unexpected operation exception.
- //
- int exceptionNumber = (int)0x80131431;
- CryptographicException^ cryptographicException = gcnew CryptographicException( exceptionNumber );
- //
-
- Console::WriteLine( L"Created a CryptographicException with the "
- L"following error code: {0}", exceptionNumber );
- }
-
- void StringConstructor()
- {
- // Construct a CryptographicException using a custom error message.
- //
- String^ errorMessage = (L"Unexpected Operation exception.");
- CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage );
- //
-
- Console::WriteLine( L"Created a CryptographicException with the "
- L"following error message: {0}", errorMessage );
- }
-
- void StringExceptionConstructor()
- {
- // Construct a CryptographicException using a custom error message
- // and an inner exception.
- //
- String^ errorMessage = (L"The current operation is not supported.");
- NullReferenceException^ nullException = gcnew NullReferenceException;
- CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage,nullException );
- //
-
- Console::WriteLine( L"Created a CryptographicException with the "
- L"following error message: {0} and the inner exception of {1}", errorMessage, nullException );
- }
-
- void StringStringConstructor()
- {
- // Create a CryptographicException using a time format and a the
- // current date.
- //
- String^ dateFormat = L"{0:t}";
- String^ timeStamp = (DateTime::Now.ToString());
- CryptographicException^ cryptographicException = gcnew CryptographicException( dateFormat,timeStamp );
- //
-
- Console::WriteLine( L"Created a CryptographicException with ({0}) as the format and ({1}) as the message.", dateFormat, timeStamp );
- }
-
- // Construct an invalid DSACryptoServiceProvider to throw a
- // CryptographicException for introspection.
- void ShowProperties()
- {
- try
- {
- // Create a DSACryptoServiceProvider with invalid provider type
- // code to throw a CryptographicException exception.
- CspParameters^ cspParams = gcnew CspParameters( 44 );
- DSACryptoServiceProvider^ DSAalg = gcnew DSACryptoServiceProvider( cspParams );
- }
- catch ( CryptographicException^ ex )
- {
- // Retrieve the link to the help file for the exception.
- //
- String^ helpLink = ex->HelpLink;
- //
-
- // Retrieve the exception that caused the current
- // CryptographicException exception.
- //
- System::Exception^ innerException = ex->InnerException;
- //
-
- String^ innerExceptionMessage = L"";
- if ( innerException != nullptr )
- {
- innerExceptionMessage = innerException->ToString();
- }
-
- // Retrieve the message that describes the exception.
- //
- String^ message = ex->Message;
- //
-
- // Retrieve the name of the application that caused the exception.
- //
- String^ exceptionSource = ex->Source;
- //
-
- // Retrieve the call stack at the time the exception occurred.
- //
- String^ stackTrace = ex->StackTrace;
- //
-
- // Retrieve the method that threw the exception.
- //
- System::Reflection::MethodBase^ targetSite = ex->TargetSite;
- //
-
- String^ siteName = targetSite->Name;
-
- // Retrieve the entire exception as a single string.
- //
- String^ entireException = ex->ToString();
- //
-
- // GetObjectData
- setSerializationInfo( &ex );
-
- // Get the root exception that caused the current
- // CryptographicException exception.
- //
- System::Exception^ baseException = ex->GetBaseException();
- //
-
- String^ baseExceptionMessage = L"";
- if ( baseException != nullptr )
- {
- baseExceptionMessage = baseException->Message;
- }
- Console::WriteLine( L"Caught an expected exception:" );
- Console::WriteLine( entireException );
- Console::WriteLine( L"\n" );
- Console::WriteLine( L"Properties of the exception are as follows:" );
- Console::WriteLine( L"Message: {0}", message );
- Console::WriteLine( L"Source: {0}", exceptionSource );
- Console::WriteLine( L"Stack trace: {0}", stackTrace );
- Console::WriteLine( L"Help link: {0}", helpLink );
- Console::WriteLine( L"Target site's name: {0}", siteName );
- Console::WriteLine( L"Base exception message: {0}", baseExceptionMessage );
- Console::WriteLine( L"Inner exception message: {0}", innerExceptionMessage );
- }
-
- }
-
- void setSerializationInfo( interior_ptr ex )
- {
- // Insert information about the exception into a serialized object.
- //
- FormatterConverter^ formatConverter = gcnew FormatterConverter;
- SerializationInfo^ serializationInfo = gcnew SerializationInfo( ( *ex)->GetType(),formatConverter );
- StreamingContext streamingContext = StreamingContext(StreamingContextStates::All);
- ( *ex)->GetObjectData( serializationInfo, streamingContext );
- //
- }
-
-};
-
-void main()
-{
- CryptographicExceptionMembers::Run();
-}
-
-//
-// This sample produces the following output:
-//
-// Created an empty CryptographicException.
-// Created a CryptographicException with the following error code: -2146233295
-// Created a CryptographicException with the following error message:
-// Unexpected Operation exception.
-// Created a CryptographicException with the following error message: The
-// current operation is not supported. and the inner exception of
-// System.NullReferenceException: Object reference not set to an instance of
-// an object.
-// Created a CryptographicException with ({0:t}) as the format and (2/24/2004
-// 2:13:15 PM) as the message.
-// Caught an expected exception:
-// System.Security.Cryptography.CryptographicException: CryptoAPI
-// cryptographic service provider (CSP) for this implementation could not be
-// acquired.
-// at System.Security.Cryptography.DSACryptoServiceProvider..ctor(Int32
-// dwKeySize, CspParameters parameters)
-// at System.Security.Cryptography.DSACryptoServiceProvider..ctor(
-// CspParametersparameters)
-// at CryptographicExceptionMembers.ShowProperties() in c:\inetpub\
-// vssolutions\test\testbuild\consoleapplication1\class1.cs:line 109
-//
-//
-// Properties of the exception are as follows:
-// Message: CryptoAPI cryptographic service provider (CSP) for this
-// implementation could not be acquired.
-// Source: mscorlib
-// Stack trace:
-// at System.Security.Cryptography.DSACryptoServiceProvider..ctor(
-// Int32 dwKeySize, CspParameters parameters)
-// at System.Security.Cryptography.DSACryptoServiceProvider..ctor(
-// CspParameters parameters)
-// at CryptographicExceptionMembers.ShowProperties() in c:\inetpub\
-// vssolutions\test\testbuild\consoleapplication1\class1.cs:line 109
-// Help link:
-// Target site's name: .ctor
-// Base exception message: CryptoAPI cryptographic service provider (CSP) for
-// this implementation could not be acquired.
-// Inner exception message:
-// This sample ended successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp
deleted file mode 100644
index 463fd5703f5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-int main()
-{
- try
- {
-
- //Create a new instance of DSA.
- DSA^ DSA = DSA::Create();
-
- //The hash to sign.
- array^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135};
-
- //Create an DSASignatureFormatter object and pass it the
- //DSA instance to transfer the key information.
- DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA );
-
- //Set the hash algorithm to SHA1.
- DSAFormatter->SetHashAlgorithm( "SHA1" );
-
- //Create a signature for HashValue and return it.
- array^SignedHash = DSAFormatter->CreateSignature( Hash );
-
- //Create an DSASignatureDeformatter object and pass it the
- //DSA instance to transfer the key information.
- DSASignatureDeformatter^ DSADeformatter = gcnew DSASignatureDeformatter( DSA );
-
- //Verify the hash and display the results to the console.
- if ( DSADeformatter->VerifySignature( Hash, SignedHash ) )
- {
- Console::WriteLine( "The signature was verified." );
- }
- else
- {
- Console::WriteLine( "The signature was not verified." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp
deleted file mode 100644
index bc448969175..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-int main()
-{
- try
- {
-
- //Create a new instance of DSA.
- DSA^ DSA = DSA::Create();
-
- //The hash to sign.
- array^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135};
-
- //Create an DSASignatureFormatter Object* and pass it the
- //DSA instance to transfer the key information.
- DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA );
-
- //Set the hash algorithm to SHA1.
- DSAFormatter->SetHashAlgorithm( "SHA1" );
-
- //Create a signature for HashValue and return it.
- array^SignedHash = DSAFormatter->CreateSignature( Hash );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp
deleted file mode 100644
index 2d3ec8ddc55..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-class MyMainClass
-{
-public:
- static void DecodeFromFile( String^ inFileName, String^ outFileName )
- {
- FromBase64Transform^ myTransform = gcnew FromBase64Transform( FromBase64TransformMode::IgnoreWhiteSpaces );
- array^myOutputBytes = gcnew array(myTransform->OutputBlockSize);
-
- //Open the input and output files.
- FileStream^ myInputFile = gcnew FileStream( inFileName,FileMode::Open,FileAccess::Read );
- FileStream^ myOutputFile = gcnew FileStream( outFileName,FileMode::Create,FileAccess::Write );
-
- //Retrieve the file contents into a Byte array.
- array^myInputBytes = gcnew array(myInputFile->Length);
- myInputFile->Read( myInputBytes, 0, myInputBytes->Length );
-
- //Transform the data in chunks the size of InputBlockSize.
- int i = 0;
- while ( myInputBytes->Length - i > 4 )
- {
- myTransform->TransformBlock( myInputBytes, i, 4, myOutputBytes, 0 );
-
- /*myTransform->InputBlockSize*/
- i += 4;
-
- /*myTransform->InputBlockSize*/
- myOutputFile->Write( myOutputBytes, 0, myTransform->OutputBlockSize );
- }
-
-
- //Transform the final block of data.
- myOutputBytes = myTransform->TransformFinalBlock( myInputBytes, i, myInputBytes->Length - i );
- myOutputFile->Write( myOutputBytes, 0, myOutputBytes->Length );
-
- //Free up any used resources.
- myTransform->Clear();
- myInputFile->Close();
- myOutputFile->Close();
- }
-
-};
-
-int main()
-{
- MyMainClass * m = new MyMainClass;
-
- //Insert your file names into this method call.
- m->DecodeFromFile( "c:\\encoded.txt", "c:\\roundtrip.txt" );
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp
deleted file mode 100644
index 7ac5fae23ff..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// This sample demonstrates how to use each member of the KeySizes class.
-//
-
-using namespace System;
-using namespace System::Security::Cryptography;
-
-namespace CryptographySample
-{
- ref class KeySizesMembers
- {
- public:
- static void Work()
- {
- // Initializes a new instance of the KeySizes class
- // with the specified key values.
- //
- int minSize = 64;
- int maxSize = 1024;
- int skipSize = 64;
- KeySizes^ keySizes =
- gcnew KeySizes(minSize, maxSize, skipSize);
- //
-
- // Show the values of the keys.
- ShowKeys(gcnew array(1) {keySizes},
- "Custom Keys");
-
- // Create a new symmetric algorithm and display its
- // key values.
- Aes^ aes = Aes::Create();
- ShowKeys(aes->LegalKeySizes, aes->ToString());
- Console::WriteLine("aes.blocksize:{0}",
- aes->BlockSize);
-
- // Create a new RSA algorithm and display its key values.
- RSA^ rsa = RSA::Create();
- ShowKeys(rsa->LegalKeySizes, rsa->ToString());
- Console::WriteLine("RSA KeySize ="
- " {0}",
- rsa->KeySize);
-
- Console::WriteLine("This sample completed successfully; "
- "press Enter to exit.");
- Console::ReadLine();
- }
-
- private:
- // Display specified KeySize properties to the console.
- static void ShowKeys(array ^ keySizes,
- String^ objectName)
- {
- // Retrieve the first KeySizes in the array.
- KeySizes^ firstKeySize = keySizes[0];
-
- // Retrieve the minimum key size in bits.
- //
- int minKeySize = firstKeySize->MinSize;
- //
-
- // Retrieve the maximum key size in bits.
- //
- int maxKeySize = firstKeySize->MaxSize;
- //
-
- // Retrieve the interval between valid key size in bits.
- //
- int skipKeySize = firstKeySize->SkipSize;
- //
-
- Console::Write("\n KeySizes retrieved from the ");
- Console::WriteLine("{0} object.", objectName);
- Console::WriteLine("Minimum key size bits: {0}",
- minKeySize);
- Console::WriteLine("Maximum key size bits: {0}",
- maxKeySize);
- Console::WriteLine("Interval between key size bits: {0}",
- skipKeySize);
- }
- };
-}
-
-using namespace CryptographySample;
-
-int main()
-{
- KeySizesMembers::Work();
-}
-//
-// This sample produces the following output:
-//
-// KeySizes retrieved from the Custom Keys object.
-// Minimum key size bits: 64
-// Maximum key size bits: 1024
-// Interval between key size bits: 64
-//
-// KeySizes retrieved from the
-// System.Security.Cryptography.Aes object.
-// Minimum key size bits: 128
-// Maximum key size bits: 256
-// Interval between key size bits: 64
-// aes.blocksize:128
-//
-// KeySizes retrieved from the
-// System.Security.Cryptography.RSA object.
-// Minimum key size bits: 512
-// Maximum key size bits: 16384
-// Interval between key size bits: 64
-// RSA KeySize = 2048
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp
deleted file mode 100644
index d25c4d73ac5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// This sample demonstrates how to extend the KeyedHashAlgorithm class.
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-
-namespace Contoso
-{
- public ref class ContosoKeyedHash: public KeyedHashAlgorithm
- {
- private:
- KeyedHashAlgorithm^ keyedCrypto;
-
- public:
- ContosoKeyedHash( array^ rgbKey )
- {
- Init( L"System.Security.Cryptography.KeyedHashAlgorithm", rgbKey );
- }
-
- ContosoKeyedHash( String^ keyedHashName, array^ rgbKey )
- {
- Init( keyedHashName, rgbKey );
- }
-
- void Init( String^ keyedHashName, array^ rgbKey )
- {
- // Make sure we know which algorithm to use
- if ( rgbKey != nullptr )
- {
- KeyValue = rgbKey;
- HashSizeValue = 160;
-
- // Create a KeyedHashAlgorithm encryptor
- if ( keyedHashName == nullptr )
- {
-
- //
- keyedCrypto = KeyedHashAlgorithm::Create();
- //
- }
- else
- {
- //
- keyedCrypto = KeyedHashAlgorithm::Create( keyedHashName );
- //
- }
- }
- else
- {
- throw gcnew ArgumentNullException( L"rgbKey" );
- }
- }
-
- // Override abstract methods from the HashAlgorithm class.
- virtual void Initialize() override {}
-
- property array^ Key
- {
- //
- virtual array^ get() override
- {
- return dynamic_cast^>(keyedCrypto->Key->Clone());
- }
-
- virtual void set( array^value ) override
- {
- keyedCrypto->Key = dynamic_cast^>(value->Clone());
- }
- }
- //
-
- protected:
- virtual void HashCore( array^ , int /*ibStart*/, int /*cbSize*/ ) override {}
-
- virtual array^ HashFinal() override
- {
- return gcnew array(0);
- }
- };
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp
deleted file mode 100644
index 3c77ea0c947..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-// This sample demonstrates how to derive from
-// the MaskGenerationMethod class.
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-
-namespace Contoso
-{
- //
- ref class MaskGenerator: MaskGenerationMethod
- {
- private:
- String^ hashNameValue;
-
- public:
- // Initialize a mask to encrypt using the SHA256 algorithm.
- MaskGenerator()
- {
- hashNameValue = "SHA256";
- }
-
- //
- // Create a mask with the specified seed.
- //
- virtual array^ GenerateMask(array^ seed, int maskLength) override
- {
- HashAlgorithm^ hash;
- array^ rgbCounter = gcnew array(4);
- array^ targetRgb = gcnew array(maskLength);
- UInt32 counter = 0;
- for (int inc = 0; inc < targetRgb->Length; )
- {
- ConvertIntToByteArray(counter++, rgbCounter);
- hash = (HashAlgorithm^)CryptoConfig::CreateFromName(
- hashNameValue);
- array^ temp = gcnew array(
- 4 + seed->Length);
- Buffer::BlockCopy(rgbCounter, 0, temp, 0, 4);
- Buffer::BlockCopy(seed, 0, temp, 4, seed->Length);
- hash->ComputeHash(temp);
- if (targetRgb->Length - inc > hash->HashSize / 8)
- {
- Buffer::BlockCopy(hash->Hash, 0, targetRgb, inc,
- hash->Hash->Length);
- }
- else
- {
- Buffer::BlockCopy(hash->Hash, 0, targetRgb, inc,
- targetRgb->Length - inc);
- }
-
- inc += hash->Hash->Length;
- }
- return targetRgb;
- }
-
- private:
- //
- // Convert the specified integer to the byte array.
- void ConvertIntToByteArray(UInt32 source,
- array^ targetBytes)
- {
- UInt32 remainder;
- int inc = 0;
-
- // Clear the array prior to filling it.
- Array::Clear(targetBytes, 0, targetBytes->Length);
- while (source > 0)
- {
- remainder = source % 256;
- targetBytes[ 3 - inc ] = (Byte)remainder;
- source = (source - remainder) / 256;
- inc++;
- }
- }
- };
-
- // This class demonstrates how to create the MaskGenerator class
- // and call its GenerateMask member.
- ref class MaskGeneratorImpl
- {
- public:
- void static Work()
- {
- array^ seed = gcnew array(4){
- 0x01,0x02,0x03,0x04};
- int length = 16;
- MaskGenerator^ maskGenerator = gcnew MaskGenerator;
- array^ mask = maskGenerator->GenerateMask(seed,
- length);
- Console::WriteLine("Generated the following mask:");
- Console::WriteLine(System::Text::Encoding::
- ASCII::get()->GetString(mask));
- Console::WriteLine("This sample completed successfully;"
- " press Enter to exit.");
- Console::ReadLine();
- }
- };
-}
-
-void main()
-{
- Contoso::MaskGeneratorImpl::Work();
-}
-
-//
-// This sample produces the following output:
-//
-// Generated the following mask:
-// ?"TFd(?~OtO?
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp
deleted file mode 100644
index 18a61d351be..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-//
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-int main()
-{
- try
- {
-
- //initialze the Byte arrays to the public key information.
- array^PublicKey = {214,46,220,83,160,73,40,39,201,155,19,202,3,11,191,178,56,74,90,36,248,103,18,144,170,163,145,87,54,61,34,220,222,207,137,149,173,14,92,120,206,222,158,28,40,24,30,16,175,108,128,35,230,118,40,121,113,125,216,130,11,24,90,48,194,240,105,44,76,34,57,249,228,125,80,38,9,136,29,117,207,139,168,181,85,137,126,10,126,242,120,247,121,8,100,12,201,171,38,226,193,180,190,117,177,87,143,242,213,11,44,180,113,93,106,99,179,68,175,211,164,116,64,148,226,254,172,147};
- array^Exponent = {1,0,1};
-
- //Values to store encrypted symmetric keys.
- array^EncryptedSymmetricKey;
- array^EncryptedSymmetricIV;
-
- //Create a new instance of RSACryptoServiceProvider.
- RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
-
- //Create a new instance of RSAParameters.
- RSAParameters RSAKeyInfo;
-
- //Set RSAKeyInfo to the public key values.
- RSAKeyInfo.Modulus = PublicKey;
- RSAKeyInfo.Exponent = Exponent;
-
- //Import key parameters into RSA.
- RSA->ImportParameters( RSAKeyInfo );
-
- //Create a new instance of the Aes class.
- Aes^ aes = Aes::Create();
-
- //Encrypt the symmetric key and IV.
- EncryptedSymmetricKey = RSA->Encrypt( aes->Key, false );
- EncryptedSymmetricIV = RSA->Encrypt( aes->IV, false );
- Console::WriteLine( "Aes Key and IV have been encrypted with RSACryptoServiceProvider." );
- }
- catch ( CryptographicException^ e )
- {
-
- //Catch and display a CryptographicException
- //to the console.
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp
deleted file mode 100644
index 92218fec226..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-void main()
-{
- //
- try
- {
- //Create a new RSACryptoServiceProvider Object*.
- RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
-
- //Export the key information to an RSAParameters object.
- //Pass false to export the public key information or pass
- //true to export public and private key information.
- RSAParameters RSAParams = RSA->ExportParameters( false );
- }
- catch ( CryptographicException^ e )
- {
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( e->Message );
- }
- //
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp
deleted file mode 100644
index a5bf383b029..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-
-int main()
-{
- //
- try
- {
- //Create a new RSACryptoServiceProvider object.
- RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
-
- //Export the key information to an RSAParameters object.
- //Pass false to export the public key information or pass
- //true to export public and private key information.
- RSAParameters RSAParams = RSA->ExportParameters( false );
-
- //Create another RSACryptoServiceProvider object.
- RSACryptoServiceProvider^ RSA2 = gcnew RSACryptoServiceProvider;
-
- //Import the key information from the other
- //RSACryptoServiceProvider object.
- RSA2->ImportParameters( RSAParams );
- }
- catch ( CryptographicException^ e )
- {
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( e->Message );
- }
- //
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp
deleted file mode 100644
index 9f6ac45281c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-array^ RSAEncrypt( array^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding )
-{
- try
- {
-
- //Create a new instance of RSACryptoServiceProvider.
- RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
-
- //Import the RSA Key information. This only needs
- //toinclude the public key information.
- RSA->ImportParameters( RSAKeyInfo );
-
- //Encrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
-
- array^encryptedData = RSA->Encrypt( DataToEncrypt, DoOAEPPadding );
- delete RSA;
- return encryptedData;
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- return nullptr;
- }
-
-}
-
-array^ RSADecrypt( array^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding )
-{
- try
- {
-
- //Create a new instance of RSACryptoServiceProvider.
- RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
-
- //Import the RSA Key information. This needs
- //to include the private key information.
- RSA->ImportParameters( RSAKeyInfo );
-
- //Decrypt the passed byte array and specify OAEP padding.
- //OAEP padding is only available on Microsoft Windows XP or
- //later.
-
- array^decryptedData = RSA->Decrypt( DataToDecrypt, DoOAEPPadding );
- delete RSA;
- return decryptedData;
- }
- //Catch and display a CryptographicException
- //to the console.
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e );
- return nullptr;
- }
-
-}
-
-int main()
-{
- try
- {
-
- //Create a UnicodeEncoder to convert between byte array and string.
- UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding;
-
- //Create byte arrays to hold original, encrypted, and decrypted data.
- array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" );
- array^encryptedData;
- array^decryptedData;
-
- //Create a new instance of RSACryptoServiceProvider to generate
- //public and private key data.
- RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider;
-
- //Pass the data to ENCRYPT, the public key information
- //(using RSACryptoServiceProvider.ExportParameters(false),
- //and a boolean flag specifying no OAEP padding.
- encryptedData = RSAEncrypt( dataToEncrypt, RSA->ExportParameters( false ), false );
-
- //Pass the data to DECRYPT, the private key information
- //(using RSACryptoServiceProvider.ExportParameters(true),
- //and a boolean flag specifying no OAEP padding.
- decryptedData = RSADecrypt( encryptedData, RSA->ExportParameters( true ), false );
-
- //Display the decrypted plaintext to the console.
- Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) );
- delete RSA;
- }
- catch ( ArgumentNullException^ )
- {
-
- //Catch this exception in case the encryption did
- //not succeed.
- Console::WriteLine( "Encryption failed." );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp
deleted file mode 100644
index cb8ce0d69c9..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-// This sample demonstrates how to encode and decode a string using
-// the RSAOAEPKeyExchangeFormatter and RSAOAEPKeyExchangeDeformatter classes.
-//
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Text;
-
-ref class RSAEncoder
-{
-private:
- // Use a member variable to hold the RSA key for encoding and decoding.
- RSA^ rsaKey;
-
-public:
- [STAThread]
- static void Main()
- {
- String^ message = L"A phrase to be encoded.";
- RSAEncoder^ rsaEncoder = gcnew RSAEncoder;
- rsaEncoder->InitializeKey( RSA::Create() );
- Console::WriteLine( L"Encoding the following message:" );
- Console::WriteLine( message );
- array^encodedMessage = rsaEncoder->EncodeMessage( message );
- Console::WriteLine( L"Resulting message encoded:" );
- Console::WriteLine( Encoding::ASCII->GetString( encodedMessage ) );
- String^ decodedMessage = rsaEncoder->DecodeMessage( encodedMessage );
- Console::WriteLine( L"Resulting message decoded:" );
- Console::WriteLine( decodedMessage );
-
- // Construct a formatter to demonstrate how to set each property.
- rsaEncoder->ConstructFormatter();
-
- // Construct a deformatter to demonstrate how to set each property.
- rsaEncoder->ConstructDeformatter();
- Console::WriteLine( L"This sample completed successfully, "
- L" press enter to continue." );
- Console::ReadLine();
- }
-
-
-private:
- // Initialize an rsaKey member variable with the specified RSA key.
- void InitializeKey( RSA^ key )
- {
- rsaKey = key;
- }
-
- // Use the RSAOAEPKeyExchangeDeformatter class to decode the
- // specified message.
- array^ EncodeMessage( String^ message )
- {
- array^encodedMessage = nullptr;
- try
- {
-
- // Construct a formatter with the specified RSA key.
- //
- RSAOAEPKeyExchangeFormatter^ keyEncryptor =
- gcnew RSAOAEPKeyExchangeFormatter( rsaKey );
- //
-
- // Convert the message to bytes to create the encrypted data.
- //
- array^byteMessage = Encoding::ASCII->GetBytes( message );
- encodedMessage = keyEncryptor->CreateKeyExchange( byteMessage );
- //
- }
- catch ( Exception^ ex )
- {
- Console::WriteLine( L"Unexpected exception caught:{0}", ex );
- }
-
- return encodedMessage;
- }
-
- // Use the RSAOAEPKeyExchangeDeformatter class to decode the
- // specified message.
- String^ DecodeMessage( array^encodedMessage )
- {
- String^ decodedMessage = nullptr;
- try
- {
- // Construct a deformatter with the specified RSA key.
- //
- RSAOAEPKeyExchangeDeformatter^ keyDecryptor =
- gcnew RSAOAEPKeyExchangeDeformatter( rsaKey );
- //
-
- // Decrypt the encoded message.
- //
- array^decodedBytes = keyDecryptor->DecryptKeyExchange( encodedMessage );
- //
-
- // Retrieve a string representation of the decoded message.
- decodedMessage = Encoding::ASCII->GetString( decodedBytes );
- }
- catch ( Exception^ ex )
- {
- Console::WriteLine( L"Unexpected exception caught:{0}", ex );
- }
-
- return decodedMessage;
- }
-
-
- // Create an RSAOAEPKeyExchangeFormatter object with a new RSA key.
- // Display its properties to the console.
- void ConstructFormatter()
- {
- // Construct an empty Optimal Asymmetric Encryption Padding (OAEP)
- // key exchange.
- //
- RSAOAEPKeyExchangeFormatter^ rsaFormatter = gcnew RSAOAEPKeyExchangeFormatter;
- //
-
- // Create an RSA and set it into the specified
- // RSAOAEPKeyExchangeFormatter.
- //
- RSA^ key = RSA::Create();
- rsaFormatter->SetKey( key );
- //
-
- // Create a random number using the RNGCryptoServiceProvider provider.
- //
- RandomNumberGenerator^ ring = RandomNumberGenerator::Create();
- rsaFormatter->Rng = ring;
- //
-
- // Export InverseQ and set it into the RSAOAEPKeyExchangeFormatter.
- //
- rsaFormatter->Parameter = key->ExportParameters( true ).InverseQ;
- //
-
- Console::WriteLine();
- Console::WriteLine( L"**{0}**", rsaFormatter );
- Console::Write( L"The following random number was generated using the " );
- Console::WriteLine( L"class:" );
- Console::WriteLine( rsaFormatter->Rng );
- Console::WriteLine();
- Console::Write( L"The RSA formatter contains the following InverseQ" );
- Console::WriteLine( L" parameter:" );
- Console::WriteLine( Encoding::ASCII->GetString( rsaFormatter->Parameter ) );
- Console::WriteLine();
-
- //
- String^ xmlParameters = rsaFormatter->Parameters;
- //
-
- Console::WriteLine( L"The RSA formatter has the following parameters:" );
- Console::WriteLine( xmlParameters );
- }
-
- // Create an RSAOAEPKeyExchangeDeformatter object with a new RSA key.
- // Display its properties to the console.
- void ConstructDeformatter()
- {
- // Construct an empty OAEP key exchange.
- //
- RSAOAEPKeyExchangeDeformatter^ rsaDeformatter =
- gcnew RSAOAEPKeyExchangeDeformatter;
- //
-
- // Create an RSAKey and set it into the specified
- // RSAOAEPKeyExchangeFormatter.
- //
- RSA^ key = RSA::Create();
- rsaDeformatter->SetKey( key );
- //
-
- Console::WriteLine();
- Console::WriteLine( L"**{0}**", rsaDeformatter );
-
- //
- String^ xmlParameters = rsaDeformatter->Parameters;
- //
-
- Console::WriteLine();
- Console::WriteLine( L"The RSA deformatter has the following " );
- Console::WriteLine( L"parameters:{0}", xmlParameters );
- }
-};
-
-int main()
-{
- RSAEncoder::Main();
-}
-
-//
-// This sample produces the following output:
-//
-// Encoding the following message:
-// A phrase to be encoded.
-// Resulting message encoded: %?}T:v??xu?eD)YucItjwu¦ALH HB,Uj??2xq?.?s45
-// ?f?L2?=X?CPzWx???"q5?6&N"AE,Z+T?(]S?_7~,?G{?VV!:S?df?
-// Resulting message decoded:
-// A phrase to be encoded.
-//
-// **System.Security.Cryptography.RSAOAEPKeyExchangeFormatter**
-// The following random number was generated using the class:
-// System.Security.Cryptography.RNGCryptoServiceProvider
-//
-// The RSA formatter contains the following InverseQ parameter:
-// 3MM??]D#?mBq_;:ws^1?ko??,_ ??A[hyWcP$?`v.>@?^!dU%\?H0N'??Ca?Ns
-//
-// The RSA formatter has the following parameters:
-//
-//
-// **System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter**
-//
-// The RSA deformatter has the following
-// parameters:
-// This sample completed successfully, press enter to continue.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp
deleted file mode 100644
index 1cf5a6c9d9b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-// This sample demonstrates how to use each member of the ToBase64Transform
-// class. The file named members.cs is read in and written out as a
-// transformed file named members.enc.
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Security::Cryptography;
-
-ref class Members
-{
-public:
- [STAThread]
- static void Main()
- {
- String^ appPath = (String::Concat(
- System::IO::Directory::GetCurrentDirectory(), L"\\" ));
-
- // Insert your file names into this method call.
- EncodeFromFile( String::Concat( appPath, L"members.cpp" ),
- String::Concat( appPath, L"members.enc" ) );
- Console::WriteLine( L"This sample completed successfully; "
- L"press Enter to exit." );
- Console::ReadLine();
- }
-
-private:
- // Read in the specified source file and write out an encoded target file.
- static void EncodeFromFile( String^ sourceFile, String^ targetFile )
- {
- // Verify members.cpp exists at the specified directory.
- if ( !File::Exists( sourceFile ) )
- {
- Console::Write( L"Unable to locate source file located at " );
- Console::WriteLine( L"{0}.", sourceFile );
- Console::Write( L"Please correct the path and run the " );
- Console::WriteLine( L"sample again." );
- return;
- }
-
- // Retrieve the input and output file streams.
- FileStream^ inputFileStream = gcnew FileStream(
- sourceFile,FileMode::Open,FileAccess::Read );
- FileStream^ outputFileStream = gcnew FileStream(
- targetFile,FileMode::Create,FileAccess::Write );
-
- // Create a new ToBase64Transform object to convert to base 64.
- //
- ToBase64Transform^ base64Transform = gcnew ToBase64Transform;
- //
-
- // Create a new byte array with the size of the output block size.
- //
- array^outputBytes = gcnew array(
- base64Transform->OutputBlockSize);
- //
-
- // Retrieve the file contents into a byte array.
- array^inputBytes = gcnew array(inputFileStream->Length);
- inputFileStream->Read( inputBytes, 0, inputBytes->Length );
-
- // Verify that multiple blocks can not be transformed.
- //
- if ( !base64Transform->CanTransformMultipleBlocks )
- //
- {
- // Initializie the offset size.
- int inputOffset = 0;
-
- // Iterate through inputBytes transforming by blockSize.
- //
- //
- int inputBlockSize = base64Transform->InputBlockSize;
- //
- while ( inputBytes->Length - inputOffset > inputBlockSize )
- {
- base64Transform->TransformBlock(
- inputBytes,
- inputOffset,
- inputBytes->Length - inputOffset,
- outputBytes,
- 0 );
-
- inputOffset += base64Transform->InputBlockSize;
- outputFileStream->Write(
- outputBytes,
- 0,
- base64Transform->OutputBlockSize );
- }
- //
-
- // Transform the final block of data.
- //
- outputBytes = base64Transform->TransformFinalBlock(
- inputBytes,
- inputOffset,
- inputBytes->Length - inputOffset );
- //
- outputFileStream->Write( outputBytes, 0, outputBytes->Length );
- Console::WriteLine( L"Created encoded file at {0}", targetFile );
- }
-
- // Determine if the current transform can be reused.
- //
- if ( !base64Transform->CanReuseTransform )
- //
- {
- // Free up any used resources.
- //
- base64Transform->Clear();
- //
- }
-
- // Close file streams.
- inputFileStream->Close();
- outputFileStream->Close();
- }
-};
-
-int main()
-{
- Members::Main();
-}
-
-//
-// This sample produces the following output:
-//
-// Created encoded file at C:\ConsoleApplication1\\membersvcs.enc
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp
deleted file mode 100644
index 080c61111a3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-//
-//
-// This example signs a file specified by a URI
-// using a detached signature. It then verifies
-// the signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key )
-{
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Assign the key to the SignedXml object.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
-
- // Add the passed URI to the reference object.
- reference->Uri = URIString;
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) );
- xmlDigitalSignature->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyDetachedSignature( String^ XmlSigFileName )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( XmlSigFileName );
-
- // Create a new SignedXMl object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-
-[STAThread]
-int main()
-{
- array^args = Environment::GetCommandLineArgs();
-
- // The URI to sign.
- String^ resourceToSign = "http://www.microsoft.com";
-
- // The name of the file to which to save the XML signature.
- String^ XmlFileName = "xmldsig.xml";
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- Console::WriteLine( "Signing: {0}", resourceToSign );
-
- // Sign the detached resourceand save the signature in an XML file.
- SignDetachedResource( resourceToSign, XmlFileName, Key );
- Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
-
- //Verify the XML signature in the XML file.
- bool result = VerifyDetachedSignature( XmlFileName );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp
deleted file mode 100644
index 780d8fbafbf..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", Key );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp
deleted file mode 100644
index d4942102cf3..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-//
-//
-// This example signs a file specified by a URI
-// using a detached signature. It then verifies
-// the signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignDetachedResource( String^ URIString, String^ XmlSigFileName, DSA^ DSAKey )
-{
-
- // Create a SignedXml Object*.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Assign the DSA key to the SignedXml object.
- signedXml->SigningKey = DSAKey;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
-
- // Add the passed URI to the reference object.
- reference->Uri = URIString;
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add a DSAKeyValue to the KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew DSAKeyValue( safe_cast(DSAKey) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) );
- xmlDigitalSignature->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyDetachedSignature( String^ XmlSigFileName )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( XmlSigFileName );
-
- // Create a new SignedXMl object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Find the S"Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-
-[STAThread]
-int main()
-{
- array^args = Environment::GetCommandLineArgs();
-
- // The URI to sign.
- String^ resourceToSign = "http://www.microsoft.com";
-
- // The name of the file to which to save the XML signature.
- String^ XmlFileName = "xmldsig.xml";
- try
- {
-
- // Generate a DSA signing key.
- DSA^ DSAKey = DSA::Create();
- Console::WriteLine( "Signing: {0}", resourceToSign );
-
- // Sign the detached resourceand save the signature in an XML file.
- SignDetachedResource( resourceToSign, XmlFileName, DSAKey );
- Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
-
- //Verify the XML signature in the XML file.
- bool result = VerifyDetachedSignature( XmlFileName );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp
deleted file mode 100644
index 20276a9a84d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, DSA^ DSAKey )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the DSA key to the SignedXml document.
- signedXml->SigningKey = DSAKey;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add a transformation to the reference.
- Transform^ trns = gcnew XmlDsigC14NTransform;
- reference->AddTransform( trns );
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add a DSAKeyValue to the KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew DSAKeyValue( safe_cast(DSAKey) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate a DSA signing key.
- DSA^ DSAKey = DSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", DSAKey );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp
deleted file mode 100644
index aca4a856e3f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-//
-//
-// This example signs a file specified by a URI
-// using a detached signature. It then verifies
-// the signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key, String^ Certificate )
-{
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Assign the key to the SignedXml object.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
-
- // Add the passed URI to the reference object.
- reference->Uri = URIString;
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Create a new KeyInfo object.
- KeyInfo^ keyInfo = gcnew KeyInfo;
-
- // Load the X509 certificate.
- X509Certificate^ MSCert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Load the certificate into a KeyInfoX509Data object
- // and add it to the KeyInfo object.
- keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) );
-
- // Add the KeyInfo object to the SignedXml object.
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) );
- xmlDigitalSignature->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-
-[STAThread]
-int main()
-{
- array^args = Environment::GetCommandLineArgs();
-
- // The URI to sign.
- String^ resourceToSign = "http://www.microsoft.com";
-
- // The name of the file to which to save the XML signature.
- String^ XmlFileName = "xmldsig.xml";
-
- // The name of the X509 certificate
- String^ Certificate = "microsoft.cer";
- try
- {
-
- // Generate a signing key. This key should match the certificate.
- RSA^ Key = RSA::Create();
- Console::WriteLine( "Signing: {0}", resourceToSign );
-
- // Sign the detached resource and save the signature in an XML file.
- SignDetachedResource( resourceToSign, XmlFileName, Key, Certificate );
- Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp
deleted file mode 100644
index 31aee98e1a6..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ Certificate )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Create a new KeyInfo object.
- KeyInfo^ keyInfo = gcnew KeyInfo;
-
- // Load the X509 certificate.
- X509Certificate^ MSCert = X509Certificate::CreateFromCertFile( Certificate );
-
- // Load the certificate into a KeyInfoX509Data object
- // and add it to the KeyInfo object.
- keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) );
-
- // Add the KeyInfo object to the SignedXml object.
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- String^ Certificate = "microsoft.cer";
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", Key, Certificate );
- Console::WriteLine( "XML file signed." );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- return 0;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp
deleted file mode 100644
index 43ae77e2392..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ RSAKey )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the RSA key to the SignedXml document.
- signedXml->SigningKey = RSAKey;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add a RSAKeyValue to the KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate a RSA signing key.
- RSA^ RSAKey = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", RSAKey );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml" );
-
- // Display the results of the signature verification to \
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp
deleted file mode 100644
index 8d9b7b1fc42..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-
-
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ RSAKey )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the RSA key to the SignedXml document.
- signedXml->SigningKey = RSAKey;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add a transformation to the reference.
- Transform^ trns = gcnew XmlDsigC14NTransform;
- reference->AddTransform( trns );
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue to the KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate an RSA signing key.
- RSA^ RSAKey = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", RSAKey );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp
deleted file mode 100644
index fa1867d2679..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-//
-//
-// This example signs a file specified by a URI
-// using a detached signature. It then verifies
-// the signed XML.
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file. This method does not
-// save the public key within the XML file. This file cannot be verified unless
-// the verifying code has the key with which it was signed.
-void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key )
-{
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Assign the key to the SignedXml object.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
-
- // Add the passed URI to the reference object.
- reference->Uri = URIString;
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) );
- xmlDigitalSignature->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file against an asymmetric
-// algorithm and return the result.
-static Boolean VerifyDetachedSignature( String^ XmlSigFileName, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Load the passedXML file into the document.
- xmlDocument->Load( XmlSigFileName );
-
- // Create a new SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( dynamic_cast(nodeList[ 0 ]) );
-
- // Check the signature against the passed asymmetric key
- // and return the result.
- return signedXml->CheckSignature( Key );
-}
-
-int main()
-{
-
- // The URI to sign.
- String^ resourceToSign = "http://www.microsoft.com";
-
- // The name of the file to which to save the XML signature.
- String^ XmlFileName = "xmldsig.xml";
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- Console::WriteLine( "Signing: {0}", resourceToSign );
-
- // Sign the detached resourceand save the signature in an XML file.
- SignDetachedResource( resourceToSign, XmlFileName, Key );
- Console::WriteLine( "XML Signature was successfully computed and saved to {0}.", XmlFileName );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
-
- //Verify the XML signature in the XML file against the key.
- bool result = VerifyDetachedSignature( XmlFileName, Key );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp
deleted file mode 100644
index 270360c4f71..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file. This method does not
-// save the public key within the XML file. This file cannot be verified unless
-// the verifying code has the key with which it was signed.
-void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file against an asymmetric
-// algorithm and return the result.
-Boolean VerifyXmlFile( String^ Name, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature( Key );
-}
-
-
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument Object*.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "signedExample.xml", Key );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml", Key );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp
deleted file mode 100644
index 979040a9f1c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-//
-//
-// This example signs a file specified by a URI
-// using a detached signature. It then verifies
-// the signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file.
-void SignDetachedResource( String^ URIString, String^ XmlSigFileName, KeyedHashAlgorithm^ Key )
-{
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
-
- // Add the passed URI to the reference object.
- reference->Uri = URIString;
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Compute the signature.
- signedXml->ComputeSignature( Key );
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) );
- xmlDigitalSignature->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-Boolean VerifyDetachedSignature( String^ XmlSigFileName, KeyedHashAlgorithm^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Load the passedXML file into the document.
- xmlDocument->Load( XmlSigFileName );
-
- // Create a new SignedXml object and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature( Key );
-}
-
-int main()
-{
- try
- {
-
- // The URI to sign.
- String^ resourceToSign = "http://www.microsoft.com";
-
- // The name of the file to which to save the XML signature.
- String^ XmlFileName = "xmlsig.xml";
-
- // Generate a signing key.
- HMACSHA256^ Key = gcnew HMACSHA256;
- Console::WriteLine( "Signing: {0}", resourceToSign );
-
- // Sign the detached resourceand save the signature in an XML file.
- SignDetachedResource( resourceToSign, XmlFileName, Key );
- Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
-
- //Verify the XML signature in the XML file.
- bool result = VerifyDetachedSignature( XmlFileName, Key );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp
deleted file mode 100644
index 5ea1b276c55..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
-//
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, KeyedHashAlgorithm^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using its name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXML object.
- signedXml->AddReference( reference );
-
- // Compute the signature.
- signedXml->ComputeSignature( Key );
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-// Verify the signature of an XML file and return the result.
-Boolean VerifyXmlFile( String^ Name, KeyedHashAlgorithm^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXMl object and pass it
- // the XMl document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the "Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature( Key );
-}
-
-
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument object.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode object.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the filename specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-int main()
-{
- try
- {
-
- // Generate a signing key.
- HMACSHA256^ Key = gcnew HMACSHA256;
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", Key );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying Signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml", Key );
-
- // Display the results of the signature verification to \
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- return 0;
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp
deleted file mode 100644
index 24b3bee5ff8..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-//
-//
-// This example signs a file specified by a URI
-// using a detached signature. It then verifies
-// the signed XML.
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ RSAKey )
-{
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Assign the key to the SignedXml object.
- signedXml->SigningKey = RSAKey;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
-
- // Add the passed URI to the reference object.
- reference->Uri = URIString;
-
- // Add a transformation if the URI is an XML file.
- if ( URIString->EndsWith( "xml" ) )
- {
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement object.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Save the signed XML document to a file specified
- // using the passed string.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) );
- xmlDigitalSignature->WriteTo( xmltw );
- xmltw->Close();
- }
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyDetachedSignature( String^ XmlSigFileName )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( XmlSigFileName );
-
- // Create a new SignedXMl object.
- SignedXml^ signedXml = gcnew SignedXml;
-
- // Find the S"Signature" node and create a new
- // XmlNodeList object.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-int main()
-{
-
- // The URI to sign.
- String^ resourceToSign = "http://www.microsoft.com";
-
- // The name of the file to which to save the XML signature.
- String^ XmlFileName = "xmldsig.xml";
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
- Console::WriteLine( "Signing: {0}", resourceToSign );
-
- // Sign the detached resourceand save the signature in an XML file.
- SignDetachedResource( resourceToSign, XmlFileName, Key );
- Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
-
- //Verify the XML signature in the XML file.
- bool result = VerifyDetachedSignature( XmlFileName );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp
deleted file mode 100644
index 19f81fd3bec..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-//
-// This example signs an XML file using an
-// envelope signature. It then verifies the
-// signed XML.
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-using namespace System::Xml;
-
-//
-// Sign an XML file and save the signature in a new file.
-void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key )
-{
-
- // Create a new XML document.
- XmlDocument^ doc = gcnew XmlDocument;
-
- // Format the document to ignore white spaces.
- doc->PreserveWhitespace = false;
-
- // Load the passed XML file using it's name.
- doc->Load( gcnew XmlTextReader( FileName ) );
-
- // Create a SignedXml Object*.
- SignedXml^ signedXml = gcnew SignedXml( doc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = "";
-
- // Add an enveloped transformation to the reference.
- XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform;
- reference->AddTransform( env );
-
- // Add the reference to the SignedXml Object*.
- signedXml->AddReference( reference );
-
- // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
- KeyInfo^ keyInfo = gcnew KeyInfo;
- keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) );
- signedXml->KeyInfo = keyInfo;
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Get the XML representation of the signature and save
- // it to an XmlElement Object*.
- XmlElement^ xmlDigitalSignature = signedXml->GetXml();
-
- // Append the element to the XML document.
- doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) );
- if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid )
- {
- doc->RemoveChild( doc->FirstChild );
- }
-
-
- // Save the signed XML document to a file specified
- // using the passed String*.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) );
- doc->WriteTo( xmltw );
- xmltw->Close();
-}
-
-
-//
-//
-// Verify the signature of an XML file and return the result.
-Boolean VerifyXmlFile( String^ Name )
-{
-
- // Create a new XML document.
- XmlDocument^ xmlDocument = gcnew XmlDocument;
-
- // Format using white spaces.
- xmlDocument->PreserveWhitespace = true;
-
- // Load the passed XML file into the document.
- xmlDocument->Load( Name );
-
- // Create a new SignedXml Object* and pass it
- // the XML document class.
- SignedXml^ signedXml = gcnew SignedXml( xmlDocument );
-
- // Find the S"Signature" node and create a new
- // XmlNodeList Object*.
- XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
-
- // Load the signature node.
- signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) );
-
- // Check the signature and return the result.
- return signedXml->CheckSignature();
-}
-
-
-//
-// Create example data to sign.
-void CreateSomeXml( String^ FileName )
-{
-
- // Create a new XmlDocument Object*.
- XmlDocument^ document = gcnew XmlDocument;
-
- // Create a new XmlNode Object*.
- XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" );
-
- // Add some text to the node.
- node->InnerText = "Example text to be signed.";
-
- // Append the node to the document.
- document->AppendChild( node );
-
- // Save the XML document to the file name specified.
- XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) );
- document->WriteTo( xmltw );
- xmltw->Close();
-}
-
-void main()
-{
- try
- {
-
- // Generate a signing key.
- RSA^ Key = RSA::Create();
-
- // Create an XML file to sign.
- CreateSomeXml( "Example.xml" );
- Console::WriteLine( "New XML file created." );
-
- // Sign the XML that was just created and save it in a
- // new file.
- SignXmlFile( "Example.xml", "SignedExample.xml", Key );
- Console::WriteLine( "XML file signed." );
-
- // Verify the signature of the signed XML.
- Console::WriteLine( "Verifying signature..." );
- bool result = VerifyXmlFile( "SignedExample.xml" );
-
- // Display the results of the signature verification to
- // the console.
- if ( result )
- {
- Console::WriteLine( "The XML signature is valid." );
- }
- else
- {
- Console::WriteLine( "The XML signature is not valid." );
- }
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp
deleted file mode 100644
index 35c00691bbc..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-
-namespace CryptographyXmlDsigBase64Transform
-{
- ref class Example
- {
- public:
- static void Produce()
- {
-
- // Encrypt an XML message
- EncryptXML(LoadXMLDoc());
-
- // Using XmlDsigBase64Transform resolving a Uri.
- Uri^ baseUri = gcnew Uri("http://www.microsoft.com");
- String^ relativeUri = "msdn";
- Uri^ absoluteUri = ResolveUris(baseUri, relativeUri);
- Console::WriteLine("This sample completed successfully; "
- "press Enter to exit.");
- Console::ReadLine();
- }
-
-
- private:
-
- // Encrypt the text in the specified XmlDocument.
- static void EncryptXML(XmlDocument^ xmlDoc)
- {
-
- //
- XmlDsigBase64Transform^ xmlTransform =
- gcnew XmlDsigBase64Transform;
- //
- // Ensure the transform is using the proper algorithm.
- //
- xmlTransform->Algorithm =
- SignedXml::XmlDsigBase64TransformUrl;
- //
- // Retrieve the XML representation of the current
- // transform.
- //
- XmlElement^ xmlInTransform = xmlTransform->GetXml();
- //
- Console::WriteLine("Xml representation of the "
- "current transform: ");
- Console::WriteLine(xmlInTransform->OuterXml);
-
- // Retrieve the valid input types for the current
- // transform.
- //
- array^ validInTypes = xmlTransform->InputTypes;
- //
- // Verify the xmlTransform can accept the XMLDocument
- // as an input type.
- for each (Type^ validInType in validInTypes)
- {
- if (validInType == xmlDoc->GetType())
- {
-
- // Demonstrate loading the entire Xml Document.
- //
- xmlTransform->LoadInput(xmlDoc);
- //
- // This transform is created for demonstration
- // purposes.
- XmlDsigBase64Transform^ secondTransform =
- gcnew XmlDsigBase64Transform;
- //
- String^ classDescription =
- secondTransform->ToString();
- //
- // This call does not perform as expected.
- // LoadInnerXml is overridden by the
- // XmlDsigBase64Transform class, but is
- // stubbed out.
- //
- secondTransform->LoadInnerXml(
- xmlDoc->SelectNodes("//."));
- //
- break;
- }
-
- }
-
- //
- array^ validOutTypes = xmlTransform->OutputTypes;
- //
- for each (Type^ validOutType in validOutTypes)
- {
- if (validOutType == Stream::typeid)
- {
- try
- {
-
- //
- Type^ streamType = Stream::typeid;
- CryptoStream^ outputStream =
- (CryptoStream^)(xmlTransform->GetOutput(
- streamType));
- //
- // Read the CryptoStream into a stream reader.
- StreamReader^ streamReader =
- gcnew StreamReader(outputStream);
-
- // Read the stream into a string.
- String^ outputMessage =
- streamReader->ReadToEnd();
-
- // Close the streams.
- outputStream->Close();
- streamReader->Close();
-
- // Display to the console the Xml before and
- // after encryption.
- Console::WriteLine("Encoding the following "
- "message: {0}", xmlDoc->InnerText);
- Console::WriteLine("Message encoded: {0}",
- outputMessage);
- }
- catch (CryptographicException^ ex)
- {
- Console::WriteLine("Cryptographic exception "
- "caught: {0}", ex);
- }
-
- break;
- }
- else
- {
-
- //
- Object^ outputObject = xmlTransform->GetOutput();
- //
- }
-
- }
- }
-
-
- // Create an XML document with Element and Text nodes.
- static XmlDocument^ LoadXMLDoc()
- {
- XmlDocument^ xmlDoc = gcnew XmlDocument;
- XmlNode^ mainNode =
- xmlDoc->CreateNode(XmlNodeType::Element,
- "ContosoMessages", "http://www.contoso.com");
- XmlNode^ textNode = xmlDoc->CreateTextNode("Some text "
- "to encode.");
- mainNode->AppendChild(textNode);
- xmlDoc->AppendChild(mainNode);
- Console::WriteLine("Created the following XML Document "
- "for transformation: ");
- Console::WriteLine(xmlDoc->InnerXml);
- return xmlDoc;
- }
-
-
- // Resolve the specified base and relative Uri's.
- static Uri^ ResolveUris(Uri^ baseUri, String^ relativeUri)
- {
-
- //
- XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver;
- xmlResolver->Credentials =
- System::Net::CredentialCache::DefaultCredentials;
- XmlDsigBase64Transform^ xmlTransform =
- gcnew XmlDsigBase64Transform;
- xmlTransform->Resolver = xmlResolver;
- //
- Uri^ absoluteUri = xmlResolver->ResolveUri(baseUri,
- relativeUri);
- if (absoluteUri != nullptr)
- {
- Console::WriteLine("Resolved the base Uri and "
- "relative Uri to the following:");
- Console::WriteLine(absoluteUri);
- }
- else
- {
- Console::WriteLine("Unable to resolve the base "
- "Uri and relative Uri");
- }
-
- return absoluteUri;
- }
-
- };
-
-}
-
-int main()
-{
- CryptographyXmlDsigBase64Transform::Example::Produce();
-}
-
-//
-// This sample produces the following output:
-//
-// Created the following XML Document for transformation:
-// Some text to encode.
-//
-// Xml representation of the current transform:
-//
-// Encoding the following message: Some text to encode.
-// Message encoded: Jmr^
-// Resolved the base Uri and relative Uri to the following:
-// http://www.microsoft.com/msdn
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp
deleted file mode 100644
index 9c590aba971..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-//
-#using
-#using
-#using
-using namespace System;
-using namespace System::IO;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Security::Cryptography::X509Certificates;
-
-ref class Class1
-{
-private:
- static String^ Certificate = L"..\\..\\my509.cer";
-
-public:
- [STAThread]
- static void Main()
- {
- // Encrypt an XML message
- XmlDocument^ productsXml = LoadProducts();
- ShowTransformProperties( productsXml );
- SignDocument( productsXml );
- ShowTransformProperties( productsXml );
-
- // Use XmlDsigC14NTransform to resolve a Uri.
- Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" );
- String^ relativeUri = L"xml";
- Uri^ absoluteUri = ResolveUris( baseUri, relativeUri );
- Console::WriteLine( L"This sample completed successfully; "
- L"press Enter to exit." );
- Console::ReadLine();
- }
-
-
-private:
- // Encrypt the text in the specified XmlDocument.
- static void ShowTransformProperties( XmlDocument^ xmlDoc )
- {
- //
- XmlDsigC14NTransform^ xmlTransform =
- gcnew XmlDsigC14NTransform( true );
- //
-
- // Ensure the transform is using the appropriate algorithm.
- //
- xmlTransform->Algorithm =
- SignedXml::XmlDsigExcC14NTransformUrl;
- //
-
- // Retrieve the XML representation of the current transform.
- //
- XmlElement^ xmlInTransform = xmlTransform->GetXml();
- //
-
- Console::WriteLine( L"\nXml representation of the current transform: " );
- Console::WriteLine( xmlInTransform->OuterXml );
-
- // Retrieve the valid input types for the current transform.
- //
- array^validInTypes = xmlTransform->InputTypes;
- //
-
- // Verify the xmlTransform can accept the XMLDocument as an
- // input type.
- for ( int i = 0; i < validInTypes->Length; i++ )
- {
- if ( validInTypes[ i ] == xmlDoc->GetType() )
- {
- // Load the document into the transfrom.
- //
- xmlTransform->LoadInput( xmlDoc );
- //
-
- //
- XmlDsigC14NTransform^ secondTransform = gcnew XmlDsigC14NTransform;
- //
-
- //
- String^ classDescription = secondTransform->ToString();
- //
-
- // This call does not perform as expected.
- // This transform does not contain inner XML elements
- //
- secondTransform->LoadInnerXml( xmlDoc->SelectNodes( L"//." ) );
- //
-
- break;
- }
- }
-
- //
- array^validOutTypes = xmlTransform->OutputTypes;
- //
-
- for ( int i = 0; i < validOutTypes->Length; i++ )
- {
- if ( validOutTypes[ i ] == System::IO::Stream::typeid )
- {
- try
- {
-
- //
- Type^ streamType = System::IO::Stream::typeid;
- MemoryStream^ outputStream = static_cast(
- xmlTransform->GetOutput( streamType ));
- //
-
- // Read the CryptoStream into a stream reader.
- StreamReader^ streamReader =
- gcnew StreamReader( outputStream );
-
- // Read the stream into a string.
- String^ outputMessage = streamReader->ReadToEnd();
-
- // Close the streams.
- outputStream->Close();
- streamReader->Close();
-
- // Display to the console the Xml before and after
- // encryption.
- Console::WriteLine( L"Encoding the following xml: {0}",
- xmlDoc->OuterXml );
- Console::WriteLine( L"Message encoded: {0}", outputMessage );
- }
- catch ( Exception^ ex )
- {
- Console::WriteLine( L"Unexpected exception caught: {0}", ex );
- }
-
- break;
- }
- else
- {
- //
- Object^ outputObject = xmlTransform->GetOutput();
- //
- }
- }
- }
-
- // Create an XML document describing various products.
- static XmlDocument^ LoadProducts()
- {
- XmlDocument^ xmlDoc = gcnew XmlDocument;
- String^ contosoProducts = L"";
- contosoProducts = String::Concat( contosoProducts,
- L"123");
- contosoProducts = String::Concat( contosoProducts,
- L"Router");
- contosoProducts = String::Concat( contosoProducts,
- L"456");
- contosoProducts = String::Concat( contosoProducts,
- L"Keyboard");
-
- // Include a comment to test the comments feature of the transform.
- contosoProducts = String::Concat( contosoProducts,
- L"" );
-
- // Include the CDATA tag to test the transform results.
- contosoProducts = String::Concat( contosoProducts,
- L"" );
- contosoProducts = String::Concat( contosoProducts,
- L"" );
-
- xmlDoc->LoadXml( contosoProducts );
- return xmlDoc;
- }
-
- // Create a signature and add it to the specified document.
- static void SignDocument( XmlDocument^ xmlDoc )
- {
- // Generate a signing key.
- RSA^ Key = RSA::Create();
-
- // Create a SignedXml object.
- SignedXml^ signedXml = gcnew SignedXml( xmlDoc );
-
- // Add the key to the SignedXml document.
- signedXml->SigningKey = Key;
-
- // Create a reference to be signed.
- Reference^ reference = gcnew Reference;
- reference->Uri = L"";
-
- // Add an enveloped transformation to the reference.
- reference->AddTransform( gcnew XmlDsigC14NTransform );
-
- // Add the reference to the SignedXml object.
- signedXml->AddReference( reference );
- try
- {
- // Create a new KeyInfo object.
- KeyInfo^ keyInfo = gcnew KeyInfo;
-
- // Load the X509 certificate.
- X509Certificate^ MSCert =
- X509Certificate::CreateFromCertFile( Certificate );
-
- // Load the certificate into a KeyInfoX509Data object
- // and add it to the KeyInfo object.
- keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) );
-
- // Add the KeyInfo object to the SignedXml object.
- signedXml->KeyInfo = keyInfo;
- }
- catch ( FileNotFoundException^ )
- {
- Console::WriteLine( L"Unable to locate the following file: {0}",
- Certificate );
- }
- catch ( CryptographicException^ ex )
- {
- Console::WriteLine( L"Unexpected exception caught while creating "
- L"the certificate:{0}", ex );
- }
-
- // Compute the signature.
- signedXml->ComputeSignature();
-
- // Add the signature branch to the original tree so it is enveloped.
- xmlDoc->DocumentElement->AppendChild( signedXml->GetXml() );
- }
-
- // Resolve the specified base and relative Uri's .
- static Uri^ ResolveUris( Uri^ baseUri, String^ relativeUri )
- {
- //
- XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver;
- xmlResolver->Credentials =
- System::Net::CredentialCache::DefaultCredentials;
- XmlDsigC14NTransform^ xmlTransform = gcnew XmlDsigC14NTransform;
- xmlTransform->Resolver = xmlResolver;
- //
-
- Uri^ absoluteUri = xmlResolver->ResolveUri( baseUri, relativeUri );
- if ( absoluteUri != nullptr )
- {
- Console::WriteLine(
- L"\nResolved the base Uri and relative Uri to the following:" );
- Console::WriteLine( absoluteUri );
- }
- else
- {
- Console::WriteLine( L"Unable to resolve the base Uri and relative Uri" );
- }
-
- return absoluteUri;
- }
-};
-
-int main()
-{
- Class1::Main();
-}
-
-//
-// This sample produces the following output:
-//
-// Xml representation of the current transform:
-//
-// Encoding the following xml: 123Rou
-// ter456Keyboard
-// Message encoded: 123Rou
-// ter456Keyboard'http:\\www.contoso.com\partner.asp?h1=en&h2=cr'
-// Xml representation of the current transform:
-//
-// Encoding the following xml: 123Rou
-// ter456Keyboard
-// BFN2s0/NA2NGgb/R0mvfnNM0Ito=
-// vSfZUG5xHuNxzOSEbQjN
-// dtEt1D+O7I1LTJ13RrwLaJSfQPrdT/s8IeaA+idw2f2WGuGrdqMJUddpE4GxfK61HmPQ6S7lBG+
-// +ND+YaUYf2AtTRs3SnToXQQrARa/pHVjsKxYHR/9tjy6maHBwxjgjFQABvYZu0gZHYRuXvvfxv0
-// 8=MIICCzCCAXSgAwIBAgIQ5eVQY8pRZ5xBF2WLkYPjijANBgkqhkiG
-// 9w0BAQQFADAbMRkwFwYDVQQDExBHcmVnc0NlcnRpZmljYXRlMB4XDTAzMDkxNzIzMzU0N1oXDTM
-// 5MTIzMTIzNTk1OVowGzEZMBcGA1UEAxMQR3JlZ3NDZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQ
-// EFAAOBjQAwgYkCgYEAmFJ4v7rS3BYTXgVW9PgBFfTYAcB/m9mOFCmUrrChcBpoEtu/tSESlNfEH
-// pECIdqg9vUrCNSkY08HRn3ueNeBSnSpssWd8/XoOboWLh1nd+79Y5uZd1WOJI4s0XM0MegZgCoJ
-// cEEhpxCd/HOPIQvEsbpN/DuFiovZLo+Ek3hHoxMCAwEAAaNQME4wTAYDVR0BBEUwQ4AQaCb19dl
-// yf/zSxPVYQZY9AKEdMBsxGTAXBgNVBAMTEEdyZWdzQ2VydGlmaWNhdGWCEOXlUGPKUWecQRdli5
-// GD44owDQYJKoZIhvcNAQEEBQADgYEAZuZaFDGDJogh7FuT0hfaMAVlRONv6wWVBJVV++eUo38Xu
-// RfJ5nNJ0UnhiV2sEtLobYBPEIrNhuk8skdU0AHgx4ILiA4rR96ifWwxtrFQF+h+DL2ZB7xhwcOJ
-// +Pa7IC4wIaEp/oBmmX+JHSzfQt6/If4ohwikfxfljKMyIcMlwl4=
-//
-// Message encoded: 123Router456Keyboard
'http:\\ww
-// w.contoso.com\partner.asp?h1=en&h2=cr'BFN2s0/NA2NGgb/R0mvfnNM0Ito=
-// vSfZUG5xHuNxzOSEbQjN
-// dtEt1D+O7I1LTJ13RrwLaJSfQPrdT/s8IeaA+idw2f2WGuGrdqMJUddpE4GxfK61HmPQ6S7lBG+
-// +ND+YaUYf2AtTRs3SnToXQQrARa/pHVjsKxYHR/9tjy6maHBwxjgjFQABvYZu0gZHYRuXvvfxv0
-// 8=MIICCzCCAXSgAwIBAgIQ5eVQY8pRZ5xBF2WLkYPjijANBgkqhkiG
-// 9w0BAQQFADAbMRkwFwYDVQQDExBHcmVnc0NlcnRpZmljYXRlMB4XDTAzMDkxNzIzMzU0N1oXDTM
-// 5MTIzMTIzNTk1OVowGzEZMBcGA1UEAxMQR3JlZ3NDZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQ
-// EFAAOBjQAwgYkCgYEAmFJ4v7rS3BYTXgVW9PgBFfTYAcB/m9mOFCmUrrChcBpoEtu/tSESlNfEH
-// pECIdqg9vUrCNSkY08HRn3ueNeBSnSpssWd8/XoOboWLh1nd+79Y5uZd1WOJI4s0XM0MegZgCoJ
-// cEEhpxCd/HOPIQvEsbpN/DuFiovZLo+Ek3hHoxMCAwEAAaNQME4wTAYDVR0BBEUwQ4AQaCb19dl
-// yf/zSxPVYQZY9AKEdMBsxGTAXBgNVBAMTEEdyZWdzQ2VydGlmaWNhdGWCEOXlUGPKUWecQRdli5
-// GD44owDQYJKoZIhvcNAQEEBQADgYEAZuZaFDGDJogh7FuT0hfaMAVlRONv6wWVBJVV++eUo38Xu
-// RfJ5nNJ0UnhiV2sEtLobYBPEIrNhuk8skdU0AHgx4ILiA4rR96ifWwxtrFQF+h+DL2ZB7xhwcOJ
-// +Pa7IC4wIaEp/oBmmX+JHSzfQt6/If4ohwikfxfljKMyIcMlwl4=
-//
-// Resolved the base Uri and relative Uri to the following:
-// http://www.contoso.com/xml
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp
deleted file mode 100644
index bf4107ed47b..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Security::Cryptography::X509Certificates;
-
-public ref class EnvelopedSignatureSample
-{
-private:
- static String^ Certificate = "..\\..\\my509.cer";
-
- // Encrypt the text in the specified XmlDocument.
-public:
- static void ShowTransformProperties(XmlDocument^ xmlDoc)
- {
- //
- XmlDsigEnvelopedSignatureTransform^ xmlTransform =
- gcnew XmlDsigEnvelopedSignatureTransform();
- //
-
- // Ensure the transform is using the proper algorithm.
- //
- xmlTransform->Algorithm =
- SignedXml::XmlDsigEnvelopedSignatureTransformUrl;
- //
-
- // Retrieve the XML representation of the current transform.
- //
- XmlElement^ xmlInTransform = xmlTransform->GetXml();
- //
-
- Console::WriteLine("\nXml representation of the current transform: ");
- Console::WriteLine(xmlInTransform->OuterXml);
-
- // Retrieve the valid input types for the current transform.
- //
- array^ validInTypes = xmlTransform->InputTypes;
- //
-
- // Verify the xmlTransform can accept the XMLDocument as an
- // input type.
- for (int i = 0; i < validInTypes->Length; i++)
- {
- if (validInTypes[i] == xmlDoc->GetType())
- {
- // Load the document into the transfrom.
- //
- xmlTransform->LoadInput(xmlDoc);
- //
-
- //
- bool IncludeComments = true;
- // This transform is created for demonstration purposes.
- XmlDsigEnvelopedSignatureTransform^ secondTransform =
- gcnew XmlDsigEnvelopedSignatureTransform(IncludeComments);
- //
-
- //
- String^ classDescription = secondTransform->ToString();
- //
-
- // This call does not perform as expected.
- //
- // An enveloped signature has no inner XML elements
- secondTransform->LoadInnerXml(xmlDoc->SelectNodes("//."));
- //
-
- break;
- }
- }
-
- //
- array^ validOutTypes = xmlTransform->OutputTypes;
- //
-
- for (int i = validOutTypes->Length-1; i >= 0; i--)
- {
- if (validOutTypes[i] == System::Xml::XmlDocument::typeid)
- {
- //
- Type^ xmlDocumentType = System::Xml::XmlDocument::typeid;
- XmlDocument^ xmlDocumentOutput = (XmlDocument^)
- xmlTransform->GetOutput(xmlDocumentType);
- //
-
- // Display to the console the Xml before and after
- // encryption.
- Console::WriteLine("Result of the GetOutput method call" +
- " from the current transform: " +
- xmlDocumentOutput->OuterXml);
-
- break;
- }
- else if (validOutTypes[i] == System::Xml::XmlNodeList::typeid)
- {
- Type^ xmlNodeListType = System::Xml::XmlNodeList::typeid;
- XmlNodeList^ xmlNodes = (XmlNodeList^)
- xmlTransform->GetOutput(xmlNodeListType);
-
- // Display to the console the Xml before and after
- // encryption.
- Console::WriteLine("Encoding the following message: " +
- xmlDoc->InnerText);
-
- Console::WriteLine("Nodes of the XmlNodeList retrieved " +
- "from GetOutput:");
- for (int j = 0; j < xmlNodes->Count; j++)
- {
- Console::WriteLine("Node " + j +
- " has the following name: " +
- xmlNodes->Item(j)->Name +
- " and the following InnerXml: " +
- xmlNodes->Item(j)->InnerXml);
- }
-
- break;
- }
- else
- {
- //
- Object^ outputObject = xmlTransform->GetOutput();
- //
- }
- }
- }
-
- // Create an XML document describing various products.
-public:
- static XmlDocument^ LoadProducts()
- {
- XmlDocument^ xmlDoc = gcnew XmlDocument();
-
- String^ contosoProducts = "" +
- "123Router" +
- "" +
- "456Keyboard" +
- "" +
- "789Monitor" +
- "" +
- "";
-
- xmlDoc->LoadXml(contosoProducts);
- return xmlDoc;
- }
-
- // Create a signature and add it to the specified document.
-public:
- static void SignDocument(XmlDocument^ xmlDoc)
- {
- // Generate a signing key.
- RSA^ key = RSA::Create();
-
- // Create a SignedXml object.
- SignedXml^ signedDocument = gcnew SignedXml(xmlDoc);
-
- // Add the key to the SignedXml document.
- signedDocument->SigningKey = key;
-
- // Create a reference to be signed.
- Reference^ referenceToBeSigned = gcnew Reference();
- referenceToBeSigned->Uri = "";
-
- // Add an enveloped transformation to the reference.
- referenceToBeSigned->AddTransform(
- gcnew XmlDsigEnvelopedSignatureTransform());
-
- // Add the reference to the SignedXml object.
- signedDocument->AddReference(referenceToBeSigned);
-
- if(File::Exists(Certificate))
- {
- // Create a new KeyInfo object.
- KeyInfo^ info = gcnew KeyInfo();
-
- // Load the X509 certificate.
- X509Certificate^ certFromFile =
- X509Certificate::CreateFromCertFile(Certificate);
-
- // Load the certificate into a KeyInfoX509Data object
- // and add it to the KeyInfo object.
- info->AddClause(gcnew KeyInfoX509Data(certFromFile));
-
- // Add the KeyInfo object to the SignedXml object.
- signedDocument->KeyInfo = info;
- }
- else
- {
- Console::WriteLine("Unable to locate the following file: " +
- Certificate);
- }
-
- // Compute the signature.
- signedDocument->ComputeSignature();
-
- // Add the signature branch to the original tree so it is enveloped.
- xmlDoc->DocumentElement->AppendChild(signedDocument->GetXml());
- }
-
- // Resolve the specified base and relative Uri's .
-public:
- static Uri^ ResolveUris(Uri^ baseUri, String^ relativeUri)
- {
- //
- XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver();
- xmlResolver->Credentials =
- System::Net::CredentialCache::DefaultCredentials;
-
- XmlDsigEnvelopedSignatureTransform^ xmlTransform =
- gcnew XmlDsigEnvelopedSignatureTransform();
- xmlTransform->Resolver = xmlResolver;
- //
-
- Uri^ absoluteUri = xmlResolver->ResolveUri(baseUri, relativeUri);
-
- if (absoluteUri != nullptr)
- {
- Console::WriteLine(
- "\nResolved the base Uri and relative Uri to the following:");
- Console::WriteLine(absoluteUri->ToString());
- }
- else
- {
- Console::WriteLine(
- "Unable to resolve the base Uri and relative Uri");
- }
- return absoluteUri;
- }
-};
-
-[STAThread]
-int main()
-{
- // Encrypt an XML message
- XmlDocument^ productsXml = EnvelopedSignatureSample::LoadProducts();
- EnvelopedSignatureSample::ShowTransformProperties(productsXml);
-
- EnvelopedSignatureSample::SignDocument(productsXml);
- EnvelopedSignatureSample::ShowTransformProperties(productsXml);
-
- // Use XmlDsigEnvelopedSignatureTransform to resolve a Uri.
- Uri^ baseUri = gcnew Uri("http://www.contoso.com");
- String^ relativeUri = "xml";
- Uri^ absoluteUri =
- EnvelopedSignatureSample::ResolveUris(baseUri, relativeUri);
-
- Console::WriteLine("This sample completed successfully; " +
- "press Enter to exit.");
- Console::ReadLine();
-}
-
-//
-// This sample produces the following output:
-//
-// Xml representation of the current transform:
-//
-// Result of the GetOutput method call from the current transform:
-// 123Router
-// 456Keyboard789
-// Monitor
-// Unable to load the following file: ..\\my509.cer
-//
-// Xml representation of the current transform:
-//
-// Result of the GetOutput method call from the current transform:
-// 123Router
-// 456Keyboard789
-// Monitor
-//
-// KvPW6HUiIUMEDS0YSoT
-// gpo2JPbA=c/njCGDru/a
-// WAmWG83I+mWO040xOzxvmNx0b0o8ZyPc9j5VwApdAt103OGBtB1H6EkOvt7Ekw+PVuUo8m5LzLP
-// yaTxUDMbb2kZZ5itSkGD4rmMUMUMuzrkAoquJZjxeOydBJ2CMehV2rE3RMPLIwRX176DZVy5JKU
-// 6Cb7PR2Rpw=
-//
-// Resolved the base Uri and relative Uri to the following:
-// http://www.contoso.com/xml
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp
deleted file mode 100644
index 5a53f0d8e0a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-//
-#using
-#using
-#using
-using namespace System;
-using namespace System::IO;
-using namespace System::Xml;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::Xml;
-using namespace System::Text;
-
-ref class Class1
-{
-public:
- [STAThread]
- static void Main()
- {
- XmlDocument^ productsXml = LoadProducts();
- XmlNodeList^ xsltNodeList = GetXsltAsNodeList();
- TransformDoc( productsXml, xsltNodeList );
-
- // Use XmlDsigXsltTransform to resolve a Uri.
- Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" );
- String^ relativeUri = L"xml";
- Uri^ absoluteUri = ResolveUris( baseUri, relativeUri );
- Console::WriteLine( L"This sample completed successfully; "
- L"press Enter to exit." );
- Console::ReadLine();
- }
-
-private:
- static void TransformDoc( XmlDocument^ xmlDoc, XmlNodeList^ xsltNodeList )
- {
- try
- {
- // Construct a new XmlDsigXsltTransform.
- //
- XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform;
- //
-
- // Load the Xslt tranform as a node list.
- //
- xmlTransform->LoadInnerXml( xsltNodeList );
- //
-
- // Load the Xml document to perform the tranform on.
- //
- XmlNamespaceManager^ namespaceManager;
- namespaceManager = gcnew XmlNamespaceManager( xmlDoc->NameTable );
- XmlNodeList^ productsNodeList;
- productsNodeList = xmlDoc->SelectNodes( L"//.", namespaceManager );
- xmlTransform->LoadInput( productsNodeList );
- //
-
- // Retrieve the output from the transform.
- //
- Stream^ outputStream = (Stream^)xmlTransform->GetOutput(
- System::IO::Stream::typeid );
- //
-
- // Read the output stream into a stream reader.
- StreamReader^ streamReader = gcnew StreamReader( outputStream );
-
- // Read the stream into a string.
- String^ outputMessage = streamReader->ReadToEnd();
-
- // Close the streams.
- outputStream->Close();
- streamReader->Close();
-
- // Display to the console the Xml before and after
- // encryption.
- Console::WriteLine( L"\nResult of transformation: {0}", outputMessage );
- ShowTransformProperties( xmlTransform );
- }
- catch ( Exception^ ex )
- {
- Console::WriteLine( L"Caught exception in TransformDoc method: {0}", ex );
- }
- }
-
- static XmlNodeList^ GetXsltAsNodeList()
- {
- String^ transformXml = L"" );
- transformXml = String::Concat( transformXml,
- L"" );
- transformXml = String::Concat( transformXml,
- L"