diff --git a/includes/remarks/System.IO.Compression/CompressionLevel/CompressionLevel.md b/includes/remarks/System.IO.Compression/CompressionLevel/CompressionLevel.md index 9462976b916..c9318b19777 100644 --- a/includes/remarks/System.IO.Compression/CompressionLevel/CompressionLevel.md +++ b/includes/remarks/System.IO.Compression/CompressionLevel/CompressionLevel.md @@ -3,17 +3,11 @@ Compression operations usually involve a tradeoff between the speed and the effe The following methods of the , , , , and classes include a parameter named `compressionLevel` that lets you specify the compression level: - - - - - - - - - - - - - ## Examples @@ -21,4 +15,4 @@ The following methods of the , class. :::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program3.cs" id="Snippet3"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb" id="Snippet3"::: +:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program3.vb" id="Snippet3"::: diff --git a/includes/remarks/System.IO.Compression/ZipArchive/.ctor_Stream_ZipArchiveMode_Boolean_Encoding.md b/includes/remarks/System.IO.Compression/ZipArchive/.ctor_Stream_ZipArchiveMode_Boolean_Encoding.md index c2769c4f11b..8be8dea016d 100644 --- a/includes/remarks/System.IO.Compression/ZipArchive/.ctor_Stream_ZipArchiveMode_Boolean_Encoding.md +++ b/includes/remarks/System.IO.Compression/ZipArchive/.ctor_Stream_ZipArchiveMode_Boolean_Encoding.md @@ -2,20 +2,17 @@ If the `mode` parameter is set to class. It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder. :::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program1.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program1.vb" id="Snippet1"::: +:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program1.vb" id="Snippet1"::: diff --git a/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp deleted file mode 100644 index aa305292301..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::AccessControl; - -// Adds an ACL entry on the specified directory for the -// specified account. -void AddDirectorySecurity(String^ directoryName, String^ account, - FileSystemRights rights, AccessControlType controlType) -{ - // Create a new DirectoryInfo object. - DirectoryInfo^ dInfo = gcnew DirectoryInfo(directoryName); - - // Get a DirectorySecurity object that represents the - // current security settings. - DirectorySecurity^ dSecurity = dInfo->GetAccessControl(); - - // Add the FileSystemAccessRule to the security settings. - dSecurity->AddAccessRule( gcnew FileSystemAccessRule(account, - rights, controlType)); - - // Set the new access settings. - dInfo->SetAccessControl(dSecurity); -} - -// Removes an ACL entry on the specified directory for the -// specified account. -void RemoveDirectorySecurity(String^ directoryName, String^ account, - FileSystemRights rights, AccessControlType controlType) -{ - // Create a new DirectoryInfo object. - DirectoryInfo^ dInfo = gcnew DirectoryInfo(directoryName); - - // Get a DirectorySecurity object that represents the - // current security settings. - DirectorySecurity^ dSecurity = dInfo->GetAccessControl(); - - // Add the FileSystemAccessRule to the security settings. - dSecurity->RemoveAccessRule(gcnew FileSystemAccessRule(account, - rights, controlType)); - - // Set the new access settings. - dInfo->SetAccessControl(dSecurity); -} - -int main() -{ - String^ directoryName = "TestDirectory"; - String^ accountName = "MYDOMAIN\\MyAccount"; - if (!Directory::Exists(directoryName)) - { - Console::WriteLine("The directory {0} could not be found.", - directoryName); - return 0; - } - try - { - Console::WriteLine("Adding access control entry for {0}", - directoryName); - - // Add the access control entry to the directory. - AddDirectorySecurity(directoryName, accountName, - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Removing access control entry from {0}", - directoryName); - - // Remove the access control entry from the directory. - RemoveDirectorySecurity(directoryName, accountName, - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Done."); - } - catch (UnauthorizedAccessException^) - { - Console::WriteLine("You are not authorised to carry" + - " out this procedure."); - } - catch (System::Security::Principal:: - IdentityNotMappedException^) - { - Console::WriteLine("The account {0} could not be found.", accountName); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp deleted file mode 100644 index d74a7ca473d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// System::Reflection::Emit::ModuleBuilder.DefineDocument -/* -The following example demonstrates the 'DefineDocument' method -of 'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. -It gets the Object* representing the defined document using the method -'DefineDocument'. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; -using namespace System::Diagnostics::SymbolStore; -public ref class CodeGenerator -{ -private: - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - CodeGenerator() - { - - // Get the current application domain for the current thread. - AppDomain^ currentDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define a dynamic assembly in the current domain. - myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Define a dynamic module in S"TempAssembly" assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule", "Resource.mod", true ); - - // Define a document for source.on 'TempModule' module. - ISymbolDocumentWriter^ myDocument = myModuleBuilder->DefineDocument( "RTAsm.il", SymDocumentType::Text, SymLanguageType::ILAssembly, SymLanguageVendor::Microsoft ); - Console::WriteLine( "The object representing the defined document is: {0}", myDocument ); - } - -}; - -int main() -{ - CodeGenerator^ myGenerator = gcnew CodeGenerator; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp deleted file mode 100644 index bf3e8e72213..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UnmanagedMarshalObsolete/cpp/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::InteropServices; - -void main() -{ - AppDomain^ myDomain = AppDomain::CurrentDomain; - AssemblyName^ myAsmName = gcnew AssemblyName("EmitMarshalAs"); - - AssemblyBuilder^ myAssembly = - myDomain->DefineDynamicAssembly(myAsmName, - AssemblyBuilderAccess::RunAndSave); - - ModuleBuilder^ myModule = - myAssembly->DefineDynamicModule(myAsmName->Name, - myAsmName->Name + ".dll"); - - TypeBuilder^ myType = - myModule->DefineType("Sample", TypeAttributes::Public); - - MethodBuilder^ myMethod = - myType->DefineMethod("Test", MethodAttributes::Public, - nullptr, gcnew array { String::typeid }); - - - // Get a parameter builder for the parameter that needs the - // attribute, using the HasFieldMarshal attribute. In this - // example, the parameter is at position 0 and has the name - // "arg". - ParameterBuilder^ pb = - myMethod->DefineParameter(0, - ParameterAttributes::HasFieldMarshal, "arg"); - - // Get the MarshalAsAttribute constructor that takes an - // argument of type UnmanagedType. - // - //Type^ maattrType = MarshalAsAttribute::typeid; - ConstructorInfo^ ci = - (MarshalAsAttribute::typeid)->GetConstructor( - gcnew array { UnmanagedType::typeid }); - - // Create a CustomAttributeBuilder representing the attribute, - // specifying the necessary unmanaged type. In this case, - // UnmanagedType.BStr is specified. - // - CustomAttributeBuilder^ cabuilder = - gcnew CustomAttributeBuilder( - ci, gcnew array { UnmanagedType::BStr }); - - // Apply the attribute to the parameter. - // - pb->SetCustomAttribute(cabuilder); - - - ILGenerator^ il = myMethod->GetILGenerator(); - il->Emit(OpCodes::Ret); - - Type^ finished = myType->CreateType(); - myAssembly->Save(myAsmName->Name + ".dll"); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp deleted file mode 100644 index 79226085d31..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: Form -{ -protected: - TextBox^ textBox1; - // - void GetComments() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - // Print the comments in a text box. - textBox1->Text = "Comments: " + myFileVersionInfo->Comments; - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp deleted file mode 100644 index 49678c8cdc2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "Hello" ); - myAL->Add( "World" ); - myAL->Add( "!" ); - - // Displays the properties and values of the ArrayList. - Console::WriteLine( "myAL" ); - Console::WriteLine( " Count: {0}", myAL->Count ); - Console::WriteLine( " Capacity: {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* -This code produces output similar to the following: - -myAL - Count: 3 - Capacity: 4 - Values: Hello World ! - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp deleted file mode 100644 index 2755de2cbe1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, char mySeparator ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - - // Creates and initializes a new Queue. - Queue^ myQueue = gcnew Queue; - myQueue->Enqueue( "jumps" ); - myQueue->Enqueue( "over" ); - myQueue->Enqueue( "the" ); - myQueue->Enqueue( "lazy" ); - myQueue->Enqueue( "dog" ); - - // Displays the ArrayList and the Queue. - Console::WriteLine( "The ArrayList initially contains the following:" ); - PrintValues( myAL, '\t' ); - Console::WriteLine( "The Queue initially contains the following:" ); - PrintValues( myQueue, '\t' ); - - // Copies the Queue elements to the end of the ArrayList. - myAL->AddRange( myQueue ); - - // Displays the ArrayList. - Console::WriteLine( "The ArrayList now contains the following:" ); - PrintValues( myAL, '\t' ); -} - -void PrintValues( IEnumerable^ myList, char mySeparator ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -The ArrayList initially contains the following: - The quick brown fox -The Queue initially contains the following: - jumps over the lazy dog -The ArrayList now contains the following: - The quick brown fox jumps over the lazy dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp deleted file mode 100644 index f7052b8c414..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void FindMyObject( ArrayList^ myList, Object^ myObject ); -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. BinarySearch requires - // a sorted ArrayList. - ArrayList^ myAL = gcnew ArrayList; - for ( int i = 0; i <= 4; i++ ) - myAL->Add( i * 2 ); - - // Displays the ArrayList. - Console::WriteLine( "The Int32 ArrayList contains the following:" ); - PrintValues( myAL ); - - // Locates a specific object that does not exist in the ArrayList. - Object^ myObjectOdd = 3; - FindMyObject( myAL, myObjectOdd ); - - // Locates an object that exists in the ArrayList. - Object^ myObjectEven = 6; - FindMyObject( myAL, myObjectEven ); -} - -void FindMyObject( ArrayList^ myList, Object^ myObject ) -{ - int myIndex = myList->BinarySearch( myObject ); - if ( myIndex < 0 ) - Console::WriteLine( "The object to search for ({0}) is not found. The next larger object is at index {1}.", myObject, ~myIndex ); - else - Console::WriteLine( "The object to search for ({0}) is at index {1}.", myObject, myIndex ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Int32 ArrayList contains the following: - 0 2 4 6 8 - The object to search for (3) is not found. The next larger object is at index 2. - The object to search for (6) is at index 3. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp deleted file mode 100644 index cd02a23fd6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public ref class SimpleStringComparer : public IComparer -{ - virtual int Compare(Object^ x, Object^ y) sealed = IComparer::Compare - { - String^ cmpstr = (String^)x; - return cmpstr->CompareTo((String^)y); - } -}; - -public ref class MyArrayList : public ArrayList -{ -public: - static void Main() - { - // Creates and initializes a new ArrayList. - MyArrayList^ coloredAnimals = gcnew MyArrayList(); - - coloredAnimals->Add("White Tiger"); - coloredAnimals->Add("Pink Bunny"); - coloredAnimals->Add("Red Dragon"); - coloredAnimals->Add("Green Frog"); - coloredAnimals->Add("Blue Whale"); - coloredAnimals->Add("Black Cat"); - coloredAnimals->Add("Yellow Lion"); - - // BinarySearch requires a sorted ArrayList. - coloredAnimals->Sort(); - - // Compare results of an iterative search with a binary search - int index = coloredAnimals->IterativeSearch("White Tiger"); - Console::WriteLine("Iterative search, item found at index: {0}", index); - - index = coloredAnimals->BinarySearch("White Tiger", gcnew SimpleStringComparer()); - Console::WriteLine("Binary search, item found at index: {0}", index); - } - - int IterativeSearch(Object^ finditem) - { - int index = -1; - - for (int i = 0; i < this->Count; i++) - { - if (finditem->Equals(this[i])) - { - index = i; - break; - } - } - return index; - } -}; - -int main() -{ - MyArrayList::Main(); -} -// -// This code produces the following output. -// -// Iterative search, item found at index: 5 -// Binary search, item found at index: 5 -// -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp deleted file mode 100644 index ecce0f77c76..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Trim the ArrayList. - myAL->TrimToSize(); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "After TrimToSize," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Clear the ArrayList. - myAL->Clear(); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Trim the ArrayList again. - myAL->TrimToSize(); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "After the second TrimToSize," ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Capacity : 16 - Values: The quick brown fox jumps - After TrimToSize, - Count : 5 - Capacity : 5 - Values: The quick brown fox jumps - After Clear, - Count : 0 - Capacity : 5 - Values: - After the second TrimToSize, - Count : 0 - Capacity : 16 - Values: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 350784fe0ae..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^myArr, char mySeparator ); -int main() -{ - - // Creates and initializes the source ArrayList. - ArrayList^ mySourceList = gcnew ArrayList; - mySourceList->Add( "three" ); - mySourceList->Add( "napping" ); - mySourceList->Add( "cats" ); - mySourceList->Add( "in" ); - mySourceList->Add( "the" ); - mySourceList->Add( "barn" ); - - // Creates and initializes the one-dimensional target Array. - array^myTargetArray = gcnew array(15); - myTargetArray[ 0 ] = "The"; - myTargetArray[ 1 ] = "quick"; - myTargetArray[ 2 ] = "brown"; - myTargetArray[ 3 ] = "fox"; - myTargetArray[ 4 ] = "jumps"; - myTargetArray[ 5 ] = "over"; - myTargetArray[ 6 ] = "the"; - myTargetArray[ 7 ] = "lazy"; - myTargetArray[ 8 ] = "dog"; - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the second element from the source ArrayList to the target ArrayList starting at index 7. - mySourceList->CopyTo( 1, myTargetArray, 7, 1 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target ArrayList starting at index 6. - mySourceList->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target ArrayList starting at index 0. - mySourceList->CopyTo( myTargetArray ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^myArr, char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ] ); - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over the napping dog - The quick brown fox jumps over three napping cats in the barn - three napping cats in the barn three napping cats in the barn - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp deleted file mode 100644 index de10c82aaf7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^myArr, char mySeparator ); -int main() -{ - - // Creates and initializes the source ArrayList. - ArrayList^ mySourceList = gcnew ArrayList; - mySourceList->Add( "three" ); - mySourceList->Add( "napping" ); - mySourceList->Add( "cats" ); - mySourceList->Add( "in" ); - mySourceList->Add( "the" ); - mySourceList->Add( "barn" ); - - // Creates and initializes the one-dimensional target Array. - array^myTargetArray = gcnew array(15); - myTargetArray[ 0 ] = "The"; - myTargetArray[ 1 ] = "quick"; - myTargetArray[ 2 ] = "brown"; - myTargetArray[ 3 ] = "fox"; - myTargetArray[ 4 ] = "jumps"; - myTargetArray[ 5 ] = "over"; - myTargetArray[ 6 ] = "the"; - myTargetArray[ 7 ] = "lazy"; - myTargetArray[ 8 ] = "dog"; - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the second element from the source ArrayList to the target Array, starting at index 7. - mySourceList->CopyTo( 1, myTargetArray, 7, 1 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target Array, starting at index 6. - mySourceList->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source ArrayList to the target Array, starting at index 0. - mySourceList->CopyTo( myTargetArray ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^myArr, char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ] ); - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over the napping dog - The quick brown fox jumps over three napping cats in the barn - three napping cats in the barn three napping cats in the barn - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp deleted file mode 100644 index 2d45857cac0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList with three elements of the same value. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "the" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - myAL->Add( "in" ); - myAL->Add( "the" ); - myAL->Add( "barn" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Search for the first occurrence of the duplicated value. - String^ myString = "the"; - int myIndex = myAL->IndexOf( myString ); - Console::WriteLine( "The first occurrence of \"{0}\" is at index {1}.", myString, myIndex ); - - // Search for the first occurrence of the duplicated value in the last section of the ArrayList. - myIndex = myAL->IndexOf( myString, 4 ); - Console::WriteLine( "The first occurrence of \"{0}\" between index 4 and the end is at index {1}.", myString, myIndex ); - - // Search for the first occurrence of the duplicated value in a section of the ArrayList. - myIndex = myAL->IndexOf( myString, 6, 6 ); - Console::WriteLine( "The first occurrence of \"{0}\" between index 6 and index 11 is at index {1}.", myString, myIndex ); -} - -void PrintIndexAndValues( IEnumerable^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " [{0}]: {1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList contains the following values: - [0]: the - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - [9]: in - [10]: the - [11]: barn - - The first occurrence of "the" is at index 0. - The first occurrence of "the" between index 4 and the end is at index 6. - The first occurrence of "the" between index 6 and index 11 is at index 6. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp deleted file mode 100644 index f29a6c01426..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList using Insert instead of Add. - ArrayList^ myAL = gcnew ArrayList; - myAL->Insert( 0, "The" ); - myAL->Insert( 1, "fox" ); - myAL->Insert( 2, "jumps" ); - myAL->Insert( 3, "over" ); - myAL->Insert( 4, "the" ); - myAL->Insert( 5, "dog" ); - - // Creates and initializes a new Queue. - Queue^ myQueue = gcnew Queue; - myQueue->Enqueue( "quick" ); - myQueue->Enqueue( "brown" ); - - // Displays the ArrayList and the Queue. - Console::WriteLine( "The ArrayList initially contains the following:" ); - PrintValues( myAL ); - Console::WriteLine( "The Queue initially contains the following:" ); - PrintValues( myQueue ); - - // Copies the Queue elements to the ArrayList at index 1. - myAL->InsertRange( 1, myQueue ); - - // Displays the ArrayList. - Console::WriteLine( "After adding the Queue, the ArrayList now contains:" ); - PrintValues( myAL ); - - // Search for "dog" and add "lazy" before it. - myAL->Insert( myAL->IndexOf( "dog" ), "lazy" ); - - // Displays the ArrayList. - Console::WriteLine( "After adding \"lazy\", the ArrayList now contains:" ); - PrintValues( myAL ); - - // Add "!!!" at the end. - myAL->Insert( myAL->Count, "!!!" ); - - // Displays the ArrayList. - Console::WriteLine( "After adding \"!!!\", the ArrayList now contains:" ); - PrintValues( myAL ); - - // Inserting an element beyond Count throws an exception. - try - { - myAL->Insert( myAL->Count + 1, "anystring" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following: - The fox jumps over the dog - The Queue initially contains the following: - quick brown - After adding the Queue, the ArrayList now contains: - The quick brown fox jumps over the dog - After adding "lazy", the ArrayList now contains: - The quick brown fox jumps over the lazy dog - After adding "!!!", the ArrayList now contains: - The quick brown fox jumps over the lazy dog !!! - Exception: System.ArgumentOutOfRangeException: Insertion index was out of range. Must be non-negative and less than or equal to size. - Parameter name: index - at System.Collections.ArrayList.Insert(Int32 index, Object value) - at SamplesArrayList.Main() - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp deleted file mode 100644 index e5271eb3ea7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp +++ /dev/null @@ -1,127 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, char mySeparator ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Create a fixed-size wrapper around the ArrayList. - ArrayList^ myFixedSizeAL = ArrayList::FixedSize( myAL ); - - // Display whether the ArrayLists have a fixed size or not. - Console::WriteLine( "myAL {0}.", myAL->IsFixedSize ? (String^)"has a fixed size" : "does not have a fixed size" ); - Console::WriteLine( "myFixedSizeAL {0}.", myFixedSizeAL->IsFixedSize ? (String^)"has a fixed size" : "does not have a fixed size" ); - Console::WriteLine(); - - // Display both ArrayLists. - Console::WriteLine( "Initially," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - - // Sort is allowed in the fixed-size ArrayList. - myFixedSizeAL->Sort(); - - // Display both ArrayLists. - Console::WriteLine( "After Sort," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - - // Reverse is allowed in the fixed-size ArrayList. - myFixedSizeAL->Reverse(); - - // Display both ArrayLists. - Console::WriteLine( "After Reverse," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - - // Add an element to the standard ArrayList. - myAL->Add( "AddMe" ); - - // Display both ArrayLists. - Console::WriteLine( "After adding to the standard ArrayList," ); - Console::Write( "Standard :" ); - PrintValues( myAL, ' ' ); - Console::Write( "Fixed size:" ); - PrintValues( myFixedSizeAL, ' ' ); - Console::WriteLine(); - - // Adding or inserting elements to the fixed-size ArrayList throws an exception. - try - { - myFixedSizeAL->Add( "AddMe2" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - - try - { - myFixedSizeAL->Insert( 3, "InsertMe" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, char mySeparator ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myAL does not have a fixed size. - myFixedSizeAL has a fixed size. - - Initially, - Standard : The quick brown fox jumps over the lazy dog - Fixed size: The quick brown fox jumps over the lazy dog - After Sort, - Standard : brown dog fox jumps lazy over quick the The - Fixed size: brown dog fox jumps lazy over quick the The - After Reverse, - Standard : The the quick over lazy jumps fox dog brown - Fixed size: The the quick over lazy jumps fox dog brown - After adding to the standard ArrayList, - Standard : The the quick over lazy jumps fox dog brown AddMe - Fixed size: The the quick over lazy jumps fox dog brown AddMe - - Exception: System.NotSupportedException: Collection was of a fixed size. - at System.Collections.FixedSizeArrayList.Add(Object obj) - at SamplesArrayList.Main() - Exception: System.NotSupportedException: Collection was of a fixed size. - at System.Collections.FixedSizeArrayList.Insert(Int32 index, Object obj) - at SamplesArrayList.Main() - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 83e78208a4d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new ArrayList instance. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - - // Creates a synchronized wrapper around the ArrayList. - ArrayList^ mySyncdAL = ArrayList::Synchronized( myAL ); - - // Displays the sychronization status of both ArrayLists. - String^ szRes = myAL->IsSynchronized ? (String^)"synchronized" : "not synchronized"; - Console::WriteLine( "myAL is {0}.", szRes ); - String^ szSyncRes = mySyncdAL->IsSynchronized ? (String^)"synchronized" : "not synchronized"; - Console::WriteLine( "mySyncdAL is {0}.", szSyncRes ); -} - -/* - This code produces the following output. - - myAL is not synchronized. - mySyncdAL is synchronized. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index 7180bf8a5e0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesArrayList -{ -public: - static void Main() - { - // - ArrayList^ myCollection = gcnew ArrayList(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesArrayList::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp deleted file mode 100644 index 29c9798e23c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList with three elements of the same value. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "the" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - myAL->Add( "in" ); - myAL->Add( "the" ); - myAL->Add( "barn" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Searches for the last occurrence of the duplicated value. - String^ myString = "the"; - int myIndex = myAL->LastIndexOf( myString ); - Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in the first section of the ArrayList. - myIndex = myAL->LastIndexOf( myString, 8 ); - Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward. - myIndex = myAL->LastIndexOf( myString, 10, 6 ); - Console::WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex ); -} - -void PrintIndexAndValues( IEnumerable^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " [{0}]: {1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList contains the following values: - [0]: the - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - [9]: in - [10]: the - [11]: barn - - The last occurrence of "the" is at index 10. - The last occurrence of "the" between the start and index 8 is at index 6. - The last occurrence of "the" between index 10 and index 5 is at index 10. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp deleted file mode 100644 index 874f42b2001..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "red" ); - myAL->Add( "orange" ); - myAL->Add( "yellow" ); - - // Creates a read-only copy of the ArrayList. - ArrayList^ myReadOnlyAL = ArrayList::ReadOnly( myAL ); - - // Displays whether the ArrayList is read-only or writable. - Console::WriteLine( "myAL is {0}.", myAL->IsReadOnly ? (String^)"read-only" : "writable" ); - Console::WriteLine( "myReadOnlyAL is {0}.", myReadOnlyAL->IsReadOnly ? (String^)"read-only" : "writable" ); - - // Displays the contents of both collections. - Console::WriteLine( "\nInitially," ); - Console::WriteLine( "The original ArrayList myAL contains:" ); - for ( int i(0); i < myAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myAL[ i ]) ); - Console::WriteLine( "The read-only ArrayList myReadOnlyAL contains:" ); - for ( int i(0); i < myReadOnlyAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myReadOnlyAL[ i ]) ); - - // Adding an element to a read-only ArrayList throws an exception. - Console::WriteLine( "\nTrying to add a new element to the read-only ArrayList:" ); - try - { - myReadOnlyAL->Add( "green" ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( String::Concat( "Exception: ", myException->ToString() ) ); - } - - - // Adding an element to the original ArrayList affects the read-only ArrayList. - myAL->Add( "blue" ); - - // Displays the contents of both collections again. - Console::WriteLine( "\nAfter adding a new element to the original ArrayList," ); - Console::WriteLine( "The original ArrayList myAL contains:" ); - for ( int i(0); i < myAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myAL[ i ]) ); - Console::WriteLine( "The read-only ArrayList myReadOnlyAL contains:" ); - for ( int i(0); i < myReadOnlyAL->Count; ++i ) - Console::WriteLine( " {0}", static_cast(myReadOnlyAL[ i ]) ); -} - -/* -This code produces the following output. - -myAL is writable. -myReadOnlyAL is read-only. - -Initially, -The original ArrayList myAL contains: - red - orange - yellow -The read-only ArrayList myReadOnlyAL contains: - red - orange - yellow - -Trying to add a new element to the read-only ArrayList: -Exception: System.NotSupportedException: Collection is read-only. - at System.Collections.ReadOnlyArrayList.Add(Object obj) - at SamplesArrayList.Main() - -After adding a new element to the original ArrayList, -The original ArrayList myAL contains: - red - orange - yellow - blue -The read-only ArrayList myReadOnlyAL contains: - red - orange - yellow - blue - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp deleted file mode 100644 index 4b53513ceb4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following:" ); - PrintValues( myAL ); - - // Removes the element containing "lazy". - myAL->Remove( "lazy" ); - - // Displays the current state of the ArrayList. - Console::WriteLine( "After removing \"lazy\":" ); - PrintValues( myAL ); - - // Removes the element at index 5. - myAL->RemoveAt( 5 ); - - // Displays the current state of the ArrayList. - Console::WriteLine( "After removing the element at index 5:" ); - PrintValues( myAL ); - - // Removes three elements starting at index 4. - myAL->RemoveRange( 4, 3 ); - - // Displays the current state of the ArrayList. - Console::WriteLine( "After removing three elements starting at index 4:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following: - The quick brown fox jumps over the lazy dog - After removing "lazy": - The quick brown fox jumps over the dog - After removing the element at index 5: - The quick brown fox jumps the dog - After removing three elements starting at index 4: - The quick brown fox - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp deleted file mode 100644 index 0de76e16267..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates a new ArrayList with five elements and initialize each element with a null value. - ArrayList^ myAL = ArrayList::Repeat( 0, 5 ); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "ArrayList with five elements with a null value" ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); - - // Creates a new ArrayList with seven elements and initialize each element with the string "abc". - myAL = ArrayList::Repeat( "abc", 7 ); - - // Displays the count, capacity and values of the ArrayList. - Console::WriteLine( "ArrayList with seven elements with a string value" ); - Console::WriteLine( " Count : {0}", myAL->Count ); - Console::WriteLine( " Capacity : {0}", myAL->Capacity ); - Console::Write( " Values:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - ArrayList with five elements with a null value - Count : 5 - Capacity : 16 - Values: - ArrayList with seven elements with a string value - Count : 7 - Capacity : 16 - Values: abc abc abc abc abc abc abc - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp deleted file mode 100644 index 0fed55d8877..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintValues( myAL ); - - // Reverses the sort order of the values of the ArrayList. - myAL->Reverse(); - - // Displays the values of the ArrayList. - Console::WriteLine( "After reversing:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following values: - The - quick - brown - fox - jumps - over - the - lazy - dog - - After reversing: - dog - lazy - the - over - jumps - fox - brown - quick - The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp deleted file mode 100644 index 94b787234f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "QUICK" ); - myAL->Add( "BROWN" ); - myAL->Add( "FOX" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintValues( myAL ); - - // Reverses the sort order of the values of the ArrayList. - myAL->Reverse( 1, 3 ); - - // Displays the values of the ArrayList. - Console::WriteLine( "After reversing:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following values: - The - QUICK - BROWN - FOX - jumps - over - the - lazy - dog - - After reversing: - The - FOX - BROWN - QUICK - jumps - over - the - lazy - dog - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp deleted file mode 100644 index 87913eb48c0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, char mySeparator ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Creates and initializes the source ICollection. - Queue^ mySourceList = gcnew Queue; - mySourceList->Enqueue( "big" ); - mySourceList->Enqueue( "gray" ); - mySourceList->Enqueue( "wolf" ); - - // Displays the values of five elements starting at index 0. - ArrayList^ mySubAL = myAL->GetRange( 0, 5 ); - Console::WriteLine( "Index 0 through 4 contains:" ); - PrintValues( mySubAL, '\t' ); - - // Replaces the values of five elements starting at index 1 with the values in the ICollection. - myAL->SetRange( 1, mySourceList ); - - // Displays the values of five elements starting at index 0. - mySubAL = myAL->GetRange( 0, 5 ); - Console::WriteLine( "Index 0 through 4 now contains:" ); - PrintValues( mySubAL, '\t' ); -} - -void PrintValues( IEnumerable^ myList, char mySeparator ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Index 0 through 4 contains: - The quick brown fox jumps - Index 0 through 4 now contains: - The big gray wolf jumps - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp deleted file mode 100644 index 0b0876c0b0f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList ); -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintValues( myAL ); - - // Sorts the values of the ArrayList. - myAL->Sort(); - - // Displays the values of the ArrayList. - Console::WriteLine( "After sorting:" ); - PrintValues( myAL ); -} - -void PrintValues( IEnumerable^ myList ) -{ - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The ArrayList initially contains the following values: - The - quick - brown - fox - jumps - over - the - lazy - dog - - After sorting: - brown - dog - fox - jumps - lazy - over - quick - the - The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp deleted file mode 100644 index d0f81ed9be8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp +++ /dev/null @@ -1,119 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes several BitArrays. - BitArray^ myBA1 = gcnew BitArray( 5 ); - BitArray^ myBA2 = gcnew BitArray( 5,false ); - array^myBytes = {1,2,3,4,5}; - BitArray^ myBA3 = gcnew BitArray( myBytes ); - array^myBools = {true,false,true,true,false}; - BitArray^ myBA4 = gcnew BitArray( myBools ); - array^myInts = {6,7,8,9,10}; - BitArray^ myBA5 = gcnew BitArray( myInts ); - - // Displays the properties and values of the BitArrays. - Console::WriteLine( "myBA1" ); - Console::WriteLine( " Count: {0}", myBA1->Count ); - Console::WriteLine( " Length: {0}", myBA1->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA1, 8 ); - Console::WriteLine( "myBA2" ); - Console::WriteLine( " Count: {0}", myBA2->Count ); - Console::WriteLine( " Length: {0}", myBA2->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine( "myBA3" ); - Console::WriteLine( " Count: {0}", myBA3->Count ); - Console::WriteLine( " Length: {0}", myBA3->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA3, 8 ); - Console::WriteLine( "myBA4" ); - Console::WriteLine( " Count: {0}", myBA4->Count ); - Console::WriteLine( " Length: {0}", myBA4->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA4, 8 ); - Console::WriteLine( "myBA5" ); - Console::WriteLine( " Count: {0}", myBA5->Count ); - Console::WriteLine( " Length: {0}", myBA5->Length ); - Console::WriteLine( " Values:" ); - PrintValues( myBA5, 8 ); -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myBA1 - Count: 5 - Length: 5 - Values: - False False False False False - myBA2 - Count: 5 - Length: 5 - Values: - False False False False False - myBA3 - Count: 40 - Length: 40 - Values: - True False False False False False False False - False True False False False False False False - True True False False False False False False - False False True False False False False False - True False True False False False False False - myBA4 - Count: 5 - Length: 5 - Values: - True False True True False - myBA5 - Count: 160 - Length: 160 - Values: - False True True False False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - True True True False False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - False False False True False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - True False False True False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - False True False True False False False False - False False False False False False False False - False False False False False False False False - False False False False False False False False - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp deleted file mode 100644 index fec3d1d5c3e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesLocker -{ -public: - static void Main() - { - // - BitArray^ myCollection = gcnew BitArray(64, true); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesLocker::Main(); -} - - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp deleted file mode 100644 index cfd52ecb27a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 2 ] = false; - myBA2[ 1 ] = true; - myBA2[ 3 ] = true; - - // Performs a bitwise AND operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - Console::WriteLine( "Result" ); - Console::Write( "AND:" ); - PrintValues( myBA1->And( myBA2 ), 8 ); - Console::WriteLine(); - Console::WriteLine( "After AND" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - - // Performing AND between BitArray instances of different sizes returns an exception. - try - { - BitArray^ myBA3 = gcnew BitArray( 8 ); - myBA3[ 0 ] = false; - myBA3[ 1 ] = false; - myBA3[ 2 ] = false; - myBA3[ 3 ] = false; - myBA3[ 4 ] = true; - myBA3[ 5 ] = true; - myBA3[ 6 ] = true; - myBA3[ 7 ] = true; - myBA1->And( myBA3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - Result - AND: False False False True - - After AND - myBA1: False False False True - myBA2: False True False True - - Exception: System.ArgumentException: Array lengths must be the same. - at System.Collections.BitArray.And(BitArray value) - at SamplesBitArray.Main() - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp deleted file mode 100644 index c1f547de31b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,104 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myArr ); -int main() -{ - // Creates and initializes the source BitArray. - BitArray^ myBA = gcnew BitArray( 4 ); - myBA[ 0 ] = true; - myBA[ 1 ] = true; - myBA[ 2 ] = true; - myBA[ 3 ] = true; - - // Creates and initializes the one-dimensional target Array of type Boolean. - array^myBoolArray = gcnew array(8); - myBoolArray[ 0 ] = false; - myBoolArray[ 1 ] = false; - - // Displays the values of the target Array. - Console::WriteLine( "The target Boolean Array contains the following (before and after copying):" ); - PrintValues( dynamic_cast(myBoolArray) ); - - // Copies the entire source BitArray to the target BitArray, starting at index 3. - myBA->CopyTo( myBoolArray, 3 ); - - // Displays the values of the target Array. - PrintValues( dynamic_cast(myBoolArray) ); - - // Creates and initializes the one-dimensional target Array of type integer. - array^myIntArray = gcnew array(8); - myIntArray[ 0 ] = 42; - myIntArray[ 1 ] = 43; - - // Displays the values of the target Array. - Console::WriteLine( "The target integer Array contains the following (before and after copying):" ); - PrintValues( dynamic_cast(myIntArray) ); - - // Copies the entire source BitArray to the target BitArray, starting at index 3. - myBA->CopyTo( myIntArray, 3 ); - - // Displays the values of the target Array. - PrintValues( dynamic_cast(myIntArray) ); - - // Creates and initializes the one-dimensional target Array of type byte. - Array^ myByteArray = Array::CreateInstance( Byte::typeid, 8 ); - myByteArray->SetValue( (Byte)10, 0 ); - myByteArray->SetValue( (Byte)11, 1 ); - - // Displays the values of the target Array. - Console::WriteLine( "The target byte Array contains the following (before and after copying):" ); - PrintValues( myByteArray ); - - // Copies the entire source BitArray to the target BitArray, starting at index 3. - myBA->CopyTo( myByteArray, 3 ); - - // Displays the values of the target Array. - PrintValues( myByteArray ); - - // Returns an exception if the array is not of type Boolean, integer or byte. - try - { - Array^ myStringArray = Array::CreateInstance( String::typeid, 8 ); - myStringArray->SetValue( "Hello", 0 ); - myStringArray->SetValue( "World", 1 ); - myBA->CopyTo( myStringArray, 3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myArr ) -{ - IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Boolean Array contains the following (before and after copying): - False False False False False False False False - False False False True True True True False - The target integer Array contains the following (before and after copying): - 42 43 0 0 0 0 0 0 - 42 43 0 15 0 0 0 0 - The target byte Array contains the following (before and after copying): - 10 11 0 0 0 0 0 0 - 10 11 0 15 0 0 0 0 - Exception: System.ArgumentException: Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[]. - at System.Collections.BitArray.CopyTo(Array array, Int32 index) - at SamplesBitArray.Main() - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp deleted file mode 100644 index 6417fdd49ba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myCol ); -int main() -{ - - // Creates and initializes a BitArray. - BitArray^ myBA = gcnew BitArray( 5 ); - - // Displays the properties and values of the BitArray. - Console::WriteLine( "myBA values:" ); - PrintIndexAndValues( myBA ); - - // Sets all the elements to true. - myBA->SetAll( true ); - - // Displays the properties and values of the BitArray. - Console::WriteLine( "After setting all elements to true," ); - PrintIndexAndValues( myBA ); - - // Sets the last index to false. - myBA->Set( myBA->Count - 1, false ); - - // Displays the properties and values of the BitArray. - Console::WriteLine( "After setting the last element to false," ); - PrintIndexAndValues( myBA ); - - // Gets the value of the last two elements. - Console::WriteLine( "The last two elements are: " ); - Console::WriteLine( " at index {0} : {1}", myBA->Count - 2, myBA->Get( myBA->Count - 2 ) ); - Console::WriteLine( " at index {0} : {1}", myBA->Count - 1, myBA->Get( myBA->Count - 1 ) ); -} - -void PrintIndexAndValues( IEnumerable^ myCol ) -{ - int i = 0; - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " [{0}]: {1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myBA values: - [0]: False - [1]: False - [2]: False - [3]: False - [4]: False - - After setting all elements to true, - [0]: True - [1]: True - [2]: True - [3]: True - [4]: True - - After setting the last element to false, - [0]: True - [1]: True - [2]: True - [3]: True - [4]: False - - The last two elements are: - at index 3 : True - at index 4 : False - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp deleted file mode 100644 index ca1de36ae1e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 1 ] = true; - myBA2[ 2 ] = false; - myBA2[ 3 ] = true; - - // Performs a bitwise NOT operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - myBA1->Not(); - myBA2->Not(); - Console::WriteLine( "After NOT" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - After NOT - myBA1: True True False False - myBA2: True False True False - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp deleted file mode 100644 index 0a5de2543d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 1 ] = true; - myBA2[ 2 ] = false; - myBA2[ 3 ] = true; - - // Performs a bitwise OR operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - Console::WriteLine( "Result" ); - Console::Write( "OR:" ); - PrintValues( myBA1->Or( myBA2 ), 8 ); - Console::WriteLine(); - Console::WriteLine( "After OR" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - - // Performing OR between BitArray instances of different sizes returns an exception. - try - { - BitArray^ myBA3 = gcnew BitArray( 8 ); - myBA3[ 0 ] = false; - myBA3[ 1 ] = false; - myBA3[ 2 ] = false; - myBA3[ 3 ] = false; - myBA3[ 4 ] = true; - myBA3[ 5 ] = true; - myBA3[ 6 ] = true; - myBA3[ 7 ] = true; - myBA1->Or( myBA3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - Result - OR: False True True True - - After OR - myBA1: False True True True - myBA2: False True False True - - Exception: System.ArgumentException: Array lengths must be the same. - at System.Collections.BitArray.Or(BitArray value) - at SamplesBitArray.Main() - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp deleted file mode 100644 index cd12c4f4ea2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp +++ /dev/null @@ -1,99 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myList, int myWidth ); -int main() -{ - - // Creates and initializes two BitArrays of the same size. - BitArray^ myBA1 = gcnew BitArray( 4 ); - BitArray^ myBA2 = gcnew BitArray( 4 ); - myBA1[ 0 ] = false; - myBA1[ 1 ] = false; - myBA1[ 2 ] = true; - myBA1[ 3 ] = true; - myBA2[ 0 ] = false; - myBA2[ 1 ] = true; - myBA2[ 2 ] = false; - myBA2[ 3 ] = true; - - // Performs a bitwise XOR operation between BitArray instances of the same size. - Console::WriteLine( "Initial values" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - Console::WriteLine( "Result" ); - Console::Write( "XOR:" ); - PrintValues( myBA1->Xor( myBA2 ), 8 ); - Console::WriteLine(); - Console::WriteLine( "After XOR" ); - Console::Write( "myBA1:" ); - PrintValues( myBA1, 8 ); - Console::Write( "myBA2:" ); - PrintValues( myBA2, 8 ); - Console::WriteLine(); - - // Performing XOR between BitArray instances of different sizes returns an exception. - try - { - BitArray^ myBA3 = gcnew BitArray( 8 ); - myBA3[ 0 ] = false; - myBA3[ 1 ] = false; - myBA3[ 2 ] = false; - myBA3[ 3 ] = false; - myBA3[ 4 ] = true; - myBA3[ 5 ] = true; - myBA3[ 6 ] = true; - myBA3[ 7 ] = true; - myBA1->Xor( myBA3 ); - } - catch ( Exception^ myException ) - { - Console::WriteLine( "Exception: {0}", myException ); - } - -} - -void PrintValues( IEnumerable^ myList, int myWidth ) -{ - int i = myWidth; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - if ( i <= 0 ) - { - i = myWidth; - Console::WriteLine(); - } - - i--; - Console::Write( "{0,8}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initial values - myBA1: False False True True - myBA2: False True False True - - Result - XOR: False True True False - - After XOR - myBA1: False True True False - myBA2: False True False True - - Exception: System.ArgumentException: Array lengths must be the same. - at System.Collections.BitArray.Xor(BitArray value) - at SamplesBitArray.Main() - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp deleted file mode 100644 index cd78af80b5c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -public ref class SomeClass -{ -// -private: - static BooleanSwitch^ boolSwitch = gcnew BooleanSwitch("mySwitch", - "Switch in config file"); - -public: - static void Main( ) - { - //... - Console::WriteLine("Boolean switch {0} configured as {1}", - boolSwitch->DisplayName, ((Boolean^)boolSwitch->Enabled)->ToString()); - if (boolSwitch->Enabled) - { - //... - } - } -// -}; - -int main() -{ - SomeClass::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp deleted file mode 100644 index 824f579d9be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -// -public ref class BooleanSwitchTest -{ -private: - - /* Create a BooleanSwitch for data.*/ - static BooleanSwitch^ dataSwitch = gcnew BooleanSwitch( "Data","DataAccess module" ); - -public: - static void MyMethod( String^ location ) - { - - //Insert code here to handle processing. - if ( dataSwitch->Enabled ) - Console::WriteLine( "Error happened at {0}", location ); - } - -}; - -int main() -{ - - //Run the method which writes an error message specifying the location of the error. - BooleanSwitchTest::MyMethod( "in main" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp deleted file mode 100644 index fb8731a2646..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -// -public ref class BooleanSwitchTest -{ -private: - - /* Create a BooleanSwitch for data.*/ - static BooleanSwitch^ dataSwitch = gcnew BooleanSwitch( "Data","DataAccess module" ); - -public: - static void MyMethod( String^ location ) - { - - //Insert code here to handle processing. - if ( dataSwitch->Enabled ) - Console::WriteLine( "Error happened at {0}", location ); - } - -}; - -int main() -{ - - //Run the method that writes an error message specifying the location of the error. - BooleanSwitchTest::MyMethod( "in main" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp deleted file mode 100644 index ca1ec41a454..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTimeFormatInfo.GetAllDateTimePatterns Example/CPP/source.cpp +++ /dev/null @@ -1,109 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Globalization; -public ref class SamplesDateTimeFormatInfo -{ -public: - static void Main() - { - - // Creates a new DateTimeFormatinfo. - DateTimeFormatInfo^ myDtfi = gcnew DateTimeFormatInfo; - - // Gets and prints all the patterns - array^myPatternsArray = myDtfi->GetAllDateTimePatterns(); - Console::WriteLine( "ALL the patterns:" ); - PrintIndexAndValues( myPatternsArray ); - - // Gets and prints the pattern(s) associated with some of the format characters. - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'd' ); - Console::WriteLine( "The patterns for 'd':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'D' ); - Console::WriteLine( "The patterns for 'D':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'f' ); - Console::WriteLine( "The patterns for 'f':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'F' ); - Console::WriteLine( "The patterns for 'F':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'r' ); - Console::WriteLine( "The patterns for 'r':" ); - PrintIndexAndValues( myPatternsArray ); - myPatternsArray = myDtfi->GetAllDateTimePatterns( 'R' ); - Console::WriteLine( "The patterns for 'R':" ); - PrintIndexAndValues( myPatternsArray ); - } - - public: - static void PrintIndexAndValues( array^myArray ) { - int i = 0; - for each ( String^ s in myArray ) - Console::WriteLine( "\t[{0}]:\t{1}", i++, s ); - Console::WriteLine(); - } -}; - -int main() -{ - SamplesDateTimeFormatInfo::Main(); -} - -/* -This code produces the following output. - -ALL the patterns: - [0]: MM/dd/yyyy - [1]: dddd, dd MMMM yyyy - [2]: dddd, dd MMMM yyyy HH:mm - [3]: dddd, dd MMMM yyyy hh:mm tt - [4]: dddd, dd MMMM yyyy H:mm - [5]: dddd, dd MMMM yyyy h:mm tt - [6]: dddd, dd MMMM yyyy HH:mm:ss - [7]: MM/dd/yyyy HH:mm - [8]: MM/dd/yyyy hh:mm tt - [9]: MM/dd/yyyy H:mm - [10]: MM/dd/yyyy h:mm tt - [11]: MM/dd/yyyy HH:mm:ss - [12]: MMMM dd - [13]: MMMM dd - [14]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - [15]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - [16]: yyyy'-'MM'-'dd'T'HH':'mm':'ss - [17]: HH:mm - [18]: hh:mm tt - [19]: H:mm - [20]: h:mm tt - [21]: HH:mm:ss - [22]: yyyy'-'MM'-'dd HH':'mm':'ss'Z' - [23]: dddd, dd MMMM yyyy HH:mm:ss - [24]: yyyy MMMM - [25]: yyyy MMMM - -The patterns for 'd': - [0]: MM/dd/yyyy - -The patterns for 'D': - [0]: dddd, dd MMMM yyyy - -The patterns for 'f': - [0]: dddd, dd MMMM yyyy HH:mm - [1]: dddd, dd MMMM yyyy hh:mm tt - [2]: dddd, dd MMMM yyyy H:mm - [3]: dddd, dd MMMM yyyy h:mm tt - -The patterns for 'F': - [0]: dddd, dd MMMM yyyy HH:mm:ss - -The patterns for 'r': - [0]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - -The patterns for 'R': - [0]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT' -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp deleted file mode 100644 index 3aab3172dfa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// Specify /DDEBUG when compiling. - -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - #if defined(DEBUG) - Debug::Listeners->Add( gcnew TextWriterTraceListener( Console::Out ) ); - Debug::AutoFlush = true; - Debug::Indent(); - Debug::WriteLine( "Entering Main" ); - #endif - Console::WriteLine( "Hello World." ); - #if defined(DEBUG) - Debug::WriteLine( "Exiting Main" ); - Debug::Unindent(); - #endif - return 0; -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp deleted file mode 100644 index 4cd8faa26fc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - - // - // Create a local value. - int index; - - // Perform some action that sets the local value. - index = -40; - - // Test that the local value is valid. - #if defined(DEBUG) - Debug::Assert( index > -1 ); - #endif - // - - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp deleted file mode 100644 index db8c6bd2ccb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -void MyMethod( Object^ obj, Type^ type ); - -int main( void ) -{ - MyMethod( nullptr, nullptr ); - return 0; -} - -// -void MyMethod( Object^ obj, Type^ type ) -{ - #if defined(DEBUG) - Debug::Assert( type != nullptr, "Type paramater is null" ); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp deleted file mode 100644 index 06b428a1024..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -void MyMethod( Object^ obj, Type^ type ); - -int main( void ) -{ - MyMethod( nullptr, nullptr ); - return 0; -} - -// -void MyMethod( Object^ obj, Type^ type ) -{ - #if defined(DEBUG) - Debug::Assert( type != nullptr, "Type paramater is null", "Can't get object for null type" ); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp deleted file mode 100644 index a9769743b9c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// Specify /DDEBUG when compiling. - -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -void main() -{ - #if defined(DEBUG) - // Create a new stream object for an output file named TestFile.txt. - FileStream^ myFileStream = - gcnew FileStream( "TestFile.txt", FileMode::Append ); - - // Add the stream object to the trace listeners. - TextWriterTraceListener^ myTextListener = - gcnew TextWriterTraceListener( myFileStream ); - Debug::Listeners->Add( myTextListener ); - - // Write output to the file. - Debug::WriteLine( "Test output" ); - - // Flush and close the output stream. - Debug::Flush(); - Debug::Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp deleted file mode 100644 index 52656e679ec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -enum class Option -{ - First, Second, Last -}; - -ref class Test -{ -public: - void SomeMethod() - { - int option = (int)Option::Last + 1; - double result; - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(DEBUG) - Debug::Fail( "Unknown Option" + option ); - #endif - result = 1.0; - break; - } - // - } -}; - -int main( void ) -{ - try - { - Object^ b; - b->ToString(); - } - // - catch ( Exception^ e ) - { - #if defined(DEBUG) - Debug::Fail( "Unknown Option " + option + ", using the default." ); - #endif - } - // - - Test^ test = gcnew Test(); - test->SomeMethod(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp deleted file mode 100644 index 3333cf56f0b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -enum class Option -{ - First, Second, Last -}; - -ref class Test -{ -public: - void SomeMethod() - { - int option = (int)Option::Last + 1; - double result; - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(DEBUG) - Debug::Fail( "Unknown Option" + option, "Result set to 1.0" ); - #endif - result = 1.0; - break; - } - // - } -}; - -int main( void ) -{ - try - { - Object^ b; - b->ToString(); - } - // - catch ( Exception^ e ) - { - #if defined(DEBUG) - Debug::Fail( "Cannot find SpecialController, proceeding with StandardController", "Setting Controller to default value" ); - #endif - } - // - - Test^ test = gcnew Test(); - test->SomeMethod(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp deleted file mode 100644 index daaf7687108..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - // - #if defined(DEBUG) - Debug::WriteLine( "List of errors:" ); - Debug::Indent(); - Debug::WriteLine( "Error 1: File not found" ); - Debug::WriteLine( "Error 2: Directory not found" ); - Debug::Unindent(); - Debug::WriteLine( "End of list of errors" ); - #endif - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp deleted file mode 100644 index 267bc674630..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -int main( void ) -{ - - // - // Create a listener that outputs to the console screen - // and add it to the debug listeners. - #if defined(DEBUG) - TextWriterTraceListener^ myWriter = - gcnew TextWriterTraceListener( System::Console::Out ); - Debug::Listeners->Add( myWriter ); - #endif - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp deleted file mode 100644 index 6b4827ca3c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( myObject, category ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::Write( " Object is not valid for this category." ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp deleted file mode 100644 index db1cf0381a5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteIf( generalSwitch->TraceVerbose, - "My second error message." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp deleted file mode 100644 index 21e33495423..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, myObject ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, - " is not a valid value for this method." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp deleted file mode 100644 index 9fa1f596191..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceVerbose, String::Concat( myObject, - " is not a valid object for category: " ), category ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceError, - " Please use a different category." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp deleted file mode 100644 index aa9a5022701..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceVerbose, myObject, category ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceError, - " Object is not valid for this category." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp deleted file mode 100644 index ef9961a738d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "My error message. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( "My second error message." ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp deleted file mode 100644 index c3a53e7adcd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "Invalid object. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( myObject ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp deleted file mode 100644 index 05f395a2ce6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "My error message. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( "My second error message.", category ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp deleted file mode 100644 index 8c64d37cc22..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( generalSwitch->TraceError ) - { - #if defined(DEBUG) - Debug::Write( "Invalid object for category. " ); - #endif - } - // Write a second message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - #if defined(DEBUG) - Debug::WriteLine( myObject, category ); - #endif - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp deleted file mode 100644 index 8ded25d813b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp deleted file mode 100644 index fefafc88fcc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "Invalid object. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, myObject ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp deleted file mode 100644 index ee7c49907b7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message.", category ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp deleted file mode 100644 index d7fb6a3dfaa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ - // - // Class-level declaration. - // Create a TraceSwitch. - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General","Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - // Write the message if the TraceSwitch level is set to Error or higher. - #if defined(DEBUG) - Debug::WriteIf(generalSwitch->TraceError, "Invalid object for category. "); - - // Write a second message if the TraceSwitch level is set to Verbose. - Debug::WriteLineIf( generalSwitch->TraceVerbose, myObject, category ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp deleted file mode 100644 index 296584f4b92..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - DirectoryInfo^ dir = gcnew DirectoryInfo( "." ); - String^ dirName = dir->Name; - Console::WriteLine( "DirectoryInfo name is {0}.", dirName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp deleted file mode 100644 index 1d5d2c3bae2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Windows::Forms; - -// -int main() -{ - - // Creates an exception with an error message. - Exception^ myException = gcnew Exception( "This is an exception test" ); - - // Creates an ErrorEventArgs with the exception. - ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException ); - - // Extracts the exception from the ErrorEventArgs and display it. - Exception^ myReturnedException = myErrorEventArgs->GetException(); - MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp deleted file mode 100644 index dafe3cd798d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Windows::Forms; - -// -int main() -{ - - //Creates an exception with an error message. - Exception^ myException = gcnew Exception( "This is an exception test" ); - - //Creates an ErrorEventArgs with the exception. - ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException ); - - //Extracts the exception from the ErrorEventArgs and display it. - Exception^ myReturnedException = myErrorEventArgs->GetException(); - MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp deleted file mode 100644 index 220658df802..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create an EventLog instance and assign its log name. - EventLog^ myLog = gcnew EventLog; - myLog->Log = "myNewLog"; - myLog->Clear(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp deleted file mode 100644 index 837b9e669dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "MySource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp deleted file mode 100644 index d34be2b024f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - String^ logName; - if ( EventLog::SourceExists( "MySource", "MyMachine") ) - { - - // Find the log associated with this source. - logName = EventLog::LogNameFromSourceName( "MySource", "MyMachine" ); - // Make sure the source is in the log we believe it to be in - if (logName != "MyLog") - return -1; - // Delete the source and the log. - EventLog::DeleteEventSource( "MySource", "MyMachine" ); - EventLog::Delete( logName, "MyMachine" ); - Console::WriteLine( "{0} deleted.", logName ); - } - else - { - // Create the event source to make next try successful. - EventSourceCreationData^ mySourceData = gcnew EventSourceCreationData("MySource", "MyLog"); - mySourceData->MachineName = "MyMachine"; - EventLog::CreateEventSource(mySourceData); - } -} - -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp deleted file mode 100644 index 7fbbf42dd7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - String^ logName; - if ( EventLog::SourceExists( "MySource" ) ) - { - - // Find the log associated with this source. - logName = EventLog::LogNameFromSourceName( "MySource", "." ); - // Make sure the source is in the log we believe it to be in - if (logName != "MyLog") - return -1; - // Delete the source and the log. - EventLog::DeleteEventSource( "MySource" ); - EventLog::Delete( logName ); - Console::WriteLine( "{0} deleted.", logName ); - } - else - { - // Create the event source to make next try successful. - EventLog::CreateEventSource("MySource", "MyLog"); - } -} - -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp deleted file mode 100644 index 8d2633a605a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -ref class MySample -{ -public: - static void MyOnEntryWritten( Object^ /*source*/, EntryWrittenEventArgs^ e ) - { - Console::WriteLine( "Written: {0}", e->Entry->Message ); - } - -}; - -int main() -{ - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "MyCustomLog"; - myNewLog->EntryWritten += gcnew EntryWrittenEventHandler( MySample::MyOnEntryWritten ); - myNewLog->EnableRaisingEvents = true; - Console::WriteLine( "Press \'q\' to quit." ); - - // Wait for the EntryWrittenEvent or a quit command. - while ( Console::Read() != 'q' ) - { - - // Wait. - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp deleted file mode 100644 index b53690fb654..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - EventLog^ myLog = gcnew EventLog; - myLog->Log = "MyNewLog"; - System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp deleted file mode 100644 index 6a70ed0eae5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -ref class MySample -{ -private: - - // This member is used to wait for events. - static AutoResetEvent^ signal; - -public: - static void main() - { - signal = gcnew AutoResetEvent( false ); - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Source = "testEventLogEvent"; - myNewLog->EntryWritten += gcnew EntryWrittenEventHandler( MyOnEntryWritten ); - myNewLog->EnableRaisingEvents = true; - myNewLog->WriteEntry("Test message", EventLogEntryType::Information); - signal->WaitOne(); - } - - static void MyOnEntryWritten( Object^ /*source*/, EntryWrittenEventArgs^ /*e*/ ) - { - Console::WriteLine("In event handler"); - signal->Set(); - } - -}; - -int main() -{ - MySample::main(); -} - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp deleted file mode 100644 index 784d135be2e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - - // Create an EventLog instance and assign its log name. - EventLog^ myLog = gcnew EventLog( "myNewLog" ); - - // Read the event log entries. - System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp deleted file mode 100644 index d4a6b83d0d1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog", "myServer" ); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - // Create an EventLog instance and assign its log name. - EventLog^ myLog = gcnew EventLog( "myNewLog","myServer" ); - - // Read the event log entries. - System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp deleted file mode 100644 index 1406cddf5c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //An event log source should not be created and immediately used. - //There is a latency time to enable the source, it should be created - //prior to executing the application that uses the source. - //Execute this sample a second time to use the new source. - EventLog::CreateEventSource( "MySource", "MyNewLog"); - Console::WriteLine( "CreatingEventSource" ); - // The source is created. Exit the application to allow it to be registered. - return 0; - } - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog( "myNewLog",".","MySource" ); - - // Write an entry to the log. - myLog->WriteEntry( String::Format( "Writing to event log on {0}", myLog->MachineName ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp deleted file mode 100644 index 0bb3db04e83..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - array^remoteEventLogs; - remoteEventLogs = EventLog::GetEventLogs( "myServer" ); - Console::WriteLine( "Number of logs on computer: {0}", remoteEventLogs->Length ); - System::Collections::IEnumerator^ myEnum = remoteEventLogs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLog^ log = safe_cast(myEnum->Current); - Console::WriteLine( "Log: {0}", log->Log ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp deleted file mode 100644 index e9a75f0cb41..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "NewEventLog"; - System::Collections::IEnumerator^ myEnum = myNewLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp deleted file mode 100644 index fe550a181e0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "NewEventLog"; - myNewLog->MachineName = "MyServer"; - System::Collections::IEnumerator^ myEnum = myNewLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - Console::WriteLine( "\tEntry: {0}", entry->Message ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp deleted file mode 100644 index 44c4682c561..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - } - - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "MySource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing to event log." ); - Console::WriteLine( "Message written to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp deleted file mode 100644 index c66d775c270..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource", "MyServer" ) ) - { - EventLog::CreateEventSource( "MySource", "MyNewLog", "MyServer" ); - Console::WriteLine( "CreatingEventSource" ); - } - - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "MySource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing to event log." ); - Console::WriteLine( "Message written to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp deleted file mode 100644 index 8980996197a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "myNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - } - - - // Write an informational entry to the event log. - EventLog::WriteEntry( "MySource", "Writing to event log." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp deleted file mode 100644 index 52610a420c6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog("MyNewLog"); - myLog->Source = "MyNewLogSource"; - - // Write an informational entry to the event log. - myLog->WriteEntry( "Writing warning to event log.", EventLogEntryType::Warning ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp deleted file mode 100644 index 126dd6381a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp +++ /dev/null @@ -1,16 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - - // Write an informational entry to the event log. - EventLog::WriteEntry( "MySource", "Writing warning to event log.", EventLogEntryType::Warning ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp deleted file mode 100644 index bae18050fe1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -// -int main() -{ - #if defined(TRACE) - - // Create a trace listener for the event log. - EventLogTraceListener^ myTraceListener = - gcnew EventLogTraceListener( "myEventLogSource" ); - - // Add the event log trace listener to the collection. - Trace::Listeners->Add( myTraceListener ); - - // Write output to the event log. - Trace::WriteLine( "Test output" ); - - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp deleted file mode 100644 index d0051f61250..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -using namespace System; -using namespace System::IO; - -public ref class Form1 -{ -protected: - void Method( String^ name ) - { -// -FileStream^ s2 = gcnew FileStream( name, FileMode::Open, FileAccess::Read, FileShare::Read ); -// - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp deleted file mode 100644 index 73b079909b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main( void ) -{ - FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Read ); - if ( fs->CanRead && fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt can be both written to and read from." ); - } - else - { - Console::WriteLine( "MyFile.txt is not writable" ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp deleted file mode 100644 index 1c4c9b8a84c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanWrite Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main( void ) -{ - FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Write ); - if ( fs->CanRead && fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt can be both written to and read from." ); - } - else - { - Console::WriteLine( "MyFile.txt is writable." ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp deleted file mode 100644 index 6d129222b6a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::IO::IsolatedStorage; - -void Method( FileStream^ s ) -{ - // - if ( s->Length == s->Position ) - { - Console::WriteLine( "End of file has been reached." ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp deleted file mode 100644 index 9239a2c8f3e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - - -public ref class Class1 -{ - -public: - static void Main() - { - // Get the file version for the notepad. - // Use either of the two following methods. - FileVersionInfo::GetVersionInfo(Path::Combine(Environment::SystemDirectory, "Notepad.exe")); - FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - - - // Print the file name and version number. - Console::WriteLine("File: " + myFileVersionInfo->FileDescription + "\n" + - "Version number: " + myFileVersionInfo->FileVersion); - } -}; - -int main() -{ - Class1::Main(); -} -// - - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp deleted file mode 100644 index 2a2d18167f1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - - // -private: - void GetCompanyName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - - // Print the company name. - textBox1->Text = "The company name: " + myFileVersionInfo->CompanyName; - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp deleted file mode 100644 index 0766d0bcf94..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileBuildPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe"); - - // Print the file build number. - textBox1->Text = String::Format( "File build number: {0}", myFileVersionInfo->FileBuildPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp deleted file mode 100644 index 944efb43eff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Windows::Forms; -using namespace System::Diagnostics; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileDescription() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file description. - textBox1->Text = String::Concat( "File description: ", myFileVersionInfo->FileDescription ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp deleted file mode 100644 index fe1fceca8b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - - // -private: - void GetFileMajorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo( "%systemroot%\\Notepad.exe" ); - - // Print the file major part number. - textBox1->Text = String::Concat( "File major part number: ", myFileVersionInfo->FileMajorPart ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp deleted file mode 100644 index 1c1a34b3c9a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileMinorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file minor part number. - textBox1->Text = String::Concat( "File minor part number: ", myFileVersionInfo->FileMinorPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp deleted file mode 100644 index c9afaf47525..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file name. - textBox1->Text = String::Concat( "File name: ", myFileVersionInfo->FileName ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp deleted file mode 100644 index ff28177ca51..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFilePrivatePart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the file private part number. - textBox1->Text = String::Concat( "File private part number: ", myFileVersionInfo->FilePrivatePart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp deleted file mode 100644 index d957207f64e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetInternalName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the internal name. - textBox1->Text = String::Concat( "Internal name: ", myFileVersionInfo->InternalName ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp deleted file mode 100644 index 03806600176..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsDebug() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file contains debugging information. - textBox1->Text = String::Concat( "File contains debugging information: ", - myFileVersionInfo->IsDebug ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp deleted file mode 100644 index 679f5f4c274..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsPatched() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file has a patch installed. - textBox1->Text = String::Concat( "File has patch installed: ", myFileVersionInfo->IsPatched ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp deleted file mode 100644 index fc4df817667..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsPreRelease() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file is a prerelease version. - textBox1->Text = String::Concat( "File is prerelease version ", myFileVersionInfo->IsPreRelease ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp deleted file mode 100644 index 83dd4978d95..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsPrivateBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the version is a private build. - textBox1->Text = String::Concat( "Version is a private build: ", myFileVersionInfo->IsPrivateBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp deleted file mode 100644 index 252a113a733..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetIsSpecialBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print whether the file is a special build. - textBox1->Text = String::Concat( "File is a special build: ", myFileVersionInfo->IsSpecialBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp deleted file mode 100644 index c4f8e392537..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetCopyright() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the copyright notice. - textBox1->Text = String::Concat( "Copyright notice: ", myFileVersionInfo->LegalCopyright ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp deleted file mode 100644 index 0ed892c3443..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetTrademarks() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the trademarks. - textBox1->Text = String::Concat( "Trademarks: ", myFileVersionInfo->LegalTrademarks ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp deleted file mode 100644 index 06de83f723a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetOriginalName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the original file name. - textBox1->Text = String::Concat( "Original file name: ", myFileVersionInfo->OriginalFilename ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp deleted file mode 100644 index 9087c661b55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetPrivateBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the private build number. - textBox1->Text = String::Concat( "Private build number: ", myFileVersionInfo->PrivateBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp deleted file mode 100644 index 81913117b81..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductBuildPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product build part number. - textBox1->Text = String::Concat( "Product build part number: ", myFileVersionInfo->ProductBuildPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp deleted file mode 100644 index c08b8bbc59b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductMajorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product major part number. - textBox1->Text = String::Concat( "Product major part number: ", myFileVersionInfo->ProductMajorPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp deleted file mode 100644 index a419d991f9a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductMinorPart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product minor part number. - textBox1->Text = String::Concat( "Product minor part number: ", myFileVersionInfo->ProductMinorPart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp deleted file mode 100644 index 4b5b6d28591..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductName() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product name. - textBox1->Text = String::Concat( "Product name: ", myFileVersionInfo->ProductName ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp deleted file mode 100644 index 9ef151fdcab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductPrivatePart() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product private part number. - textBox1->Text = String::Concat( "Product private part number: ", myFileVersionInfo->ProductPrivatePart ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp deleted file mode 100644 index 37638630d5a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetProductVersion() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the product version number. - textBox1->Text = String::Concat( "Product version number: ", myFileVersionInfo->ProductVersion ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp deleted file mode 100644 index a3f209f9682..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetSpecialBuild() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print the special build information. - textBox1->Text = String::Concat( "Special build information: ", myFileVersionInfo->SpecialBuild ); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp deleted file mode 100644 index fbecc3c9e0c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1 : public Form -{ -protected: - TextBox^ textBox1; - -// -private: - void GetFileVersion2() - { - // Get the file version for the notepad. - FileVersionInfo^ myFileVersionInfo = - FileVersionInfo::GetVersionInfo( Environment::SystemDirectory + "\\Notepad.exe" ); - - // Print all the version information. - textBox1->Text = myFileVersionInfo->ToString(); - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp deleted file mode 100644 index 69ae75d0f48..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Policy; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - array^dataArray; - - void Method() - { - // - HashAlgorithm^ sha = SHA256::Create(); - array^ result = sha->ComputeHash( dataArray ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp deleted file mode 100644 index 473f4a7a126..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public class HashtableExample -{ -public: - static void Main() - { - // Creates and initializes a new Hashtable. - Hashtable^ clouds = gcnew Hashtable(); - clouds->Add("Cirrus", "Castellanus"); - clouds->Add("Cirrocumulus", "Stratiformis"); - clouds->Add("Altostratus", "Radiatus"); - clouds->Add("Stratocumulus", "Perlucidus"); - clouds->Add("Stratus", "Fractus"); - clouds->Add("Nimbostratus", "Pannus"); - clouds->Add("Cumulus", "Humilis"); - clouds->Add("Cumulonimbus", "Incus"); - - // Displays the keys and values of the Hashtable using GetEnumerator() - - IDictionaryEnumerator^ denum = clouds->GetEnumerator(); - DictionaryEntry dentry; - - Console::WriteLine(); - Console::WriteLine(" Cloud Type Variation"); - Console::WriteLine(" -----------------------------"); - while (denum->MoveNext()) - { - dentry = (DictionaryEntry) denum->Current; - Console::WriteLine(" {0,-17}{1}", dentry.Key, dentry.Value); - } - Console::WriteLine(); - - // Displays the keys and values of the Hashtable using foreach statement - - Console::WriteLine(" Cloud Type Variation"); - Console::WriteLine(" -----------------------------"); - for each (DictionaryEntry de in clouds) - { - Console::WriteLine(" {0,-17}{1}", de.Key, de.Value); - } - Console::WriteLine(); - } -}; - -int main() -{ - HashtableExample::Main(); -} - -// The program displays the following output to the console: -// -// Cloud Type Variation -// ----------------------------- -// Cirrocumulus Stratiformis -// Stratocumulus Perlucidus -// Cirrus Castellanus -// Cumulus Humilis -// Nimbostratus Pannus -// Stratus Fractus -// Altostratus Radiatus -// Cumulonimbus Incus -// -// Cloud Type Variation -// ----------------------------- -// Cirrocumulus Stratiformis -// Stratocumulus Perlucidus -// Cirrus Castellanus -// Cumulus Humilis -// Nimbostratus Pannus -// Stratus Fractus -// Altostratus Radiatus -// Cumulonimbus Incus*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp deleted file mode 100644 index 21cce15687b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "one", "The" ); - myHT->Add( "two", "quick" ); - myHT->Add( "three", "brown" ); - myHT->Add( "four", "fox" ); - - // Displays the Hashtable. - Console::WriteLine( "The Hashtable contains the following:" ); - PrintKeysAndValues( myHT ); -} - -void PrintKeysAndValues( Hashtable^ myHT ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}:\t{1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Hashtable contains the following: - -KEY- -VALUE- - two: quick - three: brown - four: fox - one: The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp deleted file mode 100644 index 87875e40e37..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "one", "The" ); - myHT->Add( "two", "quick" ); - myHT->Add( "three", "brown" ); - myHT->Add( "four", "fox" ); - myHT->Add( "five", "jumps" ); - - // Displays the count and values of the Hashtable. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myHT->Count ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( myHT ); - - // Clears the Hashtable. - myHT->Clear(); - - // Displays the count and values of the Hashtable. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myHT->Count ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( myHT ); -} - -void PrintKeysAndValues( Hashtable^ myHT ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}:\t{1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Values: - -KEY- -VALUE- - two: quick - three: brown - four: fox - five: jumps - one: The - - After Clear, - Count : 0 - Values: - -KEY- -VALUE- - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp deleted file mode 100644 index b6d25cecb55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( (int^)0, "zero" ); - myHT->Add( 1, "one" ); - myHT->Add( 2, "two" ); - myHT->Add( 3, "three" ); - myHT->Add( 4, "four" ); - - // Displays the values of the Hashtable. - Console::WriteLine( "The Hashtable contains the following values:" ); - PrintIndexAndKeysAndValues( myHT ); - - // Searches for a specific key. - int myKey = 2; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, myHT->ContainsKey( myKey ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); - myKey = 6; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, myHT->ContainsKey( myKey ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); - - // Searches for a specific value. - String^ myValue = "three"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, myHT->ContainsValue( myValue ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); - myValue = "nine"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, myHT->ContainsValue( myValue ) ? (String^)"in the Hashtable" : "NOT in the Hashtable" ); -} - -void PrintIndexAndKeysAndValues( Hashtable^ myHT ) -{ - int i = 0; - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i++, de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Hashtable contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 4 four - [1]: 3 three - [2]: 2 two - [3]: 1 one - [4]: 0 zero - - The key "2" is in the Hashtable. - The key "6" is NOT in the Hashtable. - The value "three" is in the Hashtable. - The value "nine" is NOT in the Hashtable. - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 70190cc955d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^myArr, char mySeparator ); -int main() -{ - - // Creates and initializes the source Hashtable. - Hashtable^ mySourceHT = gcnew Hashtable; - mySourceHT->Add( "A", "valueA" ); - mySourceHT->Add( "B", "valueB" ); - - // Creates and initializes the one-dimensional target Array. - array^myTargetArray = gcnew array(15); - myTargetArray[ 0 ] = "The"; - myTargetArray[ 1 ] = "quick"; - myTargetArray[ 2 ] = "brown"; - myTargetArray[ 3 ] = "fox"; - myTargetArray[ 4 ] = "jumps"; - myTargetArray[ 5 ] = "over"; - myTargetArray[ 6 ] = "the"; - myTargetArray[ 7 ] = "lazy"; - myTargetArray[ 8 ] = "dog"; - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following before:" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the keys in the source Hashtable to the target Hashtable, starting at index 6. - Console::WriteLine( "After copying the keys, starting at index 6:" ); - mySourceHT->Keys->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the values in the source Hashtable to the target Hashtable, starting at index 6. - Console::WriteLine( "After copying the values, starting at index 6:" ); - mySourceHT->Values->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^myArr, char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ] ); - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following before: - The quick brown fox jumps over the lazy dog - After copying the keys, starting at index 6: - The quick brown fox jumps over B A dog - After copying the values, starting at index 6: - The quick brown fox jumps over valueB valueA dog - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp deleted file mode 100644 index 5e205ba0c28..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesHashtable -{ -public: - static void Main() - { - // - Hashtable^ myCollection = gcnew Hashtable(); - bool lockTaken = false; - - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -void main() -{ - SamplesHashtable::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 4696c2337e9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( (int^)0, "zero" ); - myHT->Add( 1, "one" ); - myHT->Add( 2, "two" ); - myHT->Add( 3, "three" ); - myHT->Add( 4, "four" ); - - // Creates a synchronized wrapper around the Hashtable. - Hashtable^ mySyncdHT = Hashtable::Synchronized( myHT ); - - // Displays the sychronization status of both Hashtables. - Console::WriteLine( "myHT is {0}.", myHT->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdHT is {0}.", mySyncdHT->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* - This code produces the following output. - - myHT is not synchronized. - mySyncdHT is synchronized. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp deleted file mode 100644 index 23ce290b57a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( Hashtable^ myHT ); -int main() -{ - - // Creates and initializes a new Hashtable. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "1a", "The" ); - myHT->Add( "1b", "quick" ); - myHT->Add( "1c", "brown" ); - myHT->Add( "2a", "fox" ); - myHT->Add( "2b", "jumps" ); - myHT->Add( "2c", "over" ); - myHT->Add( "3a", "the" ); - myHT->Add( "3b", "lazy" ); - myHT->Add( "3c", "dog" ); - - // Displays the Hashtable. - Console::WriteLine( "The Hashtable initially contains the following:" ); - PrintKeysAndValues( myHT ); - - // Removes the element with the key "3b". - myHT->Remove( "3b" ); - - // Displays the current state of the Hashtable. - Console::WriteLine( "After removing \"lazy\":" ); - PrintKeysAndValues( myHT ); -} - -void PrintKeysAndValues( Hashtable^ myHT ) -{ - IEnumerator^ myEnum = myHT->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = *safe_cast(myEnum->Current); - Console::WriteLine( " {0}: {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Hashtable initially contains the following: - 2c: over - 3a: the - 2b: jumps - 3b: lazy - 1b: quick - 3c: dog - 2a: fox - 1c: brown - 1a: The - - After removing "lazy": - 2c: over - 3a: the - 2b: jumps - 1b: quick - 3c: dog - 2a: fox - 1c: brown - 1a: The - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp deleted file mode 100644 index c9eb24638ad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -#include "pch.h" - -using namespace System; -using namespace System::IO; - -class MyClassCPP -{ -public: - - int static Run() - { - FileSystemWatcher^ watcher = gcnew FileSystemWatcher("C:\\path\\to\\folder"); - - watcher->NotifyFilter = static_cast(NotifyFilters::Attributes - | NotifyFilters::CreationTime - | NotifyFilters::DirectoryName - | NotifyFilters::FileName - | NotifyFilters::LastAccess - | NotifyFilters::LastWrite - | NotifyFilters::Security - | NotifyFilters::Size); - - watcher->Changed += gcnew FileSystemEventHandler(MyClassCPP::OnChanged); - watcher->Created += gcnew FileSystemEventHandler(MyClassCPP::OnCreated); - watcher->Deleted += gcnew FileSystemEventHandler(MyClassCPP::OnDeleted); - watcher->Renamed += gcnew RenamedEventHandler(MyClassCPP::OnRenamed); - watcher->Error += gcnew ErrorEventHandler(MyClassCPP::OnError); - - watcher->Filter = "*.txt"; - watcher->IncludeSubdirectories = true; - watcher->EnableRaisingEvents = true; - - Console::WriteLine("Press enter to exit."); - Console::ReadLine(); - - return 0; - } - -private: - - static void OnChanged(Object^ sender, FileSystemEventArgs^ e) - { - if (e->ChangeType != WatcherChangeTypes::Changed) - { - return; - } - Console::WriteLine("Changed: {0}", e->FullPath); - } - - static void OnCreated(Object^ sender, FileSystemEventArgs^ e) - { - Console::WriteLine("Created: {0}", e->FullPath); - } - - static void OnDeleted(Object^ sender, FileSystemEventArgs^ e) - { - Console::WriteLine("Deleted: {0}", e->FullPath); - } - - static void OnRenamed(Object^ sender, RenamedEventArgs^ e) - { - Console::WriteLine("Renamed:"); - Console::WriteLine(" Old: {0}", e->OldFullPath); - Console::WriteLine(" New: {0}", e->FullPath); - } - - static void OnError(Object^ sender, ErrorEventArgs^ e) - { - PrintException(e->GetException()); - } - - static void PrintException(Exception^ ex) - { - if (ex != nullptr) - { - Console::WriteLine("Message: {0}", ex->Message); - Console::WriteLine("Stacktrace:"); - Console::WriteLine(ex->StackTrace); - Console::WriteLine(); - PrintException(ex->InnerException); - } - } -}; - - -int main() -{ - MyClassCPP::Run(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp deleted file mode 100644 index 0c7dbce3903..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -String^ PrintArraySet( array^myArr ) -{ - String^ myStr = nullptr; - myStr = myArr[ 0 ].ToString(); - for ( int i = 1; i < myArr->Length; i++ ) - myStr = String::Concat( myStr, ", ", myArr[ i ].ToString() ); - return myStr; -} - -int main() -{ - - // Creates a new NumberFormatinfo. - NumberFormatInfo^ myNfi = gcnew NumberFormatInfo; - - // Takes a long value. - Int64 myInt = 123456789012345; - - // Displays the value with default formatting. - Console::WriteLine( "Default \t\t:\t{0}", myInt.ToString( "N", myNfi ) ); - - // Displays the value with three elements in the GroupSize array. - array^newInts1 = {2,3,4}; - myNfi->NumberGroupSizes = newInts1; - Console::WriteLine( "Grouping ( {0} )\t:\t{1}", PrintArraySet( myNfi->NumberGroupSizes ), myInt.ToString( "N", myNfi ) ); - - // Displays the value with zero as the last element in the GroupSize array. - array^newInts2 = {2,4,0}; - myNfi->NumberGroupSizes = newInts2; - Console::WriteLine( "Grouping ( {0} )\t:\t{1}", PrintArraySet( myNfi->NumberGroupSizes ), myInt.ToString( "N", myNfi ) ); -} - -/* -This code produces the following output. - -Default : 123, 456, 789, 012, 345.00 -Grouping (2, 3, 4) : 12, 3456, 7890, 123, 45.00 -Grouping (2, 4, 0) : 123456789, 0123, 45.00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp deleted file mode 100644 index 25d277574d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create a new NumberFormatinfo. - NumberFormatInfo^ nfi = gcnew NumberFormatInfo; - - // Takes a negative value. - Int64 value = -1234; - - // Displays the value with default formatting. - Console::WriteLine("{0,-20} {1,-10}", "Default:", - value.ToString("N", nfi)); - - // Displays the value with other patterns. - for (int i = 0; i <= 4; i++) { - nfi->NumberNegativePattern = i; - Console::WriteLine("{0,-20} {1,-10}", - String::Format("Pattern {0}:", - nfi->NumberNegativePattern), - value.ToString("N", nfi)); - } -} -// The example displays the following output: -// Default: -1,234.00 -// Pattern 0: (1,234.00) -// Pattern 1: -1,234.00 -// Pattern 2: - 1,234.00 -// Pattern 3: 1,234.00- -// Pattern 4: 1,234.00 - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp deleted file mode 100644 index 37dced94673..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "Hello" ); - myQ->Enqueue( "World" ); - myQ->Enqueue( "!" ); - - // Displays the properties and values of the Queue. - Console::WriteLine( "myQ" ); - Console::WriteLine( "\tCount: {0}", myQ->Count ); - Console::Write( "\tValues:" ); - PrintValues( myQ ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myQ - Count: 3 - Values: Hello World ! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp deleted file mode 100644 index 7ff5770c590..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( Queue^ myQ ); -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "The" ); - myQ->Enqueue( "quick" ); - myQ->Enqueue( "brown" ); - myQ->Enqueue( "fox" ); - myQ->Enqueue( "jumps" ); - - // Displays the count and values of the Queue. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myQ->Count ); - Console::Write( " Values:" ); - PrintValues( myQ ); - - // Clears the Queue. - myQ->Clear(); - - // Displays the count and values of the Queue. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myQ->Count ); - Console::Write( " Values:" ); - PrintValues( myQ ); -} - -void PrintValues( Queue^ myQ ) -{ - IEnumerator^ myEnum = myQ->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::Write( " {0}", myObj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Values: The quick brown fox jumps - After Clear, - Count : 0 - Values: - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp deleted file mode 100644 index da270065dbb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( Array^ myArr, char mySeparator ); -int main() -{ - // Creates and initializes the source Queue. - Queue^ mySourceQ = gcnew Queue; - mySourceQ->Enqueue( "three" ); - mySourceQ->Enqueue( "napping" ); - mySourceQ->Enqueue( "cats" ); - mySourceQ->Enqueue( "in" ); - mySourceQ->Enqueue( "the" ); - mySourceQ->Enqueue( "barn" ); - - // Creates and initializes the one-dimensional target Array. - Array^ myTargetArray = Array::CreateInstance( String::typeid, 15 ); - myTargetArray->SetValue( "The", 0 ); - myTargetArray->SetValue( "quick", 1 ); - myTargetArray->SetValue( "brown", 2 ); - myTargetArray->SetValue( "fox", 3 ); - myTargetArray->SetValue( "jumps", 4 ); - myTargetArray->SetValue( "over", 5 ); - myTargetArray->SetValue( "the", 6 ); - myTargetArray->SetValue( "lazy", 7 ); - myTargetArray->SetValue( "dog", 8 ); - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Queue to the target Array, starting at index 6. - mySourceQ->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Queue to a new standard array. - array^myStandardArray = mySourceQ->ToArray(); - - // Displays the values of the new standard array. - Console::WriteLine( "The new standard array contains the following:" ); - PrintValues( myStandardArray, ' ' ); -} - -void PrintValues( Array^ myArr, char mySeparator ) -{ - IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, myObj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - The new standard array contains the following: - three napping cats in the barn - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp deleted file mode 100644 index 7238b539959..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "The" ); - myQ->Enqueue( "quick" ); - myQ->Enqueue( "brown" ); - myQ->Enqueue( "fox" ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); - - // Removes an element from the Queue. - Console::WriteLine( "(Dequeue)\t{0}", myQ->Dequeue() ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); - - // Removes another element from the Queue. - Console::WriteLine( "(Dequeue)\t{0}", myQ->Dequeue() ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); - - // Views the first element in the Queue but does not remove it. - Console::WriteLine( "(Peek) \t{0}", myQ->Peek() ); - - // Displays the Queue. - Console::Write( "Queue values:" ); - PrintValues( myQ ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Queue values: The quick brown fox - (Dequeue) The - Queue values: quick brown fox - (Dequeue) quick - Queue values: brown fox - (Peek) brown - Queue values: brown fox - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index ce3246510e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new Queue. - Queue^ myQ = gcnew Queue; - myQ->Enqueue( "The" ); - myQ->Enqueue( "quick" ); - myQ->Enqueue( "brown" ); - myQ->Enqueue( "fox" ); - - // Creates a synchronized wrapper around the Queue. - Queue^ mySyncdQ = Queue::Synchronized( myQ ); - - // Displays the sychronization status of both Queues. - Console::WriteLine( "myQ is {0}.", myQ->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdQ is {0}.", mySyncdQ->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* -This code produces the following output. - -myQ is not synchronized. -mySyncdQ is synchronized. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index 8bfdf62af62..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesQueue -{ -public: - static void Main() - { - // - Queue^ myCollection = gcnew Queue(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesQueue::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp deleted file mode 100644 index 9d881778d4a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Cryptography; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - array^ random = gcnew array(100); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - rng->GetBytes( random ); // The array is now filled with cryptographically strong random bytes. - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp deleted file mode 100644 index c9dcb18468c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Cryptography; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - array^ random = gcnew array(100); - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - rng->GetNonZeroBytes( random ); // The array is now filled with cryptographically strong random bytes, and none are zero. - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp deleted file mode 100644 index ebd4a81690e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -int main() -{ - - // Creates a resource writer. - IResourceWriter^ writer = gcnew ResourceWriter( "myResources.resources" ); - - // Adds resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Writes the resources to the file or stream, and closes it. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp deleted file mode 100644 index aa1b6553ab8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Print the byte array in a readable format. -void PrintByteArray( array^array ) -{ - int i; - for ( i = 0; i < array->Length; i++ ) - { - Console::Write( String::Format( "{0:X2}", array[ i ] ) ); - if ( (i % 4) == 3 ) - Console::Write( " " ); - - } - Console::WriteLine(); -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "Usage: hashdir " ); - return 0; - } - - try - { - - // Create a DirectoryInfo object representing the specified directory. - DirectoryInfo^ dir = gcnew DirectoryInfo( args[ 1 ] ); - - // Get the FileInfo objects for every file in the directory. - array^files = dir->GetFiles(); - - // Initialize a SHA256 hash object. - SHA256 ^ mySHA256 = SHA256Managed::Create(); - array^hashValue; - - // Compute and print the hash values for each file in directory. - System::Collections::IEnumerator^ myEnum = files->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FileInfo^ fInfo = safe_cast(myEnum->Current); - - // Create a fileStream for the file. - FileStream^ fileStream = fInfo->Open( FileMode::Open ); - - // Compute the hash of the fileStream. - hashValue = mySHA256->ComputeHash( fileStream ); - - // Write the name of the file to the Console. - Console::Write( "{0}: ", fInfo->Name ); - - // Write the hash value to the Console. - PrintByteArray( hashValue ); - - // Close the file. - fileStream->Close(); - } - return 0; - } - catch ( DirectoryNotFoundException^ ) - { - Console::WriteLine( "Error: The directory specified could not be found." ); - } - catch ( IOException^ ) - { - Console::WriteLine( "Error: A file in the directory could not be accessed." ); - } - -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp deleted file mode 100644 index 471fe0f815a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - SHA384^ shaM = gcnew SHA384Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp deleted file mode 100644 index 6a0aa345a43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - - SHA384^ shaM = gcnew SHA384Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp deleted file mode 100644 index 2a84c2dc7ba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - SHA512^ shaM = gcnew SHA512Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp deleted file mode 100644 index a22a11fb2ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Data; -using namespace System::Security::Cryptography; - -public ref class Sample -{ -protected: - void Method() - { - int DATA_SIZE = 1024; - - // - array^ data = gcnew array( DATA_SIZE ); - array^ result; - - SHA512^ shaM = gcnew SHA512Managed; - result = shaM->ComputeHash( data ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp deleted file mode 100644 index c7e0914d780..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp +++ /dev/null @@ -1,27 +0,0 @@ -using namespace System; -using namespace System::Collections; - -public ref class SamplesSortedList -{ -public: - static void Main() - { - // Creates and initializes a new SortedList. - SortedList^ mySortedList = gcnew SortedList(); - mySortedList->Add("Third", "!"); - mySortedList->Add("Second", "World"); - mySortedList->Add("First", "Hello"); - - // - for each (DictionaryEntry de in mySortedList) - { - //... - } - // - } -}; - -int main() -{ - SamplesSortedList::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp deleted file mode 100644 index bc3817bdcfe..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -public ref class SamplesSortedList -{ -public: - static void PrintKeysAndValues( SortedList^ myList ) - { - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); - } - -}; - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "Third", "!" ); - mySL->Add( "Second", "World" ); - mySL->Add( "First", "Hello" ); - - // Displays the properties and values of the SortedList. - Console::WriteLine( "mySL" ); - Console::WriteLine( " Count: {0}", mySL->Count ); - Console::WriteLine( " Capacity: {0}", mySL->Capacity ); - Console::WriteLine( " Keys and Values:" ); - SamplesSortedList::PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -mySL -Count: 3 -Capacity: 16 -Keys and Values: --KEY- -VALUE- -First: Hello -Second: World -Third: ! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp deleted file mode 100644 index ce1205d460a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "one", "The" ); - mySL->Add( "two", "quick" ); - mySL->Add( "three", "brown" ); - mySL->Add( "four", "fox" ); - - // Displays the SortedList. - Console::WriteLine( "The SortedList contains the following:" ); - PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -The SortedList contains the following: - -KEY- -VALUE- - four: fox - one: The - three: brown - two: quick -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp deleted file mode 100644 index d4b3dbf1600..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "one", "The" ); - mySL->Add( "two", "quick" ); - mySL->Add( "three", "brown" ); - mySL->Add( "four", "fox" ); - mySL->Add( "five", "jumps" ); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); - - // Trims the SortedList. - mySL->TrimToSize(); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "After TrimToSize," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); - - // Clears the SortedList. - mySL->Clear(); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); - - // Trims the SortedList again. - mySL->TrimToSize(); - - // Displays the count, capacity and values of the SortedList. - Console::WriteLine( "After the second TrimToSize," ); - Console::WriteLine( " Count : {0}", mySL->Count ); - Console::WriteLine( " Capacity : {0}", mySL->Capacity ); - Console::WriteLine( " Values:" ); - PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -Initially, - Count : 5 - Capacity : 16 - Values: - -KEY- -VALUE- - five: jumps - four: fox - one: The - three: brown - two: quick - -After TrimToSize, - Count : 5 - Capacity : 5 - Values: - -KEY- -VALUE- - five: jumps - four: fox - one: The - three: brown - two: quick - -After Clear, - Count : 0 - Capacity : 16 - Values: - -KEY- -VALUE- - -After the second TrimToSize, - Count : 0 - Capacity : 16 - Values: - -KEY- -VALUE- - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp deleted file mode 100644 index e233d2f4884..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i, myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 2, "two" ); - mySL->Add( 4, "four" ); - mySL->Add( 1, "one" ); - mySL->Add( 3, "three" ); - mySL->Add( (int^)0, "zero" ); - - // Displays the values of the SortedList. - Console::WriteLine( "The SortedList contains the following values:" ); - PrintIndexAndKeysAndValues( mySL ); - - // Searches for a specific key. - int myKey = 2; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, mySL->ContainsKey( myKey ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); - myKey = 6; - Console::WriteLine( "The key \"{0}\" is {1}.", myKey, mySL->ContainsKey( myKey ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); - - // Searches for a specific value. - String^ myValue = "three"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, mySL->ContainsValue( myValue ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); - myValue = "nine"; - Console::WriteLine( "The value \"{0}\" is {1}.", myValue, mySL->ContainsValue( myValue ) ? (String^)"in the SortedList" : "NOT in the SortedList" ); -} - -/* -This code produces the following output. - -The SortedList contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 three - [4]: 4 four - -The key "2" is in the SortedList. -The key "6" is NOT in the SortedList. -The value "three" is in the SortedList. -The value "nine" is NOT in the SortedList. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 5bb708f958a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -using namespace System; -using namespace System::Collections; -void PrintValues( array^ myArr, Char mySeparator ); -int main() -{ - - // Creates and initializes the source SortedList. - SortedList^ mySourceList = gcnew SortedList; - mySourceList->Add( 2, "cats" ); - mySourceList->Add( 3, "in" ); - mySourceList->Add( 1, "napping" ); - mySourceList->Add( 4, "the" ); - mySourceList->Add( 0, "three" ); - mySourceList->Add( 5, "barn" ); - - // Creates and initializes the one-dimensional target Array. - array^tempArray = {"The","quick","brown","fox","jumps","over","the","lazy","dog"}; - array^myTargetArray = gcnew array(15); - int i = 0; - IEnumerator^ myEnum = tempArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ s = safe_cast(myEnum->Current); - myTargetArray[ i ].Key = i; - myTargetArray[ i ].Value = s; - i++; - } - - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source SortedList to the target SortedList, starting at index 6. - mySourceList->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); -} - -void PrintValues( array^ myArr, Char mySeparator ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::Write( "{0}{1}", mySeparator, myArr[ i ].Value ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp deleted file mode 100644 index 987dd455be0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 1.3, "fox" ); - mySL->Add( 1.4, "jumps" ); - mySL->Add( 1.5, "over" ); - mySL->Add( 1.2, "brown" ); - mySL->Add( 1.1, "quick" ); - mySL->Add( 1.0, "The" ); - mySL->Add( 1.6, "the" ); - mySL->Add( 1.8, "dog" ); - mySL->Add( 1.7, "lazy" ); - - // Gets the key and the value based on the index. - int myIndex = 3; - Console::WriteLine( "The key at index {0} is {1}.", myIndex, mySL->GetKey( myIndex ) ); - Console::WriteLine( "The value at index {0} is {1}.", myIndex, mySL->GetByIndex( myIndex ) ); - - // Gets the list of keys and the list of values. - IList^ myKeyList = mySL->GetKeyList(); - IList^ myValueList = mySL->GetValueList(); - - // Prints the keys in the first column and the values in the second column. - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < mySL->Count; i++ ) - Console::WriteLine( "\t{0}\t{1}", myKeyList[ i ], myValueList[ i ] ); -} - -/* -This code produces the following output. - -The key at index 3 is 1.3. -The value at index 3 is fox. - -KEY- -VALUE- - 1 The - 1.1 quick - 1.2 brown - 1.3 fox - 1.4 jumps - 1.5 over - 1.6 the - 1.7 lazy - 1.8 dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp deleted file mode 100644 index e9197a41dd1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i, myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 1, "one" ); - mySL->Add( 3, "three" ); - mySL->Add( 2, "two" ); - mySL->Add( 4, "four" ); - mySL->Add( 0, "zero" ); - - // Displays the values of the SortedList. - Console::WriteLine( "The SortedList contains the following values:" ); - PrintIndexAndKeysAndValues( mySL ); - - // Searches for a specific key. - int myKey = 2; - Console::WriteLine( "The key \"{0}\" is at index {1}.", myKey, mySL->IndexOfKey( myKey ) ); - - // Searches for a specific value. - String^ myValue = "three"; - Console::WriteLine( "The value \"{0}\" is at index {1}.", myValue, mySL->IndexOfValue( myValue ) ); -} - -/* -This code produces the following output. - -The SortedList contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 three - [4]: 4 four - -The key "2" is at index 2. -The value "three" is at index 3. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 3808b907c27..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 2, "two" ); - mySL->Add( 3, "three" ); - mySL->Add( 1, "one" ); - mySL->Add( (int^)0, "zero" ); - mySL->Add( 4, "four" ); - - // Creates a synchronized wrapper around the SortedList. - SortedList^ mySyncdSL = SortedList::Synchronized( mySL ); - - // Displays the sychronization status of both SortedLists. - Console::WriteLine( "mySL is {0}.", mySL->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdSL is {0}.", mySyncdSL->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* -This code produces the following output. - -mySL is not synchronized. -mySyncdSL is synchronized. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index fb191eafec5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesSortedList -{ -public: - static void Main() - { - // - SortedList^ myCollection = gcnew SortedList(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesSortedList::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp deleted file mode 100644 index 86e30997f0a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t{0}:\t{1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "3c", "dog" ); - mySL->Add( "2c", "over" ); - mySL->Add( "1c", "brown" ); - mySL->Add( "1a", "The" ); - mySL->Add( "1b", "quick" ); - mySL->Add( "3a", "the" ); - mySL->Add( "3b", "lazy" ); - mySL->Add( "2a", "fox" ); - mySL->Add( "2b", "jumps" ); - - // Displays the SortedList. - Console::WriteLine( "The SortedList initially contains the following:" ); - PrintKeysAndValues( mySL ); - - // Removes the element with the key "3b". - mySL->Remove( "3b" ); - - // Displays the current state of the SortedList. - Console::WriteLine( "After removing \"lazy\":" ); - PrintKeysAndValues( mySL ); - - // Removes the element at index 5. - mySL->RemoveAt( 5 ); - - // Displays the current state of the SortedList. - Console::WriteLine( "After removing the element at index 5:" ); - PrintKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -The SortedList initially contains the following: - -KEY- -VALUE- - 1a: The - 1b: quick - 1c: brown - 2a: fox - 2b: jumps - 2c: over - 3a: the - 3b: lazy - 3c: dog - -After removing "lazy": - -KEY- -VALUE- - 1a: The - 1b: quick - 1c: brown - 2a: fox - 2b: jumps - 2c: over - 3a: the - 3c: dog - -After removing the element at index 5: - -KEY- -VALUE- - 1a: The - 1b: quick - 1c: brown - 2a: fox - 2b: jumps - 3a: the - 3c: dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp deleted file mode 100644 index 71da886cdc1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -void PrintIndexAndKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( "\t-INDEX-\t-KEY-\t-VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( "\t[{0}]:\t{1}\t{2}", i, myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new SortedList. - SortedList^ mySL = gcnew SortedList; - mySL->Add( 2, "two" ); - mySL->Add( 3, "three" ); - mySL->Add( 1, "one" ); - mySL->Add( 0, "zero" ); - mySL->Add( 4, "four" ); - - // Displays the values of the SortedList. - Console::WriteLine( "The SortedList contains the following values:" ); - PrintIndexAndKeysAndValues( mySL ); - - // Replaces the values at index 3 and index 4. - mySL->SetByIndex( 3, "III" ); - mySL->SetByIndex( 4, "IV" ); - - // Displays the updated values of the SortedList. - Console::WriteLine( "After replacing the value at index 3 and index 4," ); - PrintIndexAndKeysAndValues( mySL ); -} - -/* -This code produces the following output. - -The SortedList contains the following values: - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 three - [4]: 4 four - -After replacing the value at index 3 and index 4, - -INDEX- -KEY- -VALUE- - [0]: 0 zero - [1]: 1 one - [2]: 2 two - [3]: 3 III - [4]: 4 IV -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp deleted file mode 100644 index fd38bcf4520..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "Hello" ); - myStack->Push( "World" ); - myStack->Push( "!" ); - - // Displays the properties and values of the Stack. - Console::WriteLine( "myStack" ); - Console::WriteLine( "\tCount: {0}", myStack->Count ); - Console::Write( "\tValues:" ); - PrintValues( myStack ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - myStack - Count: 3 - Values: ! World Hello - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp deleted file mode 100644 index a60b6d00fde..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection ); -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "The" ); - myStack->Push( "quick" ); - myStack->Push( "brown" ); - myStack->Push( "fox" ); - myStack->Push( "jumps" ); - - // Displays the count and values of the Stack. - Console::WriteLine( "Initially," ); - Console::WriteLine( " Count : {0}", myStack->Count ); - Console::Write( " Values:" ); - PrintValues( myStack ); - - // Clears the Stack. - myStack->Clear(); - - // Displays the count and values of the Stack. - Console::WriteLine( "After Clear," ); - Console::WriteLine( " Count : {0}", myStack->Count ); - Console::Write( " Values:" ); - PrintValues( myStack ); -} - -void PrintValues( IEnumerable^ myCollection ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Initially, - Count : 5 - Values: jumps fox brown quick The - After Clear, - Count : 0 - Values: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp deleted file mode 100644 index ae4b0f72df0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( Array^ myArr, char mySeparator ); -int main() -{ - // Creates and initializes the source Stack. - Stack^ mySourceQ = gcnew Stack; - mySourceQ->Push( "barn" ); - mySourceQ->Push( "the" ); - mySourceQ->Push( "in" ); - mySourceQ->Push( "cats" ); - mySourceQ->Push( "napping" ); - mySourceQ->Push( "three" ); - - // Creates and initializes the one-dimensional target Array. - Array^ myTargetArray = Array::CreateInstance( String::typeid, 15 ); - myTargetArray->SetValue( "The", 0 ); - myTargetArray->SetValue( "quick", 1 ); - myTargetArray->SetValue( "brown", 2 ); - myTargetArray->SetValue( "fox", 3 ); - myTargetArray->SetValue( "jumps", 4 ); - myTargetArray->SetValue( "over", 5 ); - myTargetArray->SetValue( "the", 6 ); - myTargetArray->SetValue( "lazy", 7 ); - myTargetArray->SetValue( "dog", 8 ); - - // Displays the values of the target Array. - Console::WriteLine( "The target Array contains the following (before and after copying):" ); - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Stack to the target Array, starting at index 6. - mySourceQ->CopyTo( myTargetArray, 6 ); - - // Displays the values of the target Array. - PrintValues( myTargetArray, ' ' ); - - // Copies the entire source Stack to a new standard array. - array^myStandardArray = mySourceQ->ToArray(); - - // Displays the values of the new standard array. - Console::WriteLine( "The new standard array contains the following:" ); - PrintValues( myStandardArray, ' ' ); -} - -void PrintValues( Array^ myArr, char mySeparator ) -{ - IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ myObj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, myObj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - The new standard array contains the following: - three napping cats in the barn - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp deleted file mode 100644 index 7b964e928e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "The" ); - myStack->Push( "quick" ); - myStack->Push( "brown" ); - myStack->Push( "fox" ); - - // Creates a synchronized wrapper around the Stack. - Stack^ mySyncdStack = Stack::Synchronized( myStack ); - - // Displays the sychronization status of both Stacks. - Console::WriteLine( "myStack is {0}.", myStack->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); - Console::WriteLine( "mySyncdStack is {0}.", mySyncdStack->IsSynchronized ? (String^)"synchronized" : "not synchronized" ); -} - -/* -This code produces the following output. - -myStack is not synchronized. -mySyncdStack is synchronized. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp deleted file mode 100644 index d44a2d7b9a1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class SamplesStack -{ -public: - static void Main() - { - // - Stack^ myCollection = gcnew Stack(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesStack::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp deleted file mode 100644 index 1e77a8f04a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -void PrintValues( IEnumerable^ myCollection, char mySeparator ); -int main() -{ - - // Creates and initializes a new Stack. - Stack^ myStack = gcnew Stack; - myStack->Push( "The" ); - myStack->Push( "quick" ); - myStack->Push( "brown" ); - myStack->Push( "fox" ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); - - // Removes an element from the Stack. - Console::WriteLine( "(Pop)\t\t{0}", myStack->Pop() ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); - - // Removes another element from the Stack. - Console::WriteLine( "(Pop)\t\t{0}", myStack->Pop() ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); - - // Views the first element in the Stack but does not remove it. - Console::WriteLine( "(Peek)\t\t{0}", myStack->Peek() ); - - // Displays the Stack. - Console::Write( "Stack values:" ); - PrintValues( myStack, '\t' ); -} - -void PrintValues( IEnumerable^ myCollection, char mySeparator ) -{ - IEnumerator^ myEnum = myCollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::Write( "{0}{1}", mySeparator, obj ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Stack values: fox brown quick The - (Pop) fox - Stack values: brown quick The - (Pop) brown - Stack values: quick The - (Peek) quick - Stack values: quick The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp deleted file mode 100644 index 63fd237a4c2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Write ); - if ( fs->CanRead && fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt can be both written to and read from." ); - } - else - if ( fs->CanWrite ) - { - Console::WriteLine( "MyFile.txt is writable." ); - } -} - -//This code outputs "MyFile.txt is writable." -//To get the output message "MyFile.txt can be both written to and read from.", -//change the FileAccess parameter to ReadWrite in the FileStream constructor. -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp deleted file mode 100644 index e644fe2a10f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -public ref class Block -{ -public: - static void Main() - { - Stream^ s = gcnew MemoryStream(); - for (int i = 0; i < 100; i++) - { - s->WriteByte((Byte)i); - } - s->Position = 0; - - // Now read s into a byte buffer. - array^ bytes = gcnew array(s->Length); - int numBytesToRead = (int) s->Length; - int numBytesRead = 0; - while (numBytesToRead > 0) - { - // Read may return anything from 0 to 10. - int n = s->Read(bytes, numBytesRead, 10); - // The end of the file is reached. - if (n == 0) - { - break; - } - numBytesRead += n; - numBytesToRead -= n; - } - s->Close(); - // numBytesToRead should be 0 now, and numBytesRead should - // equal 100. - Console::WriteLine("number of bytes read: {0:d}", numBytesRead); - } -}; - -int main() -{ - Block::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp deleted file mode 100644 index 035727fe0c6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - FileStream^ sb = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate ); - array^b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'}; - StreamWriter^ sw = gcnew StreamWriter( sb ); - sw->Write( b, 3, 8 ); - sw->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp deleted file mode 100644 index cf774966a53..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -public ref class SomeClass -{ -// -private: - static BooleanSwitch^ boolSwitch = gcnew BooleanSwitch("mySwitch", - "Switch in config file"); - -public: - static void Main( ) - { - //... - Console::WriteLine("Boolean switch {0} configured as {1}", - boolSwitch->DisplayName, ((Boolean^)boolSwitch->Enabled)->ToString()); - if (boolSwitch->Enabled) - { - //... - } - } -// -}; - -int main() -{ - SomeClass::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp deleted file mode 100644 index 35f255928a0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -// -// The following are possible values for the new switch. -public enum class MethodTracingSwitchLevel -{ - Off = 0, - EnteringMethod = 1, - ExitingMethod = 2, - Both = 3 -}; - - -// -// -public ref class MyMethodTracingSwitch: public Switch -{ -protected: - bool outExit; - bool outEnter; - MethodTracingSwitchLevel level; - -public: - MyMethodTracingSwitch( String^ displayName, String^ description ) - : Switch( displayName, description ) - {} - - property MethodTracingSwitchLevel Level - { - MethodTracingSwitchLevel get() - { - return level; - } - - void set( MethodTracingSwitchLevel value ) - { - SetSwitchSetting( (int)value ); - } - } - -protected: - void SetSwitchSetting( int value ) - { - if ( value < 0 ) - { - value = 0; - } - - if ( value > 3 ) - { - value = 3; - } - - level = (MethodTracingSwitchLevel)value; - outEnter = false; - if ((value == (int)MethodTracingSwitchLevel::EnteringMethod) || - (value == (int)MethodTracingSwitchLevel::Both)) - { - outEnter = true; - } - - outExit = false; - if ((value == (int)MethodTracingSwitchLevel::ExitingMethod) || - (value == (int)MethodTracingSwitchLevel::Both)) - { - outExit = true; - } - } - -public: - property bool OutputExit - { - bool get() - { - return outExit; - } - } - - property bool OutputEnter - { - bool get() - { - return outEnter; - } - } -}; - - -// -// -public ref class Class1 -{ -private: - - /* Create an instance of MyMethodTracingSwitch.*/ - static MyMethodTracingSwitch^ mySwitch = - gcnew MyMethodTracingSwitch( "Methods","Trace entering and exiting method" ); - -public: - static void main() - { - // Add the console listener to see trace messages as console output - Trace::Listeners->Add(gcnew ConsoleTraceListener(true)); - Debug::AutoFlush = true; - - // Set the switch level to both enter and exit - mySwitch->Level = MethodTracingSwitchLevel::Both; - - // Write a diagnostic message if the switch is set to entering. - Debug::WriteLineIf(mySwitch->OutputEnter, "Entering Main"); - - // Insert code to handle processing here... - - // Write another diagnostic message if the switch is set to exiting. - Debug::WriteLineIf(mySwitch->OutputExit, "Exiting Main"); - } -}; -// - -int main() -{ - Class1::main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp deleted file mode 100644 index 830c7d9c618..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -// -void main() -{ - #if defined(TRACE) - // Create a file for output named TestFile.txt. - Stream^ myFile = File::Create( "TestFile.txt" ); - - // Create a new text writer using the output stream and - // add it to the trace listeners. - TextWriterTraceListener^ myTextListener = - gcnew TextWriterTraceListener( myFile ); - Trace::Listeners->Add( myTextListener ); - - // Write output to the file. - Trace::Write( "Test output " ); - - // Flush the output. - Trace::Flush(); - Trace::Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp deleted file mode 100644 index e338a01270a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -void main() -{ - #if defined(TRACE) - TextWriterTraceListener^ myTextListener = nullptr; - - // Create a file for output named TestFile.txt. - String^ myFileName = "TestFile.txt"; - StreamWriter^ myOutputWriter = gcnew StreamWriter( myFileName,true ); - - // Add a TextWriterTraceListener for the file. - if ( myOutputWriter ) - { - myTextListener = gcnew TextWriterTraceListener( myOutputWriter ); - Trace::Listeners->Add( myTextListener ); - } - - // Write trace output to all trace listeners. - Trace::WriteLine( - String::Concat( DateTime::Now.ToString(), " - Trace output" ) ); - if ( myTextListener ) - { - // Remove and close the file writer/trace listener. - myTextListener->Flush(); - Trace::Listeners->Remove( myTextListener ); - myTextListener->Close(); - } - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp deleted file mode 100644 index a8af3ae4585..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -// -void main() -{ - #if defined(TRACE) - // Create a text writer that writes to the console screen and add - // it to the trace listeners. - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - - // Write the output to the console screen. - myWriter->Write( "Write to console screen. " ); - myWriter->WriteLine( "Again, write to the Console screen." ); - - // Flush and close the output. - myWriter->Flush(); - myWriter->Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp deleted file mode 100644 index 17598cbac6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -// -void main() -{ - #if defined(TRACE) - // Create a text writer that writes to the console screen and add - // it to the trace listeners. - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - - // Write the output to the console screen. - myWriter->Write( "Write to the Console screen. " ); - myWriter->WriteLine( "Again, write to console screen." ); - - // Flush and close the output. - myWriter->Flush(); - myWriter->Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp deleted file mode 100644 index aed5e7442ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Sample -{ -protected: - void Method() - { - // - #if defined(TRACE) - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - #endif - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp deleted file mode 100644 index bfaeea7c89b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// Specify /DTRACE when compiling. - -#using -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - #if defined(TRACE) - Trace::Listeners->Add( gcnew TextWriterTraceListener( Console::Out ) ); - Trace::AutoFlush = true; - Trace::Indent(); - Trace::WriteLine( "Entering Main" ); - #endif - Console::WriteLine( "Hello World." ); - #if defined(TRACE) - Trace::WriteLine( "Exiting Main" ); - Trace::Unindent(); - #endif - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp deleted file mode 100644 index bf1accda6fd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -protected: - // Create an index for an array. - int index; - - void Method() - { - // Perform some action that sets the index. - // Test that the index value is valid. - #if defined(TRACE) - Trace::Assert( index > -1 ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp deleted file mode 100644 index b8c99bf228b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -public: - static void MyMethod( Type^ type, Type^ baseType ) - { - #if defined(TRACE) - Trace::Assert( type != nullptr, "Type parameter is null" ); - #endif - - // Perform some processing. - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp deleted file mode 100644 index 862da8804df..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -public: - static void MyMethod( Type^ type, Type^ baseType ) - { - #if defined(TRACE) - Trace::Assert( type != nullptr, "Type parameter is null", "Can't get object for null type" ); - #endif - - // Perform some processing. - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp deleted file mode 100644 index 7f8c353e0c2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - enum class Option - { - First, Second - }; - -protected: - double result; - -public: - void Method( Option option ) - { - try - { - // try something here - } - // - catch ( Exception^ ) - { - #if defined(TRACE) - Trace::Fail( "Unknown Option " + option + ", using the default." ); - #endif - } - // - - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(TRACE) - Trace::Fail(String::Format("Unknown Option {0}", option)); - #endif - result = 1.0; - break; - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp deleted file mode 100644 index 377a4428493..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - enum class Option - { - First, Second - }; - -protected: - double result; - -public: - void Method( Option option, String^ userInput ) - { - int value = 0; - int newValue = 1; - try - { - value = Int32::Parse( userInput ); - } - // - catch ( Exception^ ) - { - #if defined(TRACE) - Trace::Fail( String::Format( "Invalid value: {0}", value ), - "Resetting value to newValue." ); - #endif - value = newValue; - } - // - - // - switch ( option ) - { - case Option::First: - result = 1.0; - break; - - // Insert additional cases. - - default: - #if defined(TRACE) - Trace::Fail( String::Format( "Unsupported option {0}", option ), - "Result set to 1.0" ); - #endif - result = 1.0; - break; - } - // - } - -}; - -void main() -{ - Form1^ myForm = gcnew Form1; - myForm->Method( Form1::Option::Second, "not an integer string" ); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp deleted file mode 100644 index 00e2126d795..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Specify /DTRACE when compiling. - -#using -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -void main() -{ - #if defined(TRACE) - // Create a file for output named TestFile.txt. - FileStream^ myFileStream = - gcnew FileStream( "TestFile.txt", FileMode::Append ); - - // Create a new text writer using the output stream - // and add it to the trace listeners. - TextWriterTraceListener^ myTextListener = - gcnew TextWriterTraceListener( myFileStream ); - Trace::Listeners->Add( myTextListener ); - - // Write output to the file. - Trace::WriteLine( "Test output" ); - - // Flush and close the output stream. - Trace::Flush(); - Trace::Close(); - #endif -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp deleted file mode 100644 index 8465839ad87..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - Trace::WriteLine( "List of errors:" ); - Trace::Indent(); - Trace::WriteLine( "Error 1: File not found" ); - Trace::WriteLine( "Error 2: Directory not found" ); - Trace::Unindent(); - Trace::WriteLine( "End of list of errors" ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp deleted file mode 100644 index aaba2c756c3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Class1 -{ -public: - void Method() - { - // - // Create a ConsoletTraceListener and add it to the trace listeners. - #if defined(TRACE) - ConsoleTraceListener^ myWriter = gcnew ConsoleTraceListener( ); - Trace::Listeners->Add( myWriter ); - #endif - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp deleted file mode 100644 index b5c173d444f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod() - { - // Write the message if the TraceSwitch level is set - // to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "My error message. " ); - } - - // Write a second message if the TraceSwitch level is set - // to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( "My second error message." ); - } - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp deleted file mode 100644 index 6aa428982f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( myObject ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( " is not a valid value for this method." ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp deleted file mode 100644 index c37eb6cb2bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::Write( String::Concat( myObject, - " is not a valid object for category: " ), category ); - } - - // Write a second message if the TraceSwitch level is set to - // Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::WriteLine( " Please use a different category." ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp deleted file mode 100644 index 815cd36e34c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::Write( myObject, category ); - } - - // Write a second message if the TraceSwitch level is set to - // Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::WriteLine( " Object is not valid for this category." ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp deleted file mode 100644 index 49f4eaff259..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod() - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to - // Error or higher. - Trace::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message." ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp deleted file mode 100644 index 14dfd2e3487..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, myObject ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - " is not a valid value for this method." ); - #endif - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp deleted file mode 100644 index fa99d333ccc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - Trace::WriteIf( generalSwitch->TraceVerbose, - String::Concat( myObject, - " is not a valid object for category: " ), category ); - - // Write a second message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteLineIf( generalSwitch->TraceError, - " Please use a different category." ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp deleted file mode 100644 index 7b433a3415c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set to Verbose. - Trace::WriteIf( generalSwitch->TraceVerbose, myObject, category ); - - // Write a second message if the TraceSwitch level is set to - // Error or higher. - Trace::WriteLineIf( generalSwitch->TraceError, - " Object is not valid for this category." ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp deleted file mode 100644 index 69e7837f9bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "Invalid object. " ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( myObject ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp deleted file mode 100644 index 408ce11e5e2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "My error message. " ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( "My second error message.", category ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp deleted file mode 100644 index 9b663621991..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - if ( generalSwitch->TraceError ) - { - Trace::Write( "Invalid object for category. " ); - } - - // Write a second message if the TraceSwitch level - // is set to Verbose. - if ( generalSwitch->TraceVerbose ) - { - Trace::WriteLine( myObject, category ); - } - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp deleted file mode 100644 index e0248f58cc3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level - // is set to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, "Invalid object. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, myObject ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp deleted file mode 100644 index f0ced96de43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, "My error message. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - "My second error message.", category ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp deleted file mode 100644 index 3b1d19efcba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -using namespace System; -using namespace System::Diagnostics; - -public ref class Test -{ -// -// Class-level declaration. -// Create a TraceSwitch. -private: - static TraceSwitch^ generalSwitch = - gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyErrorMethod( Object^ myObject, String^ category ) - { - #if defined(TRACE) - // Write the message if the TraceSwitch level is set - // to Error or higher. - Trace::WriteIf( generalSwitch->TraceError, - "Invalid object for category. " ); - - // Write a second message if the TraceSwitch level is set - // to Verbose. - Trace::WriteLineIf( generalSwitch->TraceVerbose, - myObject, category ); - #endif - } -// -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp deleted file mode 100644 index 0839abd6837..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - /* Create a listener, which outputs to the console screen, and - * add it to the trace listeners. */ - TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; - myWriter->Writer = System::Console::Out; - Trace::Listeners->Add( myWriter ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp deleted file mode 100644 index f2af2f1ef67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "mySwitch","Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( mySwitch->TraceError ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp deleted file mode 100644 index 1c6a7b5ea20..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; - -public ref class TraceErr -{ -// -private: - static TraceSwitch^ appSwitch = gcnew TraceSwitch("mySwitch", - "Switch in config file"); - -public: - static void Main(array^ args) - { - //... - Console::WriteLine("Trace switch {0} configured as {1}", - appSwitch->DisplayName, appSwitch->Level.ToString()); - if (appSwitch->TraceError) - { - //... - } - } -// -}; - -int main() -{ - array^ args = gcnew array{}; - TraceErr::Main(args); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp deleted file mode 100644 index 7806bc0fb37..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Error or higher. - if ( mySwitch->TraceError ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp deleted file mode 100644 index b3d9962e4cc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Info or higher. - if ( mySwitch->TraceInfo ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp deleted file mode 100644 index 9135da63a48..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // - // Class-level declaration. - /* Create a TraceSwitch to use in the entire application.*/ -private: - static TraceSwitch^ mySwitch = gcnew TraceSwitch( "General", "Entire Application" ); - -public: - static void MyMethod() - { - // Write the message if the TraceSwitch level is set to Warning or higher. - if ( mySwitch->TraceWarning ) - Console::WriteLine( "My error message." ); - - // Write the message if the TraceSwitch level is set to Verbose. - if ( mySwitch->TraceVerbose ) - Console::WriteLine( "My second error message." ); - } - - static void main() - { - // Run the method that prints error messages based on the switch level. - MyMethod(); - } - // -}; - -int main() -{ - Form1::main(); -} diff --git a/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp b/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp deleted file mode 100644 index 6f8b7354593..00000000000 --- a/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -using namespace System; -using namespace System::Runtime::ConstrainedExecution; - -[assembly:ReliabilityContractAttribute( - Consistency::MayCorruptInstance, Cer::None)]; -namespace ReliabilityLibrary -{ - class SomeClass {}; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp deleted file mode 100644 index 56d68e22b91..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic DnsPermissionAttributeExample/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -#using - -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Net; -using namespace System; - -// -//Uses the DnsPermissionAttribute to restrict access only to those who have permission. - -[DnsPermission(SecurityAction::Demand,Unrestricted=true)] -public ref class MyClass -{ -public: - static IPAddress^ GetIPAddress() - { - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - return ipAddress; - } - -}; - -int main() -{ - try - { - - //Grants Access. - Console::WriteLine( " Access granted\n The local host IP Address is :{0}", MyClass::GetIPAddress() ); - } - // Denies Access. - catch ( SecurityException^ securityException ) - { - Console::WriteLine( "Access denied" ); - Console::WriteLine( securityException->ToString() ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp deleted file mode 100644 index 4613eef8236..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -using namespace System; -using namespace System::Runtime::Serialization; - -// Class added so sample will compile -ref class Node -{ -public: - Node( int /*i*/ ){} -}; - -// -// A serializable LinkedList example. For the full LinkedList implementation -// see the Serialization sample. -[Serializable] -ref class LinkedList: public ISerializable -{ -private: - Node^ m_head; - Node^ m_tail; - - // Serializes the object. -public: - virtual void GetObjectData( SerializationInfo^ info, StreamingContext /*context*/ ) - { - // Stores the m_head and m_tail references in the SerializationInfo info. - info->AddValue( "head", m_head, m_head->GetType() ); - info->AddValue( "tail", m_tail, m_tail->GetType() ); - } - - // Constructor that is called automatically during deserialization. -private: - // Reconstructs the object from the information in SerializationInfo info - LinkedList( SerializationInfo^ info, StreamingContext /*context*/ ) - { - Node^ temp = gcnew Node( 0 ); - // Retrieves the values of Type temp.GetType() from SerializationInfo info - m_head = dynamic_cast(info->GetValue( "head", temp->GetType() )); - m_tail = dynamic_cast(info->GetValue( "tail", temp->GetType() )); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp deleted file mode 100644 index 1b5f86b7e5c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_Constructor/CPP/dateclient_socketpermission_constructor.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -This program demonstrates the 'SocketPermission(PermissionState)', -'SocketPermission(NetworkAccess, TransportType, String*, int) constructors, -'FromXml', 'Intersect', 'AddPermission' methods and 'AllPorts' field -of 'SocketPermission' class. - -This program provides a class called 'DateClient' that functions as a client -for a 'DateServer'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateClient' class -provides a method called 'GetDate' which returns the current date on the server. -The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -TransportType, String*, int)' constructor. A third 'SocketPermission' Object* is -formed from the intersection of the above two 'SocketPermission' objects with the -use of the 'Intersect' method of 'SocketPermission' class. This 'SocketPermission' -Object* is used by the 'GetDate' method to verify the permissions of the calling -method. If the calling method has the requisite permissions the 'GetDate' method -connects to the 'DateServer' and returns the current date that the 'DateServer' -sends. If any exception occurs the 'GetDate' method returns an empty String*. - -Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Security; -using namespace System::Security::Permissions; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateClient_SocketPermission_Constructor" ); - Console::WriteLine( "\tDateClient_SocketPermission_Constructor " ); - Console::WriteLine( "\tThe ipaddress argument is the ip address of the Date server." ); - Console::WriteLine( "\tThe port argument is the port of the Date server." ); -} - -public ref class DateClient -{ -private: - Socket^ serverSocket; - Encoding^ asciiEncoding; - IPAddress^ serverAddress; - - int serverPort; - -public: - // The constructor takes the address and port of the remote server. - DateClient( IPAddress^ ipAddress, int port ) - { - serverAddress = ipAddress; - serverPort = port; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - asciiEncoding = Encoding::ASCII; - } - - String^ GetDate() - { -// -// -// -// -// -// - SocketPermission^ socketPermission1 = gcnew SocketPermission( PermissionState::Unrestricted ); - - // Create a 'SocketPermission' Object* for two ip addresses. - SocketPermission^ socketPermission2 = gcnew SocketPermission( PermissionState::None ); - SecurityElement^ securityElement1 = socketPermission2->ToXml(); - // 'SocketPermission' Object* for 'Connect' permission - SecurityElement^ securityElement2 = gcnew SecurityElement( "ConnectAccess" ); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All'ports for the ip-address. - SecurityElement^ securityElement3 = gcnew SecurityElement( "URI","192.168.144.238#-1#3" ); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and - // for 'All' ports for the ip-address. - SecurityElement^ securityElement4 = gcnew SecurityElement( "URI","192.168.144.240#-1#3" ); - securityElement2->AddChild( securityElement3 ); - securityElement2->AddChild( securityElement4 ); - securityElement1->AddChild( securityElement2 ); - - // Obtain a 'SocketPermission' Object* using 'FromXml' method. - socketPermission2->FromXml( securityElement1 ); - - Console::WriteLine( "\nDisplays the result of FromXml method : \n" ); - Console::WriteLine( socketPermission2 ); - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission^ socketPermission3 = - gcnew SocketPermission( NetworkAccess::Connect, - TransportType::All, - "192.168.144.238", - SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3->AddPermission( NetworkAccess::Connect, - TransportType::All, - "192.168.144.239", - SocketPermission::AllPorts ); - - Console::WriteLine( "Displays the result of AddPermission method : \n" ); - Console::WriteLine( socketPermission3 ); - - // Find the intersection between two 'SocketPermission' objects. - socketPermission1 = dynamic_cast(socketPermission2->Intersect( socketPermission3 )); - - Console::WriteLine( "Displays the result of Intersect method :\n " ); - Console::WriteLine( socketPermission1 ); - - // Demand that the calling method have the requsite socket permission. - socketPermission1->Demand(); -// -// -// -// -// -// - // Get the current date from the remote date server. - try - { - int bytesReceived; - array^getByte = gcnew array(100); - serverSocket->Connect( gcnew IPEndPoint( serverAddress,serverPort ) ); - bytesReceived = serverSocket->Receive( getByte, getByte->Length, SocketFlags::None ); - return asciiEncoding->GetString( getByte, 0, bytesReceived ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return ""; - } - } -}; - -// demonstrates the caller of the 'GetDate' method for the 'DateClient' object. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 2 ) - { - PrintUsage(); - return 0; - } - - try - { - DateClient^ myDateClient = gcnew DateClient( IPAddress::Parse( args[ 0 ] ),Int32::Parse( args[ 1 ] ) ); - String^ currentDate = myDateClient->GetDate(); - Console::WriteLine( "The current date and time is : " ); - Console::WriteLine( " {0}", currentDate ); - } - // This exception is thrown by the called method in the context of improper permissions. - catch ( SecurityException^ e ) - { - Console::WriteLine( "\nSecurityException raised : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp b/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp deleted file mode 100644 index 427b6c42002..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DateClient_SocketPermission_ToXml/CPP/dateclient_socketpermission_toxml.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -This program demonstrates the 'ToXml' and 'IsUnrestricted' method and 'ConnectList' property of -'SocketPermission' class. - -This program provides a class called 'DateClient' that functions as a client -for a 'DateServer'. A 'DateServer' is a server that provides the current date on -the server in response to a request from a client. The 'DateClient' class -provides a method called 'GetDate' which returns the current date on the server. -The 'GetDate' is the method that shows the use of 'SocketPermission' class. An -instance of 'SocketPermission' is obtained using the 'FromXml' method. Another -instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, -TransportType, String*, int)' constructor. A third 'SocketPermission' Object* is -formed from the union of the above two 'SocketPermission' objects with the use of the -'Union' method of 'SocketPermission' class. This 'SocketPermission' Object* is used by -the 'GetDate' method to verify the permissions of the calling method. If the calling -method has the requisite permissions the 'GetDate' method connects to the 'DateServer' -and returns the current date that the 'DateServer' sends. If any exception occurs -the 'GetDate' method returns an empty String*. - -Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Collections; -using namespace System::Security; -using namespace System::Security::Permissions; - -void PrintUsage() -{ - Console::WriteLine( "Usage : DateClient_SocketPermission_ToXml" ); - Console::WriteLine( "\tDateClient_SocketPermission_ToXml " ); - Console::WriteLine( "\tThe ipaddress argument is the ip address of the Date server." ); - Console::WriteLine( "\tThe port argument is the port of the Date server." ); -} - -public ref class DateClient -{ -private: - Socket^ serverSocket; - Encoding^ asciiEncoding; - IPAddress^ serverAddress; - int serverPort; - - // The constructor takes the address and port of the remote server. -public: - DateClient( IPAddress^ serverIpAddress, int port ) - { - serverAddress = serverIpAddress; - serverPort = port; - serverSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - asciiEncoding = Encoding::ASCII; - } - -private: - - // Print a security element and all its children, in a depth-first manner. - void PrintSecurityElement( SecurityElement^ securityElementObj, int depth ) - { - Console::WriteLine( "Depth : {0}", depth ); - Console::WriteLine( "Tag : {0}", securityElementObj->Tag ); - Console::WriteLine( "Text : {0}", securityElementObj->Text ); - if ( securityElementObj->Children != nullptr ) - Console::WriteLine( "Children : {0}", securityElementObj->Children->Count ); - - if ( securityElementObj->Attributes != nullptr ) - { - IEnumerator^ attributeEnumerator = securityElementObj->Attributes->GetEnumerator(); - while ( attributeEnumerator->MoveNext() ) - Console::WriteLine( "Attribute - \" {0}\" , Value - \" {1}\"", (dynamic_cast(attributeEnumerator))->Key, (dynamic_cast(attributeEnumerator))->Value ); - } - - Console::WriteLine( "" ); - if ( securityElementObj->Children != nullptr ) - { - depth += 1; - for ( int i = 0; i < securityElementObj->Children->Count; i++ ) - PrintSecurityElement( dynamic_cast(securityElementObj->Children[ i ]), depth ); - } - } - - -public: - String^ GetDate() - { - // - // - // - SocketPermission^ socketPermission1 = gcnew SocketPermission( PermissionState::Unrestricted ); - - // Create a 'SocketPermission' Object* for two ip addresses. - SocketPermission^ socketPermission2 = gcnew SocketPermission( PermissionState::None ); - SecurityElement^ securityElement4 = socketPermission2->ToXml(); - - // 'SocketPermission' Object* for 'Connect' permission - SecurityElement^ securityElement1 = gcnew SecurityElement( "ConnectAccess" ); - - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement^ securityElement2 = gcnew SecurityElement( "URI","192.168.144.238#-1#3" ); - - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement^ securityElement3 = gcnew SecurityElement( "URI","192.168.144.240#-1#3" ); - securityElement1->AddChild( securityElement2 ); - securityElement1->AddChild( securityElement3 ); - securityElement4->AddChild( securityElement1 ); - - // Obtain a 'SocketPermission' Object* using 'FromXml' method. - socketPermission2->FromXml( securityElement4 ); - - // Create another 'SocketPermission' Object* with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission^ socketPermission3 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::All,"192.168.144.238",SocketPermission::AllPorts ); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3->AddPermission( NetworkAccess::Connect, TransportType::All, "192.168.144.239", SocketPermission::AllPorts ); - Console::WriteLine( "\nChecks the Socket permissions using IsUnrestricted method : " ); - if ( socketPermission1->IsUnrestricted() ) - Console::WriteLine( "Socket permission is unrestricted" ); - else - Console::WriteLine( "Socket permission is restricted" ); - - Console::WriteLine(); - Console::WriteLine( "Display result of ConnectList property : \n" ); - IEnumerator^ enumerator = socketPermission3->ConnectList; - while ( enumerator->MoveNext() ) - { - Console::WriteLine( "The hostname is : {0}", dynamic_cast(enumerator->Current)->Hostname ); - Console::WriteLine( "The port is : {0}", dynamic_cast(enumerator->Current)->Port ); - Console::WriteLine( "The Transport type is : {0}", dynamic_cast(enumerator->Current)->Transport ); - } - - Console::WriteLine( "" ); - Console::WriteLine( "Display Security Elements :\n " ); - PrintSecurityElement( socketPermission2->ToXml(), 0 ); - - // Get a 'SocketPermission' Object* which is a union of two other 'SocketPermission' objects. - socketPermission1 = dynamic_cast(socketPermission3->Union( socketPermission2 )); - - // Demand that the calling method have the socket permission. - socketPermission1->Demand(); - // - // - // - - // Get the current date from the remote date server. - try - { - int bytesReceived; - array^getByte = gcnew array(100); - serverSocket->Connect( gcnew IPEndPoint( serverAddress,serverPort ) ); - bytesReceived = serverSocket->Receive( getByte, getByte->Length, static_cast(0) ); - return asciiEncoding->GetString( getByte, 0, bytesReceived ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - return ""; - } - } -}; - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' Object*. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length != 2 ) - { - PrintUsage(); - return 0; - } - - try - { - DateClient^ myDateClient = gcnew DateClient( IPAddress::Parse( args[ 0 ] ),Int32::Parse( args[ 1 ] ) ); - String^ currentDate = myDateClient->GetDate(); - Console::WriteLine( "The current date and time is : " ); - Console::WriteLine( " {0}", currentDate ); - } - // This exception is thrown by the called method in the context of improper permissions. - catch ( SecurityException^ e ) - { - Console::WriteLine( "\nSecurityException raised : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp b/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp deleted file mode 100644 index 9e6468dcd8f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// NCLMailPerms -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Security::Permissions; - -namespace SmtpPermissionsExamples -{ - public ref class TestSmtpPermissions - { - public: - // - static SmtpPermission^ CreateConnectPermission() - { - SmtpPermission^ connectAccess = - gcnew SmtpPermission(SmtpAccess::Connect); - Console::WriteLine("Access? {0}", connectAccess->Access); - return connectAccess; - } - // - - // - static SmtpPermission^ CreateUnrestrictedPermission() - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - Console::WriteLine("Is unrestricted? {0}", - allAccess->IsUnrestricted()); - return allAccess; - } - // - - // - static SmtpPermission^ CreatePermissionCopy(SmtpPermission^ p) - { - SmtpPermission^ copy = (SmtpPermission^) p->Copy(); - return copy; - } - // - - // - static SmtpPermission^ CreateUnrestrictedPermission2() - { - SmtpPermission^ allAccess = gcnew SmtpPermission(true); - Console::WriteLine("Is unrestricted? {0}", - allAccess->IsUnrestricted()); - return allAccess; - } - // - - // - static SmtpPermission^ GiveFullAccess( - SmtpPermission^ permission) - { - permission->AddPermission(SmtpAccess::Connect); - return permission; - } - // - - // - static SmtpPermission^ IntersectionWithFull( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return (SmtpPermission^) permission->Intersect(allAccess); - } - // - - // - static bool CheckSubSet( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return permission->IsSubsetOf(allAccess); - } - // - - // - static SmtpPermission^ UnionWithFull( - SmtpPermission^ permission) - { - SmtpPermission^ allAccess = - gcnew SmtpPermission(PermissionState::Unrestricted); - return (SmtpPermission^) permission->Union(allAccess); - } - // - }; -}; - -int main() -{ -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp b/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp deleted file mode 100644 index c38764723e0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// NclNetworkInfoPerms -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -static void CreatePermission() -{ - - // - // - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ unrestricted = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::Unrestricted ); - - // - Console::WriteLine( L"Is unrestricted? {0}", unrestricted->IsUnrestricted() ); - - // - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ read = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read ); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ copyPermission = dynamic_cast(read->Copy()); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ unionPermission = dynamic_cast(read->Union( unrestricted )); - Console::WriteLine( L"Is subset?{0}", read->IsSubsetOf( unionPermission ) ); - - // - System::Net::NetworkInformation::NetworkInformationPermission^ intersectPermission = dynamic_cast(read->Intersect( unrestricted )); - - // - // - System::Net::NetworkInformation::NetworkInformationPermission^ permission = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::None ); - permission->AddPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read ); - Console::WriteLine( L"Access is {0}", permission->Access ); - - // -} - -int main() -{ - CreatePermission(); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp deleted file mode 100644 index 252b3995880..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SocketPermissionExample/CPP/source.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Security::Permissions; -using namespace System::Collections; - -void MySocketPermission() -{ -// -// - // Creates a SocketPermission restricting access to and from all URIs. - SocketPermission^ mySocketPermission1 = gcnew SocketPermission( PermissionState::None ); - - // The socket to which this permission will apply will allow connections from www.contoso.com. - mySocketPermission1->AddPermission( NetworkAccess::Accept, TransportType::Tcp, "www.contoso.com", 11000 ); - - // Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com. - SocketPermission^ mySocketPermission2 = gcnew SocketPermission( NetworkAccess::Connect,TransportType::Tcp, "www.southridgevideo.com",11002 ); - - // Creates a SocketPermission from the union of two SocketPermissions. - SocketPermission^ mySocketPermissionUnion = - (SocketPermission^)( mySocketPermission1->Union( mySocketPermission2 ) ); - - // Checks to see if the union was successfully created by using the IsSubsetOf method. - if ( mySocketPermission1->IsSubsetOf( mySocketPermissionUnion ) && - mySocketPermission2->IsSubsetOf( mySocketPermissionUnion ) ) - { - Console::WriteLine( "This union contains permissions from both mySocketPermission1 and mySocketPermission2" ); - - // Prints the allowable accept URIs to the console. - Console::WriteLine( "This union accepts connections on :" ); - - IEnumerator^ myEnumerator = mySocketPermissionUnion->AcceptList; - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( safe_cast( myEnumerator->Current )->ToString() ); - } - - // Prints the allowable connect URIs to the console. - Console::WriteLine( "This union permits connections to :" ); - - myEnumerator = mySocketPermissionUnion->ConnectList; - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( safe_cast( myEnumerator->Current )->ToString() ); - } - } -// - -// - // Creates a SocketPermission from the intersect of two SocketPermissions. - SocketPermission^ mySocketPermissionIntersect = - (SocketPermission^)( mySocketPermission1->Intersect( mySocketPermissionUnion ) ); - - // mySocketPermissionIntersect should now contain the permissions of mySocketPermission1. - if ( mySocketPermission1->IsSubsetOf( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "This is expected" ); - } - - // mySocketPermissionIntersect should not contain the permissios of mySocketPermission2. - if ( mySocketPermission2->IsSubsetOf( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "This should not print" ); - } -// - -// - // Creates a copy of the intersect SocketPermission. - SocketPermission^ mySocketPermissionIntersectCopy = - (SocketPermission^)( mySocketPermissionIntersect->Copy() ); - if ( mySocketPermissionIntersectCopy->Equals( mySocketPermissionIntersect ) ) - { - Console::WriteLine( "Copy successfull" ); - } -// - - // Converts a SocketPermission to XML format and then immediately converts it back to a SocketPermission. - mySocketPermission1->FromXml( mySocketPermission1->ToXml() ); - - // Checks to see if permission for this socket resource is unrestricted. If it is, then there is no need to - // demand that permissions be enforced. - if ( mySocketPermissionUnion->IsUnrestricted() ) - { - //Do nothing. There are no restrictions. - } - else - { - // Enforces the permissions found in mySocketPermissionUnion on any Socket Resources used below this statement. - mySocketPermissionUnion->Demand(); - } - - IPHostEntry^ myIpHostEntry = Dns::Resolve( "www.contoso.com" ); - IPEndPoint^ myLocalEndPoint = gcnew IPEndPoint( myIpHostEntry->AddressList[ 0 ], 11000 ); - - Socket^ s = gcnew Socket( myLocalEndPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - s->Connect( myLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::Write( "Exception Thrown: " ); - Console::WriteLine( e->ToString() ); - } - - // Perform all socket operations in here. - s->Close(); -// -} - -int main() -{ - MySocketPermission(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp deleted file mode 100644 index f4e56ffd6bf..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Accept/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -/* -* Demonstrate how to use the WebPermissionAttribute to specify the Accept property. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - // Deny access to a specific resource by setting the Accept property. - [method:WebPermission(SecurityAction::Deny,Accept="http://www.contoso.com/Private.htm")] - - static void CheckAcceptPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Accept, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - // Pass the security check when accessing allowed resources. - CheckAcceptPermission( "http://www.contoso.com/" ); - Console::WriteLine( "Public page has passed Accept permission check" ); - - try - { - // Throw a SecurityException when trying to access not allowed resources. - CheckAcceptPermission( "http://www.contoso.com/Private.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Exception trying to access private resource: {0}", e->Message ); - } - } -// -}; - -int main() -{ - WebPermissionAttribute_AcceptConnect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp deleted file mode 100644 index 05d097162a9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptConnect/CPP/webpermissionattribute_acceptconnect.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -// Demonstrate how to use the WebPermissionAttribute to specify an allowable ConnectPattern. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -// -public: - // Deny access to a specific resource by setting the ConnectPattern property. - [method:WebPermission(SecurityAction::Deny,ConnectPattern="http://www.contoso.com/")] - - void Connect() - { - // Create a Connection. - HttpWebRequest^ myWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://www.contoso.com" )); - Console::WriteLine( "This line should never be printed" ); - } -// -// -}; - -int main() -{ - try - { - WebPermissionAttribute_AcceptConnect^ myWebAttrib = gcnew WebPermissionAttribute_AcceptConnect; - myWebAttrib->Connect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Security Exception raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp deleted file mode 100644 index fd594b719b1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_AcceptPattern/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -/* -This program demonstrates the 'Connect' and 'Accept' properties of the class 'WebPermissionAttribute'. -The program uses declarative security for calling the code in 'Connect' method. -By using the 'Accept' and 'Connect' properties of 'WebPermissionAttribute' accept and connect access -has been given to the uri www.contoso.com. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Text::RegularExpressions; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - [method:WebPermission(SecurityAction::Deny,AcceptPattern="http://www\\.contoso\\.com/Private/.*")] - static void CheckAcceptPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Accept, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - // Passes a security check. - CheckAcceptPermission( "http://www.contoso.com/Public/page.htm" ); - Console::WriteLine( "Public page has passed Accept permission check" ); - - try - { - // Throws a SecurityException. - CheckAcceptPermission( "http://www.contoso.com/Private/page.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception: {0}", e->Message ); - } - } -// -}; - -int main() -{ - WebPermissionAttribute_AcceptConnect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp deleted file mode 100644 index d369bcc8ee1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Connect/CPP/source.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::connect; - -// Demonstrate how to use the WebPermissionAttribute Connect property. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_Connect -{ -// -public: - // Set the WebPermissionAttribute Connect property. - [method:WebPermission(SecurityAction::Deny,Connect="http://www.contoso.com/Private.htm")] - - static void demoDenySite() - { - //Pass the security check. - CheckConnectPermission( "http://www.contoso.com/Public.htm" ); - Console::WriteLine( "Public page has passed connect permission check" ); - - try - { - //Throw a SecurityException. - CheckConnectPermission( "http://www.contoso.com/Private.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception {0}", e->Message ); - } - } - - static void CheckConnectPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Connect, uriToCheck ); - permissionToCheck->Demand(); - } -// -}; - -int main() -{ - WebPermissionAttribute_Connect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp deleted file mode 100644 index 648da93ee85..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_ConnectPattern/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Connect; - -// Demonstrate how to use the WebPermissionAttribute ConnectPattern property. - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Text::RegularExpressions; - -public ref class WebPermissionAttribute_Connect -{ -// -public: - // Set the WebPermissionAttribute ConnectPattern property. - [WebPermission(SecurityAction::Deny,ConnectPattern="http://www\\.contoso\\.com/Private/.*")] - - static void CheckConnectPermission( String^ uriToCheck ) - { - WebPermission^ permissionToCheck = gcnew WebPermission; - permissionToCheck->AddPermission( NetworkAccess::Connect, uriToCheck ); - permissionToCheck->Demand(); - } - - static void demoDenySite() - { - //Pass the security check. - CheckConnectPermission( "http://www.contoso.com/Public/page.htm" ); - Console::WriteLine( "Public page has passed Connect permission check" ); - - try - { - //Throw a SecurityException. - CheckConnectPermission( "http://www.contoso.com/Private/page.htm" ); - Console::WriteLine( "This line will not be printed" ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Expected exception {0}", e->Message ); - } - } -}; -// - -int main() -{ - WebPermissionAttribute_Connect::demoDenySite(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp deleted file mode 100644 index 8606c8f6c78..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermissionAttribute_Constructor/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// System::Net::WebPermissionAttribute::Connect;System::Net::WebPermissionAttribute::Accept; - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::IO; - -public ref class WebPermissionAttribute_AcceptConnect -{ -// -public: - // Set the declarative security for the URI. - [WebPermission(SecurityAction::Deny,Connect="http://www.contoso.com/")] - void Connect() - { - // Throw an exception. - try - { - HttpWebRequest^ myWebRequest = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e ); - } -// - } -}; - -int main() -{ - try - { - WebPermissionAttribute_AcceptConnect^ myWebAttrib = gcnew WebPermissionAttribute_AcceptConnect; - myWebAttrib->Connect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Security Exception raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp deleted file mode 100644 index df794666883..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_AcceptConnectList/CPP/webpermission_acceptconnectlist.cpp +++ /dev/null @@ -1,99 +0,0 @@ - - -// System::Net::WebPermission::ConnectList;System::Net::WebPermission::AcceptList; -/** -* This program demonstrates the use of the ConnectList and AcceptList WebPermission -* class prerties. -* It first creates a WebPermission object with Permissionstate set to None and then -* sets the Connect and Accept access right to some predefined URLs. -* The using the AcceptList and ConnectList properties it displays the URLs that have -* the Accept and Connect permission set, respectively. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class WebPermission_AcceptConnectList -{ -public: - void DisplayAcceptConnect() - { - // Create a 'WebPermission' object with permission state set to 'None'. - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Allow 'Connect' access right to first set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.contoso.com" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.alpineskihouse.com" ); - - // Allow 'Accept' access right to second set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.contoso.com" ); - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.adventure-works.com" ); - myWebPermission1->AddPermission( NetworkAccess::Accept, "http://www.alpineskihouse.com" ); - - // Check whether all callers higher in the call stack have been granted the permission or not. - myWebPermission1->Demand(); - Console::WriteLine( "The Attributes, Values and Children of the 'WebPermission' object are :\n" ); - - // Display the Attributes, Values and Children of the XML encoded instance. - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - - // - // Gets all URIs with Connect permission. - IEnumerator^ myEnum = myWebPermission1->ConnectList; - Console::WriteLine( "\nThe URIs with Connect permission are :\n" ); - while ( myEnum->MoveNext() ) - { - Console::WriteLine( "\tThe URI is : {0}", myEnum->Current ); - } - // - - // - // Get all URI's with Accept permission. - IEnumerator^ myEnum1 = myWebPermission1->AcceptList; - Console::WriteLine( "\n\nThe URIs with Accept permission are :\n" ); - while ( myEnum1->MoveNext() ) - { - Console::WriteLine( "\tThe URI is : {0}", myEnum1->Current ); - } - // - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtabel. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-Attribute-\t-Value-" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - - Console::WriteLine(); - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : \n" ); - while ( myEnumerator1->MoveNext() ) - Console::Write( myEnumerator1->Current ); - } - -}; - -int main() -{ - try - { - WebPermission_AcceptConnectList * myWebPermission_AcceptConnectList = new WebPermission_AcceptConnectList; - myWebPermission_AcceptConnectList->DisplayAcceptConnect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp deleted file mode 100644 index 7ecf4f0e7a0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Constructor4/CPP/webpermission_constructor4.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// System::Net::WebPermission::WebPermission(NetworkAccess, Regex); - -/* -This program demonstrates the 'WebPermission(NetworkAccess, Regex)' constructor of 'WebPermission' class. -First a 'Regex' Object* is created that will accept all the urls which is having the hostfragment of -'www.contoso.com'.Then a 'WebPermission' Object* created by passing the 'NetworkAccess' permission and -'Regex' Object* as parameters. It checks the 'WebPermission' for all the url's having the host fragment -as 'www.contoso.com'. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Text::RegularExpressions; -using namespace System::Collections; - -class WebPermission_regexConstructor -{ -public: - void CreateRegexConstructor() - { -// - // Create an instance of 'Regex' that accepts all URL's containing the host - // fragment 'www.contoso.com'. - Regex^ myRegex = gcnew Regex( "http://www.contoso.com/.*" ); - - // Create a WebPermission that gives the permissions to all the hosts containing - // the same fragment. - WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex ); - - // Checks all callers higher in the call stack have been granted the permission. - myWebPermission->Demand(); -// - - Console::WriteLine( "Attribute and Values of WebPermission are : \n" ); - // Display the Attributes, Values and Children of the XML encoded copied instance. - PrintKeysAndValues( myWebPermission->ToXml()->Attributes, myWebPermission->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-ATTRIBUTES-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "\nThe Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermission_regexConstructor * myWebPermissionRegex = new WebPermission_regexConstructor; - myWebPermissionRegex->CreateRegexConstructor(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException raised: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp deleted file mode 100644 index 8b3e407874a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Copy/CPP/webpermission_copy.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// System::Net::WebPermission::WebPermission(PermissionState);System::Net::WebPermission::Copy; - -/** -* This program demonstrates the WebPermission(PermissionState) constructor and -* Copy method of the WebPermission class . -* It creates a WebPermission instance with Permissionstate set to None and -* sets the access right to one pair of URLs. -* Then it uses the Copy method to create another instance of WebPermission class -* Finally, the attributes , values and childrens of both the XML encoded instances -* are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class CopyWebPermission -{ -public: - void CreateCopy() - { -// - // Create a WebPermission instance. - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Allow access to the first set of URL's. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.microsoft.com/default.htm" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.msn.com" ); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission1->Demand(); -// - -// - // Create another WebPermission instance that is the copy of the above WebPermission instance. - WebPermission^ myWebPermission2 = (WebPermission^)(myWebPermission1->Copy()); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission2->Demand(); -// - - Console::WriteLine( "The Attributes and Values are :\n" ); - // Display the Attributes, Values and Children of the XML encoded instance. - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - Console::WriteLine( "\nCopied Instance Attributes and Values are:\n" ); - - // Display the Attributes, Values and Children of the XML encoded copied instance. - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Gets the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are: " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - CopyWebPermission^ myCopyWebPermission = gcnew CopyWebPermission; - myCopyWebPermission->CreateCopy(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp deleted file mode 100644 index ea42dec4dbc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_FromToXml/CPP/webpermission_fromtoxml.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// System::Net::WebPermission::ToXml;System::Net::WebPermission::FromXml; - -/** -* This program shows the use of the ToXml and FromXml methods of the WebPermission class. -* It creates a WebPermission instance with the Permissionstate set to None and -* displays the attributes and the values of the XML encoded instance . -* Then a SecurityElement instance is created and it's attributes are -* set. -* Finally, using the FromXml method the WebPermission instance is reconstructed from -* the above SecurityElement instance and the attributes are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -public ref class WebPermission_FromToXml -{ -public: - void CallXml() - { -// - // Create a WebPermission without permission on the protected resource - WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None ); - - // Create a SecurityElement by calling the ToXml method on the WebPermission - // instance and display its attributes (which hold the XML encoding of - // the WebPermission). - Console::WriteLine( "Attributes and Values of the WebPermission are:" ); - myWebPermission1->ToXml(); - - // Create another WebPermission with no permission on the protected resource - WebPermission^ myWebPermission2 = gcnew WebPermission( PermissionState::None ); - - //Converts the new WebPermission from XML using myWebPermission1. - myWebPermission2->FromXml( myWebPermission1->ToXml() ); -// - - Console::WriteLine( "The Attributes and Values of 'WebPermission' instance after reconstruction are: \n" ); - // Display the Attributes and values of the XML encoded instances. - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable ) - { - // Get the enumerator to iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } -}; - -int main() -{ - try - { - WebPermission_FromToXml^ myWebPermission_FromToXml = gcnew WebPermission_FromToXml; - myWebPermission_FromToXml->CallXml(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp deleted file mode 100644 index 692f71b9fea..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Intersect/CPP/webpermission_intersect.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// System::Net::WebPermission::WebPermission(); -// System::Net::WebPermission->AddPermission(NetworkAccess, stringuri); -// System::Net::WebPermission::Intersect; - -/** -* This program shows the use of the WebPermission() constructor, the AddPermission, -* and Intersect' methods of the WebPermission' class. -* It first creates two WebPermission objects with no arguments, with each of them -* setting the access rights to one pair of URLs. -* Then it displays the attributes , values and childrens of the XML encoded instances. -* Finally, it creates a third WebPermission Object* using the logical intersection of the -* first two objects. It does so by using the Intersect method. -* It then displays the attributes , values and childrens of the related XML encoded -* instances. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class WebPermissionIntersect -{ -public: - void CreateIntersect() - { -// - // Create two WebPermission instances. - WebPermission^ myWebPermission1 = gcnew WebPermission; - WebPermission^ myWebPermission2 = gcnew WebPermission; - -// - // Allow access to the first set of resources. - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.contoso.com/default.htm" ); - myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com/default.htm" ); - - // Check whether if the callers higher in the call stack have been granted - // access permissions. - myWebPermission1->Demand(); -// - - // Allow access right to the second set of resources. - myWebPermission2->AddPermission( NetworkAccess::Connect, "http://www.alpineskihouse.com/default.htm" ); - myWebPermission2->AddPermission( NetworkAccess::Connect, "http://www.baldwinmuseumofscience.com/default.htm" ); - myWebPermission2->Demand(); - -// - // Display the attributes , values and childrens of the XML encoded instances. - Console::WriteLine( "Attributes and values of first 'WebPermission' instance are :" ); - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - - Console::WriteLine( "\nAttributes and values of second 'WebPermission' instance are : " ); - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - -// - // Create a third WebPermission instance via the logical intersection of the previous - // two WebPermission instances. - WebPermission^ myWebPermission3 = (WebPermission^)(myWebPermission1->Intersect( myWebPermission2 )); - - Console::WriteLine( "\nAttributes and Values of the WebPermission instance after the Intersect are:\n" ); - Console::WriteLine( myWebPermission3->ToXml() ); -// - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionIntersect * myWebPermissionIntersect = new WebPermissionIntersect; - myWebPermissionIntersect->CreateIntersect(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp deleted file mode 100644 index aa616240be8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset/CPP/webpermission_issubset.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// System::Net::WebPermission->AddPermission(NetworkAccess, regex); -// System::Net::WebPermission::IsSubsetOf; - -/** -* This program shows how to use the AddPermission(NetworkAccess, regex) and -* IsSubset methods of WebPermission class. -* It creates two WebPermission instances with the Connect access rights for the -* specified URIs. -* For he first WebPermission instance, a Connect access right is given to the -* URLs with the host fragment www.microsoft.com. This is done by using -* the AddPermission(NetworkAccess, regex) method. -* Then, a third WebPermission instance is created with the Connect access right to -* the URLs of the first and second WebPermission instances. -* Finally, the attributes, values and children of that instance are displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -using namespace System::Text::RegularExpressions; - -class WebPermissionIsSubset -{ -public: - void CheckSubset() - { -// - // Create a WebPermission. - WebPermission^ myWebPermission1 = gcnew WebPermission; - - // Allow Connect access to the specified URLs. - myWebPermission1->AddPermission( NetworkAccess::Connect, gcnew Regex( "http://www\\.contoso\\.com/.*", - (RegexOptions)(RegexOptions::Compiled | RegexOptions::IgnoreCase | RegexOptions::Singleline) ) ); - - myWebPermission1->Demand(); -// - - // Create another WebPermission with the specified URL. - WebPermission^ myWebPermission2 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com" ); - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission2->Demand(); - -// - WebPermission^ myWebPermission3 = nullptr; - - // Check which permissions have the Connect access to more number of URLs. - if ( myWebPermission2->IsSubsetOf( myWebPermission1 ) ) - { - Console::WriteLine( "\n WebPermission2 is the Subset of WebPermission1\n" ); - myWebPermission3 = myWebPermission1; - } - else if ( myWebPermission1->IsSubsetOf( myWebPermission2 ) ) - { - Console::WriteLine( "\n WebPermission1 is the Subset of WebPermission2" ); - myWebPermission3 = myWebPermission2; - } - else - { - // Create the third permission. - myWebPermission3 = (WebPermission^)(myWebPermission1->Union( myWebPermission2 )); - } -// - - // Prints the attributes, values and children of XML encoded instances. - Console::WriteLine( "\nAttributes and Values of third WebPermission instance are : " ); - PrintKeysAndValues( myWebPermission3->ToXml()->Attributes, myWebPermission3->ToXml()->Children ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionIsSubset * myWebPermissionIsSubset = new WebPermissionIsSubset; - myWebPermissionIsSubset->CheckSubset(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp deleted file mode 100644 index 5f132c99a7c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_IsSubset2/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// System::Net::WebPermission->AddPermission(NetworkAccess, regex);System::Net::WebPermission::IsSubsetOf; - -/** -* This program shows the use of the AddPermission(NetworkAccess, regex) and -* IsSubset methods of the WebPermission class. -* It creates two WebPermission instances with the Connect access rights for the specified -* URIs. The second URI being a subset of the first one. -* Then the IsSubsetOf method is called to verify that the second URI is indeed a subset -* of the firts one. The result of the call to the IsSubsetOf is then displayed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; -using namespace System::Text::RegularExpressions; - -static void myIsSubsetExample() -{ -// - // Create the target permission. - WebPermission^ targetPermission = gcnew WebPermission; - targetPermission->AddPermission( NetworkAccess::Connect, gcnew Regex( "www\\.contoso\\.com/Public/.*" ) ); - - // Create the permission for a URI matching target. - WebPermission^ connectPermission = gcnew WebPermission; - connectPermission->AddPermission( NetworkAccess::Connect, "www.contoso.com/Public/default.htm" ); - - //The following statement prints true. - Console::WriteLine( "Is the second URI a subset of the first one?: {0}", connectPermission->IsSubsetOf( targetPermission ) ); -// -} - -int main() -{ - // Verify that the second URI is a subset of the first one. - myIsSubsetExample(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp deleted file mode 100644 index ccc6b055614..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Regex/CPP/regex.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Text::RegularExpressions; -using namespace System::Collections; - -void MySample() -{ -// - // Create a Regex that accepts all URLs containing the host fragment www.contoso.com. - Regex^ myRegex = gcnew Regex( "http://www\\.contoso\\.com/.*" ); - - // Create a WebPermission that gives permissions to all the hosts containing the same host fragment. - WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex ); - - //Add connect privileges for a www.adventure-works.com. - myWebPermission->AddPermission( NetworkAccess::Connect, "http://www.adventure-works.com" ); - - //Add accept privileges for www.alpineskihouse.com. - myWebPermission->AddPermission( NetworkAccess::Accept, "http://www.alpineskihouse.com/" ); - - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission->Demand(); - - // Get all the URIs with Connect permission. - IEnumerator^ myConnectEnum = myWebPermission->ConnectList; - Console::WriteLine( "\nThe 'URIs' with 'Connect' permission are :\n" ); - while ( myConnectEnum->MoveNext() ) - { - Console::WriteLine( "\t{0}", myConnectEnum->Current ); - } - - // Get all the URIs with Accept permission. - IEnumerator^ myAcceptEnum = myWebPermission->AcceptList; - Console::WriteLine( "\n\nThe 'URIs' with 'Accept' permission is :\n" ); - - while ( myAcceptEnum->MoveNext() ) - { - Console::WriteLine( "\t{0}", myAcceptEnum->Current ); - } -// -} - -int main() -{ - MySample(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp b/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp deleted file mode 100644 index 9610688f608..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebPermission_Union/CPP/webpermission_union.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// System::Net::WebPermission::WebPermission(NetworkAccess, uriString);System::Net::WebPermission::Union; - -/** -* This program shows the use of the WebPermission(NetworkAccess access, String* uriString) -* constructor and Union method of the WebPermission' class. -* It creates two instance of the WebPermission class with the specified access -* rights to the predefined URIs. -* It displays the attributes , values and childrens of those XML encoded -* instances. -* Then, using the Union method, it creates a third WebPermission instance -* via a logical union of the first two. -* Finally, it displays the attributes , values and childrens of those XML encoded -* instances. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class WebPermissionUnion -{ -public: - void CreateUnion() - { -// - // Create a WebPermission::instance. - WebPermission^ myWebPermission1 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com/default.htm" ); - myWebPermission1->Demand(); -// - - // Create another WebPermission instance. - WebPermission^ myWebPermission2 = gcnew WebPermission( NetworkAccess::Connect,"http://www.adventure-works.com" ); - myWebPermission2->Demand(); - - // Print the attributes, values and childrens of the XML encoded instances. - Console::WriteLine( "Attributes and values of the first WebPermission are : " ); - PrintKeysAndValues( myWebPermission1->ToXml()->Attributes, myWebPermission1->ToXml()->Children ); - - Console::WriteLine( "\nAttributes and values of the second WebPermission are : " ); - PrintKeysAndValues( myWebPermission2->ToXml()->Attributes, myWebPermission2->ToXml()->Children ); - -// - // Create another WebPermission that is the Union of previous two WebPermission - // instances. - WebPermission^ myWebPermission3 = (WebPermission^)(myWebPermission1->Union( myWebPermission2 )); - Console::WriteLine( "\nAttributes and values of the WebPermission after the Union are : " ); - // Display the attributes, values and children. - Console::WriteLine( myWebPermission3->ToXml() ); -// - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable, IEnumerable^ myList ) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - - Console::WriteLine(); - IEnumerator^ myEnumerator1 = myList->GetEnumerator(); - Console::WriteLine( "The Children are : " ); - while ( myEnumerator1->MoveNext() ) - { - Console::Write( "\t {0}", myEnumerator1->Current ); - } - } -}; - -int main() -{ - try - { - WebPermissionUnion^ myWebPermissionUnion = gcnew WebPermissionUnion; - myWebPermissionUnion->CreateUnion(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs deleted file mode 100644 index 85272db70cb..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoContractToViewHostAdapter.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System.AddIn.Pipeline; -namespace LibraryContractsHostAdapters -{ - public class BookInfoContractToViewHostAdapter : LibraryContractsHAV.BookInfo - { - private Library.IBookInfoContract _contract; - - private ContractHandle _handle; - - public BookInfoContractToViewHostAdapter(Library.IBookInfoContract contract) - { - _contract = contract; - _handle = new ContractHandle(contract); - } - - public override string ID() - { - return _contract.ID(); - } - public override string Author() - { - return _contract.Author(); - } - public override string Title() - { - return _contract.Title(); - } - public override string Genre() - { - return _contract.Genre(); - } - public override string Price() - { - return _contract.Price(); - } - public override string Publish_Date() - { - return _contract.Publish_Date(); - } - public override string Description() - { - return _contract.Description(); - } - - internal Library.IBookInfoContract GetSourceContract() { - return _contract; - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs deleted file mode 100644 index 68f94470b83..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoHostAdapter.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -namespace LibraryContractsHostAdapters -{ -public class BookInfoHostAdapter -{ - - internal static LibraryContractsHAV.BookInfo ContractToViewAdapter(Library.IBookInfoContract contract) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) && - (contract.GetType().Equals(typeof(BookInfoViewToContractHostAdapter)))) - { - return ((BookInfoViewToContractHostAdapter)(contract)).GetSourceView(); - } - else { - return new BookInfoContractToViewHostAdapter(contract); - } - } - - internal static Library.IBookInfoContract ViewToContractAdapter(LibraryContractsHAV.BookInfo view) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) && - (view.GetType().Equals(typeof(BookInfoContractToViewHostAdapter)))) - { - return ((BookInfoContractToViewHostAdapter)(view)).GetSourceContract(); - } - else { - return new BookInfoViewToContractHostAdapter(view); - } - } -} -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs deleted file mode 100644 index c54d68911a7..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListContractT/BookInfoViewToContractHostAdapter.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System.AddIn.Pipeline; -namespace LibraryContractsHostAdapters -{ -public class BookInfoViewToContractHostAdapter : ContractBase, Library.IBookInfoContract -{ - private LibraryContractsHAV.BookInfo _view; - - public BookInfoViewToContractHostAdapter(LibraryContractsHAV.BookInfo view) - { - _view = view; - } - - public virtual string ID() - { - return _view.ID(); - } - public virtual string Author() - { - return _view.Author(); - } - public virtual string Title() - { - return _view.Title(); - } - public virtual string Genre() - { - return _view.Genre(); - } - public virtual string Price() - { - return _view.Price(); - } - public virtual string Publish_Date() - { - return _view.Publish_Date(); - } - public virtual string Description() - { - return _view.Description(); - } - internal LibraryContractsHAV.BookInfo GetSourceView() - { - return _view; - } -} -} -// \ No newline at end of file diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs deleted file mode 100644 index 5ae55a0e328..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoAddInAdapter.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; - -namespace LibraryContractsAddInAdapters -{ - public class BookInfoAddInAdapter - { - internal static LibraryContractsBase.BookInfo ContractToViewAdapter(Library.IBookInfoContract contract) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) && - (contract.GetType().Equals(typeof(BookInfoViewToContractAddInAdapter)))) - { - return ((BookInfoViewToContractAddInAdapter)(contract)).GetSourceView(); - } - else - { - return new BookInfoContractToViewAddInAdapter(contract); - } - } - - internal static Library.IBookInfoContract ViewToContractAdapter(LibraryContractsBase.BookInfo view) - { - if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) && - (view.GetType().Equals(typeof(BookInfoContractToViewAddInAdapter)))) - { - return ((BookInfoContractToViewAddInAdapter)(view)).GetSourceContract(); - } - else - { - return new BookInfoViewToContractAddInAdapter(view); - } - } - } -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs deleted file mode 100644 index 5b622c29606..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoContractToViewAddInAdapter.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using System.AddIn.Pipeline; -namespace LibraryContractsAddInAdapters -{ - -public class BookInfoContractToViewAddInAdapter : LibraryContractsBase.BookInfo -{ - private Library.IBookInfoContract _contract; - private System.AddIn.Pipeline.ContractHandle _handle; - public BookInfoContractToViewAddInAdapter(Library.IBookInfoContract contract) - { - _contract = contract; - _handle = new ContractHandle(contract); - } - - public override string ID() - { - return _contract.ID(); - } - public override string Author() - { - return _contract.Author(); - } - public override string Title() - { - return _contract.Title(); - } - public override string Genre() - { - return _contract.Genre(); - } - public override string Price() - { - return _contract.Price(); - } - public override string Publish_Date() - { - return _contract.Publish_Date(); - } - public override string Description() - { - return _contract.Description(); - } - - internal Library.IBookInfoContract GetSourceContract() { - return _contract; - } -} -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs deleted file mode 100644 index 34e5741b020..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/BookInfoViewToContractAddInAdapter.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; - -namespace LibraryContractsAddInAdapters -{ -public class BookInfoViewToContractAddInAdapter : System.AddIn.Pipeline.ContractBase, Library.IBookInfoContract -{ - private LibraryContractsBase.BookInfo _view; - public BookInfoViewToContractAddInAdapter(LibraryContractsBase.BookInfo view) - { - _view = view; - } - public virtual string ID() - { - return _view.ID(); - } - public virtual string Author() - { - return _view.Author(); - } - public virtual string Title() - { - return _view.Title(); - } - public virtual string Genre() - { - return _view.Genre(); - } - public virtual string Price() - { - return _view.Price(); - } - public virtual string Publish_Date() - { - return _view.Publish_Date(); - } - public virtual string Description() - { - return _view.Description(); - } - - internal LibraryContractsBase.BookInfo GetSourceView() { - return _view; - } -} -} -// diff --git a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs b/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs deleted file mode 100644 index c1a316ec94e..00000000000 --- a/snippets/csharp/System.AddIn.Pipeline/CollectionAdapters/ToIListT/LibraryManagerAddInAdapter.cs +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.312 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ -using System.IO; -using System; -namespace LibraryContractsAddInAdapters { - - -public class LibraryManagerAddInAdapter -{ - - internal static LibraryContractsBase.LibraryManager ContractToViewAdapter(Library.ILibraryManagerContract contract) - { - StreamWriter sw = new StreamWriter(@"c:\meow\adaptercalls.txt", true); - sw.WriteLine("Called LibraryManagerAddInAdapter.ContractToViewAdapter"); - sw.Close(); - if (contract.GetType().Equals(typeof(LibraryManagerViewToContractAddInAdapter))) - { - return ((LibraryManagerViewToContractAddInAdapter)(contract)).GetSourceView(); - } - else { - return new LibraryManagerContractToViewAddInAdapter(contract); - } - } - - internal static Library.ILibraryManagerContract ViewToContractAdapter(LibraryContractsBase.LibraryManager view) - { - StreamWriter sw = new StreamWriter(@"c:\meow\adaptercalls.txt", true); - sw.WriteLine("Called LibraryManagerAddInAdapter.ViewToContractAdapter"); - sw.Close(); - if (view.GetType().Equals(typeof(LibraryManagerContractToViewAddInAdapter))) - { - return ((LibraryManagerContractToViewAddInAdapter)(view)).GetSourceContract(); - } - else { - return new LibraryManagerViewToContractAddInAdapter(view); - } - } -} -} - diff --git a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile b/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile deleted file mode 100644 index c9949278a80..00000000000 --- a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: source.dll source2.dll - -source.dll : source.cs - csc source.cs /r:Microsoft.jscript.dll - -source2.dll : source2.cs - csc source2.cs diff --git a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs b/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs deleted file mode 100644 index f9deeb81e5a..00000000000 --- a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source2.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -using System; -using System.CodeDom; -using System.CodeDom.Compiler; - -public class UsingTheCodeDOM -{ - public static void Main() - { - // - CodeCompileUnit compileUnit = new CodeCompileUnit(); - // - - // - CodeNamespace samples = new CodeNamespace("Samples"); - // - - // - samples.Imports.Add(new CodeNamespaceImport("System")); - // - - // - compileUnit.Namespaces.Add( samples ); - // - - // - CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1"); - // - - // - samples.Types.Add(class1); - // - - // - CodeEntryPointMethod start = new CodeEntryPointMethod(); - CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression( - new CodeTypeReferenceExpression("System.Console"), - "WriteLine", new CodePrimitiveExpression("Hello World!")); - start.Statements.Add(cs1); - // - - // - class1.Members.Add( start ); - // - - CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp"); - codeProvider.GenerateCodeFromCompileUnit(compileUnit, Console.Out, new CodeGeneratorOptions()); - } -} -// diff --git a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs b/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs deleted file mode 100644 index 166d3b9a4e9..00000000000 --- a/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source3.cs +++ /dev/null @@ -1,111 +0,0 @@ -// -using System; -using System.IO; -using System.CodeDom; -using System.CodeDom.Compiler; -using Microsoft.CSharp; - -class Example -{ - public static void Main() - { - string sourcefile; - string exefile; - - CodeCompileUnit codeUnit = new CodeCompileUnit(); - sourcefile = GenerateCSharpCode(codeUnit); - exefile = sourcefile.Substring(0, sourcefile.LastIndexOf('.')) + ".exe"; - Console.WriteLine("outfile: {0}", exefile); - CompileCSharpCode(sourcefile, exefile); - } - - // - public static string GenerateCSharpCode(CodeCompileUnit compileunit) - { - // Generate the code with the C# code provider. - // - CSharpCodeProvider provider = new CSharpCodeProvider(); - // - - // Build the output file name. - string sourceFile; - if (provider.FileExtension[0] == '.') - { - sourceFile = "HelloWorld" + provider.FileExtension; - } - else - { - sourceFile = "HelloWorld." + provider.FileExtension; - } - - // Create a TextWriter to a StreamWriter to the output file. - using (StreamWriter sw = new StreamWriter(sourceFile, false)) - { - IndentedTextWriter tw = new IndentedTextWriter(sw, " "); - - // Generate source code using the code provider. - provider.GenerateCodeFromCompileUnit(compileunit, tw, - new CodeGeneratorOptions()); - - // Close the output file. - tw.Close(); - } - - return sourceFile; - } - // - - // - public static bool CompileCSharpCode(string sourceFile, string exeFile) - { - CSharpCodeProvider provider = new CSharpCodeProvider(); - - // Build the parameters for source compilation. - CompilerParameters cp = new CompilerParameters(); - - // Add an assembly reference. - cp.ReferencedAssemblies.Add( "System.dll" ); - - // Generate an executable instead of - // a class library. - cp.GenerateExecutable = true; - - // Set the assembly file name to generate. - cp.OutputAssembly = exeFile; - - // Save the assembly as a physical file. - cp.GenerateInMemory = false; - - // Invoke compilation. - CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile); - - if (cr.Errors.Count > 0) - { - // Display compilation errors. - Console.WriteLine("Errors building {0} into {1}", - sourceFile, cr.PathToAssembly); - foreach (CompilerError ce in cr.Errors) - { - Console.WriteLine(" {0}", ce.ToString()); - Console.WriteLine(); - } - } - else - { - Console.WriteLine("Source {0} built into {1} successfully.", - sourceFile, cr.PathToAssembly); - } - - // Return the results of compilation. - if (cr.Errors.Count > 0) - { - return false; - } - else - { - return true; - } - } - // -} -// diff --git a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs b/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs deleted file mode 100644 index 8db49e05961..00000000000 --- a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Install.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* The following example creates an assembly which is used to demonstrate - the methods, properties and constructors of the 'AssemblyInstaller' class. -*/ - -using System; -using System.ComponentModel; -using System.Configuration.Install; -using System.Collections; - -namespace MyAssembly -{ - [RunInstallerAttribute(true)] - public class MyProjectInstaller : Installer - { - static void Main() - { - Console.WriteLine( "Hello World" ); - } - } -} diff --git a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs b/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs deleted file mode 100644 index 8db49e05961..00000000000 --- a/snippets/csharp/System.Configuration.Install/AssemblyInstaller/.ctor/MyAssembly_Uninstall.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* The following example creates an assembly which is used to demonstrate - the methods, properties and constructors of the 'AssemblyInstaller' class. -*/ - -using System; -using System.ComponentModel; -using System.Configuration.Install; -using System.Collections; - -namespace MyAssembly -{ - [RunInstallerAttribute(true)] - public class MyProjectInstaller : Installer - { - static void Main() - { - Console.WriteLine( "Hello World" ); - } - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly11.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/AddRange/MyAssembly21.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Contains/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/CopyTo/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Item/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly1.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs b/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs deleted file mode 100644 index 5aacc9836ce..00000000000 --- a/snippets/csharp/System.Configuration.Install/InstallerCollection/Overview/MyAssembly2.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - This program is supposed to be used with the IntallerCollection_***.cs - examples. Provide the exe of this program as input to the - InstallerCollection_***.exe programs. -*/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Configuration.Install; - -[RunInstaller(true)] -public class MyInstaller : Installer -{ - - public override void Install(IDictionary savedState) - { - base.Install(savedState); - Console.WriteLine("Install ...\n"); - } - - public override void Commit(IDictionary savedState) - { - base.Commit(savedState); - Console.WriteLine("Committing ...\n"); - } - - public override void Rollback(IDictionary savedState) - { - base.Rollback(savedState); - Console.WriteLine("RollBack ...\n"); - } - - public override void Uninstall(IDictionary savedState) - { - base.Uninstall(savedState); - Console.WriteLine("UnInstall ...\n"); - } -} - -// An Assembly that has its own installer. -public class MyAssembly1 -{ - public static void Main() - { - Console.WriteLine("This assembly is just an example for the Installer\n"); - } -} diff --git a/snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs b/snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs deleted file mode 100644 index 74a4a0c5ef9..00000000000 --- a/snippets/csharp/System.Data.Linq.Mapping/AssociationAttribute/Overview/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Data.Linq; -using System.Data.Linq.Mapping; -using System.Data.Common; - -namespace cs_testbed -{ - class Program - { - static void Main(string[] args) - { - - Northwnd db = new Northwnd(@"c:\northwnd.mdf"); - Console.ReadLine(); - } - } -} diff --git a/snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs b/snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs deleted file mode 100644 index e6dff76f5cf..00000000000 --- a/snippets/csharp/System.Data.Linq.Mapping/ColumnAttribute/AutoSync/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace cs_ColumnAttributes2 -{ - class Program - { - static void Main(string[] args) - { - } - } -} diff --git a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs b/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs deleted file mode 100644 index 9647657c61c..00000000000 --- a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor1.cs +++ /dev/null @@ -1,62 +0,0 @@ -// System.Diagnostics.CounterCreationDataCollection.CounterCreationDataCollection(CounterCreationData[]) - -/* - The following program demonstrates 'CounterCreationDataCollection(CounterCreationData[])' - constructor of 'CounterCreationDataCollection' class. - An instance of 'CounterCreationDataCollection' is created by passing an array of - 'CounterCreationData' to the constructor. The counters of the 'CounterCreationDataCollection' - are displayed to the console. - - */ -using System; -using System.Diagnostics; - -public class CounterCreationExample -{ - public static void Main() - { - try - { - // - string myCategoryName; - int numberOfCounters; - Console.Write("Enter the category Name : "); - myCategoryName = Console.ReadLine(); - // Check if the category already exists or not. - if (!PerformanceCounterCategory.Exists(myCategoryName)) - { - Console.Write("Enter the number of counters : "); - numberOfCounters = int.Parse(Console.ReadLine()); - CounterCreationData[] myCounterCreationData = - new CounterCreationData[numberOfCounters]; - - for (int i = 0; i < numberOfCounters; i++) - { - Console.Write("Enter the counter name for {0} counter : ", i); - myCounterCreationData[i] = new CounterCreationData(); - myCounterCreationData[i].CounterName = Console.ReadLine(); - } - CounterCreationDataCollection myCounterCollection = - new CounterCreationDataCollection(myCounterCreationData); - // Create the category. - PerformanceCounterCategory.Create(myCategoryName, - "Sample Category", - PerformanceCounterCategoryType.SingleInstance, myCounterCollection); - - Console.WriteLine("The list of counters in 'CounterCollection' are :"); - for (int i = 0; i < myCounterCollection.Count; i++) - Console.WriteLine("Counter {0} is '{1}'", i, myCounterCollection[i].CounterName); - } - else - { - Console.WriteLine("The category already exists"); - } - // - } - catch (Exception e) - { - Console.WriteLine("Exception: {0}.", e.Message); - return; - } - } -} diff --git a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs b/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs deleted file mode 100644 index 9647657c61c..00000000000 --- a/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdata.cs +++ /dev/null @@ -1,62 +0,0 @@ -// System.Diagnostics.CounterCreationDataCollection.CounterCreationDataCollection(CounterCreationData[]) - -/* - The following program demonstrates 'CounterCreationDataCollection(CounterCreationData[])' - constructor of 'CounterCreationDataCollection' class. - An instance of 'CounterCreationDataCollection' is created by passing an array of - 'CounterCreationData' to the constructor. The counters of the 'CounterCreationDataCollection' - are displayed to the console. - - */ -using System; -using System.Diagnostics; - -public class CounterCreationExample -{ - public static void Main() - { - try - { - // - string myCategoryName; - int numberOfCounters; - Console.Write("Enter the category Name : "); - myCategoryName = Console.ReadLine(); - // Check if the category already exists or not. - if (!PerformanceCounterCategory.Exists(myCategoryName)) - { - Console.Write("Enter the number of counters : "); - numberOfCounters = int.Parse(Console.ReadLine()); - CounterCreationData[] myCounterCreationData = - new CounterCreationData[numberOfCounters]; - - for (int i = 0; i < numberOfCounters; i++) - { - Console.Write("Enter the counter name for {0} counter : ", i); - myCounterCreationData[i] = new CounterCreationData(); - myCounterCreationData[i].CounterName = Console.ReadLine(); - } - CounterCreationDataCollection myCounterCollection = - new CounterCreationDataCollection(myCounterCreationData); - // Create the category. - PerformanceCounterCategory.Create(myCategoryName, - "Sample Category", - PerformanceCounterCategoryType.SingleInstance, myCounterCollection); - - Console.WriteLine("The list of counters in 'CounterCollection' are :"); - for (int i = 0; i < myCounterCollection.Count; i++) - Console.WriteLine("Counter {0} is '{1}'", i, myCounterCollection[i].CounterName); - } - else - { - Console.WriteLine("The category already exists"); - } - // - } - catch (Exception e) - { - Console.WriteLine("Exception: {0}.", e.Message); - return; - } - } -} diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs deleted file mode 100644 index 22233dce8a3..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/averagetimer32.cs +++ /dev/null @@ -1,373 +0,0 @@ -// Notice that the sample is conditionally compiled for Everett vs. -// Whidbey builds. Whidbey introduced new APIs that are not available -// in Everett. Snippet IDs do not overlap between Whidbey and Everett; -// Snippet #1 is Everett, Snippet #2 and #3 are Whidbey. - -#if (BELOW_WHIDBEY_BUILD) - -// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Runtime.InteropServices; - -public class App -{ - - private static PerformanceCounter PC; - private static PerformanceCounter BPC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - SetupCategory(); - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - - - - private static bool SetupCategory() - { - - if ( !PerformanceCounterCategory.Exists("AverageTimer32SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData averageTimer32 = new CounterCreationData(); - averageTimer32.CounterType = PerformanceCounterType.AverageTimer32; - averageTimer32.CounterName = "AverageTimer32Sample"; - CCDC.Add(averageTimer32); - - // Add the base counter. - CounterCreationData averageTimer32Base = new CounterCreationData(); - averageTimer32Base.CounterType = PerformanceCounterType.AverageBase; - averageTimer32Base.CounterName = "AverageTimer32SampleBase"; - CCDC.Add(averageTimer32Base); - - // Create the category. - PerformanceCounterCategory.Create("AverageTimer32SampleCategory", - "Demonstrates usage of the AverageTimer32 performance counter type", - CCDC); - - return(true); - } - else - { - Console.WriteLine("Category exists - " + "AverageTimer32SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter("AverageTimer32SampleCategory", - "AverageTimer32Sample", - false); - - BPC = new PerformanceCounter("AverageTimer32SampleCategory", - "AverageTimer32SampleBase", - false); - - PC.RawValue = 0; - BPC.RawValue = 0; - } - - - private static void CollectSamples(ArrayList samplesList) - { - - long perfTime = 0; - Random r = new Random( DateTime.Now.Millisecond ); - - // Loop for the samples. - for (int i = 0; i < 10; i++) { - - QueryPerformanceCounter(out perfTime); - PC.RawValue = perfTime; - - BPC.IncrementBy(10); - - System.Threading.Thread.Sleep(1000); - Console.WriteLine("Next value = " + PC.NextValue().ToString()); - samplesList.Add(PC.NextSample()); - } - - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSample.Calculate((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - } - } - - - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - // PERF_AVERAGE_TIMER - // Description - This counter type measures the time it takes, on - // average, to complete a process or operation. Counters of this - // type display a ratio of the total elapsed time of the sample - // interval to the number of processes or operations completed - // during that time. This counter type measures time in ticks - // of the system clock. The F variable represents the number of - // ticks per second. The value of F is factored into the equation - // so that the result can be displayed in seconds. - // - // Generic type - Average - // - // Formula - ((N1 - N0) / F) / (D1 - D0), where the numerator (N) - // represents the number of ticks counted during the last - // sample interval, F represents the frequency of the ticks, - // and the denominator (D) represents the number of operations - // completed during the last sample interval. - // - // Average - ((Nx - N0) / F) / (Dx - D0) - // - // Example - PhysicalDisk\ Avg. Disk sec/Transfer - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Int64 n1 = s1.RawValue; - Int64 n0 = s0.RawValue; - ulong f = (ulong)s1.SystemFrequency; - Int64 d1 = s1.BaseValue; - Int64 d0 = s0.BaseValue; - - double numerator = (double)(n1 - n0); - double denominator = (double)(d1 - d0); - Single counterValue = (Single)(( numerator / f ) / denominator); - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } - - - [DllImport("Kernel32.dll")] - public static extern bool QueryPerformanceCounter(out long value); - -} - -// -#else -// Build sample for Whidbey or higher. - -// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Runtime.InteropServices; - -public class App -{ - - private static PerformanceCounter PC; - private static PerformanceCounter BPC; - - private const String categoryName = "AverageTimer32SampleCategory"; - private const String counterName = "AverageTimer32Sample"; - private const String baseCounterName = "AverageTimer32SampleBase"; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if (!PerformanceCounterCategory.Exists(categoryName)) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData averageTimer32 = new CounterCreationData(); - averageTimer32.CounterType = PerformanceCounterType.AverageTimer32; - averageTimer32.CounterName = counterName; - CCDC.Add(averageTimer32); - - // Add the base counter. - CounterCreationData averageTimer32Base = new CounterCreationData(); - averageTimer32Base.CounterType = PerformanceCounterType.AverageBase; - averageTimer32Base.CounterName = baseCounterName; - CCDC.Add(averageTimer32Base); - - // Create the category. - PerformanceCounterCategory.Create(categoryName, - "Demonstrates usage of the AverageTimer32 performance counter type", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - Console.WriteLine("Category created - " + categoryName); - - return (true); - } - else - { - Console.WriteLine("Category exists - " + categoryName); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter(categoryName, - counterName, - false); - - BPC = new PerformanceCounter(categoryName, - baseCounterName, - false); - - PC.RawValue = 0; - BPC.RawValue = 0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random(DateTime.Now.Millisecond); - - // Loop for the samples. - for (int i = 0; i < 10; i++) - { - - PC.RawValue = Stopwatch.GetTimestamp(); - - BPC.IncrementBy(10); - - System.Threading.Thread.Sleep(1000); - - Console.WriteLine("Next value = " + PC.NextValue().ToString()); - samplesList.Add(PC.NextSample()); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - OutputSample((CounterSample)samplesList[i + 1]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSample.Calculate((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - // PERF_AVERAGE_TIMER - // Description - This counter type measures the time it takes, on - // average, to complete a process or operation. Counters of this - // type display a ratio of the total elapsed time of the sample - // interval to the number of processes or operations completed - // during that time. This counter type measures time in ticks - // of the system clock. The F variable represents the number of - // ticks per second. The value of F is factored into the equation - // so that the result can be displayed in seconds. - // - // Generic type - Average - // - // Formula - ((N1 - N0) / F) / (D1 - D0), where the numerator (N) - // represents the number of ticks counted during the last - // sample interval, F represents the frequency of the ticks, - // and the denominator (D) represents the number of operations - // completed during the last sample interval. - // - // Average - ((Nx - N0) / F) / (Dx - D0) - // - // Example - PhysicalDisk\ Avg. Disk sec/Transfer - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//+++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Int64 n1 = s1.RawValue; - Int64 n0 = s0.RawValue; - ulong f = (ulong)s1.SystemFrequency; - Int64 d1 = s1.BaseValue; - Int64 d0 = s0.BaseValue; - - double numerator = (double)(n1 - n0); - double denominator = (double)(d1 - d0); - Single counterValue = (Single)((numerator / f) / denominator); - return (counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// - -#endif diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs deleted file mode 100644 index 18eee683b86..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems32.cs +++ /dev/null @@ -1,137 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class NumberOfItems64 -{ - - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - if ( !PerformanceCounterCategory.Exists("NumberOfItems32SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData NOI64 = new CounterCreationData(); - NOI64.CounterType = PerformanceCounterType.NumberOfItems64; - NOI64.CounterName = "NumberOfItems32Sample"; - CCDC.Add(NOI64); - - // Create the category. - PerformanceCounterCategory.Create("NumberOfItems32SampleCategory", - "Demonstrates usage of the NumberOfItems32 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - return(true); - } - else - { - Console.WriteLine("Category exists - NumberOfItems32SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counter. - PC = new PerformanceCounter("NumberOfItems32SampleCategory", - "NumberOfItems32Sample", - false); - - PC.RawValue=0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random( DateTime.Now.Millisecond ); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - Console.Write(j + " = " + value); - - PC.IncrementBy(value); - - if ((j % 10) == 9) - { - OutputSample(PC.NextSample()); - samplesList.Add( PC.NextSample() ); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single counterValue = s1.RawValue; - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs deleted file mode 100644 index a7de24e7aa0..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/numberofitems64.cs +++ /dev/null @@ -1,136 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class NumberOfItems64 -{ - - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Perfomance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - if ( !PerformanceCounterCategory.Exists("NumberOfItems64SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData NOI64 = new CounterCreationData(); - NOI64.CounterType = PerformanceCounterType.NumberOfItems64; - NOI64.CounterName = "NumberOfItems64Sample"; - CCDC.Add(NOI64); - - // Create the category. - PerformanceCounterCategory.Create("NumberOfItems64SampleCategory", - "Demonstrates usage of the NumberOfItems64 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - return(true); - } - else - { - Console.WriteLine("Category exists - NumberOfItems64SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter("NumberOfItems64SampleCategory", - "NumberOfItems64Sample", - false); - - PC.RawValue=0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random( DateTime.Now.Millisecond ); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - Console.Write(j + " = " + value); - - PC.IncrementBy(value); - - if ((j % 10) == 9) - { - OutputSample(PC.NextSample()); - samplesList.Add( PC.NextSample() ); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single counterValue = s1.RawValue; - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} -// diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs deleted file mode 100644 index 6cdc59d744b..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/program.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -// Provides a SampleFraction counter to measure the percentage of the user processor -// time for this process to total processor time for the process. -public class App -{ - - private static PerformanceCounter perfCounter; - private static PerformanceCounter basePerfCounter; - private static Process thisProcess = Process.GetCurrentProcess(); - - public static void Main() - { - - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - if (!PerformanceCounterCategory.Exists("SampleFractionCategory")) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData sampleFraction = new CounterCreationData(); - sampleFraction.CounterType = PerformanceCounterType.SampleFraction; - sampleFraction.CounterName = "SampleFractionSample"; - CCDC.Add(sampleFraction); - - // Add the base counter. - CounterCreationData sampleFractionBase = new CounterCreationData(); - sampleFractionBase.CounterType = PerformanceCounterType.SampleBase; - sampleFractionBase.CounterName = "SampleFractionSampleBase"; - CCDC.Add(sampleFractionBase); - - // Create the category. - PerformanceCounterCategory.Create("SampleFractionCategory", - "Demonstrates usage of the SampleFraction performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - return (true); - } - else - { - Console.WriteLine("Category exists - SampleFractionCategory"); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counters. - - perfCounter = new PerformanceCounter("SampleFractionCategory", - "SampleFractionSample", - false); - - basePerfCounter = new PerformanceCounter("SampleFractionCategory", - "SampleFractionSampleBase", - false); - - perfCounter.RawValue = thisProcess.UserProcessorTime.Ticks; - basePerfCounter.RawValue = thisProcess.TotalProcessorTime.Ticks; - } - private static void CollectSamples(ArrayList samplesList) - { - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - perfCounter.IncrementBy(thisProcess.UserProcessorTime.Ticks); - - basePerfCounter.IncrementBy(thisProcess.TotalProcessorTime.Ticks); - - if ((j % 10) == 9) - { - OutputSample(perfCounter.NextSample()); - samplesList.Add(perfCounter.NextSample()); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - OutputSample((CounterSample)samplesList[i + 1]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // Description - This counter type provides A percentage counter that shows the - // average ratio of user proccessor time to total processor time during the last - // two sample intervals. - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single numerator = (Single)s1.RawValue - (Single)s0.RawValue; - Single denomenator = (Single)s1.BaseValue - (Single)s0.BaseValue; - Single counterValue = 100 * (numerator / denomenator); - return (counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs deleted file mode 100644 index 38559236e96..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond32.cs +++ /dev/null @@ -1,159 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class App -{ - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Perfomance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if ( !PerformanceCounterCategory.Exists("RateOfCountsPerSecond32SampleCategory") ) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData rateOfCounts32 = new CounterCreationData(); - rateOfCounts32.CounterType = PerformanceCounterType.RateOfCountsPerSecond32; - rateOfCounts32.CounterName = "RateOfCountsPerSecond32Sample"; - CCDC.Add(rateOfCounts32); - - // Create the category. - PerformanceCounterCategory.Create("RateOfCountsPerSecond32SampleCategory", - "Demonstrates usage of the RateOfCountsPerSecond32 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - return(true); - } - else - { - Console.WriteLine("Category exists - RateOfCountsPerSecond32SampleCategory"); - return(false); - } - } - - private static void CreateCounters() - { - // Create the counter. - PC = new PerformanceCounter("RateOfCountsPerSecond32SampleCategory", - "RateOfCountsPerSecond32Sample", - false); - - PC.RawValue=0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random( DateTime.Now.Millisecond ); - - // Initialize the performance counter. - PC.NextSample(); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - PC.IncrementBy(value); - Console.Write(j + " = " + value); - - if ((j % 10) == 9) - { - Console.WriteLine("; NextValue() = " + PC.NextValue().ToString()); - OutputSample(PC.NextSample()); - samplesList.Add( PC.NextSample() ); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for(int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample( (CounterSample)samplesList[i] ); - OutputSample( (CounterSample)samplesList[i+1] ); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i+1]) ); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // PERF_COUNTER_COUNTER - // Description - This counter type shows the average number of operations completed - // during each second of the sample interval. Counters of this type - // measure time in ticks of the system clock. The F variable represents - // the number of ticks per second. The value of F is factored into the - // equation so that the result can be displayed in seconds. - // - // Generic type - Difference - // - // Formula - (N1 - N0) / ( (D1 - D0) / F), where the numerator (N) represents the number - // of operations performed during the last sample interval, the denominator - // (D) represents the number of ticks elapsed during the last sample - // interval, and F is the frequency of the ticks. - // - // Average - (Nx - N0) / ((Dx - D0) / F) - // - // Example - System\ File Read Operations/sec - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single numerator = (Single)(s1.RawValue - s0.RawValue); - Single denomenator = (Single)(s1.TimeStamp - s0.TimeStamp) / (Single)s1.SystemFrequency; - Single counterValue = numerator / denomenator; - return(counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs deleted file mode 100644 index 3dca5cb9acf..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rateofcountspersecond64.cs +++ /dev/null @@ -1,158 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class App -{ - private static PerformanceCounter PC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Perfomance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the category. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if (!PerformanceCounterCategory.Exists("RateOfCountsPerSecond64SampleCategory")) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData rateOfCounts64 = new CounterCreationData(); - rateOfCounts64.CounterType = PerformanceCounterType.RateOfCountsPerSecond64; - rateOfCounts64.CounterName = "RateOfCountsPerSecond64Sample"; - CCDC.Add(rateOfCounts64); - - // Create the category. - PerformanceCounterCategory.Create("RateOfCountsPerSecond64SampleCategory", - "Demonstrates usage of the RateOfCountsPerSecond64 performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - return (true); - } - else - { - Console.WriteLine("Category exists - RateOfCountsPerSecond64SampleCategory"); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counter. - PC = new PerformanceCounter("RateOfCountsPerSecond64SampleCategory", - "RateOfCountsPerSecond64Sample", - false); - - PC.RawValue = 0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random(DateTime.Now.Millisecond); - - // Initialize the performance counter. - PC.NextSample(); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - - int value = r.Next(1, 10); - PC.IncrementBy(value); - Console.Write(j + " = " + value); - - if ((j % 10) == 9) - { - Console.WriteLine("; NextValue() = " + PC.NextValue().ToString()); - OutputSample(PC.NextSample()); - samplesList.Add(PC.NextSample()); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < (samplesList.Count - 1); i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - OutputSample((CounterSample)samplesList[i + 1]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i], - (CounterSample)samplesList[i + 1])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // PERF_COUNTER_COUNTER - // Description - This counter type shows the average number of operations completed - // during each second of the sample interval. Counters of this type - // measure time in ticks of the system clock. The F variable represents - // the number of ticks per second. The value of F is factored into the - // equation so that the result can be displayed in seconds. - // - // Generic type - Difference - // - // Formula - (N1 - N0) / ( (D1 - D0) / F), where the numerator (N) represents the number - // of operations performed during the last sample interval, the denominator - // (D) represents the number of ticks elapsed during the last sample - // interval, and F is the frequency of the ticks. - // - // Average - (Nx - N0) / ((Dx - D0) / F) - // - // Example - System\ File Read Operations/sec - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample s0, CounterSample s1) - { - Single numerator = (Single)(s1.RawValue - s0.RawValue); - Single denomenator = (Single)(s1.TimeStamp - s0.TimeStamp) / (Single)s1.SystemFrequency; - Single counterValue = numerator / denomenator; - return (counterValue); - } - - private static void OutputSample(CounterSample s) - { - Console.WriteLine("\r\n+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// diff --git a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs b/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs deleted file mode 100644 index 293d0bd9e2d..00000000000 --- a/snippets/csharp/System.Diagnostics/PerformanceCounterType/Overview/rawfraction.cs +++ /dev/null @@ -1,171 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Diagnostics; - -public class App -{ - private static PerformanceCounter PC; - private static PerformanceCounter BPC; - - public static void Main() - { - ArrayList samplesList = new ArrayList(); - - // If the category does not exist, create the category and exit. - // Performance counters should not be created and immediately used. - // There is a latency time to enable the counters, they should be created - // prior to executing the application that uses the counters. - // Execute this sample a second time to use the counters. - if (SetupCategory()) - return; - CreateCounters(); - CollectSamples(samplesList); - CalculateResults(samplesList); - } - - private static bool SetupCategory() - { - - if (!PerformanceCounterCategory.Exists("RawFractionSampleCategory")) - { - - CounterCreationDataCollection CCDC = new CounterCreationDataCollection(); - - // Add the counter. - CounterCreationData rf = new CounterCreationData(); - rf.CounterType = PerformanceCounterType.RawFraction; - rf.CounterName = "RawFractionSample"; - CCDC.Add(rf); - - // Add the base counter. - CounterCreationData rfBase = new CounterCreationData(); - rfBase.CounterType = PerformanceCounterType.RawBase; - rfBase.CounterName = "RawFractionSampleBase"; - CCDC.Add(rfBase); - - // Create the category. - PerformanceCounterCategory.Create("RawFractionSampleCategory", - "Demonstrates usage of the RawFraction performance counter type.", - PerformanceCounterCategoryType.SingleInstance, CCDC); - - return (true); - } - else - { - Console.WriteLine("Category exists - RawFractionSampleCategory"); - return (false); - } - } - - private static void CreateCounters() - { - // Create the counters. - PC = new PerformanceCounter("RawFractionSampleCategory", - "RawFractionSample", - false); - - BPC = new PerformanceCounter("RawFractionSampleCategory", - "RawFractionSampleBase", - false); - - PC.RawValue = 0; - BPC.RawValue = 0; - } - - private static void CollectSamples(ArrayList samplesList) - { - - Random r = new Random(DateTime.Now.Millisecond); - - // Initialize the performance counter. - PC.NextSample(); - - // Loop for the samples. - for (int j = 0; j < 100; j++) - { - int value = r.Next(1, 10); - Console.Write(j + " = " + value); - - // Increment the base every time, because the counter measures the number - // of high hits (raw fraction value) against all the hits (base value). - BPC.Increment(); - - // Get the % of samples that are 9 or 10 out of all the samples taken. - if (value >= 9) - PC.Increment(); - - // Copy out the next value every ten times around the loop. - if ((j % 10) == 9) - { - Console.WriteLine("; NextValue() = " + PC.NextValue().ToString()); - OutputSample(PC.NextSample()); - samplesList.Add(PC.NextSample()); - } - else - { - Console.WriteLine(); - } - - System.Threading.Thread.Sleep(50); - } - } - - private static void CalculateResults(ArrayList samplesList) - { - for (int i = 0; i < samplesList.Count; i++) - { - // Output the sample. - OutputSample((CounterSample)samplesList[i]); - - // Use .NET to calculate the counter value. - Console.WriteLine(".NET computed counter value = " + - CounterSampleCalculator.ComputeCounterValue((CounterSample)samplesList[i])); - - // Calculate the counter value manually. - Console.WriteLine("My computed counter value = " + - MyComputeCounterValue((CounterSample)samplesList[i])); - } - } - - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - // Formula from MSDN - - // Description - This counter type shows the ratio of a subset to its set as a percentage. - // For example, it compares the number of bytes in use on a disk to the - // total number of bytes on the disk. Counters of this type display the - // current percentage only, not an average over time. - // - // Generic type - Instantaneous, Percentage - // Formula - (N0 / D0), where D represents a measured attribute and N represents one - // component of that attribute. - // - // Average - SUM (N / D) /x - // Example - Paging File\% Usage Peak - //++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ - private static Single MyComputeCounterValue(CounterSample rfSample) - { - Single numerator = (Single)rfSample.RawValue; - Single denomenator = (Single)rfSample.BaseValue; - Single counterValue = (numerator / denomenator) * 100; - return (counterValue); - } - - // Output information about the counter sample. - private static void OutputSample(CounterSample s) - { - Console.WriteLine("+++++++++++"); - Console.WriteLine("Sample values - \r\n"); - Console.WriteLine(" BaseValue = " + s.BaseValue); - Console.WriteLine(" CounterFrequency = " + s.CounterFrequency); - Console.WriteLine(" CounterTimeStamp = " + s.CounterTimeStamp); - Console.WriteLine(" CounterType = " + s.CounterType); - Console.WriteLine(" RawValue = " + s.RawValue); - Console.WriteLine(" SystemFrequency = " + s.SystemFrequency); - Console.WriteLine(" TimeStamp = " + s.TimeStamp); - Console.WriteLine(" TimeStamp100nSec = " + s.TimeStamp100nSec); - Console.WriteLine("++++++++++++++++++++++"); - } -} - -// \ No newline at end of file diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs deleted file mode 100644 index 6f774eb4ea8..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable10.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, s1.Length - position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, s1.Length - position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, s1.Length - position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, s2.Length - position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs deleted file mode 100644 index 4cdb5f27662..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable12.cs +++ /dev/null @@ -1,127 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, - s1.Length - position, CompareOptions.None)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, - s2.Length - position, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, - s1.Length - position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, - s2.Length - position, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, - s1.Length - position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, - s2.Length - position, CompareOptions.IgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, - s1.Length - position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, - s2.Length - position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, - s1.Length - position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, - s2.Length - position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, - s1.Length - position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, - s2.Length - position, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs deleted file mode 100644 index e858a3e4585..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable6.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs b/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs deleted file mode 100644 index 9b2b2ea5a91..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/IndexOf/ignorable9.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, CompareOptions.None)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, CompareOptions.IgnoreCase)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, CompareOptions.IgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00AD", position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00AD", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADn", position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADn", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.IndexOf(s1, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s1, "\u00ADm", position, CompareOptions.Ordinal)); - - position = ci.IndexOf(s2, "n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.IndexOf(s2, "\u00ADm", position, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs b/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs deleted file mode 100644 index af8d6d515f6..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable10.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, position + 1)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, position + 1)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, position + 1)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, position + 1)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, position + 1)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, position + 1)); - } -} -// The example displays the following output: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs b/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs deleted file mode 100644 index 479b93e1aef..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable12.cs +++ /dev/null @@ -1,127 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, - position + 1, CompareOptions.None)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, - position + 1, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, - position + 1, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, - position + 1, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, - position + 1, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, - position + 1, CompareOptions.IgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, - position + 1, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, - position + 1, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, - position + 1, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, - position + 1, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, - position + 1, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, - position + 1, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// -// Ordinal comparisons: -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// diff --git a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs b/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs deleted file mode 100644 index b8b49bd76cb..00000000000 --- a/snippets/csharp/System.Globalization/CompareInfo/LastIndexOf/lastignorable9.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - CompareInfo ci = CultureInfo.CurrentCulture.CompareInfo; - - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, CompareOptions.None)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, CompareOptions.None)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, CompareOptions.IgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, CompareOptions.IgnoreCase)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, CompareOptions.IgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00AD", position, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00AD", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADn", position, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADn", position, CompareOptions.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = ci.LastIndexOf(s1, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s1, "\u00ADm", position, CompareOptions.Ordinal)); - - position = ci.LastIndexOf(s2, "m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(ci.LastIndexOf(s2, "\u00ADm", position, CompareOptions.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// -// Ordinal comparisons: -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// -1 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// diff --git a/snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs b/snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs deleted file mode 100644 index 7fb7c040e49..00000000000 --- a/snippets/csharp/System.Globalization/IdnMapping/GetHashCode/conversion1a.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string[] names = { "johann_doe@bücher.com", "vi@мойдомен.рф", "ia@παράδειγμα.δοκιμή", - "webmaster@mycharity\u3002org", - "admin@prose\u0000ware.com", "john_doe@proseware..com", - "jane_doe@a.org", "me@my_company.com" }; - IdnMapping idn = new IdnMapping(); - - foreach (var thisName in names) { - string name = thisName; - try { - int position = name.LastIndexOf("@"); - if (position >= 0) - name = name.Substring(position + 1); - - string punyCode = idn.GetAscii(name); - string name2 = idn.GetUnicode(punyCode); - Console.WriteLine("{0} --> {1} --> {2}", name, punyCode, name2); - Console.WriteLine("Original: {0}", ShowCodePoints(name)); - Console.WriteLine("Restored: {0}", ShowCodePoints(name2)); - } - catch (ArgumentException) { - Console.WriteLine("{0} is not a valid domain name.", name); - } - Console.WriteLine(); - } - } - - private static string ShowCodePoints(string str1) - { - string output = ""; - foreach (var ch in str1) - output += $"U+{(ushort)ch:X4} "; - - return output; - } -} -// The example displays the following output: -// bücher.com --> xn--bcher-kva.com --> bücher.com -// Original: U+0062 U+00FC U+0063 U+0068 U+0065 U+0072 U+002E U+0063 U+006F U+006D -// Restored: U+0062 U+00FC U+0063 U+0068 U+0065 U+0072 U+002E U+0063 U+006F U+006D -// -// мойдомен.рф --> xn--d1acklchcc.xn--p1ai --> мойдомен.рф -// Original: U+043C U+043E U+0439 U+0434 U+043E U+043C U+0435 U+043D U+002E U+0440 U+0444 -// Restored: U+043C U+043E U+0439 U+0434 U+043E U+043C U+0435 U+043D U+002E U+0440 U+0444 -// -// παράδειγμα.δοκιμή --> xn--hxajbheg2az3al.xn--jxalpdlp --> παράδειγμα.δοκιμή -// Original: U+03C0 U+03B1 U+03C1 U+03AC U+03B4 U+03B5 U+03B9 U+03B3 U+03BC U+03B1 U+002E U+03B4 U+03BF U+03BA U+03B9 U+03BC U+03AE -// Restored: U+03C0 U+03B1 U+03C1 U+03AC U+03B4 U+03B5 U+03B9 U+03B3 U+03BC U+03B1 U+002E U+03B4 U+03BF U+03BA U+03B9 U+03BC U+03AE -// -// mycharity。org --> mycharity.org --> mycharity.org -// Original: U+006D U+0079 U+0063 U+0068 U+0061 U+0072 U+0069 U+0074 U+0079 U+3002 U+006F U+0072 U+0067 -// Restored: U+006D U+0079 U+0063 U+0068 U+0061 U+0072 U+0069 U+0074 U+0079 U+002E U+006F U+0072 U+0067 -// -// prose ware.com is not a valid domain name. -// -// proseware..com is not a valid domain name. -// -// a.org --> a.org --> a.org -// Original: U+0061 U+002E U+006F U+0072 U+0067 -// Restored: U+0061 U+002E U+006F U+0072 U+0067 -// -// my_company.com --> my_company.com --> my_company.com -// Original: U+006D U+0079 U+005F U+0063 U+006F U+006D U+0070 U+0061 U+006E U+0079 U+002E U+0063 U+006F U+006D -// Restored: U+006D U+0079 U+005F U+0063 U+006F U+006D U+0070 U+0061 U+006E U+0079 U+002E U+0063 U+006F U+006D -// diff --git a/snippets/csharp/System.IO/FileStream/Overview/example2.cs b/snippets/csharp/System.IO/FileStream/Overview/example2.cs deleted file mode 100644 index 3e82970f4f2..00000000000 --- a/snippets/csharp/System.IO/FileStream/Overview/example2.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Threading.Tasks; -using System.Windows; -using System.IO; - -namespace WpfApplication1 -{ - public partial class MainWindow2 : Window - { - public MainWindow2() - { - InitializeComponent(); - } - - // - private async void Button_Click(object sender, RoutedEventArgs e) - { - string UserDirectory = @"c:\Users\exampleuser\"; - - using (StreamReader SourceReader = File.OpenText(UserDirectory + "BigFile.txt")) - { - using (StreamWriter DestinationWriter = File.CreateText(UserDirectory + "CopiedFile.txt")) - { - await CopyFilesAsync(SourceReader, DestinationWriter); - } - } - } - - public async Task CopyFilesAsync(StreamReader Source, StreamWriter Destination) - { - char[] buffer = new char[0x1000]; - int numRead; - while ((numRead = await Source.ReadAsync(buffer, 0, buffer.Length)) != 0) - { - await Destination.WriteAsync(buffer, 0, numRead); - } - } - // - } -} diff --git a/snippets/csharp/System.IO/StreamReader/Overview/source2.cs b/snippets/csharp/System.IO/StreamReader/Overview/source2.cs deleted file mode 100644 index 5fe7a2b67ff..00000000000 --- a/snippets/csharp/System.IO/StreamReader/Overview/source2.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; -using System.IO; - -public class CompBuf -{ - private const string FILE_NAME = "MyFile.txt"; - - public static void Main() - { - if (!File.Exists(FILE_NAME)) - { - Console.WriteLine($"{FILE_NAME} does not exist!"); - return; - } - FileStream fsIn = new FileStream(FILE_NAME, FileMode.Open, - FileAccess.Read, FileShare.Read); - // Create an instance of StreamReader that can read - // characters from the FileStream. - using (StreamReader sr = new StreamReader(fsIn)) - { - string input; - // While not at the end of the file, read lines from the file. - while (sr.Peek() > -1) - { - input = sr.ReadLine(); - Console.WriteLine(input); - } - } - } -} -// diff --git a/snippets/csharp/System.IO/StreamReader/Overview/source3.cs b/snippets/csharp/System.IO/StreamReader/Overview/source3.cs deleted file mode 100644 index 1ed6500a096..00000000000 --- a/snippets/csharp/System.IO/StreamReader/Overview/source3.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; -using System.IO; - -public class ReadBuf -{ - private const string FILE_NAME = "MyFile.txt"; - - public static void Main() - { - if (!File.Exists(FILE_NAME)) - { - Console.WriteLine($"{FILE_NAME} does not exist."); - return; - } - FileStream f = new FileStream(FILE_NAME, FileMode.Open, - FileAccess.Read, FileShare.Read); - // Create an instance of BinaryReader that can - // read bytes from the FileStream. - using (BinaryReader br = new BinaryReader(f)) - { - byte input; - // While not at the end of the file, read lines from the file. - while (br.PeekChar() > -1 ) - { - input = br.ReadByte(); - Console.WriteLine(input); - } - } - } -} -// diff --git a/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs b/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs deleted file mode 100644 index 3f000b094bd..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - This program demonstrates the 'Constructor' of 'DnsPermission' class. - It creates an instance of 'DnsPermission' class and checks for permission.Then it - creates a 'SecurityElement' object and prints it's attributes which hold the XML - encoding of 'DnsPermission' instance . -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main() { - try { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } -// - public void useDns() { - - // Create a DnsPermission instance. - DnsPermission permission = new DnsPermission(PermissionState.Unrestricted); - - // Check for permission. - permission.Demand(); - // Create a SecurityElement object to hold XML encoding of the DnsPermission instance. - SecurityElement securityElementObj = permission.ToXml(); - Console.WriteLine("Tag, Attributes and Values of 'DnsPermission' instance :"); - Console.WriteLine("\n\tTag :" + securityElementObj.Tag); - // Print the attributes and values. - PrintKeysAndValues(securityElementObj.Attributes); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\n\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs b/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs deleted file mode 100644 index c327b9de562..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - This program demonstrates the 'Copy' method of 'DnsPermission' class. - It creates an identical copy of 'DnsPermission' instance. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main() { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.UseDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } - -// - public void UseDns() { - // Create a DnsPermission instance. - DnsPermission myPermission = new DnsPermission(PermissionState.Unrestricted); - // Check for permission. - myPermission.Demand(); - // Create an identical copy of the above 'DnsPermission' object. - DnsPermission myPermissionCopy = (DnsPermission)myPermission.Copy(); - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :"); - // Print the attributes and values. - PrintKeysAndValues(myPermission.ToXml().Attributes); - Console.WriteLine("Attribute and values of copied instance :"); - PrintKeysAndValues(myPermissionCopy.ToXml().Attributes); - } - - private void PrintKeysAndValues(Hashtable myHashtable) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs b/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs deleted file mode 100644 index 28c3c9d7083..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs +++ /dev/null @@ -1,85 +0,0 @@ -/* - This program demonstrates the 'FromXml' method of 'DnsPermission' class. - It creates an instance of 'DnsPermission' class and prints the XML encoding of that instance.Then it - creates a 'SecurityElement' object and adds the attributes corresponding to the above 'DnsPermission' - object. A new 'DnsPermission' instance is reconstructed from the 'SecurityElement' instance by calling - 'FromXml' method and it's XML encoding is printed. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main() { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.ConstructDnsPermission(); - } -// - public void ConstructDnsPermission() { - try - { - // Create a DnsPermission instance. - DnsPermission permission = new DnsPermission(PermissionState.None); - // Create a SecurityElement instance by calling the ToXml method on the - // DnsPermission instance. - // Print its attributes, which hold the XML encoding of the DnsPermission - // instance. - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :"); - PrintKeysAndValues(permission.ToXml().Attributes); - - // Create a SecurityElement instance. - SecurityElement securityElementObj = new SecurityElement("IPermission"); - // Add attributes and values of the SecurityElement instance corresponding to - // the permission instance. - securityElementObj.AddAttribute("version", "1"); - securityElementObj.AddAttribute("Unrestricted", "true"); - securityElementObj.AddAttribute("class","System.Net.DnsPermission"); - - // Reconstruct a DnsPermission instance from an XML encoding. - DnsPermission permission1 = new DnsPermission(PermissionState.None); - permission1.FromXml(securityElementObj); - - // Print the attributes and values of the constructed DnsPermission object. - Console.WriteLine("After reconstruction Attributes and Values of new DnsPermission instance :"); - PrintKeysAndValues(permission1.ToXml().Attributes); - } - catch(NullReferenceException e) - { - Console.WriteLine("NullReferenceException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(ArgumentNullException e) - { - Console.WriteLine("ArgumentNullException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs b/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs deleted file mode 100644 index bf9d445d89f..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - This program demonstrates the 'Intersect' and 'Union' methods of 'DnsPermission' class. - It creates a 'DnsPermission' instance that is the Union/Intersection of current permission - instance and specified permission instance. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - private DnsPermission dnsPermission1; - private DnsPermission dnsPermission2; - - public static void Main() { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } - // - private void MyUnion() - { - // Create a DnsPermission instance that is the union of the current DnsPermission - // instance and the specified DnsPermission instance. - DnsPermission permission = (DnsPermission)dnsPermission1.Union(dnsPermission2); - // Print the attributes and the values of the union instance of DnsPermission. - PrintKeysAndValues(permission.ToXml().Attributes); - } -// - public void useDns() { - // Create a DnsPermission instance. - dnsPermission1 = new DnsPermission(PermissionState.Unrestricted); - dnsPermission2 = new DnsPermission(PermissionState.None); - // Check for permission. - dnsPermission1.Demand(); - dnsPermission2.Demand(); - Console.WriteLine("Attributes and Values of first DnsPermission instance :"); - PrintKeysAndValues(dnsPermission1.ToXml().Attributes); - Console.WriteLine("Attributes and Values of second DnsPermission instance :"); - PrintKeysAndValues(dnsPermission2.ToXml().Attributes); - Console.WriteLine("Union of both instances : "); - MyUnion(); - Console.WriteLine("Intersection of both instances : "); - MyIntersection(); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash tabble. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// - // Create a DnsPermission instance that is the intersection of current - // DnsPermission instance and the specified DnsPermission instance. - private void MyIntersection() - { - DnsPermission permission = (DnsPermission)dnsPermission1.Intersect(dnsPermission2); - // Print the attributes and the values of the intersection instance of - // DnsPermission. - PrintKeysAndValues(permission.ToXml().Attributes); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs b/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs deleted file mode 100644 index 69c71eb6ec1..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - This program demonstrates the 'IsSubsetOf' method of 'DnsPermission' class. - 'IsSubsetOf' method returns true, if the current DnsPermission instance allows no - more access to DNS servers than does the specified 'DnsPermission' instance. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - private DnsPermission permission; - - public static void Main() { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } -// - public void useDns() { - // Create a DnsPermission instance. - permission = new DnsPermission(PermissionState.Unrestricted); - DnsPermission dnsPermission1 = new DnsPermission(PermissionState.None); - // Check for permission. - permission.Demand(); - dnsPermission1.Demand(); - // Print the attributes and values. - Console.WriteLine("Attributes and Values of 'DnsPermission' instance :"); - PrintKeysAndValues(permission.ToXml().Attributes); - Console.WriteLine("Attributes and Values of specified 'DnsPermission' instance :"); - PrintKeysAndValues(dnsPermission1.ToXml().Attributes); - Subset(dnsPermission1); - } - - private void Subset(DnsPermission Permission1) - { - if(permission.IsSubsetOf(Permission1)) - Console.WriteLine("Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance."); - else - Console.WriteLine("Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance."); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs b/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs deleted file mode 100644 index 0369b3cd3c7..00000000000 --- a/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* - This program demonstrates the 'IsUnrestricted' method of 'DnsPermission' class. - It checks the overall permission state of the object and it will return true if the - 'DnsPermission' instance was created with unrestricted permission state otherwise false. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class DnsPermissionExample { - - public static void Main(String[] Args) { - try - { - DnsPermissionExample dnsPermissionExampleObj = new DnsPermissionExample(); - dnsPermissionExampleObj.useDns(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception caught!!!"); - Console.WriteLine("Source : " + e.Source); - Console.WriteLine("Message : " + e.Message); - } - } -// - public void useDns() { - // Create a DnsPermission instance. - DnsPermission permission = new DnsPermission(PermissionState.Unrestricted); - // Check for permission. - permission.Demand(); - Console.WriteLine("Attributes and Values of DnsPermission instance :"); - // Print the attributes and values. - PrintKeysAndValues(permission.ToXml().Attributes); - // Check the permission state. - if (permission.IsUnrestricted()) - Console.WriteLine("Overall permissions : Unrestricted"); - else - Console.WriteLine("Overall permissions : Restricted"); - } - - private void PrintKeysAndValues(Hashtable myList) { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } -// -}; diff --git a/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs b/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs deleted file mode 100644 index dda75739c35..00000000000 --- a/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Net; -using System.IO; -using System.Windows.Forms; - -public class Form1: Form -{ - public void Method() - { -// - Uri proxyURI = new Uri("http://webproxy:80"); - GlobalProxySelection.Select = new WebProxy(proxyURI); -// - } -} diff --git a/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs b/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs deleted file mode 100644 index e0230a24d8a..00000000000 --- a/snippets/csharp/System.Net/SocketPermission/.ctor/dateclient_socketpermission_constructor.cs +++ /dev/null @@ -1,157 +0,0 @@ -/* - This program demonstrates the 'SocketPermission(PermissionState)', - 'SocketPermission(NetworkAccess, TransportType, string, int) constructors, - 'FromXml', 'Intersect', 'AddPermission' methods and 'AllPorts' field - of 'SocketPermission' class. - - This program provides a class called 'DateClient' that functions as a client - for a 'DateServer'. A 'DateServer' is a server that provides the current date on - the server in response to a request from a client. The 'DateClient' class - provides a method called 'GetDate' which returns the current date on the server. - The 'GetDate' is the method that shows the use of 'SocketPermission' class. An - instance of 'SocketPermission' is obtained using the 'FromXml' method. Another - instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, - TransportType, string, int)' constructor. A third 'SocketPermission' object is - formed from the intersection of the above two 'SocketPermission' objects with the - use of the 'Intersect' method of 'SocketPermission' class. This 'SocketPermission' - object is used by the 'GetDate' method to verify the permissions of the calling - method. If the calling method has the requisite permissions the 'GetDate' method - connects to the 'DateServer' and returns the current date that the 'DateServer' - sends. If any exception occurs the 'GetDate' method returns an empty string. - - Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Collections; -using System.Security; -using System.Security.Permissions; - -public class DateClient { - - private Socket serverSocket; - private Encoding asciiEncoding; - private IPAddress serverAddress; - - private int serverPort; - - // The constructor takes the address and port of the remote server. - public DateClient(IPAddress ipAddress, int port) { - serverAddress = ipAddress; - serverPort = port; - serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - asciiEncoding = Encoding.ASCII; - } - - public String GetDate() { -// -// -// -// -// -// - SocketPermission socketPermission1 = new SocketPermission(PermissionState.Unrestricted); - - // Create a 'SocketPermission' object for two ip addresses. - SocketPermission socketPermission2 = new SocketPermission(PermissionState.None); - SecurityElement securityElement1 = socketPermission2.ToXml(); - // 'SocketPermission' object for 'Connect' permission - SecurityElement securityElement2 = new SecurityElement("ConnectAccess"); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and - // for 'All'ports for the ip-address. - SecurityElement securityElement3 = new SecurityElement("URI", "192.168.144.238#-1#3"); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and - // for 'All' ports for the ip-address. - SecurityElement securityElement4 = new SecurityElement("URI", "192.168.144.240#-1#3"); - securityElement2.AddChild(securityElement3); - securityElement2.AddChild(securityElement4); - securityElement1.AddChild(securityElement2); - - // Obtain a 'SocketPermission' object using 'FromXml' method. - socketPermission2.FromXml(securityElement1); - - Console.WriteLine("\nDisplays the result of FromXml method : \n"); - Console.WriteLine(socketPermission2.ToString()); - - // Create another 'SocketPermission' object with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission socketPermission3 = - new SocketPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.238", - SocketPermission.AllPorts); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3.AddPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.239", - SocketPermission.AllPorts); - - Console.WriteLine("Displays the result of AddPermission method : \n"); - Console.WriteLine(socketPermission3.ToString()); - - // Find the intersection between two 'SocketPermission' objects. - socketPermission1 = (SocketPermission)socketPermission2.Intersect(socketPermission3); - - Console.WriteLine("Displays the result of Intersect method :\n "); - Console.WriteLine(socketPermission1.ToString()); - - // Demand that the calling method have the requsite socket permission. - socketPermission1.Demand(); -// -// -// -// -// -// - // Get the current date from the remote date server. - try { - int bytesReceived; - byte[] getByte = new byte[100]; - serverSocket.Connect(new IPEndPoint( serverAddress, serverPort)); - bytesReceived = serverSocket.Receive( getByte, getByte.Length, 0 ); - return asciiEncoding.GetString( getByte, 0, bytesReceived ); - } - catch(Exception e) - { - Console.WriteLine("\nException raised : {0}", e.Message); - return ""; - } - } -}; - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' object. -public class UserDateClient { - - public static void Main(String[] args) { - if(args.Length != 2) - { - PrintUsage(); - return; - } - try { - DateClient myDateClient = new DateClient(IPAddress.Parse(args[0]), Int32.Parse(args[1])); - String currentDate = myDateClient.GetDate(); - Console.WriteLine("The current date and time is : "); - Console.WriteLine("{0}", currentDate); - } - // This exception is thrown by the called method in the context of improper permissions. - catch(SecurityException e) { - Console.WriteLine("\nSecurityException raised : {0}", e.Message); - } - catch(Exception e) { - Console.WriteLine("\nException raised : {0}", e.Message); - } - } - - private static void PrintUsage() { - Console.WriteLine("Usage : DateClient_SocketPermission_Constructor"); - Console.WriteLine("\tDateClient_SocketPermission_Constructor "); - Console.WriteLine("\tThe ipaddress argument is the ip address of the Date server."); - Console.WriteLine("\tThe port argument is the port of the Date server."); - } -}; diff --git a/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs b/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs deleted file mode 100644 index 02b1ca72f21..00000000000 --- a/snippets/csharp/System.Net/SocketPermission/ConnectList/dateclient_socketpermission_toxml.cs +++ /dev/null @@ -1,186 +0,0 @@ -/* - This program demonstrates the 'ToXml' and 'IsUnrestricted' method and 'ConnectList' property of - 'SocketPermission' class. - - This program provides a class called 'DateClient' that functions as a client - for a 'DateServer'. A 'DateServer' is a server that provides the current date on - the server in response to a request from a client. The 'DateClient' class - provides a method called 'GetDate' which returns the current date on the server. - The 'GetDate' is the method that shows the use of 'SocketPermission' class. An - instance of 'SocketPermission' is obtained using the 'FromXml' method. Another - instance of 'SocketPermission' is created with the 'SocketPermission(NetworkAccess, - TransportType, string, int)' constructor. A third 'SocketPermission' object is - formed from the union of the above two 'SocketPermission' objects with the use of the - 'Union' method of the 'SocketPermission' class. This 'SocketPermission' object is used by - the 'GetDate' method to verify the permissions of the calling method. If the calling - method has the requisite permissions the 'GetDate' method connects to the 'DateServer' - and returns the current date that the 'DateServer' sends. If any exception occurs - the 'GetDate' method returns an empty string. - - Note: This program requires 'DateServer_SocketPermission' program executing. -*/ - -// -// -// -using System; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Collections; -using System.Security; -using System.Security.Permissions; - -public class DateClient { - - private Socket serverSocket; - private Encoding asciiEncoding; - private IPAddress serverAddress; - - private int serverPort; - - // The constructor takes the address and port of the remote server. - public DateClient(IPAddress serverIpAddress, int port) { - serverAddress = serverIpAddress; - serverPort = port; - serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - asciiEncoding = Encoding.ASCII; - } - - // Print a security element and all its children, in a depth-first manner. - private void PrintSecurityElement(SecurityElement securityElementObj, int depth) { - - Console.WriteLine("Depth : {0}", depth); - Console.WriteLine("Tag : {0}", securityElementObj.Tag); - Console.WriteLine("Text : {0}", securityElementObj.Text); - if(securityElementObj.Children != null) - Console.WriteLine("Children : {0}", securityElementObj.Children.Count); - - if(securityElementObj.Attributes != null) { - IEnumerator attributeEnumerator = securityElementObj.Attributes.GetEnumerator(); - while(attributeEnumerator.MoveNext()) - Console.WriteLine("Attribute - \"{0}\" , Value - \"{1}\"", ((IDictionaryEnumerator)attributeEnumerator).Key, - ((IDictionaryEnumerator)attributeEnumerator).Value); - } - - Console.WriteLine(""); - - if(securityElementObj.Children != null) { - depth += 1; - for(int i = 0; i < securityElementObj.Children.Count; i++) - PrintSecurityElement((SecurityElement)(securityElementObj.Children[i]), depth); - } - } - - public String GetDate() - { - - SocketPermission socketPermission1 = new SocketPermission(PermissionState.Unrestricted); - - // Create a 'SocketPermission' object for two ip addresses. - SocketPermission socketPermission2 = new SocketPermission(PermissionState.None); - SecurityElement securityElement4 = socketPermission2.ToXml(); - // 'SocketPermission' object for 'Connect' permission - SecurityElement securityElement1 = new SecurityElement("ConnectAccess"); - // Format to specify ip address are ## - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement securityElement2 = new SecurityElement("URI", "192.168.144.238#-1#3"); - // Second 'SocketPermission' ip-address is '192.168.144.240' for 'All' transport types and for 'All' ports for the ip-address. - SecurityElement securityElement3 = new SecurityElement("URI", "192.168.144.240#-1#3"); - securityElement1.AddChild(securityElement2); - securityElement1.AddChild(securityElement3); - securityElement4.AddChild(securityElement1); - - // Obtain a 'SocketPermission' object using 'FromXml' method. - socketPermission2.FromXml(securityElement4); - - // Create another 'SocketPermission' object with two ip addresses. - // First 'SocketPermission' ip-address is '192.168.144.238' for 'All' transport types and for 'All' ports for the ip-address. - SocketPermission socketPermission3 = - new SocketPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.238", - SocketPermission.AllPorts); - - // Second 'SocketPermission' ip-address is '192.168.144.239' for 'All' transport types and for 'All' ports for the ip-address. - socketPermission3.AddPermission(NetworkAccess.Connect, - TransportType.All, - "192.168.144.239", - SocketPermission.AllPorts); - - Console.WriteLine("\nChecks the Socket permissions using IsUnrestricted method : "); - if(socketPermission1.IsUnrestricted()) - Console.WriteLine("Socket permission is unrestricted"); - else - Console.WriteLine("Socket permission is restricted"); - - Console.WriteLine(); - - Console.WriteLine("Display result of ConnectList property : \n"); - IEnumerator enumerator = socketPermission3.ConnectList; - while(enumerator.MoveNext()) { - Console.WriteLine("The hostname is : {0}", ((EndpointPermission)enumerator.Current).Hostname); - Console.WriteLine("The port is : {0}", ((EndpointPermission)enumerator.Current).Port); - Console.WriteLine("The Transport type is : {0}", ((EndpointPermission)enumerator.Current).Transport); - } - Console.WriteLine(""); - - Console.WriteLine("Display Security Elements :\n "); - PrintSecurityElement(socketPermission2.ToXml(), 0); - - // Get a 'SocketPermission' object which is a union of two other 'SocketPermission' objects. - socketPermission1 = (SocketPermission)socketPermission3.Union(socketPermission2); - - // Demand that the calling method have the socket permission. - socketPermission1.Demand(); - - // Get the current date from the remote date server. - try { - int bytesReceived; - byte[] getByte = new byte[100]; - serverSocket.Connect(new IPEndPoint( serverAddress, serverPort)); - bytesReceived = serverSocket.Receive( getByte, getByte.Length, 0 ); - return asciiEncoding.GetString( getByte, 0, bytesReceived ); - } - catch(Exception e) - { - Console.WriteLine("\nException raised : {0}", e.Message); - return ""; - } - } -}; -// -// -// - -// This class is used to demonstrate the caller of the 'GetDate' method for the 'DateClient' object. -public class UserDateClient { - - public static void Main(String[] args) { - if(args.Length != 2) - { - PrintUsage(); - return; - } - try { - DateClient myDateClient = new DateClient(IPAddress.Parse(args[0]), Int32.Parse(args[1])); - String currentDate = myDateClient.GetDate(); - Console.WriteLine("The current date and time is : "); - Console.WriteLine("{0}", currentDate); - } - // This exception is thrown by the called method in the context of improper permissions. - catch(SecurityException e) { - Console.WriteLine("\nSecurityException raised : {0}", e.Message); - } - catch(Exception e) { - Console.WriteLine("\nException raised : {0}", e.Message); - } - } - - private static void PrintUsage() { - Console.WriteLine("Usage : DateClient_SocketPermission_ToXml"); - Console.WriteLine("\tDateClient_SocketPermission_ToXml "); - Console.WriteLine("\tThe ipaddress argument is the ip address of the Date server."); - Console.WriteLine("\tThe port argument is the port of the Date server."); - } -}; diff --git a/snippets/csharp/System.Net/SocketPermission/Overview/source.cs b/snippets/csharp/System.Net/SocketPermission/Overview/source.cs deleted file mode 100644 index 18465949600..00000000000 --- a/snippets/csharp/System.Net/SocketPermission/Overview/source.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Text; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.Security.Permissions; -using System.Collections; - -public class MySocketPermissionExample{ - -public static void MySocketPermission(){ -// -// - - // Creates a SocketPermission restricting access to and from all URIs. - SocketPermission mySocketPermission1 = new SocketPermission(PermissionState.None); - - // The socket to which this permission will apply will allow connections from www.contoso.com. - mySocketPermission1.AddPermission(NetworkAccess.Accept, TransportType.Tcp, "www.contoso.com", 11000); - - // Creates a SocketPermission which will allow the target Socket to connect with www.southridgevideo.com. - SocketPermission mySocketPermission2 = - new SocketPermission(NetworkAccess.Connect, TransportType.Tcp, "www.southridgevideo.com", 11002); - - // Creates a SocketPermission from the union of two SocketPermissions. - SocketPermission mySocketPermissionUnion = - (SocketPermission)mySocketPermission1.Union(mySocketPermission2); - - // Checks to see if the union was successfully created by using the IsSubsetOf method. - if (mySocketPermission1.IsSubsetOf(mySocketPermissionUnion) && - mySocketPermission2.IsSubsetOf(mySocketPermissionUnion)){ - Console.WriteLine("This union contains permissions from both mySocketPermission1 and mySocketPermission2"); - - // Prints the allowable accept URIs to the console. - Console.WriteLine("This union accepts connections on :"); - - IEnumerator myEnumerator = mySocketPermissionUnion.AcceptList; - while (myEnumerator.MoveNext()) { - Console.WriteLine(((EndpointPermission)myEnumerator.Current).ToString()); - } - - // Prints the allowable connect URIs to the console. - Console.WriteLine("This union permits connections to :"); - - myEnumerator = mySocketPermissionUnion.ConnectList; - while (myEnumerator.MoveNext()) { - Console.WriteLine(((EndpointPermission)myEnumerator.Current).ToString()); - } - } - -// -// - - // Creates a SocketPermission from the intersect of two SocketPermissions. - SocketPermission mySocketPermissionIntersect = - (SocketPermission)mySocketPermission1.Intersect(mySocketPermissionUnion); - - // mySocketPermissionIntersect should now contain the permissions of mySocketPermission1. - if (mySocketPermission1.IsSubsetOf(mySocketPermissionIntersect)){ - Console.WriteLine("This is expected"); - } - // mySocketPermissionIntersect should not contain the permissios of mySocketPermission2. - if (mySocketPermission2.IsSubsetOf(mySocketPermissionIntersect)){ - Console.WriteLine("This should not print"); - } - -// - -// -// Creates a copy of the intersect SocketPermission. - SocketPermission mySocketPermissionIntersectCopy = - (SocketPermission)mySocketPermissionIntersect.Copy(); - - if (mySocketPermissionIntersectCopy.Equals(mySocketPermissionIntersect)){ - Console.WriteLine("Copy successfull"); - } - -// - - // Converts a SocketPermission to XML format and then immediately converts it back to a SocketPermission. - mySocketPermission1.FromXml(mySocketPermission1.ToXml()); - - // Checks to see if permission for this socket resource is unrestricted. If it is, then there is no need to - // demand that permissions be enforced. - if (mySocketPermissionUnion.IsUnrestricted()){ - - //Do nothing. There are no restrictions. - } - else{ - // Enforces the permissions found in mySocketPermissionUnion on any Socket Resources used below this statement. - mySocketPermissionUnion.Demand(); - } - - IPHostEntry myIpHostEntry = Dns.Resolve("www.contoso.com"); - IPEndPoint myLocalEndPoint = new IPEndPoint(myIpHostEntry.AddressList[0], 11000); - - Socket s = new Socket(myLocalEndPoint.Address.AddressFamily, - SocketType.Stream, - ProtocolType.Tcp); - try{ - s.Connect(myLocalEndPoint); - } - catch (Exception e){ - Console.WriteLine("Exception Thrown: " + e.ToString()); - } - - // Perform all socket operations in here. - - s.Close(); -// -} - -public static void Main(){ -MySocketPermissionExample.MySocketPermission(); -} -} diff --git a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs b/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs deleted file mode 100644 index 97372f19217..00000000000 --- a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_constructor4.cs +++ /dev/null @@ -1,73 +0,0 @@ -// System.Net.WebPermission.WebPermission(NetworkAccess,Regex); -/* - This program demonstrates the 'WebPermission(NetworkAccess,Regex)' constructor of 'WebPermission' class. - First a 'Regex' object is created that will accept all the urls which is having the hostfragment of - 'www.contoso.com'.Then a 'WebPermission' object created by passing the 'NetworkAccess' permission and - 'Regex' object as parameters. It checks the 'WebPermission' for all the url's having the host fragment - as 'www.contoso.com'. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Text.RegularExpressions; -using System.Collections; - -class WebPermission_regexConstructor { - - static void Main() - { - try - { - WebPermission_regexConstructor myWebPermissionRegex = new WebPermission_regexConstructor(); - myWebPermissionRegex.CreateRegexConstructor(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException raised: " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception raised: " + e.Message); - } - } - - public void CreateRegexConstructor() - { - -// - - // Create an instance of 'Regex' that accepts all URL's containing the host - // fragment 'www.contoso.com'. - Regex myRegex = new Regex(@"http://www\.contoso\.com/.*"); - - // Create a WebPermission that gives the permissions to all the hosts containing - // the same fragment. - WebPermission myWebPermission = new WebPermission(NetworkAccess.Connect,myRegex); - - // Checks all callers higher in the call stack have been granted the permission. - myWebPermission.Demand(); - -// - - Console.WriteLine("Attribute and Values of WebPermission are : \n"); - // Display the Attributes,Values and Children of the XML encoded copied instance. - PrintKeysAndValues(myWebPermission.ToXml().Attributes,myWebPermission.ToXml().Children); - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-ATTRIBUTES-\t-VALUE-"); - while (myEnumerator.MoveNext()) - {Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);} - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("\nThe Children are : "); - while (myEnumerator1.MoveNext()) - {Console.Write("\t{0}", myEnumerator1.Current);} - } - } \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs b/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs deleted file mode 100644 index 3ce63eb2464..00000000000 --- a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_copy.cs +++ /dev/null @@ -1,84 +0,0 @@ -// System.Net.WebPermission.WebPermission(PermissionState);System.Net.WebPermission.Copy; -/** - * This program demonstrates the WebPermission(PermissionState) constructor and - * Copy method of the WebPermission class . - * It creates a WebPermission instance with Permissionstate set to None and - * sets the access right to one pair of URLs. - * Then it uses the Copy method to create another instance of WebPermission class - * Finally, the attributes , values and childrens of both the XML encoded instances - * are displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class CopyWebPermission { - - static void Main() - { - try - { - CopyWebPermission myCopyWebPermission = new CopyWebPermission(); - myCopyWebPermission.CreateCopy(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CreateCopy() - { - -// - // Create a WebPermission instance. - WebPermission myWebPermission1 = new WebPermission(PermissionState.None); - - // Allow access to the first set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.microsoft.com/default.htm"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.msn.com"); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission1.Demand(); - -// - -// - // Create another WebPermission instance that is the copy of the above WebPermission instance. - WebPermission myWebPermission2 = (WebPermission) myWebPermission1.Copy(); - - // Check whether all callers higher in the call stack have been granted the permissionor not. - myWebPermission2.Demand(); - -// - Console.WriteLine("The Attributes and Values are :\n"); - // Display the Attributes,Values and Children of the XML encoded instance. - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission1.ToXml().Children); - - Console.WriteLine("\nCopied Instance Attributes and Values are :\n"); - // Display the Attributes,Values and Children of the XML encoded copied instance. - PrintKeysAndValues(myWebPermission2.ToXml().Attributes,myWebPermission2.ToXml().Children); - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - - // Gets the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } - } \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs b/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs deleted file mode 100644 index b2ed0a605bc..00000000000 --- a/snippets/csharp/System.Net/WebPermission/.ctor/webpermission_union.cs +++ /dev/null @@ -1,88 +0,0 @@ -// System.Net.WebPermission.WebPermission(NetworkAccess, uriString);System.Net.WebPermission.Union; - -/** - * This program shows the use of the WebPermission(NetworkAccess access,string uriString) - * constructor and Union method of the WebPermission' class. - * It creates two instance of the WebPermission class with the specified access - * rights to the predefined URIs. - * It displays the attributes , values and childrens of those XML encoded - * instances. - * Then, using the Union method, it creates a third WebPermission instance - * via a logical union of the first two. - * Finally, it displays the attributes , values and childrens of those XML encoded - * instances. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermissionUnion -{ - - static void Main() - { - try - { - WebPermissionUnion myWebPermissionUnion = new WebPermissionUnion(); - myWebPermissionUnion.CreateUnion(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CreateUnion() - { -// - - // Create a WebPermission.instance. - WebPermission myWebPermission1 = new WebPermission(NetworkAccess.Connect,"http://www.contoso.com/default.htm"); - myWebPermission1.Demand(); - -// - - // Create another WebPermission instance. - WebPermission myWebPermission2 = new WebPermission(NetworkAccess.Connect,"http://www.adventure-works.com"); - myWebPermission2.Demand(); - - // Print the attributes, values and childrens of the XML encoded instances. - Console.WriteLine("Attributes and values of the first WebPermission are : "); - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission1.ToXml().Children); - - Console.WriteLine("\nAttributes and values of the second WebPermission are : "); - PrintKeysAndValues(myWebPermission2.ToXml().Attributes,myWebPermission2.ToXml().Children); - -// - - // Create another WebPermission that is the Union of previous two WebPermission - // instances. - WebPermission myWebPermission3 =(WebPermission) myWebPermission1.Union(myWebPermission2); - Console.WriteLine("\nAttributes and values of the WebPermission after the Union are : "); - // Display the attributes,values and children. - Console.WriteLine(myWebPermission3.ToXml().ToString()); - -// - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } - } diff --git a/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs b/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs deleted file mode 100644 index d58ea637ea7..00000000000 --- a/snippets/csharp/System.Net/WebPermission/AcceptList/webpermission_acceptconnectlist.cs +++ /dev/null @@ -1,93 +0,0 @@ -// System.Net.WebPermission.ConnectList;System.Net.WebPermission.AcceptList; - -/** - * This program demonstrates the use of the ConnectList and AcceptList WebPermission - * class properties. - * It first creates a WebPermission object with Permissionstate set to None and then - * sets the Connect and Accept access right to some predefined URLs. - * The using the AcceptList and ConnectList properties it displays the URLs that have - * the Accept and Connect permission set, respectively. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermission_AcceptConnectList -{ - static void Main() - { - try - { - WebPermission_AcceptConnectList myWebPermission_AcceptConnectList = new WebPermission_AcceptConnectList(); - myWebPermission_AcceptConnectList.DisplayAcceptConnect(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void DisplayAcceptConnect() - { - // Create a 'WebPermission' object with permission state set to 'None'. - WebPermission myWebPermission1 = new WebPermission(PermissionState.None); - - // Allow 'Connect' access right to first set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.contoso.com"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.alpineskihouse.com"); - - // Allow 'Accept' access right to second set of URL's. - myWebPermission1.AddPermission(NetworkAccess.Accept,"http://www.contoso.com"); - myWebPermission1.AddPermission(NetworkAccess.Accept,"http://www.adventure-works.com"); - myWebPermission1.AddPermission(NetworkAccess.Accept,"http://www.alpineskihouse.com"); - - // Check whether all callers higher in the call stack have been granted the permission or not. - myWebPermission1.Demand(); - - Console.WriteLine("The Attributes,Values and Children of the 'WebPermission' object are :\n"); - // Display the Attributes,Values and Children of the XML encoded instance. - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission1.ToXml().Children); - -// - - // Gets all URIs with Connect permission. - IEnumerator myEnum = myWebPermission1.ConnectList; - Console.WriteLine("\nThe URIs with Connect permission are :\n"); - while (myEnum.MoveNext()) - { Console.WriteLine("\tThe URI is : "+myEnum.Current); } - -// - -// - - // Get all URI's with Accept permission. - IEnumerator myEnum1 = myWebPermission1.AcceptList; - Console.WriteLine("\n\nThe URIs with Accept permission are :\n"); - while (myEnum1.MoveNext()) - { Console.WriteLine("\tThe URI is : "+myEnum1.Current); } - -// - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtabel. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-Attribute-\t-Value-"); - while (myEnumerator.MoveNext()) - {Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);} - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : \n"); - while (myEnumerator1.MoveNext()) - {Console.Write( myEnumerator1.Current);} - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs b/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs deleted file mode 100644 index df66b84442a..00000000000 --- a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_intersect.cs +++ /dev/null @@ -1,97 +0,0 @@ -// System.Net.WebPermission.WebPermission(); -// System.Net.WebPermission.AddPermission(NetworkAccess,stringuri); -// System.Net.WebPermission.Intersect; -/** - * This program shows the use of the WebPermission() constructor, the AddPermission, - * and Intersect' methods of the WebPermission' class. - * It first creates two WebPermission objects with no arguments, with each of them - * setting the access rights to one pair of URLs. - * Then it displays the attributes , values and childrens of the XML encoded instances. - * Finally, it creates a third WebPermission object using the logical intersection of the - * first two objects. It does so by using the Intersect method. - * It then displays the attributes , values and childrens of the related XML encoded - * instances. - */ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermissionIntersect -{ - static void Main(String[] Args) - { - try - { - WebPermissionIntersect myWebPermissionIntersect = new WebPermissionIntersect(); - myWebPermissionIntersect.CreateIntersect(); - }catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CreateIntersect() - { -// - // Create two WebPermission instances. - WebPermission myWebPermission1 = new WebPermission(); - WebPermission myWebPermission2 = new WebPermission(); - -// - - // Allow access to the first set of resources. - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.contoso.com/default.htm"); - myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com/default.htm"); - - // Check whether if the callers higher in the call stack have been granted - // access permissions. - myWebPermission1.Demand(); - -// - // Allow access right to the second set of resources. - myWebPermission2.AddPermission(NetworkAccess.Connect,"http://www.alpineskihouse.com/default.htm"); - myWebPermission2.AddPermission(NetworkAccess.Connect,"http://www.baldwinmuseumofscience.com/default.htm"); - myWebPermission2.Demand(); - -// - - // Display the attributes , values and childrens of the XML encoded instances. - Console.WriteLine("Attributes and values of first 'WebPermission' instance are :"); - PrintKeysAndValues(myWebPermission1.ToXml().Attributes,myWebPermission2.ToXml().Children); - - Console.WriteLine("\nAttributes and values of second 'WebPermission' instance are : "); - PrintKeysAndValues(myWebPermission2.ToXml().Attributes,myWebPermission2.ToXml().Children); - -// - - // Create a third WebPermission instance via the logical intersection of the previous - // two WebPermission instances. - WebPermission myWebPermission3 =(WebPermission) myWebPermission1.Intersect(myWebPermission2); - - Console.WriteLine("\nAttributes and Values of the WebPermission instance after the Intersect are:\n"); - Console.WriteLine(myWebPermission3.ToXml().ToString()); - -// - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } -} diff --git a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs b/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs deleted file mode 100644 index 7ea6a58bf1c..00000000000 --- a/snippets/csharp/System.Net/WebPermission/AddPermission/webpermission_issubset.cs +++ /dev/null @@ -1,103 +0,0 @@ -// System.Net.WebPermission.AddPermission(NetworkAccess, regex); -// System.Net.WebPermission.IsSubsetOf; -/** - * This program shows how to use the AddPermission(NetworkAccess, regex) and - * IsSubset methods of WebPermission class. - * It creates two WebPermission instances with the Connect access rights for the - * specified URIs. - * For he first WebPermission instance, a Connect access right is given to the - * URLs with the host fragment www.microsoft.com. This is done by using - * the AddPermission(NetworkAccess, regex) method. - * Then, a third WebPermission instance is created with the Connect access right to - * the URLs of the first and second WebPermission instances. - * Finally, the attributes, values and children of that instance are displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; -using System.Text.RegularExpressions; - -class WebPermissionIsSubset{ - - static void Main() - { - try - { - WebPermissionIsSubset myWebPermissionIsSubset = new WebPermissionIsSubset(); - myWebPermissionIsSubset.CheckSubset(); - } - - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CheckSubset() - { -// - // Create a WebPermission. - WebPermission myWebPermission1 = new WebPermission(); - - // Allow Connect access to the specified URLs. - myWebPermission1.AddPermission(NetworkAccess.Connect,new Regex("http://www\\.contoso\\.com/.*", - RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline)); - - myWebPermission1.Demand(); - -// - - // Create another WebPermission with the specified URL. - WebPermission myWebPermission2 = new WebPermission(NetworkAccess.Connect,"http://www.contoso.com"); - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission2.Demand(); - -// - - WebPermission myWebPermission3 = null; - // Check which permissions have the Connect access to more number of URLs. - if(myWebPermission2.IsSubsetOf(myWebPermission1)) - { - Console.WriteLine("\n WebPermission2 is the Subset of WebPermission1\n"); - myWebPermission3 = myWebPermission1; - } - else if(myWebPermission1.IsSubsetOf(myWebPermission2)) - { - Console.WriteLine("\n WebPermission1 is the Subset of WebPermission2"); - myWebPermission3 = myWebPermission2; - } - else - { - // Create the third permission. - myWebPermission3 = (WebPermission)myWebPermission1.Union(myWebPermission2); - } - -// - // Prints the attributes , values and childrens of XML encoded instances. - - Console.WriteLine("\nAttributes and Values of third WebPermission instance are : "); - PrintKeysAndValues(myWebPermission3.ToXml().Attributes,myWebPermission3.ToXml().Children); - } - - private void PrintKeysAndValues(Hashtable myHashtable,IEnumerable myList) - { - // Get the enumerator that can iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - - IEnumerator myEnumerator1 = myList.GetEnumerator(); - Console.WriteLine("The Children are : "); - while (myEnumerator1.MoveNext()) - Console.Write("\t{0}", myEnumerator1.Current); - } - } \ No newline at end of file diff --git a/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs b/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs deleted file mode 100644 index cb870401c9a..00000000000 --- a/snippets/csharp/System.Net/WebPermission/FromXml/webpermission_fromtoxml.cs +++ /dev/null @@ -1,71 +0,0 @@ -// System.Net.WebPermission.ToXml;System.Net.WebPermission.FromXml; -/** - * This program shows the use of the ToXml and FromXml methods of the WebPermission class. - * It creates a WebPermission instance with the Permissionstate set to None and - * displays the attributes and the values of the XML encoded instance . - * Then a SecurityElement instance is created and it's attributes are - * set. - * Finally, using the FromXml method the WebPermission instance is reconstructed from - * the above SecurityElement instance and the attributes are displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; - -class WebPermission_FromToXml { - - static void Main() - { - try - { - WebPermission_FromToXml myWebPermission_FromToXml = new WebPermission_FromToXml(); - myWebPermission_FromToXml.CallXml(); - } - catch(SecurityException e) - { - Console.WriteLine("SecurityException : " + e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception : " + e.Message); - } - } - - public void CallXml() - { -// - - // Create a WebPermission without permission on the protected resource. - WebPermission myWebPermission1 = new WebPermission(PermissionState.None); - - // Create a SecurityElement by calling the ToXml method on the WebPermission - // instance and display its attributes (which hold the XML encoding of - // the WebPermission). - Console.WriteLine("Attributes and Values of the WebPermission are :"); - myWebPermission1.ToXml().ToString(); - - // Create another WebPermission with no permission on the protected resource. - WebPermission myWebPermission2 = new WebPermission(PermissionState.None); - - //Converts the new WebPermission from XML using myWebPermission1. - myWebPermission2.FromXml(myWebPermission1.ToXml()); - -// - - Console.WriteLine("The Attributes and Values of 'WebPermission' instance after reconstruction are: \n"); - // Display the Attributes and values of the XML encoded instances. - PrintKeysAndValues(myWebPermission2.ToXml().Attributes); - } - - private void PrintKeysAndValues(Hashtable myHashtable) - { - // Get the enumerator to iterate through Hashtable. - IDictionaryEnumerator myEnumerator = myHashtable.GetEnumerator(); - Console.WriteLine("\t-KEY-\t-VALUE-"); - while (myEnumerator.MoveNext()) - Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); - Console.WriteLine(); - } - } diff --git a/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs b/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs deleted file mode 100644 index 3550b42d0bf..00000000000 --- a/snippets/csharp/System.Net/WebPermission/IsSubsetOf/source.cs +++ /dev/null @@ -1,42 +0,0 @@ -// System.Net.WebPermission.AddPermission(NetworkAccess, regex);System.Net.WebPermission.IsSubsetOf; -/** - * This program shows the use of the AddPermission(NetworkAccess, regex) and - * IsSubset methods of the WebPermission class. - * It creates two WebPermission instances with the Connect access rights for the specified - * URIs. The second URI being a subset of the first one. - * Then the IsSubsetOf method is called to verify that the second URI is indeed a subset - * of the firts one. The result of the call to the IsSubsetOf is then displayed. -*/ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Collections; -using System.Text.RegularExpressions; - -public class Sample -{ - - public static void myIsSubsetExample() - { -// - - // Create the target permission. - WebPermission targetPermission = new WebPermission(); - targetPermission.AddPermission(NetworkAccess.Connect, new Regex("www\\.contoso\\.com/Public/.*")); - - // Create the permission for a URI matching target. - WebPermission connectPermission = new WebPermission(); - connectPermission.AddPermission(NetworkAccess.Connect, "www.contoso.com/Public/default.htm"); - - //The following statement prints true. - Console.WriteLine("Is the second URI a subset of the first one?: " + connectPermission.IsSubsetOf(targetPermission)); - -// - } - public static void Main() - { - // Verify that the second URI is a subset of the first one. - myIsSubsetExample(); - } -} diff --git a/snippets/csharp/System.Net/WebPermission/Overview/regex.cs b/snippets/csharp/System.Net/WebPermission/Overview/regex.cs deleted file mode 100644 index 87a4f3d56a6..00000000000 --- a/snippets/csharp/System.Net/WebPermission/Overview/regex.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.Text.RegularExpressions; -using System.Collections; - -class WebPermissionExample -{ - - public static void MySample() - { -// - - // Create a Regex that accepts all URLs containing the host fragment www.contoso.com. - Regex myRegex = new Regex(@"http://www\.contoso\.com/.*"); - - // Create a WebPermission that gives permissions to all the hosts containing the same host fragment. - WebPermission myWebPermission = new WebPermission(NetworkAccess.Connect,myRegex); - - //Add connect privileges for a www.adventure-works.com. - myWebPermission.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com"); - - //Add accept privileges for www.alpineskihouse.com. - myWebPermission.AddPermission(NetworkAccess.Accept, "http://www.alpineskihouse.com/"); - - // Check whether all callers higher in the call stack have been granted the permission. - myWebPermission.Demand(); - - // Get all the URIs with Connect permission. - IEnumerator myConnectEnum = myWebPermission.ConnectList; - Console.WriteLine("\nThe 'URIs' with 'Connect' permission are :\n"); - while (myConnectEnum.MoveNext()) - {Console.WriteLine("\t" + myConnectEnum.Current);} - - // Get all the URIs with Accept permission. - IEnumerator myAcceptEnum = myWebPermission.AcceptList; - Console.WriteLine("\n\nThe 'URIs' with 'Accept' permission is :\n"); - - while (myAcceptEnum.MoveNext()) - {Console.WriteLine("\t" + myAcceptEnum.Current);} - -// - } - - public static void Main() - { - MySample(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs deleted file mode 100644 index 987cf41fedb..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/Accept/source.cs +++ /dev/null @@ -1,49 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - -/* - * Demonstrate how to use the WebPermissionAttribute to specify the Accept property. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; - -public class WebPermissionAttribute_AcceptConnect{ -// - -// Deny access to a specific resource by setting the Accept property. -[WebPermission(SecurityAction.Deny, Accept=@"http://www.contoso.com/Private.htm")] - -public static void CheckAcceptPermission(string uriToCheck) -{ - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Accept, uriToCheck); - permissionToCheck.Demand(); -} - -public static void demoDenySite() -{ - //Pass the security check when accessing allowed resources. - CheckAcceptPermission("http://www.contoso.com/"); - Console.WriteLine("Public page has passed Accept permission check"); - - try - { - //Throw a SecurityException when trying to access not allowed resources. - CheckAcceptPermission("http://www.contoso.com/Private.htm"); - Console.WriteLine("This line will not be printed"); - } - catch (SecurityException e) - { - Console.WriteLine("Exception trying to access private resource:" + e.Message); - } - } - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs deleted file mode 100644 index 74d3922b31b..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/AcceptPattern/source.cs +++ /dev/null @@ -1,47 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; -/* -This program demonstrates the 'Connect' and 'Accept' properties of the class 'WebPermissionAttribute'. -The program uses declarative security for calling the code in 'Connect' method. -By using the 'Accept' and 'Connect' properties of 'WebPermissionAttribute' accept and connect access -has been given to the uri www.contoso.com. -*/ - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; -using System.Text.RegularExpressions; - -public class WebPermissionAttribute_AcceptConnect{ -// -[WebPermission(SecurityAction.Deny, AcceptPattern=@"http://www\.contoso\.com/Private/.*")] - -public static void CheckAcceptPermission(string uriToCheck) { - - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Accept, uriToCheck); - permissionToCheck.Demand(); -} - -public static void demoDenySite() { - //Passes a security check. - CheckAcceptPermission("http://www.contoso.com/Public/page.htm"); - Console.WriteLine("Public page has passed Accept permission check"); - - try { - //Throws a SecurityException. - CheckAcceptPermission("http://www.contoso.com/Private/page.htm"); - Console.WriteLine("This line will not be printed"); -} - catch (SecurityException e) { - Console.WriteLine("Expected exception: " + e.Message); - } - } - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs deleted file mode 100644 index b558991d521..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/Connect/source.cs +++ /dev/null @@ -1,45 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.connect; - -// Demonstrate how to use the WebPermissionAttribute Connect property. - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; - -public class WebPermissionAttribute_Connect{ -// - -// Set the WebPermissionAttribute Connect property. -[WebPermission(SecurityAction.Deny, Connect=@"http://www.contoso.com/Private.htm")] - -public static void demoDenySite() -{ - //Pass the security check. - CheckConnectPermission("http://www.contoso.com/Public.htm"); - Console.WriteLine("Public page has passed connect permission check"); - - try - { - //Throw a SecurityException. - CheckConnectPermission("http://www.contoso.com/Private.htm"); - Console.WriteLine("This line will not be printed"); - } - catch (SecurityException e) { - Console.WriteLine("Expected exception" + e.Message); - } - } - -public static void CheckConnectPermission(string uriToCheck) { - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Connect, uriToCheck); - permissionToCheck.Demand(); -} - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs b/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs deleted file mode 100644 index 6aa267ea890..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/ConnectPattern/source.cs +++ /dev/null @@ -1,48 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Connect; - -// Demonstrate how to use the WebPermissionAttribute ConnectPattern property. - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; -using System.Text.RegularExpressions; - -public class WebPermissionAttribute_Connect -{ - // - - // Set the WebPermissionAttribute ConnectPattern property. - [WebPermission(SecurityAction.Deny, ConnectPattern=@"http://www\.contoso\.com/Private/.*")] - -public static void CheckConnectPermission(string uriToCheck) -{ - WebPermission permissionToCheck = new WebPermission(); - permissionToCheck.AddPermission(NetworkAccess.Connect, uriToCheck); - permissionToCheck.Demand(); -} - -public static void demoDenySite() { - //Pass the security check. - CheckConnectPermission("http://www.contoso.com/Public/page.htm"); - Console.WriteLine("Public page has passed Connect permission check"); - - try - { - //Throw a SecurityException. - CheckConnectPermission("http://www.contoso.com/Private/page.htm"); - Console.WriteLine("This line will not be printed"); - } - catch (SecurityException e) - { - Console.WriteLine("Expected exception" + e.Message); - } - } - -// - static void Main() - { - demoDenySite(); - } - } diff --git a/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs b/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs deleted file mode 100644 index fccdc85ef47..00000000000 --- a/snippets/csharp/System.Net/WebPermissionAttribute/Overview/webpermissionattribute_acceptconnect.cs +++ /dev/null @@ -1,47 +0,0 @@ -// System.Net.WebPermissionAttribute.Connect;System.Net.WebPermissionAttribute.Accept; - -// Demonstrate how to use the WebPermissionAttribute to specify an allowable ConnectPattern. - -using System; -using System.Net; -using System.Security; -using System.Security.Permissions; -using System.IO; - -public class WebPermissionAttribute_AcceptConnect{ - -// -// - - // Deny access to a specific resource by setting the ConnectPattern property. - [WebPermission(SecurityAction.Deny, ConnectPattern=@"http://www\.contoso\.com/")] - -public void Connect() - { - // Create a Connection. - HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create("http://www.contoso.com"); - Console.WriteLine("This line should never be printed"); - } - -// -// - - static void Main() - { - - try - { - - WebPermissionAttribute_AcceptConnect myWebAttrib = new WebPermissionAttribute_AcceptConnect(); - myWebAttrib.Connect(); - } - catch(SecurityException e) - { - Console.WriteLine("Security Exception raised : "+e.Message); - } - catch(Exception e) - { - Console.WriteLine("Exception raised : "+ e.Message); - } - } - } diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs deleted file mode 100644 index eede76956de..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/BigInteger_Examples.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - // - BigInteger bigIntFromDouble = new BigInteger(179032.6541); - Console.WriteLine(bigIntFromDouble); - BigInteger bigIntFromInt64 = new BigInteger(934157136952); - Console.WriteLine(bigIntFromInt64); - // The example displays the following output: - // 179032 - // 934157136952 - // - - Console.WriteLine(); - - // - long longValue = 6315489358112; - BigInteger assignedFromLong = longValue; - Console.WriteLine(assignedFromLong); - // The example displays the following output: - // 6315489358112 - // - - Console.WriteLine(); - Console.WriteLine("Casting:"); - // - BigInteger assignedFromDouble = (BigInteger) 179032.6541; - Console.WriteLine(assignedFromDouble); - BigInteger assignedFromDecimal = (BigInteger) 64312.65m; - Console.WriteLine(assignedFromDecimal); - // The example displays the following output: - // 179032 - // 64312 - // - - Console.WriteLine(); - - // - byte[] byteArray = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; - BigInteger newBigInt = new BigInteger(byteArray); - Console.WriteLine("The value of newBigInt is {0} (or 0x{0:x}).", newBigInt); - // The example displays the following output: - // The value of newBigInt is 4759477275222530853130 (or 0x102030405060708090a). - // - - Console.WriteLine(); - - // - string positiveString = "91389681247993671255432112000000"; - string negativeString = "-90315837410896312071002088037140000"; - BigInteger posBigInt = 0; - BigInteger negBigInt = 0; - - try { - posBigInt = BigInteger.Parse(positiveString); - Console.WriteLine(posBigInt); - } - catch (FormatException) - { - Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", - positiveString); - } - - if (BigInteger.TryParse(negativeString, out negBigInt)) - Console.WriteLine(negBigInt); - else - Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", - negativeString); - - // The example displays the following output: - // 9.1389681247993671255432112E+31 - // -9.0315837410896312071002088037E+34 - // - - Console.WriteLine(); - - // - BigInteger number = BigInteger.Pow(UInt64.MaxValue, 3); - Console.WriteLine(number); - // The example displays the following output: - // 6277101735386680762814942322444851025767571854389858533375 - // - } -} diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs deleted file mode 100644 index 0ae0bb0204e..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Globalization; -using System.Numerics; - -public class Example -{ - public static void Main() - { - RoundtripBigInteger(); - Console.WriteLine(); - RoundtripInt16(); - Console.WriteLine(); - HandleSignsInByteArray(); - Console.WriteLine(); - RoundtripAmbiguous(); - Console.WriteLine(); - RoundtripWithHex(); - } - - private static void RoundtripBigInteger() - { - Console.WriteLine("Round-trip bytes"); - - // - BigInteger number = BigInteger.Pow(Int64.MaxValue, 2); - Console.WriteLine(number); - - // Write the BigInteger value to a byte array. - byte[] bytes = number.ToByteArray(); - - // Display the byte array. - foreach (byte byteValue in bytes) - Console.Write("0x{0:X2} ", byteValue); - Console.WriteLine(); - - // Restore the BigInteger value from a Byte array. - BigInteger newNumber = new BigInteger(bytes); - Console.WriteLine(newNumber); - // The example displays the following output: - // 8.5070591730234615847396907784E+37 - // 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x3F - // - // 8.5070591730234615847396907784E+37 - // - } - - private static void RoundtripInt16() - { - Console.WriteLine(); - Console.WriteLine("Round-trip an Int16 value:"); - // - short originalValue = 30000; - Console.WriteLine(originalValue); - - // Convert the Int16 value to a byte array. - byte[] bytes = BitConverter.GetBytes(originalValue); - - // Display the byte array. - foreach (byte byteValue in bytes) - Console.Write("0x{0} ", byteValue.ToString("X2")); - Console.WriteLine(); - - // Pass byte array to the BigInteger constructor. - BigInteger number = new BigInteger(bytes); - Console.WriteLine(number); - // The example displays the following output: - // 30000 - // 0x30 0x75 - // 30000 - // - } - - private static void HandleSignsInByteArray() - { - // - int negativeNumber = -1000000; - uint positiveNumber = 4293967296; - - byte[] negativeBytes = BitConverter.GetBytes(negativeNumber); - BigInteger negativeBigInt = new BigInteger(negativeBytes); - Console.WriteLine(negativeBigInt.ToString("N0")); - - byte[] tempPosBytes = BitConverter.GetBytes(positiveNumber); - byte[] positiveBytes = new byte[tempPosBytes.Length + 1]; - Array.Copy(tempPosBytes, positiveBytes, tempPosBytes.Length); - BigInteger positiveBigInt = new BigInteger(positiveBytes); - Console.WriteLine(positiveBigInt.ToString("N0")); - // The example displays the following output: - // -1,000,000 - // 4,293,967,296 - // - } - - private static void RoundtripAmbiguous() - { - Console.WriteLine("Round-trip an Ambiguous Value:"); - // - BigInteger positiveValue = 15777216; - BigInteger negativeValue = -1000000; - - Console.WriteLine("Positive value: " + positiveValue.ToString("N0")); - byte[] bytes = positiveValue.ToByteArray(); - - foreach (byte byteValue in bytes) - Console.Write("{0:X2} ", byteValue); - Console.WriteLine(); - positiveValue = new BigInteger(bytes); - Console.WriteLine("Restored positive value: " + positiveValue.ToString("N0")); - - Console.WriteLine(); - - Console.WriteLine("Negative value: " + negativeValue.ToString("N0")); - bytes = negativeValue.ToByteArray(); - foreach (byte byteValue in bytes) - Console.Write("{0:X2} ", byteValue); - Console.WriteLine(); - negativeValue = new BigInteger(bytes); - Console.WriteLine("Restored negative value: " + negativeValue.ToString("N0")); - // The example displays the following output: - // Positive value: 15,777,216 - // C0 BD F0 00 - // Restored positive value: 15,777,216 - // - // Negative value: -1,000,000 - // C0 BD F0 - // Restored negative value: -1,000,000 - // - } - - private static void RoundtripWithHex() - { - // - BigInteger negativeNumber = -1000000; - BigInteger positiveNumber = 15777216; - - string negativeHex = negativeNumber.ToString("X"); - string positiveHex = positiveNumber.ToString("X"); - - BigInteger negativeNumber2, positiveNumber2; - negativeNumber2 = BigInteger.Parse(negativeHex, - NumberStyles.HexNumber); - positiveNumber2 = BigInteger.Parse(positiveHex, - NumberStyles.HexNumber); - - Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", - negativeNumber, negativeHex, negativeNumber2); - Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", - positiveNumber, positiveHex, positiveNumber2); - // The example displays the following output: - // Converted -1,000,000 to F0BDC0 back to -1,000,000. - // Converted 15,777,216 to 0F0BDC0 back to 15,777,216. - // - } -} diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs deleted file mode 100644 index 10320826e8b..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/ByteAndHex_Examples2.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -using System; -using System.Globalization; -using System.Numerics; - -public struct HexValue -{ - public int Sign; - public string Value; -} - -public class Example -{ - public static void Main() - { - uint positiveNumber = 4039543321; - int negativeNumber = -255423975; - - // Convert the numbers to hex strings. - HexValue hexValue1, hexValue2; - hexValue1.Value = positiveNumber.ToString("X"); - hexValue1.Sign = Math.Sign(positiveNumber); - - hexValue2.Value = Convert.ToString(negativeNumber, 16); - hexValue2.Sign = Math.Sign(negativeNumber); - - // Round-trip the hexadecimal values to BigInteger values. - string hexString; - BigInteger positiveBigInt, negativeBigInt; - - hexString = (hexValue1.Sign == 1 ? "0" : "") + hexValue1.Value; - positiveBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber); - Console.WriteLine("Converted {0} to {1} and back to {2}.", - positiveNumber, hexValue1.Value, positiveBigInt); - - hexString = (hexValue2.Sign == 1 ? "0" : "") + hexValue2.Value; - negativeBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber); - Console.WriteLine("Converted {0} to {1} and back to {2}.", - negativeNumber, hexValue2.Value, negativeBigInt); - } -} -// The example displays the following output: -// Converted 4039543321 to F0C68A19 and back to 4039543321. -// Converted -255423975 to f0c68a19 and back to -255423975. -// diff --git a/snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs b/snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs deleted file mode 100644 index e2f59bd6737..00000000000 --- a/snippets/csharp/System.Numerics/BigInteger/Overview/Mutability_Examples.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Diagnostics; -using System.Numerics; - -public class Example -{ - public static void Main() - { - ShowSimpleAdd(); - PerformBigIntegerOperation(); - PerformWithIntermediary(); - } - - private static void ShowSimpleAdd() - { - // - BigInteger number = BigInteger.Multiply(Int64.MaxValue, 3); - number++; - Console.WriteLine(number); - // - } - - private static void PerformBigIntegerOperation() - { - Stopwatch sw = Stopwatch.StartNew(); - - // - BigInteger number = Int64.MaxValue ^ 5; - int repetitions = 1000000; - // Perform some repetitive operation 1 million times. - for (int ctr = 0; ctr <= repetitions; ctr++) - { - // Perform some operation. If it fails, exit the loop. - if (!SomeOperationSucceeds()) break; - // The following code executes if the operation succeeds. - number++; - } - // - - sw.Stop(); - Console.WriteLine("Incrementing a BigInteger: " + sw.Elapsed.ToString()); - } - - private static void PerformWithIntermediary() - { - Stopwatch sw = Stopwatch.StartNew(); - - // - BigInteger number = Int64.MaxValue ^ 5; - int repetitions = 1000000; - int actualRepetitions = 0; - // Perform some repetitive operation 1 million times. - for (int ctr = 0; ctr <= repetitions; ctr++) - { - // Perform some operation. If it fails, exit the loop. - if (!SomeOperationSucceeds()) break; - // The following code executes if the operation succeeds. - actualRepetitions++; - } - number += actualRepetitions; - // - - sw.Stop(); - Console.WriteLine("Incrementing a BigInteger: " + sw.Elapsed.ToString()); - } - - private static bool SomeOperationSucceeds() - { - return true; - } -} - -// -// CAPS bug: snippet2 is seen as duplicated, even though it isn't. -// \ No newline at end of file diff --git a/snippets/csharp/System.Numerics/Complex/Overview/create1.cs b/snippets/csharp/System.Numerics/Complex/Overview/create1.cs deleted file mode 100644 index f478a4fadd0..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/create1.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - // Create a complex number by calling its class constructor. - Complex c1 = new Complex(12, 6); - Console.WriteLine(c1); - - // Assign a Double to a complex number. - Complex c2 = 3.14; - Console.WriteLine(c2); - - // Cast a Decimal to a complex number. - Complex c3 = (Complex) 12.3m; - Console.WriteLine(c3); - - // Assign the return value of a method to a Complex variable. - Complex c4 = Complex.Pow(Complex.One, -1); - Console.WriteLine(c4); - - // Assign the value returned by an operator to a Complex variable. - Complex c5 = Complex.One + Complex.One; - Console.WriteLine(c5); - - // Instantiate a complex number from its polar coordinates. - Complex c6 = Complex.FromPolarCoordinates(10, .524); - Console.WriteLine(c6); - } -} -// The example displays the following output: -// (12, 6) -// (3.14, 0) -// (12.3, 0) -// (1, 0) -// (2, 0) -// (8.65824721882145, 5.00347430269914) -// \ No newline at end of file diff --git a/snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs b/snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs deleted file mode 100644 index 0fb304b1f0b..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/customfmt1.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -using System; -using System.Numerics; - -public class ComplexFormatter :IFormatProvider, ICustomFormatter -{ - public object GetFormat(Type formatType) - { - if (formatType == typeof(ICustomFormatter)) - return this; - else - return null; - } - - public string Format(string format, object arg, - IFormatProvider provider) - { - if (arg is Complex) - { - Complex c1 = (Complex) arg; - // Check if the format string has a precision specifier. - int precision; - string fmtString = String.Empty; - if (format.Length > 1) { - try { - precision = Int32.Parse(format.Substring(1)); - } - catch (FormatException) { - precision = 0; - } - fmtString = "N" + precision.ToString(); - } - if (format.Substring(0, 1).Equals("I", StringComparison.OrdinalIgnoreCase)) - return c1.Real.ToString(fmtString) + " + " + c1.Imaginary.ToString(fmtString) + "i"; - else if (format.Substring(0, 1).Equals("J", StringComparison.OrdinalIgnoreCase)) - return c1.Real.ToString(fmtString) + " + " + c1.Imaginary.ToString(fmtString) + "j"; - else - return c1.ToString(format, provider); - } - else - { - if (arg is IFormattable) - return ((IFormattable) arg).ToString(format, provider); - else if (arg != null) - return arg.ToString(); - else - return String.Empty; - } - } -} -// - -// -public class Example -{ - public static void Main() - { - Complex c1 = new Complex(12.1, 15.4); - Console.WriteLine("Formatting with ToString(): " + - c1.ToString()); - Console.WriteLine("Formatting with ToString(format): " + - c1.ToString("N2")); - Console.WriteLine("Custom formatting with I0: " + - String.Format(new ComplexFormatter(), "{0:I0}", c1)); - Console.WriteLine("Custom formatting with J3: " + - String.Format(new ComplexFormatter(), "{0:J3}", c1)); - } -} -// The example displays the following output: -// Formatting with ToString(): (12.1, 15.4) -// Formatting with ToString(format): (12.10, 15.40) -// Custom formatting with I0: 12 + 15i -// Custom formatting with J3: 12.100 + 15.400j -// diff --git a/snippets/csharp/System.Numerics/Complex/Overview/nan1.cs b/snippets/csharp/System.Numerics/Complex/Overview/nan1.cs deleted file mode 100644 index edad7d52998..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/nan1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - Complex c1 = new Complex(Double.MaxValue / 2, Double.MaxValue /2); - - Complex c2 = c1 / Complex.Zero; - Console.WriteLine(c2.ToString()); - c2 = c2 * new Complex(1.5, 1.5); - Console.WriteLine(c2.ToString()); - Console.WriteLine(); - - Complex c3 = c1 * new Complex(2.5, 3.5); - Console.WriteLine(c3.ToString()); - c3 = c3 + new Complex(Double.MinValue / 2, Double.MaxValue / 2); - Console.WriteLine(c3); - } -} -// The example displays the following output: -// (NaN, NaN) -// (NaN, NaN) -// (NaN, Infinity) -// (NaN, Infinity) -// \ No newline at end of file diff --git a/snippets/csharp/System.Numerics/Complex/Overview/precision1.cs b/snippets/csharp/System.Numerics/Complex/Overview/precision1.cs deleted file mode 100644 index 3bb618c475b..00000000000 --- a/snippets/csharp/System.Numerics/Complex/Overview/precision1.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - // - Complex value = new Complex(Double.MinValue/2, Double.MinValue/2); - Complex value2 = Complex.Exp(Complex.Log(value)); - Console.WriteLine("{0} \n{1} \nEqual: {2}", value, value2, - value == value2); - // The example displays the following output: - // (-8.98846567431158E+307, -8.98846567431158E+307) - // (-8.98846567431161E+307, -8.98846567431161E+307) - // Equal: False - // - - Console.WriteLine(); - ShowPlatform(); - } - - private static void ShowPlatform() - { - // - Complex minusOne = new Complex(-1, 0); - Console.WriteLine(Complex.Sqrt(minusOne)); - // The example displays the following output: - // (6.12303176911189E-17, 1) on 32-bit systems. - // (6.12323399573677E-17,1) on IA64 systems. - // - } -} - -// Complex minusOne = new Complex(-1,0); -// Complex.Sqrt(minusOne) returns Complex(6.12303176911189E-17, 1) where as it returns Complex on IA64. diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs deleted file mode 100644 index dd9ae0313c0..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest2.cs +++ /dev/null @@ -1,27 +0,0 @@ -/* - Note : Calls EmitClass class from 'MyEmitTestAssembly.dll' using reflection emit. -*/ - -using System; - -public class MyAssemblyResourceApplication -{ - public static void Main() - { - try - { - CallEmitMethod(); - } - catch(TypeLoadException) - { - Console.WriteLine("Unable to load EmitClass type " + - "from MyEmitTestAssembly.dll!"); - } - } - - private static void CallEmitMethod() - { - EmitClass myEmit = new EmitClass(); - Console.WriteLine(myEmit.Display()); - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs deleted file mode 100644 index 10eefad292b..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/EmittedTest3.cs +++ /dev/null @@ -1,28 +0,0 @@ -/* - Supporting file for AssemblyBuilder_DefineUnmanagedResource2.cs - Note : Calls EmitClass class from 'MyEmitTestAssembly.dll' using reflection emit. -*/ - -using System; - -public class MyAssemblyResourceApplication -{ - public static void Main() - { - try - { - CallEmitMethod(); - } - catch(TypeLoadException) - { - Console.WriteLine("Unable to load EmitClass type " + - "from MyEmitTestAssembly.dll!"); - } - } - - private static void CallEmitMethod() - { - EmitClass myEmit = new EmitClass(); - Console.WriteLine(myEmit.Display()); - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile deleted file mode 100644 index 581717571b4..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all : assemblybuilder_defineunmanagedresource.exe EmittedTest2.exe - -assemblybuilder_defineunmanagedresource.exe : assemblybuilder_defineunmanagedresource.cs - csc assemblybuilder_defineunmanagedresource.cs - -MyEmitTestAssembly.dll : assemblybuilder_defineunmanagedresource.exe - assemblybuilder_defineunmanagedresource.exe - -EmittedTest2.exe : MyEmitTestAssembly.dll EmittedTest2.cs - csc /r:MyEmitTestAssembly.dll EmittedTest2.cs \ No newline at end of file diff --git a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 b/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 deleted file mode 100644 index 42a8f53f84d..00000000000 --- a/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/makefile1 +++ /dev/null @@ -1,10 +0,0 @@ -all : assemblybuilder_defineunmanagedresource2.exe EmittedTest3.exe - -assemblybuilder_defineunmanagedresource2.exe : assemblybuilder_defineunmanagedresource2.cs - csc assemblybuilder_defineunmanagedresource2.cs - -MyEmitTestAssembly.dll : assemblybuilder_defineunmanagedresource2.exe - assemblybuilder_defineunmanagedresource2.exe - -EmittedTest3.exe : MyEmitTestAssembly.dll EmittedTest3.cs - csc /r:MyEmitTestAssembly.dll EmittedTest3.cs \ No newline at end of file diff --git a/snippets/csharp/System.Reflection/Assembly/Load/load2.cs b/snippets/csharp/System.Reflection/Assembly/Load/load2.cs deleted file mode 100644 index 171d21cc774..00000000000 --- a/snippets/csharp/System.Reflection/Assembly/Load/load2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; -using System.Reflection; - -class Class1 -{ - public static void Main() - { - // You must supply a valid fully qualified assembly name. - // - Assembly myDll = - Assembly.Load("myDll, Version=1.0.0.1, Culture=neutral, PublicKeyToken=9b35aa32c18d4fb1"); - // - - // Display all the types contained in the specified assembly. - foreach (Type oType in myDll.GetTypes()) { - Console.WriteLine(oType.Name); - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile b/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile deleted file mode 100644 index 095c5d3c69a..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/makefile +++ /dev/null @@ -1,14 +0,0 @@ -all: source.dll source2.dll - -source.dll: TestPublicKey.snk source.cs - csc /t:library source.cs - -TestPublicKey.snk: - sn -k TestPublicKey.snk - -source2.dll: myKey.snk source2.cs - csc /t:library source2.cs - -myKey.snk: - sn -k myKey.snk - diff --git a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs b/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs deleted file mode 100644 index 4956bf1631f..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source2.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; -using System.Reflection; - -// -// Set version number for the assembly. -[assembly:AssemblyVersionAttribute("4.3.2.1")] -// Set culture as German. -[assembly:AssemblyCultureAttribute("de")] -// - -// -[assembly:AssemblyKeyFileAttribute("myKey.snk")] -[assembly:AssemblyDelaySignAttribute(true)] -// - -namespace DummySpace -{ - class DummyClass - { - public static void Main() - { - Console.WriteLine("DummySpace.DummyClass.Main()"); - } - } -} -// diff --git a/snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs b/snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs deleted file mode 100644 index ec6884776eb..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyName/Flags/keyfileattrib.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; -using System.Reflection; - -// -[assembly:AssemblyKeyFileAttribute("keyfile.snk")] -// -namespace KeyFileAttrib -{ - public class Dummy - { - public static void Main() - { - Console.WriteLine("KeyFileAttrib.Dummy.Main()"); - } - } -} -// diff --git a/snippets/csharp/System.Reflection/AssemblyName/Flags/makefile b/snippets/csharp/System.Reflection/AssemblyName/Flags/makefile deleted file mode 100644 index 1afe090101e..00000000000 --- a/snippets/csharp/System.Reflection/AssemblyName/Flags/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: assemblyname_keypair.exe KeyFileAttrib.exe - -assemblyname_keypair.exe: assemblyname_keypair.cs - csc /target:exe assemblyname_keypair.cs - -KeyFileAttrib.exe: keyfile.snk KeyFileAttrib.cs - csc /target:exe KeyFileAttrib.cs - -keyfile.snk: - sn -k keyfile.snk \ No newline at end of file diff --git a/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs b/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs deleted file mode 100644 index 06ff187cb75..00000000000 --- a/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source2.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class ExampleAttribute : Attribute -{ - private string stringVal; - - public ExampleAttribute() - { - stringVal = "This is the default string."; - } - - public string StringValue - { - get { return stringVal; } - set { stringVal = value; } - } -} - -[Example(StringValue="This is a string.")] -class Class1 -{ - public static void Main() - { - System.Reflection.MemberInfo info = typeof(Class1); - foreach (object attrib in info.GetCustomAttributes(true)) - { - Console.WriteLine(attrib); - } - } -} -// diff --git a/snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs b/snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs deleted file mode 100644 index ee13728e908..00000000000 --- a/snippets/csharp/System.Reflection/MemberInfo/DeclaringType/source.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -using System; -using System.Reflection; - -interface i -{ - int GetValuue() ; -}; - // DeclaringType for MyVar is i. - - class A : i - { - public int MyVar() { return 0; } - }; - // DeclaringType for MyVar is A. - - class B : A - { - new int MyVar() { return 0; } - }; - // DeclaringType for MyVar is B. - - class C : A - { - }; - // DeclaringType for MyVar is A. - - -namespace MyNamespace2 -{ - class Mymemberinfo - { - - public static void Main(string[] args) - { - - Console.WriteLine ("\nReflection.MemberInfo"); - - //Get the Type and MemberInfo. - Type MyType =Type.GetType("System.IO.BufferedStream"); - MemberInfo[] Mymemberinfoarray = MyType.GetMembers(); - - //Get and display the DeclaringType method. - Console.WriteLine("\nThere are {0} members in {1}.", Mymemberinfoarray.Length, MyType.FullName); - - foreach (MemberInfo Mymemberinfo in Mymemberinfoarray) - { - Console.WriteLine("Declaring type of {0} is {1}.", Mymemberinfo.Name, Mymemberinfo.DeclaringType); - } - } - } -} - -namespace MyNamespace3 -{ - class A - { - virtual public void M () {} - } - class B: A - { - override public void M () {} - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs b/snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs deleted file mode 100644 index 4c2c5bd85fb..00000000000 --- a/snippets/csharp/System.Resources/MissingManifestResourceException/Overview/showtime.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; -using System.Resources; - -public class Example -{ - public static void Main() - { - ResourceManager rm = new ResourceManager("Strings", - typeof(Example).Assembly); - string timeString = rm.GetString("TimeHeader"); - Console.WriteLine("{0} {1:T}", timeString, DateTime.Now); - } -} -// The example displays output like the following: -// The current time is 2:03:14 PM -// diff --git a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs b/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs deleted file mode 100644 index 80fec0df394..00000000000 --- a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; -using System.Globalization; -using System.Reflection; -using System.Resources; -using System.Threading; - -[assembly:NeutralResourcesLanguageAttribute("en")] -public class Example -{ - public static void Main() - { - // Select the current culture randomly to test resource fallback. - string[] cultures = { "de-DE", "en-us", "fr-FR" }; - Random rnd = new Random(); - int index = rnd.Next(0, cultures.Length); - Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultures[index]); - Console.WriteLine("The current culture is {0}", - CultureInfo.CurrentUICulture.Name); - - // Retrieve the resource. - ResourceManager rm = new ResourceManager("ExampleResources" , - typeof(Example).Assembly); - string greeting = rm.GetString("Greeting"); - - Console.Write("Enter your name: "); - string name = Console.ReadLine(); - Console.WriteLine("{0} {1}!", greeting, name); - } -} -// diff --git a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs b/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs deleted file mode 100644 index be014baff7e..00000000000 --- a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example1.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -using System.Resources; - -[assembly:NeutralResourcesLanguage("en-US")] -// -public class Example {} diff --git a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs b/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs deleted file mode 100644 index 59e51063d69..00000000000 --- a/snippets/csharp/System.Resources/NeutralResourcesLanguageAttribute/Overview/example2.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -using System.Resources; - -[assembly:NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] -// -public class Example {} diff --git a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs b/snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs deleted file mode 100644 index c19d57c8237..00000000000 --- a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/enumerate1.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -using System; -using System.Collections; -using System.Collections.Generic; -using System.Resources; - -public class Example -{ - public static void Main() - { - string resxFile = @".\CarResources.resx"; - List autos = new List(); - SortedList headers = new SortedList(); - - using (ResXResourceReader resxReader = new ResXResourceReader(resxFile)) - { - foreach (DictionaryEntry entry in resxReader) { - if (((string) entry.Key).StartsWith("EarlyAuto")) - autos.Add((Automobile) entry.Value); - else if (((string) entry.Key).StartsWith("Header")) - headers.Add((string) entry.Key, (string) entry.Value); - } - } - string[] headerColumns = new string[headers.Count]; - headers.GetValueList().CopyTo(headerColumns, 0); - Console.WriteLine("{0,-8} {1,-10} {2,-4} {3,-5} {4,-9}\n", - headerColumns); - foreach (var auto in autos) - Console.WriteLine("{0,-8} {1,-10} {2,4} {3,5} {4,9}", - auto.Make, auto.Model, auto.Year, - auto.Doors, auto.Cylinders); - } -} -// The example displays the following output: -// Make Model Year Doors Cylinders -// -// Ford Model N 1906 0 4 -// Ford Model T 1909 2 4 -// - -[Serializable()] public class Automobile -{ - private string carMake; - private string carModel; - private int carYear; - private int carDoors; - private int carCylinders; - - public Automobile(string make, string model, int year) : - this(make, model, year, 0, 0) - { } - - public Automobile(string make, string model, int year, - int doors, int cylinders) - { - this.carMake = make; - this.carModel = model; - this.carYear = year; - this.carDoors = doors; - this.carCylinders = cylinders; - } - - public string Make { - get { return this.carMake; } - } - - public string Model { - get {return this.carModel; } - } - - public int Year { - get { return this.carYear; } - } - - public int Doors { - get { return this.carDoors; } - } - - public int Cylinders { - get { return this.carCylinders; } - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs b/snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs deleted file mode 100644 index 551026945f1..00000000000 --- a/snippets/csharp/System.Resources/ResXResourceWriter/Overview/retrieve1.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Resources; -using System.Windows.Forms; - -public class CarDisplayApp : Form -{ - private const string resxFile = @".\CarResources.resx"; - Automobile[] cars; - - public static void Main() - { - CarDisplayApp app = new CarDisplayApp(); - Application.Run(app); - } - - public CarDisplayApp() - { - // Instantiate controls. - PictureBox pictureBox = new PictureBox(); - pictureBox.Location = new Point(10, 10); - this.Controls.Add(pictureBox); - DataGridView grid = new DataGridView(); - grid.Location = new Point(10, 60); - this.Controls.Add(grid); - - // Get resources from .resx file. - using (ResXResourceSet resxSet = new ResXResourceSet(resxFile)) - { - // Retrieve the string resource for the title. - this.Text = resxSet.GetString("Title"); - // Retrieve the image. - Icon image = (Icon) resxSet.GetObject("Information", true); - if (image != null) - pictureBox.Image = image.ToBitmap(); - - // Retrieve Automobile objects. - List carList = new List(); - string resName = "EarlyAuto"; - Automobile auto; - int ctr = 1; - do { - auto = (Automobile) resxSet.GetObject(resName + ctr.ToString()); - ctr++; - if (auto != null) - carList.Add(auto); - } while (auto != null); - cars = carList.ToArray(); - grid.DataSource = cars; - } - } -} -// - -[Serializable()] public class Automobile -{ - private string carMake; - private string carModel; - private int carYear; - private int carDoors; - private int carCylinders; - - public Automobile(string make, string model, int year) : - this(make, model, year, 0, 0) - { } - - public Automobile(string make, string model, int year, - int doors, int cylinders) - { - this.carMake = make; - this.carModel = model; - this.carYear = year; - this.carDoors = doors; - this.carCylinders = cylinders; - } - - public string Make { - get { return this.carMake; } - } - - public string Model { - get {return this.carModel; } - } - - public int Year { - get { return this.carYear; } - } - - public int Doors { - get { return this.carDoors; } - } - - public int Cylinders { - get { return this.carCylinders; } - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs deleted file mode 100644 index 1dd0a824c4f..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/ctor1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Resources; - -public class Example -{ - public static void Main() - { - CallCtor1(); - CallCtor2(); - } - - static void CallCtor1() - { - // - ResourceManager rm = new ResourceManager("MyCompany.StringResources", - typeof(Example).Assembly); - // - } - - static void CallCtor2() - { - // - ResourceManager rm = new ResourceManager(typeof(MyCompany.StringResources)); - // - } -} - -namespace MyCompany -{ - class StringResources {} -} \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/example.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/example.cs deleted file mode 100644 index 87cec1b7930..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/example.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -public class Example -{ - public static void Main() - { - // Create array of supported cultures - string[] cultures = {"en-CA", "en-US", "fr-FR", "ru-RU" }; - Random rnd = new Random(); - int cultureNdx = rnd.Next(0, cultures.Length); - CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; - ResourceManager rm = new ResourceManager("Greetings", typeof(Example).Assembly); - try { - CultureInfo newCulture = new CultureInfo(cultures[cultureNdx]); - Thread.CurrentThread.CurrentCulture = newCulture; - Thread.CurrentThread.CurrentUICulture = newCulture; - string greeting = String.Format("The current culture is {0}.\n{1}", - Thread.CurrentThread.CurrentUICulture.Name, - rm.GetString("HelloString")); - Console.WriteLine(greeting); - } - catch (CultureNotFoundException e) { - Console.WriteLine("Unable to instantiate culture {0}", e.InvalidCultureName); - } - finally { - Thread.CurrentThread.CurrentCulture = originalCulture; - Thread.CurrentThread.CurrentUICulture = originalCulture; - } - } -} -// The example displays output like the following: -// The current culture is ru-RU. -// Всем привет! -// diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs deleted file mode 100644 index 546ace48d36..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/example3.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -[assembly: NeutralResourcesLanguage("en-US")] - -public class Example -{ - public static void Main() - { - string[] cultureNames = { "en-US", "en-CA", "ru-RU", "fr-FR" }; - ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("Strings", "Resources", null); - - foreach (var cultureName in cultureNames) { - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureName); - string greeting = rm.GetString("Greeting", CultureInfo.CurrentCulture); - Console.WriteLine("\n{0}!", greeting); - Console.Write(rm.GetString("Prompt", CultureInfo.CurrentCulture)); - string name = Console.ReadLine(); - if (!String.IsNullOrEmpty(name)) - Console.WriteLine("{0}, {1}!", greeting, name); - } - Console.WriteLine(); - } -} -// The example displays output like the following: -// Hello! -// What is your name? Dakota -// Hello, Dakota! -// -// Hello! -// What is your name? Koani -// Hello, Koani! -// -// Здравствуйте! -// Как вас зовут?Samuel -// Здравствуйте, Samuel! -// -// Bon jour! -// Comment vous appelez-vous?Yiska -// Bon jour, Yiska! -// \ No newline at end of file diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs deleted file mode 100644 index cc900bf8b94..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/getstring.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -[assembly: NeutralResourcesLanguageAttribute("en-US")] - -public class Example -{ - public static void Main() - { - string[] cultureNames = { "en-US", "fr-FR", "ru-RU", "es-ES" }; - Random rnd = new Random(); - ResourceManager rm = new ResourceManager("Strings", - typeof(Example).Assembly); - - for (int ctr = 0; ctr <= cultureNames.Length; ctr++) { - string cultureName = cultureNames[rnd.Next(0, cultureNames.Length)]; - CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName); - Thread.CurrentThread.CurrentCulture = culture; - Thread.CurrentThread.CurrentUICulture = culture; - - Console.WriteLine("Current culture: {0}", culture.NativeName); - string timeString = rm.GetString("TimeHeader"); - Console.WriteLine("{0} {1:T}\n", timeString, DateTime.Now); - } - } -} -// The example displays output like the following: -// Current culture: English (United States) -// The current time is 9:34:18 AM -// -// Current culture: Español (España, alfabetización internacional) -// The current time is 9:34:18 -// -// Current culture: русский (Россия) -// Текущее время — 9:34:18 -// -// Current culture: français (France) -// L'heure actuelle est 09:34:18 -// -// Current culture: русский (Россия) -// Текущее время — 9:34:18 -// diff --git a/snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs b/snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs deleted file mode 100644 index 00301bf8a46..00000000000 --- a/snippets/csharp/System.Resources/ResourceManager/Overview/rmc.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -using System; -using System.Resources; -using System.Reflection; -using System.Threading; -using System.Globalization; - -class Example -{ - public static void Main() - { - string day; - string year; - string holiday; - string celebrate = "{0} will occur on {1} in {2}.\n"; - - // Create a resource manager. - ResourceManager rm = new ResourceManager("rmc", - typeof(Example).Assembly); - - Console.WriteLine("Obtain resources using the current UI culture."); - - // Get the resource strings for the day, year, and holiday - // using the current UI culture. - day = rm.GetString("day"); - year = rm.GetString("year"); - holiday = rm.GetString("holiday"); - Console.WriteLine(celebrate, holiday, day, year); - - // Obtain the es-MX culture. - CultureInfo ci = new CultureInfo("es-MX"); - - Console.WriteLine("Obtain resources using the es-MX culture."); - - // Get the resource strings for the day, year, and holiday - // using the specified culture. - day = rm.GetString("day", ci); - year = rm.GetString("year", ci); - holiday = rm.GetString("holiday", ci); -// --------------------------------------------------------------- -// Alternatively, comment the preceding 3 code statements and -// uncomment the following 4 code statements: -// ---------------------------------------------------------------- -// Set the current UI culture to "es-MX" (Spanish-Mexico). -// Thread.CurrentThread.CurrentUICulture = ci; - -// Get the resource strings for the day, year, and holiday -// using the current UI culture. Use those strings to -// display a message. -// day = rm.GetString("day"); -// year = rm.GetString("year"); -// holiday = rm.GetString("holiday"); -// --------------------------------------------------------------- - -// Regardless of the alternative that you choose, display a message -// using the retrieved resource strings. - Console.WriteLine(celebrate, holiday, day, year); - } -} -/* -This example displays the following output: - - Obtain resources using the current UI culture. - "5th of May" will occur on Friday in 2006. - - Obtain resources using the es-MX culture. - "Cinco de Mayo" will occur on Viernes in 2006. -*/ -// \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs b/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs deleted file mode 100644 index 25b9cbfd39e..00000000000 --- a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple1.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -// -[assembly:InternalsVisibleTo("Friend1a")] -[assembly:InternalsVisibleTo("Friend1b")] -// - -public class StringUtilities -{ - internal string ToTitleCase(string value) - { - string retval = null; - for (int ctr = 0; ctr <= value.Length - 1; ctr++) - if (ctr == 0) - retval += Char.ToUpper(value[ctr]); - else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1])) - retval += Char.ToUpper(value[ctr]); - else - retval += value[ctr]; - return retval; - } -} diff --git a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs b/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs deleted file mode 100644 index 981dd1b35e9..00000000000 --- a/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/multiple2.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -// -[assembly:InternalsVisibleTo("Friend2a"), - InternalsVisibleTo("Friend2b")] -// - -namespace Utilities -{ - public class StringUtilities - { - internal static string ToTitleCase(string value) - { - string retval = null; - for (int ctr = 0; ctr <= value.Length - 1; ctr++) - if (ctr == 0) - retval += Char.ToUpper(value[ctr]); - else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1])) - retval += Char.ToUpper(value[ctr]); - else - retval += value[ctr]; - return retval; - } - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs b/snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs deleted file mode 100644 index c513ddcbeff..00000000000 --- a/snippets/csharp/System.Runtime.InteropServices/ICustomMarshaler/Overview/source.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -// -using System.Runtime.InteropServices; -// - -// -public interface INew -{ - void NewMethod(); -} -// - -// -public interface ICustomMarshaler -{ - Object MarshalNativeToManaged( IntPtr pNativeData ); - IntPtr MarshalManagedToNative( Object ManagedObj ); - void CleanUpNativeData( IntPtr pNativeData ); - void CleanUpManagedData( Object ManagedObj ); - int GetNativeDataSize(); -} -// - -namespace scope1 -{ -// -interface IUserData -{ - void DoSomeStuff(INew pINew); -} -// -} - -namespace scope2 -{ -// -interface IUserData -{ - void DoSomeStuff( - [MarshalAs(UnmanagedType.CustomMarshaler, - MarshalType="NewOldMarshaler")] - INew pINew - ); -} -// -} - -// -public NewOldMarshaler : ICustomMarshaler -{ - public static ICustomMarshaler GetInstance(string pstrCookie) - => return new NewOldMarshaler(); - - public Object MarshalNativeToManaged( IntPtr pNativeData ) => throw new NotImplementedException(); - public IntPtr MarshalManagedToNative( Object ManagedObj ) => throw new NotImplementedException(); - public void CleanUpNativeData( IntPtr pNativeData ) => throw new NotImplementedException(); - public void CleanUpManagedData( Object ManagedObj ) => throw new NotImplementedException(); - public int GetNativeDataSize() => throw new NotImplementedException(); -} -// - -class StubClass -{ - public static void Main() {} -} \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs b/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs deleted file mode 100644 index dcb3edcc1bd..00000000000 --- a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Common.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -// Remote object. -public class RemoteObject : MarshalByRefObject -{ - private int callCount = 0; - - public int GetCount() - { - Console.WriteLine("GetCount has been called."); - callCount++; - return(callCount); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs b/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs deleted file mode 100644 index 51ab04ee482..00000000000 --- a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/Server.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Runtime.Remoting.Channels.Ipc; - -public class Server -{ - public static void Main(string[] args) - { - // Create the server channel. - IpcChannel serverChannel = - new IpcChannel("localhost:9090"); - - // Register the server channel. - System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel( - serverChannel); - - // Expose an object for remote calls. - System.Runtime.Remoting.RemotingConfiguration. - RegisterWellKnownServiceType( - typeof(RemoteObject), "RemoteObject.rem", - System.Runtime.Remoting.WellKnownObjectMode.Singleton); - - // Wait for the user prompt. - Console.WriteLine("Press ENTER to exit the server."); - Console.ReadLine(); - Console.WriteLine("The server is exiting."); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile b/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile deleted file mode 100644 index d5f2addf79e..00000000000 --- a/snippets/csharp/System.Runtime.Remoting.Channels.Ipc/IpcClientChannel/.ctor/makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: common.dll client.dll client2.dll server.dll - -common.dll: common.cs - csc /t:library common.cs - -server.dll: server.cs common.dll - CS>csc /t:library server.cs /r:common.dll - -client.dll: client.cs common.dll - csc /t:library server.cs /r:common.dll -client2.dll: client2.cs common.dll - csc /t:library client2.cs /r:common.dll \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs b/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs deleted file mode 100644 index bfc7711be08..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Client.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - -public class MyClient -{ - public static void Main() - { - ChannelServices.RegisterChannel(new TcpChannel()); - ActivatedClientTypeEntry myActivatedClientTypeEntry = - new ActivatedClientTypeEntry(typeof(HelloServer), - "tcp://localhost:8082"); - // Register 'HelloServer' Type on the client end so that it can be - // activated on the server. - RemotingConfiguration.RegisterActivatedClientType( - myActivatedClientTypeEntry); - // Obtain a proxy object for the remote object. - HelloServer myHelloServer = new HelloServer("ParameterString"); - if (myHelloServer == null) - { - System.Console.WriteLine("Could not locate server"); - } - else - { - Console.WriteLine("Calling remote object"); - Console.WriteLine(myHelloServer.HelloMethod("Bill")); - } - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs b/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs deleted file mode 100644 index f3155c401d0..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/ActivatedServiceTypeEntry_ObjectType_Share.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -public class HelloServer : MarshalByRefObject -{ - public HelloServer(String myString) - { - Console.WriteLine("HelloServer activated"); - Console.WriteLine("Paramater passed to the constructor is "+myString); - } - public String HelloMethod(String myName) - { - Console.WriteLine("HelloMethod : {0}",myName); - return "Hi there " + myName; - } -} \ No newline at end of file diff --git a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile b/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile deleted file mode 100644 index 5b86eeda7f0..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/ActivatedServiceTypeEntry/Overview/makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: ActivatedServiceTypeEntry_ObjectType_Server.exe ActivatedServiceTypeEntry_ObjectType_Client.exe - -ActivatedServiceTypeEntry_ObjectType_Server.exe: ActivatedServiceTypeEntry_ObjectType_Server.cs ActivatedServiceTypeEntry_ObjectType_Share.dll - csc ActivatedServiceTypeEntry_ObjectType_Server.cs /r:ActivatedServiceTypeEntry_ObjectType_Share.dll - -ActivatedServiceTypeEntry_ObjectType_Client.exe: ActivatedServiceTypeEntry_ObjectType_Client.cs ActivatedServiceTypeEntry_ObjectType_Share.dll - csc ActivatedServiceTypeEntry_ObjectType_Client.cs /r:ActivatedServiceTypeEntry_ObjectType_Share.dll - -ActivatedServiceTypeEntry_ObjectType_Share.dll: ActivatedServiceTypeEntry_ObjectType_Share.cs - csc /t:library ActivatedServiceTypeEntry_ObjectType_Share.cs diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs deleted file mode 100644 index 4c67c89a18f..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Server.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - -public class ServerClass -{ - static void Main() - { - ChannelServices.RegisterChannel(new TcpChannel(8085)); - RemotingConfiguration.RegisterActivatedServiceType(typeof(MyServerImpl)); - Console.WriteLine("Press enter to stop this process."); - Console.ReadLine(); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs deleted file mode 100644 index 007015ae622..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType1_Shared.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated..."); - } - - public String MyMethod(String name) - { - return "The client requests to "+name; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs deleted file mode 100644 index ab949209afb..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Server.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - -public class ServerClass -{ - static void Main() - { - ChannelServices.RegisterChannel(new TcpChannel(8085), false); - RemotingConfiguration.RegisterActivatedServiceType(typeof(MyServerImpl)); - Console.WriteLine("Press enter to stop this process."); - Console.ReadLine(); - } -} diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs deleted file mode 100644 index f19ff43b19b..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/RemotingConfiguration_IsRemotelyActivatedClientType2_Shared.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - int i; - public MyServerImpl() - { - i=0; - Console.WriteLine("Server Activated..."); - } - - public String MyMethod(String name) - { - i=i+1; - return "The client requests to "+name +i+" time"; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile deleted file mode 100644 index 4d13cb1ef9a..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsRemotelyActivatedClientType1_server.exe RemotingConfiguration_IsRemotelyActivatedClientType1_client.exe RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll - -RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll : RemotingConfiguration_IsRemotelyActivatedClientType1_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsRemotelyActivatedClientType1_shared.cs - -RemotingConfiguration_IsRemotelyActivatedClientType1_server.exe : RemotingConfiguration_IsRemotelyActivatedClientType1_server.cs RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll RemotingConfiguration_IsRemotelyActivatedClientType1_server.cs - -RemotingConfiguration_IsRemotelyActivatedClientType1_client.exe : RemotingConfiguration_IsRemotelyActivatedClientType1_client.cs RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClientType1_shared.dll RemotingConfiguration_IsRemotelyActivatedClientType1_client.cs - diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 deleted file mode 100644 index b2cf2345b9a..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsRemotelyActivatedClientType/makefile1 +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsRemotelyActivatedClienttype2_server.exe RemotingConfiguration_IsRemotelyActivatedClienttype2_client.exe RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll - -RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll : RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.cs - -RemotingConfiguration_IsRemotelyActivatedClienttype2_server.exe : RemotingConfiguration_IsRemotelyActivatedClienttype2_server.cs RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll RemotingConfiguration_IsRemotelyActivatedClienttype2_server.cs - -RemotingConfiguration_IsRemotelyActivatedClienttype2_client.exe : RemotingConfiguration_IsRemotelyActivatedClienttype2_client.cs RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsRemotelyActivatedClienttype2_shared.dll RemotingConfiguration_IsRemotelyActivatedClienttype2_client.cs - diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs deleted file mode 100644 index e19a1d17372..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Server.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - - public class Sample { - - public static void Main() - { - ChannelServices.RegisterChannel( new TcpChannel(8085)); - RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyServerImpl), - "SayHello", WellKnownObjectMode.Singleton); - Console.WriteLine("Press to exit..."); - Console.ReadLine(); - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs deleted file mode 100644 index 4779f341780..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType1_Shared.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated"); - } - - public String MyMethod(String name) - { - return "The string from client is " + name; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs deleted file mode 100644 index e19a1d17372..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Server.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; - - public class Sample { - - public static void Main() - { - ChannelServices.RegisterChannel( new TcpChannel(8085)); - RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyServerImpl), - "SayHello", WellKnownObjectMode.Singleton); - Console.WriteLine("Press to exit..."); - Console.ReadLine(); - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs deleted file mode 100644 index ed75db7d4c9..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/RemotingConfiguration_IsWellKnownClientType2_Shared.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Remoting; - - public class MyServerImpl :MarshalByRefObject - { - public MyServerImpl() - { - Console.WriteLine("Server Activated"); - } - - public String MyMethod(String name) - { - Console.WriteLine(name); - return "The string from server : " + name; - } - } diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile deleted file mode 100644 index 05a666573bb..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsWellKnownClientType1_server.exe RemotingConfiguration_IsWellKnownClientType1_client.exe RemotingConfiguration_IsWellKnownClientType1_shared.dll - -RemotingConfiguration_IsWellKnownClientType1_shared.dll : RemotingConfiguration_IsWellKnownClientType1_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsWellKnownClientType1_shared.cs - -RemotingConfiguration_IsWellKnownClientType1_server.exe : RemotingConfiguration_IsWellKnownClientType1_server.cs RemotingConfiguration_IsWellKnownClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType1_shared.dll RemotingConfiguration_IsWellKnownClientType1_server.cs - -RemotingConfiguration_IsWellKnownClientType1_client.exe : RemotingConfiguration_IsWellKnownClientType1_client.cs RemotingConfiguration_IsWellKnownClientType1_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType1_shared.dll RemotingConfiguration_IsWellKnownClientType1_client.cs - diff --git a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 b/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 deleted file mode 100644 index fa6e448de00..00000000000 --- a/snippets/csharp/System.Runtime.Remoting/RemotingConfiguration/IsWellKnownClientType/makefile1 +++ /dev/null @@ -1,11 +0,0 @@ -all : RemotingConfiguration_IsWellKnownClientType2_server.exe RemotingConfiguration_IsWellKnownClientType2_client.exe RemotingConfiguration_IsWellKnownClientType2_shared.dll - -RemotingConfiguration_IsWellKnownClientType2_shared.dll : RemotingConfiguration_IsWellKnownClientType2_shared.cs - csc /debug+ /nologo /t:library RemotingConfiguration_IsWellKnownClientType2_shared.cs - -RemotingConfiguration_IsWellKnownClientType2_server.exe : RemotingConfiguration_IsWellKnownClientType2_server.cs RemotingConfiguration_IsWellKnownClientType2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType2_shared.dll RemotingConfiguration_IsWellKnownClientType2_server.cs - -RemotingConfiguration_IsWellKnownClientType2_client.exe : RemotingConfiguration_IsWellKnownClientType2_client.cs RemotingConfiguration_IsWellKnownClientType2_shared.dll - csc /debug+ /nologo /r:RemotingConfiguration_IsWellKnownClientType2_shared.dll RemotingConfiguration_IsWellKnownClientType2_client.cs - diff --git a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile b/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile deleted file mode 100644 index 09a286afe5d..00000000000 --- a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: NameIdPermission.dll NameIdPermissionAttribute.dll - -NameIdPermission.dll : nameidpermission.cs - csc /t:library nameidpermission.cs - -NameIdPermissionAttribute.dll : nameidpermissionattribute.cs - csc /t:library nameidpermissionattribute.cs /r:NameIdPermission.dll - - diff --git a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs b/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs deleted file mode 100644 index ece46675a7b..00000000000 --- a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/CreationEndpointElement.cs +++ /dev/null @@ -1,55 +0,0 @@ -//---------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -//---------------------------------------------------------------- -using System; -using System.Configuration; -using System.ServiceModel.Activities; -using System.ServiceModel.Configuration; -using System.ServiceModel.Description; - -namespace Microsoft.Samples.WF.CreationEndpoint -{ - //config element for CreationEndpoint - public class CreationEndpointElement : StandardEndpointElement - { - protected override Type EndpointType - { - get { return typeof(CreationEndpoint); } - } - - protected override ConfigurationPropertyCollection Properties - { - get - { - ConfigurationPropertyCollection properties = base.Properties; - properties.Add(new ConfigurationProperty("name", typeof(String), null, ConfigurationPropertyOptions.IsRequired)); - return properties; - } - } - - protected override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription) - { - return new CreationEndpoint(); - } - - protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement channelEndpointElement) - { - } - - protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement) - { - } - - protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement) - { - } - - protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement) - { - } - } - - public class CreationEndpointCollection : StandardEndpointCollectionElement - { - } -} diff --git a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs b/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs deleted file mode 100644 index 85b0b8477aa..00000000000 --- a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/Program.cs +++ /dev/null @@ -1,67 +0,0 @@ -//---------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -//---------------------------------------------------------------- - -using System; -using System.Activities.Statements; -using System.ServiceModel; -using System.ServiceModel.Activities; - -namespace Microsoft.Samples.WF.CreationEndpoint -{ - class Program - { - static void Main(string[] args) - { - Sequence workflow; - WorkflowServiceHost host=null; - - try - { - workflow = CreateWorkflow(); - host = new WorkflowServiceHost(workflow, new Uri("net.pipe://localhost")); - CreationEndpoint creationEp = new CreationEndpoint(new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), new EndpointAddress("net.pipe://localhost/workflowCreationEndpoint")); - host.AddServiceEndpoint(creationEp); - host.Open(); - //client using NetNamedPipeBinding - IWorkflowCreation client = new ChannelFactory(creationEp.Binding, creationEp.Address).CreateChannel(); - //client using BasicHttpBinding - IWorkflowCreation client2 = new ChannelFactory(new BasicHttpBinding(), new EndpointAddress("http://localhost/workflowCreationEndpoint")).CreateChannel(); - //create instance - Console.WriteLine("Workflow Instance created using CreationEndpoint added in code. Instance Id: {0}", client.Create(null)); - //create another instance - Console.WriteLine("Workflow Instance created using CreationEndpoint added in config. Instance Id: {0}", client2.Create(null)); - Console.WriteLine("Press return to exit ..."); - Console.ReadLine(); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - finally - { - if (host != null) - { - host.Close(); - } - } - } - - static Sequence CreateWorkflow() - { - Sequence workflow = new Sequence - { - DisplayName = "CreationService", - Activities = - { - new WriteLine - { - Text = "Hello World" - } - } - }; - - return workflow; - } - } -} diff --git a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile b/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile deleted file mode 100644 index ffc017aa3aa..00000000000 --- a/snippets/csharp/System.ServiceModel.Activities/WorkflowHostingEndpoint/Overview/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: CreationEndpoint.exe - -CreationEndpoint.exe: CreationEndpoint.cs CreationEndpointElement.cs Program.cs - csc /t:exe *.cs /r:System.ServiceModel.dll /r:System.ServiceModel.Activities.dll /r:System.Activities.dll \ No newline at end of file diff --git a/snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs b/snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs deleted file mode 100644 index b52726025c2..00000000000 --- a/snippets/csharp/System.ServiceProcess/ServiceInstaller/Description/simpleservice.cs +++ /dev/null @@ -1,274 +0,0 @@ -// The following example illustrates deriving a service implementation from -// the System.ServiceProcess.ServiceBase class. This simple service starts -// a worker thread, and handles various service commands. -// The main service thread and the worker thread write their trace output -// to c:\service_log.txt. - -// - -// Turn on constant for trace output. -#define TRACE - -using System; -using System.ComponentModel; -using System.IO; -using System.ServiceProcess; -using System.Threading; -using System.Diagnostics; - -namespace SimpleServiceSample -{ - // Define custom commands for the SimpleService. - public enum SimpleServiceCustomCommands {StopWorker=128, RestartWorker, CheckWorker}; - - // Define a simple service implementation. - public class SimpleService : System.ServiceProcess.ServiceBase - { - private const String logFile = @"C:\service_log.txt"; - private static TextWriterTraceListener serviceTraceListener = null; - private Thread workerThread = null; - - // - public SimpleService() - { - CanPauseAndContinue = true; - ServiceName = "SimpleService"; - } - // - - static void Main() - { - - // Create a file for trace output. - // A new file is created each time. If a - // previous log file exists, it is overwritten. - StreamWriter myFile = File.CreateText(logFile); - - // Create a new trace listener writing to the text file, - // and add it to the trace listeners. - serviceTraceListener = new TextWriterTraceListener(myFile); - Trace.Listeners.Add(serviceTraceListener); - - Trace.AutoFlush = true; - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Service main method starting...", - "Main"); - - // Load the service into memory. - System.ServiceProcess.ServiceBase.Run(new SimpleService()); - - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Service main method exiting...", - "Main"); - - // Remove and close the trace listener for this service. - Trace.Listeners.Remove(serviceTraceListener); - - serviceTraceListener.Close(); - serviceTraceListener = null; - myFile.Close(); - } - - private void InitializeComponent() - { - // Initialize the operating properties for the service. - this.CanPauseAndContinue = true; - this.CanShutdown = true; - this.ServiceName = "SimpleService"; - } - - // Start the service. - protected override void OnStart(string[] args) - { - // Start a separate thread which does the actual work. - - if ((workerThread == null) || - ((workerThread.ThreadState & - (System.Threading.ThreadState.Unstarted | System.Threading.ThreadState.Stopped)) != 0)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Starting service worker thread.", - "OnStart"); - - workerThread = new Thread(new ThreadStart(ServiceWorkerMethod)); - workerThread.Start(); - } - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnStart"); - } - } - - // - // Stop this service. - protected override void OnStop() - { - // Signal the worker thread to exit. - if ((workerThread != null) && (workerThread.IsAlive)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Stopping service worker thread.", - "OnStop"); - - workerThread.Abort(); - - // Wait up to 500 milliseconds for the thread to terminate. - workerThread.Join(500); - } - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnStop"); - } - } - // - - // - // Pause the service. - protected override void OnPause() - { - // Pause the worker thread. - if ((workerThread != null) && - (workerThread.IsAlive) && - ((workerThread.ThreadState & - (System.Threading.ThreadState.Suspended | System.Threading.ThreadState.SuspendRequested)) == 0)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Suspending service worker thread.", - "OnPause"); - - workerThread.Suspend(); - } - - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnPause"); - } - } - // - - // - // Continue a paused service. - protected override void OnContinue() - { - - // Signal the worker thread to continue. - if ((workerThread != null) && - ((workerThread.ThreadState & - (System.Threading.ThreadState.Suspended | System.Threading.ThreadState.SuspendRequested)) != 0)) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Resuming service worker thread.", - "OnContinue"); - - workerThread.Resume(); - } - if (workerThread != null) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnContinue"); - } - } - // - - // - // Handle a custom command. - protected override void OnCustomCommand(int command) - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Custom command received: " + - command.ToString(), - "OnCustomCommand"); - - // If the custom command is recognized, - // then signal the worker thread appropriately. - - switch (command) - { - case (int) SimpleServiceCustomCommands.StopWorker: - // Signal the worker thread to terminate. - // For this custom command, the main service - // continues to run without a worker thread. - OnStop(); - break; - - case (int) SimpleServiceCustomCommands.RestartWorker: - - // Restart the worker thread if necessary. - OnStart(null); - break; - - case (int) SimpleServiceCustomCommands.CheckWorker: - - // Log the current worker thread state. - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Worker thread state = " + - workerThread.ThreadState.ToString(), - "OnCustomCommand"); - - break; - - default: - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Unrecognized custom command ignored!", - "OnCustomCommand"); - break; - } - } - // - - // Define a simple method that runs as the worker thread of - // the service. - public void ServiceWorkerMethod() - { - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Starting service worker thread.", - "Worker"); - - try - { - do - { - // Wake up every 10 seconds and write - // a message to the trace output. - - Thread.Sleep(10000); - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - heartbeat cycle.", - "Worker"); - } - while (true); - } - catch (ThreadAbortException) - { - // Another thread has signalled that this thread - // must terminate. Typically, this occurs when - // the main service thread gets a service stop - // command. - - // Write a trace line indicating the worker thread - // is exiting. Notice that this simple thread does - // not have any local objects or data to clean up. - - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Thread abort signalled.", - "Worker"); - } - - Trace.WriteLine(DateTime.Now.ToLongTimeString() + - " - Exiting service worker thread.", - "Worker"); - } - } -} -// diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs deleted file mode 100644 index 7cfee1e737d..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/System.Text.RegularExpressions.Regex.Split.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Text.RegularExpressions; - -public class RegexSplit -{ - public static void Main() - { - RegexSplit rs = new RegexSplit(); - - Console.WriteLine("Splitting 10 occurrences on a null string starting at 'a'"); - rs.Split14(); - -// Console.WriteLine("Calling static Regex.Split(string, string, RegexOptions)"); -// rs.Split11(); -// Console.WriteLine("Calling static Regex.Split with capturing parentheses and RegexOptions:"); -// rs.Split12(); -// Console.WriteLine("Calling static Regex.Split with multiple capturing parentheses and RegexOptions:"); -// rs.Split13(); - } - - private void Split14() - { - string input = "characters"; - Regex regex = new Regex(""); - string[] substrings = regex.Split(input, input.Length, input.IndexOf("a")); - Console.Write("{"); - for(int ctr = 0; ctr < substrings.Length; ctr++) - { - Console.Write(substrings[ctr]); - if (ctr < substrings.Length - 1) - Console.Write(", "); - } - Console.WriteLine("}"); - // The example produces the following output: - // {, c, h, a, r, a, c, t, e, rs} - } -} diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs deleted file mode 100644 index 2c9cfaa3c32..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split10.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - string input = @"07/14/2007"; - string pattern = @"(-)|(/)"; - - foreach (string result in Regex.Split(input, pattern)) - { - Console.WriteLine("'{0}'", result); - } - } -} -// In .NET 1.0 and 1.1, the method returns an array of -// 3 elements, as follows: -// '07' -// '14' -// '2007' -// -// In .NET 2.0 and later, the method returns an array of -// 5 elements, as follows: -// '07' -// '/' -// '14' -// '/' -// '2007' -// diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs deleted file mode 100644 index 77e5691f6ef..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split3.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - string input = @"07/14/2007"; - string pattern = @"(-)|(/)"; - Regex regex = new Regex(pattern); - foreach (string result in regex.Split(input)) - { - Console.WriteLine("'{0}'", result); - } - } -} -// Under .NET 1.0 and 1.1, the method returns an array of -// 3 elements, as follows: -// '07' -// '14' -// '2007' -// -// Under .NET 2.0 and later, the method returns an array of -// 5 elements, as follows: -// '07' -// '/' -// '14' -// '/' -// '2007' -// diff --git a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs b/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs deleted file mode 100644 index 9c43556a1e2..00000000000 --- a/snippets/csharp/System.Text.RegularExpressions/Regex/Split/split7.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - string pattern = "(-)|([|])"; // possible delimiters found in string - string input = "apple|apricot|plum|pear|pomegranate|pineapple|peach"; - - Regex regex = new Regex(pattern); - // Split on delimiters from 15th character on - string[] substrings = regex.Split(input, 4, 15); - foreach (string match in substrings) - { - Console.WriteLine("'{0}'", match); - } - } -} -// In .NET 2.0 and later, the method returns an array of -// 7 elements, as follows: -// apple|apricot|plum' -// '|' -// 'pear' -// '|' -// 'pomegranate' -// '|' -// 'pineapple|peach' -// In .NET 1.0 and 1.1, the method returns an array of -// 4 elements, as follows: -// 'apple|apricot|plum' -// 'pear' -// 'pomegranate' -// 'pineapple|peach' -// diff --git a/snippets/csharp/System.Text/Encoding/GetString/getstring.cs b/snippets/csharp/System.Text/Encoding/GetString/getstring.cs deleted file mode 100644 index bb9ec21d5f9..00000000000 --- a/snippets/csharp/System.Text/Encoding/GetString/getstring.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.IO; - -namespace ConsoleApplication1 { - class MyBinaryFile { - string m_author = null; - static void Main(string[] args) { - MyBinaryFile bf1 = new MyBinaryFile(); - bf1.Author = "Marin Millar"; - bf1.Save("a.dat"); - - MyBinaryFile bf2 = new MyBinaryFile(); - bf2.Load("a.dat"); - Console.WriteLine(bf2.Author); - - bf2.PrintEncodingInfo(System.Text.Encoding.Default); - } - public MyBinaryFile() { - } - public string Author { - set { - m_author = value; - } - get { - return m_author; - } - } - public void Save(string filename) { - FileStream fs = File.Open(filename, FileMode.Create); - WriteAuthor(fs, m_author); - fs.Flush(); - fs.Close(); - } - private void WriteAuthor(Stream binary_file, string author) { - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - // Get buffer size required for conversion - int buffersize = encoding.GetByteCount(author); - if (buffersize < 30) { - buffersize = 30; - } - // Write string into binary file with UTF8 encoding - byte[] buffer = new byte[buffersize]; - encoding.GetBytes(author, 0, author.Length, buffer, 0); - binary_file.Write(buffer, 0, 30); - } - public void Load(string filename) { - FileStream fs = File.OpenRead(filename); - m_author = ReadAuthor(fs); - fs.Close(); - } - // - private string ReadAuthor(Stream binary_file) { - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - // Read string from binary file with UTF8 encoding - byte[] buffer = new byte[30]; - binary_file.Read(buffer, 0, 30); - return encoding.GetString(buffer); - } -/* This code produces the following output. - -Marin Millar -BodyName: iso-8859-1 -HeaderName: Windows-1252 -WebName: Windows-1252 -CodePage: 1252 -EncodingName: Western European (Windows) -WindowsCodePage: 1252 -MailNewsDisplay: True -MailNewsSave: True -BrowserDisplay: True -BrowserSave: True -*/ - // - private void PrintEncodingInfo(System.Text.Encoding encoding) { - // Print information of encoding - Console.WriteLine("BodyName: " + encoding.BodyName); - Console.WriteLine("HeaderName: " + encoding.HeaderName); - Console.WriteLine("WebName: " + encoding.WebName); - Console.WriteLine("CodePage: " + encoding.CodePage); - Console.WriteLine("EncodingName: " + encoding.EncodingName); - Console.WriteLine("WindowsCodePage: " + encoding.WindowsCodePage); - Console.WriteLine("MailNewsDisplay: " + encoding.IsMailNewsDisplay); - Console.WriteLine("MailNewsSave: " + encoding.IsMailNewsSave); - Console.WriteLine("BrowserDisplay: " + encoding.IsBrowserDisplay); - Console.WriteLine("BrowserSave: " + encoding.IsBrowserSave); - } - } -} diff --git a/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs b/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs deleted file mode 100644 index 453828692e9..00000000000 --- a/snippets/csharp/System.Text/Encoding/Overview/getencoding1.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - Encoding enc = Encoding.GetEncoding(1253); - Encoding altEnc = Encoding.GetEncoding("windows-1253"); - Console.WriteLine("{0} = Code Page {1}: {2}", enc.EncodingName, - altEnc.CodePage, enc.Equals(altEnc)); - string greekAlphabet = "Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η " + - "Θ θ Ι ι Κ κ Λ λ Μ μ Ν ν Ξ ξ " + - "Ο ο Π π Ρ ρ Σ σ ς Τ τ Υ υ " + - "Φ φ Χ χ Ψ ψ Ω ω"; - Console.OutputEncoding = Encoding.UTF8; - byte[] bytes = enc.GetBytes(greekAlphabet); - Console.WriteLine("{0,-12} {1,20} {2,20:X2}", "Character", - "Unicode Code Point", "Code Page 1253"); - for (int ctr = 0; ctr < bytes.Length; ctr++) { - if (greekAlphabet[ctr].Equals(' ')) - continue; - - Console.WriteLine("{0,-12} {1,20} {2,20:X2}", greekAlphabet[ctr], - GetCodePoint(greekAlphabet[ctr]), bytes[ctr]); - } - } - - private static string GetCodePoint(char ch) - { - string retVal = "u+"; - byte[] bytes = Encoding.Unicode.GetBytes(ch.ToString()); - for (int ctr = bytes.Length - 1; ctr >= 0; ctr--) - retVal += bytes[ctr].ToString("X2"); - - return retVal; - } -} -// The example displays the following output: -// Character Unicode Code Point Code Page 1253 -// Α u+0391 C1 -// α u+03B1 E1 -// Β u+0392 C2 -// β u+03B2 E2 -// Γ u+0393 C3 -// γ u+03B3 E3 -// Δ u+0394 C4 -// δ u+03B4 E4 -// Ε u+0395 C5 -// ε u+03B5 E5 -// Ζ u+0396 C6 -// ζ u+03B6 E6 -// Η u+0397 C7 -// η u+03B7 E7 -// Θ u+0398 C8 -// θ u+03B8 E8 -// Ι u+0399 C9 -// ι u+03B9 E9 -// Κ u+039A CA -// κ u+03BA EA -// Λ u+039B CB -// λ u+03BB EB -// Μ u+039C CC -// μ u+03BC EC -// Ν u+039D CD -// ν u+03BD ED -// Ξ u+039E CE -// ξ u+03BE EE -// Ο u+039F CF -// ο u+03BF EF -// Π u+03A0 D0 -// π u+03C0 F0 -// Ρ u+03A1 D1 -// ρ u+03C1 F1 -// Σ u+03A3 D3 -// σ u+03C3 F3 -// ς u+03C2 F2 -// Τ u+03A4 D4 -// τ u+03C4 F4 -// Υ u+03A5 D5 -// υ u+03C5 F5 -// Φ u+03A6 D6 -// φ u+03C6 F6 -// Χ u+03A7 D7 -// χ u+03C7 F7 -// Ψ u+03A8 D8 -// ψ u+03C8 F8 -// Ω u+03A9 D9 -// ω u+03C9 F9 -// \ No newline at end of file diff --git a/snippets/csharp/System.Text/StringBuilder/Append/Append1.cs b/snippets/csharp/System.Text/StringBuilder/Append/Append1.cs deleted file mode 100644 index 9fb709bf3a4..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Append/Append1.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Text; - -[assembly: CLSCompliant(true)] -public class Class1 -{ - public static void Main() - { - // - char[] characters = {'/', '<', '<', ' ', '>', '>', '\\'}; - const int beginPosition = 0; - const int endPosition = 3; - - string title = "The Hound of the Baskervilles"; - - StringBuilder sb = new StringBuilder(); - sb.Append(characters, beginPosition, 4); - sb.Append(title); - sb.Append(characters, endPosition, 4); - Console.WriteLine(sb.ToString()); - // The example displays the following output: - // /<< The Hound of the Baskervilles >>\ - // - } -} diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs deleted file mode 100644 index ed96e1ca314..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/call1.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder(); - sb.Append("This is the beginning of a sentence, "); - sb.Replace("the beginning of ", ""); - sb.Insert(sb.ToString().IndexOf("a ") + 2, "complete "); - sb.Replace(",", "."); - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// This is a complete sentence. -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs deleted file mode 100644 index 8f5afae20ea..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/call2.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder("This is the beginning of a sentence, "); - sb.Replace("the beginning of ", "").Insert(sb.ToString().IndexOf("a ") + 2, - "complete ").Replace(",", "."); - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// This is a complete sentence. -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs deleted file mode 100644 index 0102f817293..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/chars1.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Globalization; -using System.Text; - -public class Example -{ - public static void Main() - { - Random rnd = new Random(); - StringBuilder sb = new StringBuilder(); - - // Generate 10 random numbers and store them in a StringBuilder. - for (int ctr = 0; ctr <= 9; ctr++) - sb.Append(rnd.Next().ToString("N5")); - - Console.WriteLine("The original string:"); - Console.WriteLine(sb.ToString()); - - // Decrease each number by one. - for (int ctr = 0; ctr < sb.Length; ctr++) { - if (Char.GetUnicodeCategory(sb[ctr]) == UnicodeCategory.DecimalDigitNumber) { - int number = (int) Char.GetNumericValue(sb[ctr]); - number--; - if (number < 0) number = 9; - - sb[ctr] = number.ToString()[0]; - } - } - Console.WriteLine("\nThe new string:"); - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// The original string: -// 1,457,531,530.00000940,522,609.000001,668,113,564.000001,998,992,883.000001,792,660,834.00 -// 000101,203,251.000002,051,183,075.000002,066,000,067.000001,643,701,043.000001,702,382,508 -// .00000 -// -// The new string: -// 0,346,420,429.99999839,411,598.999990,557,002,453.999990,887,881,772.999990,681,559,723.99 -// 999090,192,140.999991,940,072,964.999991,955,999,956.999990,532,690,932.999990,691,271,497 -// .99999 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs deleted file mode 100644 index 393dcba2227..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/default1.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -using System; -using System.Reflection; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder(); - ShowSBInfo(sb); - sb.Append("This is a sentence."); - ShowSBInfo(sb); - for (int ctr = 0; ctr <= 10; ctr++) { - sb.Append("This is an additional sentence."); - ShowSBInfo(sb); - } - } - - private static void ShowSBInfo(StringBuilder sb) - { - foreach (var prop in sb.GetType().GetProperties()) { - if (prop.GetIndexParameters().Length == 0) - Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); - } - Console.WriteLine(); - } -} -// The example displays the following output: -// Capacity: 16 MaxCapacity: 2,147,483,647 Length: 0 -// Capacity: 32 MaxCapacity: 2,147,483,647 Length: 19 -// Capacity: 64 MaxCapacity: 2,147,483,647 Length: 50 -// Capacity: 128 MaxCapacity: 2,147,483,647 Length: 81 -// Capacity: 128 MaxCapacity: 2,147,483,647 Length: 112 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 143 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 174 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 205 -// Capacity: 256 MaxCapacity: 2,147,483,647 Length: 236 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 267 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 298 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 329 -// Capacity: 512 MaxCapacity: 2,147,483,647 Length: 360 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs deleted file mode 100644 index 3c31f9dbf2c..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/delete1.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder sb = new StringBuilder("A StringBuilder object"); - ShowSBInfo(sb); - // Remove "object" from the text. - string textToRemove = "object"; - int pos = sb.ToString().IndexOf(textToRemove); - if (pos >= 0) { - sb.Remove(pos, textToRemove.Length); - ShowSBInfo(sb); - } - // Clear the StringBuilder contents. - sb.Clear(); - ShowSBInfo(sb); - } - - public static void ShowSBInfo(StringBuilder sb) - { - Console.WriteLine("\nValue: {0}", sb.ToString()); - foreach (var prop in sb.GetType().GetProperties()) { - if (prop.GetIndexParameters().Length == 0) - Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); - } - Console.WriteLine(); - } -} -// The example displays the following output: -// Value: A StringBuilder object -// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 22 -// -// Value: A StringBuilder -// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 16 -// -// Value: -// Capacity: 22 MaxCapacity: 2,147,483,647 Length: 0 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs deleted file mode 100644 index e811b7c5061..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/expand1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with no text. - StringBuilder sb = new StringBuilder(); - // Append some text. - sb.Append('*', 10).Append(" Adding Text to a StringBuilder Object ").Append('*', 10); - sb.AppendLine("\n"); - sb.AppendLine("Some code points and their corresponding characters:"); - // Append some formatted text. - for (int ctr = 50; ctr <= 60; ctr++) { - sb.AppendFormat("{0,12:X4} {1,12}", ctr, Convert.ToChar(ctr)); - sb.AppendLine(); - } - // Find the end of the introduction to the column. - int pos = sb.ToString().IndexOf("characters:") + 11 + - Environment.NewLine.Length; - // Insert a column header. - sb.Insert(pos, String.Format("{2}{0,12:X4} {1,12}{2}", "Code Unit", - "Character", "\n")); - - // Convert the StringBuilder to a string and display it. - Console.WriteLine(sb.ToString()); - } -} -// The example displays the following output: -// ********** Adding Text to a StringBuilder Object ********** -// -// Some code points and their corresponding characters: -// -// Code Unit Character -// 0032 2 -// 0033 3 -// 0034 4 -// 0035 5 -// 0036 6 -// 0037 7 -// 0038 8 -// 0039 9 -// 003A : -// 003B ; -// 003C < -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs deleted file mode 100644 index 0ccf5009804..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/immutability2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public unsafe static void Main() - { - string value = "This is the first sentence" + "."; - fixed (char* start = value) - { - value = String.Concat(value, "This is the second sentence. "); - fixed (char* current = value) - { - Console.WriteLine(start == current); - } - } - } -} -// The example displays the following output: -// False -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs deleted file mode 100644 index 9626a43ef01..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/instantiate1.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - string value = "An ordinary string"; - int index = value.IndexOf("An ") + 3; - int capacity = 0xFFFF; - - // Instantiate a StringBuilder from a string. - StringBuilder sb1 = new StringBuilder(value); - ShowSBInfo(sb1); - - // Instantiate a StringBuilder from string and define a capacity. - StringBuilder sb2 = new StringBuilder(value, capacity); - ShowSBInfo(sb2); - - // Instantiate a StringBuilder from substring and define a capacity. - StringBuilder sb3 = new StringBuilder(value, index, - value.Length - index, - capacity ); - ShowSBInfo(sb3); - } - - public static void ShowSBInfo(StringBuilder sb) - { - Console.WriteLine("\nValue: {0}", sb.ToString()); - foreach (var prop in sb.GetType().GetProperties()) { - if (prop.GetIndexParameters().Length == 0) - Console.Write("{0}: {1:N0} ", prop.Name, prop.GetValue(sb)); - } - Console.WriteLine(); - } -} -// The example displays the following output: -// Value: An ordinary string -// Capacity: 18 MaxCapacity: 2,147,483,647 Length: 18 -// -// Value: An ordinary string -// Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 18 -// -// Value: ordinary string -// Capacity: 65,535 MaxCapacity: 2,147,483,647 Length: 15 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs deleted file mode 100644 index 76cbcf070c4..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern1.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - Random rnd = new Random(); - string[] tempF = { "47.6F", "51.3F", "49.5F", "62.3F" }; - string[] tempC = { "21.2C", "16.1C", "23.5C", "22.9C" }; - string[][] temps = { tempF, tempC }; - - StringBuilder sb = new StringBuilder(); - var f = new StringBuilderFinder(sb, "F"); - var baseDate = new DateTime(2013, 5, 1); - String[] temperatures = temps[rnd.Next(2)]; - bool isFahrenheit = false; - foreach (var temperature in temperatures) { - if (isFahrenheit) - sb.AppendFormat("{0:d}: {1}\n", baseDate, temperature); - else - isFahrenheit = f.SearchAndAppend(String.Format("{0:d}: {1}\n", - baseDate, temperature)); - baseDate = baseDate.AddDays(1); - } - if (isFahrenheit) { - sb.Insert(0, "Average Daily Temperature in Degrees Fahrenheit"); - sb.Insert(47, "\n\n"); - } - else { - sb.Insert(0, "Average Daily Temperature in Degrees Celsius"); - sb.Insert(44, "\n\n"); - } - Console.WriteLine(sb.ToString()); - } -} - -public class StringBuilderFinder -{ - private StringBuilder sb; - private String text; - - public StringBuilderFinder(StringBuilder sb, String textToFind) - { - this.sb = sb; - this.text = textToFind; - } - - public bool SearchAndAppend(String stringToSearch) - { - sb.Append(stringToSearch); - return stringToSearch.Contains(text); - } -} -// The example displays output similar to the following: -// Average Daily Temperature in Degrees Celsius -// -// 5/1/2013: 21.2C -// 5/2/2013: 16.1C -// 5/3/2013: 23.5C -// 5/4/2013: 22.9C -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs deleted file mode 100644 index ea20040bbd2..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern2.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -using System; -using System.Text; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with 4 successive occurrences - // of each character in the English alphabet. - StringBuilder sb = new StringBuilder(); - for (ushort ctr = (ushort)'a'; ctr <= (ushort) 'z'; ctr++) - sb.Append(Convert.ToChar(ctr), 4); - - // Create a parallel string object. - String sbString = sb.ToString(); - // Determine where each new character sequence begins. - String pattern = @"(\w)\1+"; - MatchCollection matches = Regex.Matches(sbString, pattern); - - // Uppercase the first occurrence of the sequence, and separate it - // from the previous sequence by an underscore character. - for (int ctr = matches.Count - 1; ctr >= 0; ctr--) { - Match m = matches[ctr]; - sb[m.Index] = Char.ToUpper(sb[m.Index]); - if (m.Index > 0) sb.Insert(m.Index, "_"); - } - // Display the resulting string. - sbString = sb.ToString(); - int line = 0; - do { - int nChars = line * 80 + 79 <= sbString.Length ? - 80 : sbString.Length - line * 80; - Console.WriteLine(sbString.Substring(line * 80, nChars)); - line++; - } while (line * 80 < sbString.Length); - } -} -// The example displays the following output: -// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ -// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs deleted file mode 100644 index 4d927c66cc5..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern3.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with 4 successive occurrences - // of each character in the English alphabet. - StringBuilder sb = new StringBuilder(); - for (ushort ctr = (ushort) 'a'; ctr <= (ushort) 'z'; ctr++) - sb.Append(Convert.ToChar(ctr), 4); - - // Iterate the text to determine when a new character sequence occurs. - int position = 0; - Char current = '\u0000'; - do { - if (sb[position] != current) { - current = sb[position]; - sb[position] = Char.ToUpper(sb[position]); - if (position > 0) - sb.Insert(position, "_"); - position += 2; - } - else { - position++; - } - } while (position <= sb.Length - 1); - // Display the resulting string. - String sbString = sb.ToString(); - int line = 0; - do { - int nChars = line * 80 + 79 <= sbString.Length ? - 80 : sbString.Length - line * 80; - Console.WriteLine(sbString.Substring(line * 80, nChars)); - line++; - } while (line * 80 < sbString.Length); - } -} -// The example displays the following output: -// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ -// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs b/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs deleted file mode 100644 index 67112fb6c4e..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/pattern4.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -using System; -using System.Text; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - // Create a StringBuilder object with 4 successive occurrences - // of each character in the English alphabet. - StringBuilder sb = new StringBuilder(); - for (ushort ctr = (ushort)'a'; ctr <= (ushort) 'z'; ctr++) - sb.Append(Convert.ToChar(ctr), 4); - - // Convert it to a string. - String sbString = sb.ToString(); - - // Use a regex to uppercase the first occurrence of the sequence, - // and separate it from the previous sequence by an underscore. - string pattern = @"(\w)(\1+)"; - sbString = Regex.Replace(sbString, pattern, - m => (m.Index > 0 ? "_" : "") + - m.Groups[1].Value.ToUpper() + - m.Groups[2].Value); - - // Display the resulting string. - int line = 0; - do { - int nChars = line * 80 + 79 <= sbString.Length ? - 80 : sbString.Length - line * 80; - Console.WriteLine(sbString.Substring(line * 80, nChars)); - line++; - } while (line * 80 < sbString.Length); - } -} -// The example displays the following output: -// Aaaa_Bbbb_Cccc_Dddd_Eeee_Ffff_Gggg_Hhhh_Iiii_Jjjj_Kkkk_Llll_Mmmm_Nnnn_Oooo_Pppp_ -// Qqqq_Rrrr_Ssss_Tttt_Uuuu_Vvvv_Wwww_Xxxx_Yyyy_Zzzz -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs deleted file mode 100644 index 8e9426d47e3..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/perf1.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -public struct OperationTime -{ - public OperationTime(int ctr, TimeSpan elapsed) - { - Operations = ctr; - ElapsedTime = elapsed; - } - - public int Operations; - public TimeSpan ElapsedTime; -} - -public class Example -{ - public static void Main() - { - List stringTimes = new List(); - List builderTimes = new List(); - - // Begin the time for a string - Stopwatch sTimer = new Stopwatch(); - Stopwatch sbTimer = new Stopwatch(); - - // We want to include object instantiation in the timer. - sTimer.Start(); - string baseS1 = "Beginning"; - sTimer.Stop(); - - sbTimer.Start(); - StringBuilder baseS2 = new StringBuilder("Beginning"); - sbTimer.Stop(); - - // Record time for every 10 operations for a 100 operation string concatenation. - sTimer.Start(); - for (int ctr = 1; ctr <= 100; ctr++) { - baseS1 += "a"; - if (ctr % 10 == 0) { - sTimer.Stop(); - stringTimes.Add(new OperationTime(ctr, sTimer.Elapsed)); - sTimer.Start(); - } - }; - sTimer.Stop(); - - sbTimer.Start(); - for (int ctr = 1; ctr <= 100; ctr++) { - baseS2.Append("a"); - if (ctr % 10 == 0) { - sbTimer.Stop(); - builderTimes.Add(new OperationTime(ctr, sbTimer.Elapsed)); - sbTimer.Start(); - } - } - sbTimer.Stop(); - - // Display performance information - Console.WriteLine("{0,10} {1,20} {2,20}", - "Operations", "String Time", "StringBuilder Time"); - - for (int ctr = 0; ctr < stringTimes.Count; ctr++) - Console.WriteLine("{0,10} {1,20} {2,20}", stringTimes[ctr].Operations, - stringTimes[ctr].ElapsedTime, builderTimes[ctr].ElapsedTime); - } -} -// The example displays the following output: -// Operations String Time StringBuilder Time -// 10 00:00:00.0000019 00:00:00.0000087 -// 20 00:00:00.0000025 00:00:00.0000087 -// 30 00:00:00.0000032 00:00:00.0000090 -// 40 00:00:00.0000038 00:00:00.0000090 -// 50 00:00:00.0000090 00:00:00.0000094 -// 60 00:00:00.0000097 00:00:00.0000097 -// 70 00:00:00.0000103 00:00:00.0000097 -// 80 00:00:00.0000110 00:00:00.0000100 -// 90 00:00:00.0000181 00:00:00.0000100 -// 100 00:00:00.0000188 00:00:00.0000103 -// diff --git a/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs b/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs deleted file mode 100644 index 9e66c7977fb..00000000000 --- a/snippets/csharp/System.Text/StringBuilder/Overview/replace1.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; -using System.Text; - -public class Example -{ - public static void Main() - { - StringBuilder MyStringBuilder = new StringBuilder("Hello World!"); - MyStringBuilder.Replace('!', '?'); - Console.WriteLine(MyStringBuilder); - } -} -// The example displays the following output: -// Hello World? -// diff --git a/snippets/csharp/System/Action/Overview/Delegate.cs b/snippets/csharp/System/Action/Overview/Delegate.cs deleted file mode 100644 index a7fe2739ddf..00000000000 --- a/snippets/csharp/System/Action/Overview/Delegate.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; -using System.Windows.Forms; - -public delegate void ShowValue(); - -public class Name -{ - private string instanceName; - - public Name(string name) - { - this.instanceName = name; - } - - public void DisplayToConsole() - { - Console.WriteLine(this.instanceName); - } - - public void DisplayToWindow() - { - MessageBox.Show(this.instanceName); - } -} - -public class testTestDelegate -{ - public static void Main() - { - Name testName = new Name("Koani"); - ShowValue showMethod = testName.DisplayToWindow; - showMethod(); - } -} -// diff --git a/snippets/csharp/System/AppContext/Overview/Example4.cs b/snippets/csharp/System/AppContext/Overview/Example4.cs deleted file mode 100644 index 5a906d1f2b1..00000000000 --- a/snippets/csharp/System/AppContext/Overview/Example4.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.Reflection; - -[assembly: AssemblyVersion("1.0.0.0")] - -public static class StringLibrary -{ - public static int SubstringStartsAt(string fullString, string substr) - { - return fullString.IndexOf(substr, StringComparison.Ordinal); - } -} -// - -namespace App -{ - // - using System; - - public class Example - { - public static void Main() - { - string value = "The archaeologist"; - string substring = "archæ"; - int position = StringLibrary.SubstringStartsAt(value, substring); - if (position >= 0) - Console.WriteLine("'{0}' found in '{1}' starting at position {2}", - substring, value, position); - else - Console.WriteLine("'{0}' not found in '{1}'", substring, value); - } - } - // The example displays the following output: - // 'archæ' not found in 'The archaeologist' - // -} diff --git a/snippets/csharp/System/AppContext/Overview/Example6.cs b/snippets/csharp/System/AppContext/Overview/Example6.cs deleted file mode 100644 index e33b85efd30..00000000000 --- a/snippets/csharp/System/AppContext/Overview/Example6.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.Reflection; - -[assembly: AssemblyVersion("2.0.0.0")] - -public static class StringLibrary -{ - public static int SubstringStartsAt(string fullString, string substr) - { - return fullString.IndexOf(substr, StringComparison.CurrentCulture); - } -} -// - -namespace App -{ - // - using System; - - public class Example - { - public static void Main() - { - string value = "The archaeologist"; - string substring = "archæ"; - int position = StringLibrary.SubstringStartsAt(value, substring); - if (position >= 0) - Console.WriteLine("'{0}' found in '{1}' starting at position {2}", - substring, value, position); - else - Console.WriteLine("'{0}' not found in '{1}'", substring, value); - } - } - // The example displays the following output: - // 'archæ' found in 'The archaeologist' starting at position 4 - // -} diff --git a/snippets/csharp/System/AppContext/Overview/Example8.cs b/snippets/csharp/System/AppContext/Overview/Example8.cs deleted file mode 100644 index 5fad1b348bb..00000000000 --- a/snippets/csharp/System/AppContext/Overview/Example8.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Reflection; - -[assembly: AssemblyVersion("2.0.0.0")] - -public static class StringLibrary -{ - public static int SubstringStartsAt(string fullString, string substr) - { - bool flag; - if (AppContext.TryGetSwitch("StringLibrary.DoNotUseCultureSensitiveComparison", out flag) && flag) - return fullString.IndexOf(substr, StringComparison.Ordinal); - else - return fullString.IndexOf(substr, StringComparison.CurrentCulture); - } -} -// - -namespace App -{ - // - using System; - - public class Example - { - public static void Main() - { - string value = "The archaeologist"; - string substring = "archæ"; - int position = StringLibrary.SubstringStartsAt(value, substring); - if (position >= 0) - Console.WriteLine("'{0}' found in '{1}' starting at position {2}", - substring, value, position); - else - Console.WriteLine("'{0}' not found in '{1}'", substring, value); - } - } - // The example displays the following output: - // 'archæ' found in 'The archaeologist' starting at position 4 - // -} diff --git a/snippets/csharp/System/AppContext/Overview/ForConsumers1.cs b/snippets/csharp/System/AppContext/Overview/ForConsumers1.cs deleted file mode 100644 index 6cf41198aeb..00000000000 --- a/snippets/csharp/System/AppContext/Overview/ForConsumers1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; -using System.IO; -using System.Runtime.Versioning; - -[assembly:TargetFramework(".NETFramework,Version=v4.6.2")] - -public class Example -{ - public static void Main() - { - Console.WriteLine(Path.GetDirectoryName("file://c/temp/dirlist.txt")); - } -} -// The example displays the following output: -// Unhandled Exception: System.ArgumentException: The path is not of a legal form. -// at System.IO.Path.NewNormalizePathLimitedChecks(String path, Int32 maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.InternalGetDirectoryName(String path) -// at Example.Main() -// diff --git a/snippets/csharp/System/AppContext/Overview/GetSwitches3.cs b/snippets/csharp/System/AppContext/Overview/GetSwitches3.cs deleted file mode 100644 index 9360ee49e99..00000000000 --- a/snippets/csharp/System/AppContext/Overview/GetSwitches3.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -using System; -using System.Configuration; -using System.Globalization; -using System.Xml; - -public class Example -{ - private const string SettingName = "AppContextSwitchOverrides"; - private const string SwitchName = "Switch.Application.Utilities.SwitchName"; - - public static void Main() - { - bool flag = false; - - // Determine whether the caller has used the AppContext class directly. - if (!AppContext.TryGetSwitch(SwitchName, out flag)) { - // If switch is not defined directly, attempt to retrieve it from a configuration file. - try { - Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - if (config == null) return; - - ConfigurationSection sec = config.GetSection("runtime"); - if (sec != null) { - string rawXml = sec.SectionInformation.GetRawXml(); - if (string.IsNullOrEmpty(rawXml)) return; - - var doc = new XmlDocument(); - doc.LoadXml(rawXml); - XmlNode root = doc.FirstChild; - // Navigate the children. - if (root.HasChildNodes) { - foreach (XmlNode node in root.ChildNodes) { - if (node.Name.Equals(SettingName, StringComparison.Ordinal)) { - // Get attribute value - XmlAttribute attr = node.Attributes["value"]; - string[] nameValuePair = attr.Value.Split('='); - // Determine whether the switch we want is present. - if (SwitchName.Equals(nameValuePair[0], StringComparison.Ordinal)) { - bool tempFlag = false; - if (bool.TryParse(CultureInfo.InvariantCulture.TextInfo.ToTitleCase(nameValuePair[1]), - out tempFlag)) - AppContext.SetSwitch(nameValuePair[0], tempFlag); - } - } - } - } - } - } - catch (ConfigurationErrorsException) - {} - } - } -} -// diff --git a/snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs b/snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs deleted file mode 100644 index d047a6f0c06..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/AsyncDelegateWithStateObject.cs +++ /dev/null @@ -1,160 +0,0 @@ -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.Collections; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ -// Create a state object that holds each requested host name, -// an associated IPHostEntry object or a SocketException. - public class HostRequest - { - // Stores the requested host name. - private string hostName; - // Stores any SocketException returned by the Dns EndGetHostByName method. - private SocketException e; - // Stores an IPHostEntry returned by the Dns EndGetHostByName method. - private IPHostEntry entry; - - public HostRequest(string name) - { - hostName = name; - } - - public string HostName - { - get - { - return hostName; - } - } - - public SocketException ExceptionObject - { - get - { - return e; - } - set - { - e = value; - } - } - - public IPHostEntry HostEntry - { - get - { - return entry; - } - set - { - entry = value; - } - } - } - - public class UseDelegateAndStateForAsyncCallback - { - // The number of pending requests. - static int requestCounter; - static ArrayList hostData = new ArrayList(); - static void UpdateUserInterface() - { - // Print a message to indicate that the application - // is still working on the remaining requests. - Console.WriteLine("{0} requests remaining.", requestCounter); - } - public static void Main() - { - // Create the delegate that will process the results of the - // asynchronous request. - AsyncCallback callBack = new AsyncCallback(ProcessDnsInformation); - string host; - do - { - Console.Write(" Enter the name of a host computer or to finish: "); - host = Console.ReadLine(); - if (host.Length > 0) - { - // Increment the request counter in a thread safe manner. - Interlocked.Increment(ref requestCounter); - // Create and store the state object for this request. - HostRequest request = new HostRequest(host); - hostData.Add(request); - // Start the asynchronous request for DNS information. - Dns.BeginGetHostEntry(host, callBack, request); - } - } while (host.Length > 0); - // The user has entered all of the host names for lookup. - // Now wait until the threads complete. - while (requestCounter > 0) - { - UpdateUserInterface(); - } - // Display the results. - foreach(HostRequest r in hostData) - { - if (r.ExceptionObject != null) - { - Console.WriteLine("Request for host {0} returned the following error: {1}.", - r.HostName, r.ExceptionObject.Message); - } - else - { - // Get the results. - IPHostEntry h = r.HostEntry; - string[] aliases = h.Aliases; - IPAddress[] addresses = h.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases for {0}", r.HostName); - for (int j = 0; j < aliases.Length; j++) - { - Console.WriteLine("{0}", aliases[j]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses for {0}", r.HostName); - for (int k = 0; k < addresses.Length; k++) - { - Console.WriteLine("{0}",addresses[k].ToString()); - } - } - } - } - } - - // The following method is invoked when each asynchronous operation completes. - static void ProcessDnsInformation(IAsyncResult result) - { - // Get the state object associated with this request. - HostRequest request = (HostRequest) result.AsyncState; - try - { - // Get the results and store them in the state object. - IPHostEntry host = Dns.EndGetHostEntry(result); - request.HostEntry = host; - } - catch (SocketException e) - { - // Store any SocketExceptions. - request.ExceptionObject = e; - } - finally - { - // Decrement the request counter in a thread-safe manner. - Interlocked.Decrement(ref requestCounter); - } - } - } -} -// diff --git a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs b/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs deleted file mode 100644 index 47e992c42e8..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlock.cs +++ /dev/null @@ -1,61 +0,0 @@ -// AsynchSampler -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. -*/ - -using System; -using System.Net; -using System.Net.Sockets; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class BlockUntilOperationCompletes - { - public static void Main(string[] args) - { - // Make sure the caller supplied a host name. - if (args.Length == 0 || args[0].Length == 0) - { - // Print a message and exit. - Console.WriteLine("You must specify the name of a host computer."); - return; - } - // Start the asynchronous request for DNS information. - // This example does not use a delegate or user-supplied object - // so the last two arguments are null. - IAsyncResult result = Dns.BeginGetHostEntry(args[0], null, null); - Console.WriteLine("Processing your request for information..."); - // Do any additional work that can be done here. - try - { - // EndGetHostByName blocks until the process completes. - IPHostEntry host = Dns.EndGetHostEntry(result); - string[] aliases = host.Aliases; - IPAddress[] addresses = host.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases"); - for (int i = 0; i < aliases.Length; i++) - { - Console.WriteLine("{0}", aliases[i]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses"); - for (int i = 0; i < addresses.Length; i++) - { - Console.WriteLine("{0}",addresses[i].ToString()); - } - } - } - catch (SocketException e) - { - Console.WriteLine("An exception occurred while processing the request: {0}", e.Message); - } - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs b/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs deleted file mode 100644 index 65aae9f1582..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Async_EndBlockWait.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. - -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class WaitUntilOperationCompletes - { - public static void Main(string[] args) - { - // Make sure the caller supplied a host name. - if (args.Length == 0 || args[0].Length == 0) - { - // Print a message and exit. - Console.WriteLine("You must specify the name of a host computer."); - return; - } - // Start the asynchronous request for DNS information. - IAsyncResult result = Dns.BeginGetHostEntry(args[0], null, null); - Console.WriteLine("Processing request for information..."); - // Wait until the operation completes. - result.AsyncWaitHandle.WaitOne(); - // The operation completed. Process the results. - try - { - // Get the results. - IPHostEntry host = Dns.EndGetHostEntry(result); - string[] aliases = host.Aliases; - IPAddress[] addresses = host.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases"); - for (int i = 0; i < aliases.Length; i++) - { - Console.WriteLine("{0}", aliases[i]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses"); - for (int i = 0; i < addresses.Length; i++) - { - Console.WriteLine("{0}",addresses[i].ToString()); - } - } - } - catch (SocketException e) - { - Console.WriteLine("Exception occurred while processing the request: {0}", - e.Message); - } - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs b/snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs deleted file mode 100644 index 57b1a056665..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Async_Poll.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -/* -The following example demonstrates using asynchronous methods to -get Domain Name System information for the specified host computer. -This example polls to detect the end of the asynchronous operation. -*/ - -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class PollUntilOperationCompletes - { - static void UpdateUserInterface() - { - // Print a period to indicate that the application - // is still working on the request. - Console.Write("."); - } - public static void Main(string[] args) - { - // Make sure the caller supplied a host name. - if (args.Length == 0 || args[0].Length == 0) - { - // Print a message and exit. - Console.WriteLine("You must specify the name of a host computer."); - return; - } - // Start the asychronous request for DNS information. - IAsyncResult result = Dns.BeginGetHostEntry(args[0], null, null); - Console.WriteLine("Processing request for information..."); - - // Poll for completion information. - // Print periods (".") until the operation completes. - while (!result.IsCompleted) - { - UpdateUserInterface(); - } - // The operation is complete. Process the results. - // Print a new line. - Console.WriteLine(); - try - { - IPHostEntry host = Dns.EndGetHostEntry(result); - string[] aliases = host.Aliases; - IPAddress[] addresses = host.AddressList; - if (aliases.Length > 0) - { - Console.WriteLine("Aliases"); - for (int i = 0; i < aliases.Length; i++) - { - Console.WriteLine("{0}", aliases[i]); - } - } - if (addresses.Length > 0) - { - Console.WriteLine("Addresses"); - for (int i = 0; i < addresses.Length; i++) - { - Console.WriteLine("{0}",addresses[i].ToString()); - } - } - } - catch (SocketException e) - { - Console.WriteLine("An exception occurred while processing the request: {0}", e.Message); - } - } - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs b/snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs deleted file mode 100644 index 5bdc7826176..00000000000 --- a/snippets/csharp/System/AsyncCallback/Overview/Factorizer.cs +++ /dev/null @@ -1,140 +0,0 @@ -// -using System; -using System.Threading; -using System.Runtime.Remoting.Messaging; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - // Create a class that factors a number. - public class PrimeFactorFinder - { - public static bool Factorize( - int number, - ref int primefactor1, - ref int primefactor2) - { - primefactor1 = 1; - primefactor2 = number; - - // Factorize using a low-tech approach. - for (int i=2;i diff --git a/snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs b/snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs deleted file mode 100644 index d6d28fe797e..00000000000 --- a/snippets/csharp/System/Attribute/GetCustomAttributes/ca3.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -namespace CustAttrs3CS { - // Set a GUID and ProgId attribute for this class. - [Guid("BF235B41-52D1-46CC-9C55-046793DB363F")] - [ProgId("CustAttrs3CS.ClassWithGuidAndProgId")] - public class ClassWithGuidAndProgId { - } - - class DemoClass { - static void Main(string[] args) { - // Get the Class type to access its metadata. - Type clsType = typeof(ClassWithGuidAndProgId); - - // Iterate through all the attributes for the class. - foreach(Attribute attr in Attribute.GetCustomAttributes(clsType)) { - // Check for the Guid attribute. - if (attr.GetType() == typeof(GuidAttribute)) { - // Display the GUID. - Console.WriteLine("Class {0} has a GUID.", clsType.Name); - Console.WriteLine("GUID: {" + - ((GuidAttribute)attr).Value + "}."); - } - - // Check for the ProgId attribute. - else if (attr.GetType() == typeof(ProgIdAttribute)) { - // Display the ProgId. - Console.WriteLine("Class {0} has a ProgId.", clsType.Name); - Console.WriteLine("ProgId: \"{0}\".", - ((ProgIdAttribute)attr).Value); - } - } - } - } -} - -/* - * Output: - * Class ClassWithGuidAndProgId has a GUID. - * GUID: {BF235B41-52D1-46CC-9C55-046793DB363F}. - * Class ClassWithGuidAndProgId has a ProgId. - * ProgId: "CustAttrs3CS.ClassWithGuidAndProgId". - */ -// diff --git a/snippets/csharp/System/Boolean/Overview/binary1.cs b/snippets/csharp/System/Boolean/Overview/binary1.cs deleted file mode 100644 index 6ce7165dcbd..00000000000 --- a/snippets/csharp/System/Boolean/Overview/binary1.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool[] flags = { true, false }; - foreach (var flag in flags) { - // Get binary representation of flag. - Byte value = BitConverter.GetBytes(flag)[0]; - Console.WriteLine("Original value: {0}", flag); - Console.WriteLine("Binary value: {0} ({1})", value, - GetBinaryString(value)); - // Restore the flag from its binary representation. - bool newFlag = BitConverter.ToBoolean( new Byte[] { value }, 0); - Console.WriteLine("Restored value: {0}\n", flag); - } - } - - private static string GetBinaryString(Byte value) - { - string retVal = Convert.ToString(value, 2); - return new string('0', 8 - retVal.Length) + retVal; - } -} -// The example displays the following output: -// Original value: True -// Binary value: 1 (00000001) -// Restored value: True -// -// Original value: False -// Binary value: 0 (00000000) -// Restored value: False -// diff --git a/snippets/csharp/System/Boolean/Overview/conversion1.cs b/snippets/csharp/System/Boolean/Overview/conversion1.cs deleted file mode 100644 index 6c8e607f66a..00000000000 --- a/snippets/csharp/System/Boolean/Overview/conversion1.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Byte byteValue = 12; - Console.WriteLine(Convert.ToBoolean(byteValue)); - Byte byteValue2 = 0; - Console.WriteLine(Convert.ToBoolean(byteValue2)); - int intValue = -16345; - Console.WriteLine(Convert.ToBoolean(intValue)); - long longValue = 945; - Console.WriteLine(Convert.ToBoolean(longValue)); - SByte sbyteValue = -12; - Console.WriteLine(Convert.ToBoolean(sbyteValue)); - double dblValue = 0; - Console.WriteLine(Convert.ToBoolean(dblValue)); - float sngValue = .0001f; - Console.WriteLine(Convert.ToBoolean(sngValue)); - } -} -// The example displays the following output: -// True -// False -// True -// True -// True -// False -// True -// diff --git a/snippets/csharp/System/Boolean/Overview/conversion3.cs b/snippets/csharp/System/Boolean/Overview/conversion3.cs deleted file mode 100644 index 7b6af6d34e4..00000000000 --- a/snippets/csharp/System/Boolean/Overview/conversion3.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool flag = true; - - byte byteValue; - byteValue = Convert.ToByte(flag); - Console.WriteLine("{0} -> {1}", flag, byteValue); - - sbyte sbyteValue; - sbyteValue = Convert.ToSByte(flag); - Console.WriteLine("{0} -> {1}", flag, sbyteValue); - - double dblValue; - dblValue = Convert.ToDouble(flag); - Console.WriteLine("{0} -> {1}", flag, dblValue); - - int intValue; - intValue = Convert.ToInt32(flag); - Console.WriteLine("{0} -> {1}", flag, intValue); - } -} -// The example displays the following output: -// True -> 1 -// True -> 1 -// True -> 1 -// True -> 1 -// diff --git a/snippets/csharp/System/Boolean/Overview/format3.cs b/snippets/csharp/System/Boolean/Overview/format3.cs deleted file mode 100644 index 7df289388b1..00000000000 --- a/snippets/csharp/System/Boolean/Overview/format3.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - String[] cultureNames = { "", "en-US", "fr-FR", "ru-RU" }; - foreach (var cultureName in cultureNames) { - bool value = true; - CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName); - BooleanFormatter formatter = new BooleanFormatter(culture); - - string result = string.Format(formatter, "Value for '{0}': {1}", culture.Name, value); - Console.WriteLine(result); - } - } -} - -public class BooleanFormatter : ICustomFormatter, IFormatProvider -{ - private CultureInfo culture; - - public BooleanFormatter() : this(CultureInfo.CurrentCulture) - { } - - public BooleanFormatter(CultureInfo culture) - { - this.culture = culture; - } - - public Object GetFormat(Type formatType) - { - if (formatType == typeof(ICustomFormatter)) - return this; - else - return null; - } - - public string Format(string fmt, Object arg, IFormatProvider formatProvider) - { - // Exit if another format provider is used. - if (!formatProvider.Equals(this)) return null; - - // Exit if the type to be formatted is not a Boolean - if (!(arg is Boolean)) return null; - - bool value = (bool) arg; - switch (culture.Name) { - case "en-US": - return value.ToString(); - case "fr-FR": - if (value) - return "vrai"; - else - return "faux"; - case "ru-RU": - if (value) - return "верно"; - else - return "неверно"; - default: - return value.ToString(); - } - } -} -// The example displays the following output: -// Value for '': True -// Value for 'en-US': True -// Value for 'fr-FR': vrai -// Value for 'ru-RU': верно -// diff --git a/snippets/csharp/System/Boolean/Overview/operations1.cs b/snippets/csharp/System/Boolean/Overview/operations1.cs deleted file mode 100644 index 8948f200e66..00000000000 --- a/snippets/csharp/System/Boolean/Overview/operations1.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -using System; -using System.IO; -using System.Threading; - -public class Example -{ - public static void Main() - { - // Initialize flag variables. - bool isRedirected = false; - bool isBoth = false; - String fileName = ""; - StreamWriter sw = null; - - // Get any command line arguments. - String[] args = Environment.GetCommandLineArgs(); - // Handle any arguments. - if (args.Length > 1) { - for (int ctr = 1; ctr < args.Length; ctr++) { - String arg = args[ctr]; - if (arg.StartsWith("/") || arg.StartsWith("-")) { - switch (arg.Substring(1).ToLower()) - { - case "f": - isRedirected = true; - if (args.Length < ctr + 2) { - ShowSyntax("The /f switch must be followed by a filename."); - return; - } - fileName = args[ctr + 1]; - ctr++; - break; - case "b": - isBoth = true; - break; - default: - ShowSyntax(String.Format("The {0} switch is not supported", - args[ctr])); - return; - } - } - } - } - - // If isBoth is True, isRedirected must be True. - if (isBoth && ! isRedirected) { - ShowSyntax("The /f switch must be used if /b is used."); - return; - } - - // Handle output. - if (isRedirected) { - sw = new StreamWriter(fileName); - if (!isBoth) - Console.SetOut(sw); - } - String msg = String.Format("Application began at {0}", DateTime.Now); - Console.WriteLine(msg); - if (isBoth) sw.WriteLine(msg); - Thread.Sleep(5000); - msg = String.Format("Application ended normally at {0}", DateTime.Now); - Console.WriteLine(msg); - if (isBoth) sw.WriteLine(msg); - if (isRedirected) sw.Close(); - } - - private static void ShowSyntax(String errMsg) - { - Console.WriteLine(errMsg); - Console.WriteLine("\nSyntax: Example [[/f [/b]]\n"); - } -} -// - -public class Evaluation -{ - public void SomeMethod() - { - bool booleanValue = false; - - // - if (booleanValue ) { - // - } - - // - if (booleanValue) { - // - } - } -} diff --git a/snippets/csharp/System/Boolean/Overview/operations2.cs b/snippets/csharp/System/Boolean/Overview/operations2.cs deleted file mode 100644 index cdc198f24ae..00000000000 --- a/snippets/csharp/System/Boolean/Overview/operations2.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool[] hasServiceCharges = { true, false }; - Decimal subtotal = 120.62m; - Decimal shippingCharge = 2.50m; - Decimal serviceCharge = 5.00m; - - foreach (var hasServiceCharge in hasServiceCharges) { - Decimal total = subtotal + shippingCharge + - (hasServiceCharge ? serviceCharge : 0); - Console.WriteLine("hasServiceCharge = {1}: The total is {0:C2}.", - total, hasServiceCharge); - } - } -} -// The example displays output like the following: -// hasServiceCharge = True: The total is $128.12. -// hasServiceCharge = False: The total is $123.12. -// diff --git a/snippets/csharp/System/Boolean/Overview/parse2.cs b/snippets/csharp/System/Boolean/Overview/parse2.cs deleted file mode 100644 index 6b2242e125b..00000000000 --- a/snippets/csharp/System/Boolean/Overview/parse2.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string[] values = { null, String.Empty, "True", "False", - "true", "false", " true ", - "TrUe", "fAlSe", "fa lse", "0", - "1", "-1", "string" }; - // Parse strings using the Boolean.Parse method. - foreach (var value in values) { - try { - bool flag = Boolean.Parse(value); - Console.WriteLine("'{0}' --> {1}", value, flag); - } - catch (ArgumentException) { - Console.WriteLine("Cannot parse a null string."); - } - catch (FormatException) { - Console.WriteLine("Cannot parse '{0}'.", value); - } - } - Console.WriteLine(); - // Parse strings using the Boolean.TryParse method. - foreach (var value in values) { - bool flag = false; - if (Boolean.TryParse(value, out flag)) - Console.WriteLine("'{0}' --> {1}", value, flag); - else - Console.WriteLine("Unable to parse '{0}'", value); - } - } -} -// The example displays the following output: -// Cannot parse a null string. -// Cannot parse ''. -// 'True' --> True -// 'False' --> False -// 'true' --> True -// 'false' --> False -// ' true ' --> True -// 'TrUe' --> True -// 'fAlSe' --> False -// Cannot parse 'fa lse'. -// Cannot parse '0'. -// Cannot parse '1'. -// Cannot parse '-1'. -// Cannot parse 'string'. -// -// Unable to parse '' -// Unable to parse '' -// 'True' --> True -// 'False' --> False -// 'true' --> True -// 'false' --> False -// ' true ' --> True -// 'TrUe' --> True -// 'fAlSe' --> False -// Cannot parse 'fa lse'. -// Unable to parse '0' -// Unable to parse '1' -// Unable to parse '-1' -// Unable to parse 'string' -// diff --git a/snippets/csharp/System/Boolean/Overview/parse3.cs b/snippets/csharp/System/Boolean/Overview/parse3.cs deleted file mode 100644 index 50b3fbce057..00000000000 --- a/snippets/csharp/System/Boolean/Overview/parse3.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - String[] values = { "09", "12.6", "0", "-13 " }; - foreach (var value in values) { - bool success, result; - int number; - success = Int32.TryParse(value, out number); - if (success) { - // The method throws no exceptions. - result = Convert.ToBoolean(number); - Console.WriteLine("Converted '{0}' to {1}", value, result); - } - else { - Console.WriteLine("Unable to convert '{0}'", value); - } - } - } -} -// The example displays the following output: -// Converted '09' to True -// Unable to convert '12.6' -// Converted '0' to False -// Converted '-13 ' to True -// diff --git a/snippets/csharp/System/Boolean/Overview/size1.cs b/snippets/csharp/System/Boolean/Overview/size1.cs deleted file mode 100644 index 052002b8a1c..00000000000 --- a/snippets/csharp/System/Boolean/Overview/size1.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; - -public struct BoolStruct -{ - public bool flag1; - public bool flag2; - public bool flag3; - public bool flag4; - public bool flag5; -} - -public class Example -{ - public static void Main() - { - unsafe { - BoolStruct b = new BoolStruct(); - bool* addr = (bool*) &b; - Console.WriteLine("Size of BoolStruct: {0}", sizeof(BoolStruct)); - Console.WriteLine("Field offsets:"); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag1 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag2 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag3 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag4 - addr); - Console.WriteLine(" flag1: {0}", (bool*) &b.flag5 - addr); - } - } -} -// The example displays the following output: -// Size of BoolStruct: 5 -// Field offsets: -// flag1: 0 -// flag1: 1 -// flag1: 2 -// flag1: 3 -// flag1: 4 -// \ No newline at end of file diff --git a/snippets/csharp/System/Boolean/Overview/tostring1.cs b/snippets/csharp/System/Boolean/Overview/tostring1.cs deleted file mode 100644 index 0569b2ffa6c..00000000000 --- a/snippets/csharp/System/Boolean/Overview/tostring1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool raining = false; - bool busLate = true; - - Console.WriteLine("It is raining: {0}", raining); - Console.WriteLine("The bus is late: {0}", busLate); - } -} -// The example displays the following output: -// It is raining: False -// The bus is late: True -// diff --git a/snippets/csharp/System/Boolean/Overview/tostring2.cs b/snippets/csharp/System/Boolean/Overview/tostring2.cs deleted file mode 100644 index 31f935003af..00000000000 --- a/snippets/csharp/System/Boolean/Overview/tostring2.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool raining = false; - bool busLate = true; - - Console.WriteLine("It is raining: {0}", - raining ? "Yes" : "No"); - Console.WriteLine("The bus is late: {0}", - busLate ? "Yes" : "No" ); - } -} -// The example displays the following output: -// It is raining: No -// The bus is late: Yes -// diff --git a/snippets/csharp/System/Byte/Overview/bitwise1.cs b/snippets/csharp/System/Byte/Overview/bitwise1.cs deleted file mode 100644 index a866deaa853..00000000000 --- a/snippets/csharp/System/Byte/Overview/bitwise1.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string[] values = { Convert.ToString(12, 16), - Convert.ToString(123, 16), - Convert.ToString(245, 16) }; - - byte mask = 0xFE; - foreach (string value in values) { - Byte byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier); - Console.WriteLine("{0} And {1} = {2}", byteValue, mask, - byteValue & mask); - } - } -} -// The example displays the following output: -// 12 And 254 = 12 -// 123 And 254 = 122 -// 245 And 254 = 244 -// diff --git a/snippets/csharp/System/Byte/Overview/bitwise2.cs b/snippets/csharp/System/Byte/Overview/bitwise2.cs deleted file mode 100644 index 70ba5cbe84f..00000000000 --- a/snippets/csharp/System/Byte/Overview/bitwise2.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Globalization; - -public struct ByteString -{ - public string Value; - public int Sign; -} - -public class Example -{ - public static void Main() - { - ByteString[] values = CreateArray(-15, 123, 245); - - byte mask = 0x14; // Mask all bits but 2 and 4. - - foreach (ByteString strValue in values) { - byte byteValue = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier); - Console.WriteLine("{0} ({1}) And {2} ({3}) = {4} ({5})", - strValue.Sign * byteValue, - Convert.ToString(byteValue, 2), - mask, Convert.ToString(mask, 2), - (strValue.Sign & Math.Sign(mask)) * (byteValue & mask), - Convert.ToString(byteValue & mask, 2)); - } - } - - private static ByteString[] CreateArray(params int[] values) - { - List byteStrings = new List(); - - foreach (object value in values) { - ByteString temp = new ByteString(); - int sign = Math.Sign((int) value); - temp.Sign = sign; - - // Change two's complement to magnitude-only representation. - temp.Value = Convert.ToString(((int) value) * sign, 16); - - byteStrings.Add(temp); - } - return byteStrings.ToArray(); - } -} -// The example displays the following output: -// -15 (1111) And 20 (10100) = 4 (100) -// 123 (1111011) And 20 (10100) = 16 (10000) -// 245 (11110101) And 20 (10100) = 20 (10100) -// diff --git a/snippets/csharp/System/Byte/Overview/byteinstantiation1.cs b/snippets/csharp/System/Byte/Overview/byteinstantiation1.cs deleted file mode 100644 index 688e8e3d084..00000000000 --- a/snippets/csharp/System/Byte/Overview/byteinstantiation1.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - InstantiateByAssignment(); - InstantiateByNarrowingConversion(); - Parse(); - } - - private static void InstantiateByAssignment() - { - // - byte value1 = 64; - byte value2 = 255; - // - Console.WriteLine("{0} {1}", value1, value2); - } - - private static void InstantiateByNarrowingConversion() - { - // - int int1 = 128; - try { - byte value1 = (byte) int1; - Console.WriteLine(value1); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of a byte.", int1); - } - - double dbl2 = 3.997; - try { - byte value2 = (byte) dbl2; - Console.WriteLine(value2); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of a byte.", dbl2); - } - // The example displays the following output: - // 128 - // 3 - // - } - - private static void Parse() - { - // - string string1 = "244"; - try { - byte byte1 = Byte.Parse(string1); - Console.WriteLine(byte1); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a byte.", string1); - } - catch (FormatException) { - Console.WriteLine("'{0}' is out of range of a byte.", string1); - } - - string string2 = "F9"; - try { - byte byte2 = Byte.Parse(string2, - System.Globalization.NumberStyles.HexNumber); - Console.WriteLine(byte2); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a byte.", string2); - } - catch (FormatException) { - Console.WriteLine("'{0}' is out of range of a byte.", string2); - } - // The example displays the following output: - // 244 - // 249 - // - } -} diff --git a/snippets/csharp/System/Byte/Overview/formatting1.cs b/snippets/csharp/System/Byte/Overview/formatting1.cs deleted file mode 100644 index e6514d26275..00000000000 --- a/snippets/csharp/System/Byte/Overview/formatting1.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CallToString(); - Console.WriteLine("-----"); - CallConvert(); - } - - private static void CallToString() - { - // - byte[] numbers = { 0, 16, 104, 213 }; - foreach (byte number in numbers) { - // Display value using default formatting. - Console.Write("{0,-3} --> ", number.ToString()); - // Display value with 3 digits and leading zeros. - Console.Write(number.ToString("D3") + " "); - // Display value with hexadecimal. - Console.Write(number.ToString("X2") + " "); - // Display value with four hexadecimal digits. - Console.WriteLine(number.ToString("X4")); - } - // The example displays the following output: - // 0 --> 000 00 0000 - // 16 --> 016 10 0010 - // 104 --> 104 68 0068 - // 213 --> 213 D5 00D5 - // - } - - private static void CallConvert() - { - // - byte[] numbers ={ 0, 16, 104, 213 }; - Console.WriteLine("{0} {1,8} {2,5} {3,5}", - "Value", "Binary", "Octal", "Hex"); - foreach (byte number in numbers) { - Console.WriteLine("{0,5} {1,8} {2,5} {3,5}", - number, Convert.ToString(number, 2), - Convert.ToString(number, 8), - Convert.ToString(number, 16)); - } - // The example displays the following output: - // Value Binary Octal Hex - // 0 0 0 0 - // 16 10000 20 10 - // 104 1101000 150 68 - // 213 11010101 325 d5 - // - } -} diff --git a/snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs b/snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs deleted file mode 100644 index 54907ae9df9..00000000000 --- a/snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -using System; -using System.Globalization; - -class Example -{ - public static void Main() - { - // Define a string with a variety of character categories. - String s = "The red car drove down the long, narrow, secluded road."; - // Determine the category of each character. - foreach (var ch in s) - Console.WriteLine("'{0}': {1}", ch, Char.GetUnicodeCategory(ch)); - } -} -// The example displays the following output: -// 'T': UppercaseLetter -// 'h': LowercaseLetter -// 'e': LowercaseLetter -// ' ': SpaceSeparator -// 'r': LowercaseLetter -// 'e': LowercaseLetter -// 'd': LowercaseLetter -// ' ': SpaceSeparator -// 'c': LowercaseLetter -// 'a': LowercaseLetter -// 'r': LowercaseLetter -// ' ': SpaceSeparator -// 'd': LowercaseLetter -// 'r': LowercaseLetter -// 'o': LowercaseLetter -// 'v': LowercaseLetter -// 'e': LowercaseLetter -// ' ': SpaceSeparator -// 'd': LowercaseLetter -// 'o': LowercaseLetter -// 'w': LowercaseLetter -// 'n': LowercaseLetter -// ' ': SpaceSeparator -// 't': LowercaseLetter -// 'h': LowercaseLetter -// 'e': LowercaseLetter -// ' ': SpaceSeparator -// 'l': LowercaseLetter -// 'o': LowercaseLetter -// 'n': LowercaseLetter -// 'g': LowercaseLetter -// ',': OtherPunctuation -// ' ': SpaceSeparator -// 'n': LowercaseLetter -// 'a': LowercaseLetter -// 'r': LowercaseLetter -// 'r': LowercaseLetter -// 'o': LowercaseLetter -// 'w': LowercaseLetter -// ',': OtherPunctuation -// ' ': SpaceSeparator -// 's': LowercaseLetter -// 'e': LowercaseLetter -// 'c': LowercaseLetter -// 'l': LowercaseLetter -// 'u': LowercaseLetter -// 'd': LowercaseLetter -// 'e': LowercaseLetter -// 'd': LowercaseLetter -// ' ': SpaceSeparator -// 'r': LowercaseLetter -// 'o': LowercaseLetter -// 'a': LowercaseLetter -// 'd': LowercaseLetter -// '.': OtherPunctuation -// diff --git a/snippets/csharp/System/Char/Overview/grapheme1.cs b/snippets/csharp/System/Char/Overview/grapheme1.cs deleted file mode 100644 index d61be7b56af..00000000000 --- a/snippets/csharp/System/Char/Overview/grapheme1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter("chars1.txt"); - char[] chars = { '\u0061', '\u0308' }; - string strng = new String(chars); - sw.WriteLine(strng); - sw.Close(); - } -} -// The example produces the following output: -// ä -// diff --git a/snippets/csharp/System/Char/Overview/normalized.cs b/snippets/csharp/System/Char/Overview/normalized.cs deleted file mode 100644 index 8c79a32820e..00000000000 --- a/snippets/csharp/System/Char/Overview/normalized.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string combining = "\u0061\u0308"; - ShowString(combining); - - string normalized = combining.Normalize(); - ShowString(normalized); - } - - private static void ShowString(string s) - { - Console.Write("Length of string: {0} (", s.Length); - for (int ctr = 0; ctr < s.Length; ctr++) { - Console.Write("U+{0:X4}", Convert.ToUInt16(s[ctr])); - if (ctr != s.Length - 1) Console.Write(" "); - } - Console.WriteLine(")\n"); - } -} -// The example displays the following output: -// Length of string: 2 (U+0061 U+0308) -// -// Length of string: 1 (U+00E4) -// diff --git a/snippets/csharp/System/Char/Overview/surrogate1.cs b/snippets/csharp/System/Char/Overview/surrogate1.cs deleted file mode 100644 index a412f04384b..00000000000 --- a/snippets/csharp/System/Char/Overview/surrogate1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\chars2.txt"); - int utf32 = 0x1D160; - string surrogate = Char.ConvertFromUtf32(utf32); - sw.WriteLine("U+{0:X6} UTF-32 = {1} ({2}) UTF-16", - utf32, surrogate, ShowCodePoints(surrogate)); - sw.Close(); - } - - private static string ShowCodePoints(string value) - { - string retval = null; - foreach (var ch in value) - retval += String.Format("U+{0:X4} ", Convert.ToUInt16(ch)); - - return retval.Trim(); - } -} -// The example produces the following output: -// U+01D160 UTF-32 = ð (U+D834 U+DD60) UTF-16 -// diff --git a/snippets/csharp/System/Char/Overview/textelements2.cs b/snippets/csharp/System/Char/Overview/textelements2.cs deleted file mode 100644 index 562d83b3a26..00000000000 --- a/snippets/csharp/System/Char/Overview/textelements2.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string result = String.Empty; - for (int ctr = 0x10107; ctr <= 0x10110; ctr++) // Range of Aegean numbers. - result += Char.ConvertFromUtf32(ctr); - - Console.WriteLine("The string contains {0} characters.", result.Length); - } -} -// The example displays the following output: -// The string contains 20 characters. -// diff --git a/snippets/csharp/System/Char/Overview/textelements2a.cs b/snippets/csharp/System/Char/Overview/textelements2a.cs deleted file mode 100644 index 32239ae9920..00000000000 --- a/snippets/csharp/System/Char/Overview/textelements2a.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string result = String.Empty; - for (int ctr = 0x10107; ctr <= 0x10110; ctr++) // Range of Aegean numbers. - result += Char.ConvertFromUtf32(ctr); - - StringInfo si = new StringInfo(result); - Console.WriteLine("The string contains {0} characters.", - si.LengthInTextElements); - } -} -// The example displays the following output: -// The string contains 10 characters. -// diff --git a/snippets/csharp/System/Console/ReadLine/readline1.cs b/snippets/csharp/System/Console/ReadLine/readline1.cs deleted file mode 100644 index 66248342384..00000000000 --- a/snippets/csharp/System/Console/ReadLine/readline1.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - if (!Console.IsInputRedirected) { - Console.WriteLine("This example requires that input be redirected from a file."); - return; - } - - Console.WriteLine("About to call Console.ReadLine in a loop."); - Console.WriteLine("----"); - String s; - int ctr = 0; - do { - ctr++; - s = Console.ReadLine(); - Console.WriteLine("Line {0}: {1}", ctr, s); - } while (s != null); - Console.WriteLine("---"); - } -} -// The example displays the following output: -// About to call Console.ReadLine in a loop. -// ---- -// Line 1: This is the first line. -// Line 2: This is the second line. -// Line 3: This is the third line. -// Line 4: This is the fourth line. -// Line 5: -// --- -// \ No newline at end of file diff --git a/snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs b/snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs deleted file mode 100644 index f12196bc715..00000000000 --- a/snippets/csharp/System/Convert/ChangeType/changetype_enum3.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; - -public enum Continent -{ - Africa, Antarctica, Asia, Australia, Europe, - NorthAmerica, SouthAmerica -}; - -public class Example -{ - public static void Main() - { - // Convert a Continent to a Double. - Continent cont = Continent.NorthAmerica; - Console.WriteLine("{0:N2}", - Convert.ChangeType(cont, typeof(Double), null)); - - // Convert a Double to a Continent. - Double number = 6.0; - try { - Console.WriteLine("{0}", - Convert.ChangeType(number, typeof(Continent), null)); - } - catch (InvalidCastException) { - Console.WriteLine("Cannot convert a Double to a Continent"); - } - - Console.WriteLine("{0}", (Continent) number); - } -} -// The example displays the following output: -// 5.00 -// Cannot convert a Double to a Continent -// SouthAmerica -// diff --git a/snippets/csharp/System/Convert/ToDouble/todecimal.cs b/snippets/csharp/System/Convert/ToDouble/todecimal.cs deleted file mode 100644 index 2b316be160f..00000000000 --- a/snippets/csharp/System/Convert/ToDouble/todecimal.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -// Example of the Convert.ToDecimal( String ) and -// Convert.ToDecimal( String, IFormatProvider ) methods. -using System; -using System.Globalization; - -class ToDecimalProviderDemo -{ - static string formatter = "{0,-22}{1,-20}{2}"; - - // Get the exception type name; remove the namespace prefix. - static string GetExceptionType( Exception ex ) - { - string exceptionType = ex.GetType( ).ToString( ); - return exceptionType.Substring( - exceptionType.LastIndexOf( '.' ) + 1 ); - } - - static void ConvertToDecimal( string numericStr, - IFormatProvider provider ) - { - object defaultValue; - object providerValue; - - // Convert numericStr to decimal without a format provider. - try - { - defaultValue = Convert.ToDecimal( numericStr ); - } - catch( Exception ex ) - { - defaultValue = GetExceptionType( ex ); - } - - // Convert numericStr to decimal with a format provider. - try - { - providerValue = Convert.ToDecimal( numericStr, provider ); - } - catch( Exception ex ) - { - providerValue = GetExceptionType( ex ); - } - - Console.WriteLine( formatter, numericStr, defaultValue, - providerValue ); - } - - static void Main( ) - { - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo provider = new NumberFormatInfo( ); - - provider.NumberDecimalSeparator = ","; - provider.NumberGroupSeparator = "."; - provider.NumberGroupSizes = new int[ ] { 3 }; - - Console.WriteLine( - "This example of\n Convert.ToDecimal( String ) and \n" + - " Convert.ToDecimal( String, IFormatProvider ) \n" + - "generates the following output when run in the " + - "[{0}] culture.", - CultureInfo.CurrentCulture.Name ); - Console.WriteLine( "\nSeveral " + - "strings are converted to decimal values, using \n" + - "default formatting and a NumberFormatInfo object.\n"); - Console.WriteLine( formatter, "String to convert", - "Default/exception", "Provider/exception" ); - Console.WriteLine( formatter, "-----------------", - "-----------------", "------------------" ); - - // Convert strings, with and without an IFormatProvider. - ConvertToDecimal( "123456789", provider ); - ConvertToDecimal( "12345.6789", provider ); - ConvertToDecimal( "12345,6789", provider ); - ConvertToDecimal( "123,456.789", provider ); - ConvertToDecimal( "123.456,789", provider ); - ConvertToDecimal( "123,456,789.0123", provider ); - ConvertToDecimal( "123.456.789,0123", provider ); - } -} - -/* -This example of - Convert.ToDecimal( String ) and - Convert.ToDecimal( String, IFormatProvider ) -generates the following output when run in the [en-US] culture. - -Several strings are converted to decimal values, using -default formatting and a NumberFormatInfo object. - -String to convert Default/exception Provider/exception ------------------ ----------------- ------------------ -123456789 123456789 123456789 -12345.6789 12345.6789 123456789 -12345,6789 123456789 12345.6789 -123,456.789 123456.789 FormatException -123.456,789 FormatException 123456.789 -123,456,789.0123 123456789.0123 FormatException -123.456.789,0123 FormatException 123456789.0123 -*/ -// diff --git a/snippets/csharp/System/Convert/ToDouble/todouble2.cs b/snippets/csharp/System/Convert/ToDouble/todouble2.cs deleted file mode 100644 index b92d88a32ee..00000000000 --- a/snippets/csharp/System/Convert/ToDouble/todouble2.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - string[] values = { "1,5304e16", "1.5304e16", "1,034.1233", - "1,03221", "1630.34034" }; - System.Globalization.CultureInfo[] cultures = - { new System.Globalization.CultureInfo("en-US"), - new System.Globalization.CultureInfo("fr-FR"), - new System.Globalization.CultureInfo("es-ES") }; - - foreach (System.Globalization.CultureInfo culture in cultures) - { - Console.WriteLine("Conversions using {0} culture:", culture.Name); - foreach (string value in values) - { - Console.Write(" {0,-15} --> ", value); - try { - Console.WriteLine("{0}", Convert.ToDouble(value, culture)); - } - catch (FormatException) { - Console.WriteLine("Bad Format"); - } - catch (OverflowException) { - Console.WriteLine("Overflow"); - } - } - Console.WriteLine(); - } - // The example displays the following output: - // Conversions using en-US culture: - // 1,5304e16 --> 1.5304E+20 - // 1.5304e16 --> 1.5304E+16 - // 1,034.1233 --> 1034.1233 - // 1,03221 --> 103221 - // 1630.34034 --> 1630.34034 - // - // Conversions using fr-FR culture: - // 1,5304e16 --> 1.5304E+16 - // 1.5304e16 --> Bad Format - // 1,034.1233 --> Bad Format - // 1,03221 --> 1.03221 - // 1630.34034 --> Bad Format - // - // Conversions using es-ES culture: - // 1,5304e16 --> 1.5304E+16 - // 1.5304e16 --> 1.5304E+20 - // 1,034.1233 --> Bad Format - // 1,03221 --> 1.03221 - // 1630.34034 --> 163034034 - // - } -} diff --git a/snippets/csharp/System/Convert/ToDouble/tosingle.cs b/snippets/csharp/System/Convert/ToDouble/tosingle.cs deleted file mode 100644 index 16faefca6cb..00000000000 --- a/snippets/csharp/System/Convert/ToDouble/tosingle.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -// Example of the Convert.ToSingle( String ) and -// Convert.ToSingle( String, IFormatProvider ) methods. -using System; -using System.Globalization; - -class ToSingleProviderDemo -{ - static string formatter = "{0,-22}{1,-20}{2}"; - - // Get the exception type name; remove the namespace prefix. - static string GetExceptionType( Exception ex ) - { - string exceptionType = ex.GetType( ).ToString( ); - return exceptionType.Substring( - exceptionType.LastIndexOf( '.' ) + 1 ); - } - - static void ConvertToSingle( string numericStr, - IFormatProvider provider ) - { - object defaultValue; - object providerValue; - - // Convert numericStr to float without a format provider. - try - { - defaultValue = Convert.ToSingle( numericStr ); - } - catch( Exception ex ) - { - defaultValue = GetExceptionType( ex ); - } - - // Convert numericStr to float with a format provider. - try - { - providerValue = Convert.ToSingle( numericStr, provider ); - } - catch( Exception ex ) - { - providerValue = GetExceptionType( ex ); - } - - Console.WriteLine( formatter, numericStr, defaultValue, - providerValue ); - } - - static void Main( ) - { - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo provider = new NumberFormatInfo( ); - - provider.NumberDecimalSeparator = ","; - provider.NumberGroupSeparator = "."; - provider.NumberGroupSizes = new int[ ] { 3 }; - - Console.WriteLine( - "This example of\n Convert.ToSingle( String ) and \n" + - " Convert.ToSingle( String, IFormatProvider ) \n" + - "generates the following output when run in the " + - "[{0}] culture.", - CultureInfo.CurrentCulture.Name ); - Console.WriteLine( "\nSeveral " + - "strings are converted to float values, using \n" + - "default formatting and a NumberFormatInfo object.\n"); - Console.WriteLine( formatter, "String to convert", - "Default/exception", "Provider/exception" ); - Console.WriteLine( formatter, "-----------------", - "-----------------", "------------------" ); - - // Convert strings, with and without an IFormatProvider. - ConvertToSingle( "1234567", provider ); - ConvertToSingle( "1234.567", provider ); - ConvertToSingle( "1234,567", provider ); - ConvertToSingle( "12,345.67", provider ); - ConvertToSingle( "12.345,67", provider ); - ConvertToSingle( "1,234,567.89", provider ); - ConvertToSingle( "1.234.567,89", provider ); - } -} - -/* -This example of - Convert.ToSingle( String ) and - Convert.ToSingle( String, IFormatProvider ) -generates the following output when run in the [en-US] culture. - -Several strings are converted to float values, using -default formatting and a NumberFormatInfo object. - -String to convert Default/exception Provider/exception ------------------ ----------------- ------------------ -1234567 1234567 1234567 -1234.567 1234.567 1234567 -1234,567 1234567 1234.567 -12,345.67 12345.67 FormatException -12.345,67 FormatException 12345.67 -1,234,567.89 1234568 FormatException -1.234.567,89 FormatException 1234568 -*/ -// diff --git a/snippets/csharp/System/Convert/ToString/datetime.cs b/snippets/csharp/System/Convert/ToString/datetime.cs deleted file mode 100644 index a7f75926f3c..00000000000 --- a/snippets/csharp/System/Convert/ToString/datetime.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -// Example of the Convert.ToString( DateTime ) and -// Convert.ToString( DateTime, IFormatProvider ) methods. -using System; -using System.Globalization; - -class DateTimeIFormatProviderDemo -{ - static void DisplayDateNCultureName( DateTime testDate, - string cultureName ) - { - // Create the CultureInfo object for the specified culture, - // and use it as the IFormatProvider when converting the date. - CultureInfo culture = new CultureInfo( cultureName ); - string dateString = Convert.ToString( testDate, culture ); - - // Bracket the culture name, and display the name and date. - Console.WriteLine(" {0,-12}{1}", - String.Concat( "[", cultureName, "]" ), dateString ); - } - - static void Main( ) - { - // Specify the date to be formatted under various cultures. - DateTime tDate = new DateTime( 2003, 4, 15, 20, 30, 40, 333 ); - - Console.WriteLine( "This example of \n" + - " Convert.ToString( DateTime ) and \n" + - " Convert.ToString( DateTime, IFormatProvider )\n" + - "generates the following output. It creates " + - "CultureInfo objects \nfor several cultures " + - "and formats a DateTime value with each.\n" ); - - // Format the date without an IFormatProvider. - Console.WriteLine( " {0,-12}{1}", - null, "No IFormatProvider" ); - Console.WriteLine( " {0,-12}{1}", - null, "------------------" ); - Console.WriteLine( " {0,-12}{1}\n", - String.Concat( "[", CultureInfo.CurrentCulture.Name, "]" ), - Convert.ToString( tDate ) ); - - // Format the date with IFormatProvider for several cultures. - Console.WriteLine( " {0,-12}{1}", - "Culture", "With IFormatProvider" ); - Console.WriteLine( " {0,-12}{1}", - "-------", "--------------------" ); - - DisplayDateNCultureName( tDate, "" ); - DisplayDateNCultureName( tDate, "en-US" ); - DisplayDateNCultureName( tDate, "es-AR" ); - DisplayDateNCultureName( tDate, "fr-FR" ); - DisplayDateNCultureName( tDate, "hi-IN" ); - DisplayDateNCultureName( tDate, "ja-JP" ); - DisplayDateNCultureName( tDate, "nl-NL" ); - DisplayDateNCultureName( tDate, "ru-RU" ); - DisplayDateNCultureName( tDate, "ur-PK" ); - } -} - -/* -This example of - Convert.ToString( DateTime ) and - Convert.ToString( DateTime, IFormatProvider ) -generates the following output. It creates CultureInfo objects -for several cultures and formats a DateTime value with each. - - No IFormatProvider - ------------------ - [en-US] 4/15/2003 8:30:40 PM - - Culture With IFormatProvider - ------- -------------------- - [] 04/15/2003 20:30:40 - [en-US] 4/15/2003 8:30:40 PM - [es-AR] 15/04/2003 08:30:40 p.m. - [fr-FR] 15/04/2003 20:30:40 - [hi-IN] 15-04-2003 20:30:40 - [ja-JP] 2003/04/15 20:30:40 - [nl-NL] 15-4-2003 20:30:40 - [ru-RU] 15.04.2003 20:30:40 - [ur-PK] 15/04/2003 8:30:40 PM -*/ -// diff --git a/snippets/csharp/System/Convert/ToString/numeric.cs b/snippets/csharp/System/Convert/ToString/numeric.cs deleted file mode 100644 index 7351a1d97a6..00000000000 --- a/snippets/csharp/System/Convert/ToString/numeric.cs +++ /dev/null @@ -1,109 +0,0 @@ -// -// Example of the Convert.ToString( numeric types ) and -// Convert.ToString( numeric types, IFormatProvider ) methods. -using System; -using System.Globalization; - -class ConvertNumericProviderDemo -{ - static void Main( ) - { - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo provider = new NumberFormatInfo( ); - string formatter = "{0,22} {1}"; - - // These properties will affect the conversion. - provider.NegativeSign = "minus "; - provider.NumberDecimalSeparator = " point "; - - // These properties will not be applied. - provider.NumberDecimalDigits = 2; - provider.NumberGroupSeparator = "."; - provider.NumberGroupSizes = new int[ ] { 3 }; - - // Convert these values using default values and the - // format provider created above. - byte ByteA = 140; - SByte SByteA = -60; - UInt16 UInt16A = 61680; - short Int16A = -3855; - - UInt32 UInt32A = 4042322160; - int Int32A = -252645135; - UInt64 UInt64A = 8138269444283625712; - long Int64A = -1085102592571150095; - - float SingleA = -32.375F; - double DoubleA = 61680.3855; - decimal DecimA = 4042322160.252645135M; - object ObjDouble = (object)( -98765.4321 ); - - Console.WriteLine( "This example of " + - "Convert.ToString( numeric types ) and \n" + - "Convert.ToString( numeric types, IFormatProvider ) \n" + - "converts values of each of the CLR base numeric types " + - "to strings, \nusing default formatting and a " + - "NumberFormatInfo object." ); - Console.WriteLine( - "\nNote: Of the several NumberFormatInfo " + - "properties that are changed, \nonly the negative sign " + - "and decimal separator affect the conversions.\n" ); - Console.WriteLine( formatter, "Default", "Format Provider" ); - Console.WriteLine( formatter, "-------", "---------------" ); - - // Convert the values with and without a format provider. - Console.WriteLine( formatter, Convert.ToString( ByteA ), - Convert.ToString( ByteA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( SByteA ), - Convert.ToString( SByteA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( UInt16A ), - Convert.ToString( UInt16A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( Int16A ), - Convert.ToString( Int16A, provider ) ); - - Console.WriteLine( formatter, Convert.ToString( UInt32A ), - Convert.ToString( UInt32A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( Int32A ), - Convert.ToString( Int32A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( UInt64A ), - Convert.ToString( UInt64A, provider ) ); - Console.WriteLine( formatter, Convert.ToString( Int64A ), - Convert.ToString( Int64A, provider ) ); - - Console.WriteLine( formatter, Convert.ToString( SingleA ), - Convert.ToString( SingleA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( DoubleA ), - Convert.ToString( DoubleA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( DecimA ), - Convert.ToString( DecimA, provider ) ); - Console.WriteLine( formatter, Convert.ToString( ObjDouble ), - Convert.ToString( ObjDouble, provider ) ); - } -} - -/* -This example of Convert.ToString( numeric types ) and -Convert.ToString( numeric types, IFormatProvider ) -converts values of each of the CLR base numeric types to strings, -using default formatting and a NumberFormatInfo object. - -Note: Of the several NumberFormatInfo properties that are changed, -only the negative sign and decimal separator affect the conversions. - - Default Format Provider - ------- --------------- - 140 140 - -60 minus 60 - 61680 61680 - -3855 minus 3855 - 4042322160 4042322160 - -252645135 minus 252645135 - 8138269444283625712 8138269444283625712 - -1085102592571150095 minus 1085102592571150095 - -32.375 minus 32 point 375 - 61680.3855 61680 point 3855 - 4042322160.252645135 4042322160 point 252645135 - -98765.4321 minus 98765 point 4321 -*/ -// diff --git a/snippets/csharp/System/Convert/ToString/tostring4.cs b/snippets/csharp/System/Convert/ToString/tostring4.cs deleted file mode 100644 index 6a61d475f49..00000000000 --- a/snippets/csharp/System/Convert/ToString/tostring4.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -using System; -using System.Globalization; - -public class DummyProvider : IFormatProvider -{ - // Normally, GetFormat returns an object of the requested type - // (usually itself) if it is able; otherwise, it returns Nothing. - public object GetFormat(Type argType) - { - // Display the type of argType and return null. - Console.Write( "{0,-25}", argType.Name); - return null; - } -} - -public class Example -{ - public static void Main() - { - // Create an instance of the IFormatProvider. - IFormatProvider provider = new DummyProvider(); - - // Values to convert using DummyProvider. - int int32A = -252645135; - double doubleA = 61680.3855; - object objDouble = (object) -98765.4321; - DateTime dayTimeA = new DateTime(2009, 9, 11, 13, 45, 0); - bool boolA = true; - string stringA = "Qwerty"; - char charA = '$'; - TimeSpan tSpanA = new TimeSpan(0, 18, 0); - object objOther = provider; - - object[] objects= { int32A, doubleA, objDouble, dayTimeA, - boolA, stringA, charA, tSpanA, objOther }; - - // Call Convert.ToString(Object, provider) method for each value. - foreach (object value in objects) - Console.WriteLine("{0,-20} --> {1,20}", - value, Convert.ToString(value, provider)); - } -} -// The example displays the following output: -// NumberFormatInfo -252645135 --> -252645135 -// NumberFormatInfo 61680.3855 --> 61680.3855 -// NumberFormatInfo -98765.4321 --> -98765.4321 -// DateTimeFormatInfo 9/11/2009 1:45:00 PM --> 9/11/2009 1:45:00 PM -// True --> True -// Qwerty --> Qwerty -// $ --> $ -// 00:18:00 --> 00:18:00 -// DummyProvider --> DummyProvider -// diff --git a/snippets/csharp/System/Double/Overview/comparison1.cs b/snippets/csharp/System/Double/Overview/comparison1.cs deleted file mode 100644 index 446393419b1..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison1.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double value1 = .333333333333333; - double value2 = 1.0/3; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.333333333333333 = 0.33333333333333331: False -// diff --git a/snippets/csharp/System/Double/Overview/comparison2.cs b/snippets/csharp/System/Double/Overview/comparison2.cs deleted file mode 100644 index d3dcf9f1f4a..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double value1 = 100.10142; - value1 = Math.Sqrt(Math.Pow(value1, 2)); - double value2 = Math.Pow(value1 * 3.51, 2); - value2 = Math.Sqrt(value2) / 3.51; - Console.WriteLine("{0} = {1}: {2}\n", - value1, value2, value1.Equals(value2)); - Console.WriteLine("{0:R} = {1:R}", value1, value2); - } -} -// The example displays the following output: -// 100.10142 = 100.10142: False -// -// 100.10142 = 100.10141999999999 -// diff --git a/snippets/csharp/System/Double/Overview/comparison3.cs b/snippets/csharp/System/Double/Overview/comparison3.cs deleted file mode 100644 index 261254d1b09..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison3.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double value1 = .333333333333333; - double value2 = 1.0/3; - int precision = 7; - value1 = Math.Round(value1, precision); - value2 = Math.Round(value2, precision); - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.3333333 = 0.3333333: True -// diff --git a/snippets/csharp/System/Double/Overview/comparison4.cs b/snippets/csharp/System/Double/Overview/comparison4.cs deleted file mode 100644 index 29acc9f0921..00000000000 --- a/snippets/csharp/System/Double/Overview/comparison4.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - double one1 = .1 * 10; - double one2 = 0; - for (int ctr = 1; ctr <= 10; ctr++) - one2 += .1; - - Console.WriteLine("{0:R} = {1:R}: {2}", one1, one2, one1.Equals(one2)); - Console.WriteLine("{0:R} is approximately equal to {1:R}: {2}", - one1, one2, - IsApproximatelyEqual(one1, one2, .000000001)); - } - - static bool IsApproximatelyEqual(double value1, double value2, double epsilon) - { - // If they are equal anyway, just return True. - if (value1.Equals(value2)) - return true; - - // Handle NaN, Infinity. - if (Double.IsInfinity(value1) | Double.IsNaN(value1)) - return value1.Equals(value2); - else if (Double.IsInfinity(value2) | Double.IsNaN(value2)) - return value1.Equals(value2); - - // Handle zero to avoid division by zero - double divisor = Math.Max(value1, value2); - if (divisor.Equals(0)) - divisor = Math.Min(value1, value2); - - return Math.Abs((value1 - value2) / divisor) <= epsilon; - } -} -// The example displays the following output: -// 1 = 0.99999999999999989: False -// 1 is approximately equal to 0.99999999999999989: True -// diff --git a/snippets/csharp/System/Double/Overview/convert1.cs b/snippets/csharp/System/Double/Overview/convert1.cs deleted file mode 100644 index 88598de16e6..00000000000 --- a/snippets/csharp/System/Double/Overview/convert1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - dynamic[] values = { Byte.MinValue, Byte.MaxValue, Decimal.MinValue, - Decimal.MaxValue, Int16.MinValue, Int16.MaxValue, - Int32.MinValue, Int32.MaxValue, Int64.MinValue, - Int64.MaxValue, SByte.MinValue, SByte.MaxValue, - Single.MinValue, Single.MaxValue, UInt16.MinValue, - UInt16.MaxValue, UInt32.MinValue, UInt32.MaxValue, - UInt64.MinValue, UInt64.MaxValue }; - double dblValue; - foreach (var value in values) { - if (value.GetType() == typeof(Decimal)) - dblValue = (Double) value; - else - dblValue = value; - Console.WriteLine("{0} ({1}) --> {2:R} ({3})", - value, value.GetType().Name, - dblValue, dblValue.GetType().Name); - } - } -} -// The example displays the following output: -// 0 (Byte) --> 0 (Double) -// 255 (Byte) --> 255 (Double) -// -79228162514264337593543950335 (Decimal) --> -7.9228162514264338E+28 (Double) -// 79228162514264337593543950335 (Decimal) --> 7.9228162514264338E+28 (Double) -// -32768 (Int16) --> -32768 (Double) -// 32767 (Int16) --> 32767 (Double) -// -2147483648 (Int32) --> -2147483648 (Double) -// 2147483647 (Int32) --> 2147483647 (Double) -// -9223372036854775808 (Int64) --> -9.2233720368547758E+18 (Double) -// 9223372036854775807 (Int64) --> 9.2233720368547758E+18 (Double) -// -128 (SByte) --> -128 (Double) -// 127 (SByte) --> 127 (Double) -// -3.402823E+38 (Single) --> -3.4028234663852886E+38 (Double) -// 3.402823E+38 (Single) --> 3.4028234663852886E+38 (Double) -// 0 (UInt16) --> 0 (Double) -// 65535 (UInt16) --> 65535 (Double) -// 0 (UInt32) --> 0 (Double) -// 4294967295 (UInt32) --> 4294967295 (Double) -// 0 (UInt64) --> 0 (Double) -// 18446744073709551615 (UInt64) --> 1.8446744073709552E+19 (Double) -// diff --git a/snippets/csharp/System/Double/Overview/convert2.cs b/snippets/csharp/System/Double/Overview/convert2.cs deleted file mode 100644 index 9de1d2b7a75..00000000000 --- a/snippets/csharp/System/Double/Overview/convert2.cs +++ /dev/null @@ -1,147 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double[] values = { Double.MinValue, -67890.1234, -12345.6789, - 12345.6789, 67890.1234, Double.MaxValue, - Double.NaN, Double.PositiveInfinity, - Double.NegativeInfinity }; - checked { - foreach (var value in values) { - try { - Int64 lValue = (long) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - lValue, lValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Int64.", value); - } - try { - UInt64 ulValue = (ulong) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - ulValue, ulValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to UInt64.", value); - } - try { - Decimal dValue = (decimal) value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - dValue, dValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Decimal.", value); - } - try { - Single sValue = (float) value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - sValue, sValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Single.", value); - } - Console.WriteLine(); - } - } - } -} -// The example displays the following output for conversions performed -// in a checked context: -// Unable to convert -1.79769313486232E+308 to Int64. -// Unable to convert -1.79769313486232E+308 to UInt64. -// Unable to convert -1.79769313486232E+308 to Decimal. -// -1.79769313486232E+308 (Double) --> -Infinity (Single) -// -// -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// Unable to convert -67890.1234 to UInt64. -// -67890.1234 (Double) --> -67890.1234 (Decimal) -// -67890.1234 (Double) --> -67890.13 (Single) -// -// -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// Unable to convert -12345.6789 to UInt64. -// -12345.6789 (Double) --> -12345.6789 (Decimal) -// -12345.6789 (Double) --> -12345.68 (Single) -// -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64) -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64) -// 12345.6789 (Double) --> 12345.6789 (Decimal) -// 12345.6789 (Double) --> 12345.68 (Single) -// -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64) -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64) -// 67890.1234 (Double) --> 67890.1234 (Decimal) -// 67890.1234 (Double) --> 67890.13 (Single) -// -// Unable to convert 1.79769313486232E+308 to Int64. -// Unable to convert 1.79769313486232E+308 to UInt64. -// Unable to convert 1.79769313486232E+308 to Decimal. -// 1.79769313486232E+308 (Double) --> Infinity (Single) -// -// Unable to convert NaN to Int64. -// Unable to convert NaN to UInt64. -// Unable to convert NaN to Decimal. -// NaN (Double) --> NaN (Single) -// -// Unable to convert Infinity to Int64. -// Unable to convert Infinity to UInt64. -// Unable to convert Infinity to Decimal. -// Infinity (Double) --> Infinity (Single) -// -// Unable to convert -Infinity to Int64. -// Unable to convert -Infinity to UInt64. -// Unable to convert -Infinity to Decimal. -// -Infinity (Double) --> -Infinity (Single) -// The example displays the following output for conversions performed -// in an unchecked context: -// -1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -1.79769313486232E+308 (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -1.79769313486232E+308 to Decimal. -// -1.79769313486232E+308 (Double) --> -Infinity (Single) -// -// -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// -67890.1234 (Double) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64) -// -67890.1234 (Double) --> -67890.1234 (Decimal) -// -67890.1234 (Double) --> -67890.13 (Single) -// -// -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// -12345.6789 (Double) --> 18446744073709539271 (0xFFFFFFFFFFFFCFC7) (UInt64) -// -12345.6789 (Double) --> -12345.6789 (Decimal) -// -12345.6789 (Double) --> -12345.68 (Single) -// -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64) -// 12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64) -// 12345.6789 (Double) --> 12345.6789 (Decimal) -// 12345.6789 (Double) --> 12345.68 (Single) -// -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64) -// 67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64) -// 67890.1234 (Double) --> 67890.1234 (Decimal) -// 67890.1234 (Double) --> 67890.13 (Single) -// -// 1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// 1.79769313486232E+308 (Double) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert 1.79769313486232E+308 to Decimal. -// 1.79769313486232E+308 (Double) --> Infinity (Single) -// -// NaN (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// NaN (Double) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert NaN to Decimal. -// NaN (Double) --> NaN (Single) -// -// Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// Infinity (Double) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert Infinity to Decimal. -// Infinity (Double) --> Infinity (Single) -// -// -Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -Infinity (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -Infinity to Decimal. -// -Infinity (Double) --> -Infinity (Single) -// diff --git a/snippets/csharp/System/Double/Overview/exceptional1.cs b/snippets/csharp/System/Double/Overview/exceptional1.cs deleted file mode 100644 index 6ea7b2cc4ab..00000000000 --- a/snippets/csharp/System/Double/Overview/exceptional1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 1.1632875981534209e-225; - Double value2 = 9.1642346778e-175; - Double result = value1 * value2; - Console.WriteLine("{0} * {1} = {2}", value1, value2, result); - Console.WriteLine("{0} = 0: {1}", result, result.Equals(0.0)); - } -} -// The example displays the following output: -// 1.16328759815342E-225 * 9.1642346778E-175 = 0 -// 0 = 0: True -// diff --git a/snippets/csharp/System/Double/Overview/exceptional2.cs b/snippets/csharp/System/Double/Overview/exceptional2.cs deleted file mode 100644 index 42688e53e38..00000000000 --- a/snippets/csharp/System/Double/Overview/exceptional2.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 4.565e153; - Double value2 = 6.9375e172; - Double result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Double.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}\n", - Double.IsNegativeInfinity(result)); - - value1 = -value1; - result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Double.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}", - Double.IsNegativeInfinity(result)); - } -} - -// The example displays the following output: -// PositiveInfinity: True -// NegativeInfinity: False -// -// PositiveInfinity: False -// NegativeInfinity: True -// diff --git a/snippets/csharp/System/Double/Overview/precision1.cs b/snippets/csharp/System/Double/Overview/precision1.cs deleted file mode 100644 index dbad4e74f8b..00000000000 --- a/snippets/csharp/System/Double/Overview/precision1.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - double value = -4.42330604244772E-305; - - double fromLiteral = -4.42330604244772E-305; - double fromVariable = value; - double fromParse = Double.Parse("-4.42330604244772E-305"); - - Console.WriteLine("Double value from literal: {0,29:R}", fromLiteral); - Console.WriteLine("Double value from variable: {0,28:R}", fromVariable); - Console.WriteLine("Double value from Parse method: {0,24:R}", fromParse); - // On 32-bit versions of the .NET Framework, the output is: - // Double value from literal: -4.42330604244772E-305 - // Double value from variable: -4.42330604244772E-305 - // Double value from Parse method: -4.42330604244772E-305 - // - // On other versions of the .NET Framework, the output is: - // Double value from literal: -4.4233060424477198E-305 - // Double value from variable: -4.4233060424477198E-305 - // Double value from Parse method: -4.42330604244772E-305 - // - } -} diff --git a/snippets/csharp/System/Double/Overview/precisionlist1.cs b/snippets/csharp/System/Double/Overview/precisionlist1.cs deleted file mode 100644 index f044ef1880d..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist1.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 1/3.0; - Single sValue2 = 1/3.0f; - Double value2 = (Double) sValue2; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, - value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.33333333333333331 = 0.3333333432674408: False -// diff --git a/snippets/csharp/System/Double/Overview/precisionlist3.cs b/snippets/csharp/System/Double/Overview/precisionlist3.cs deleted file mode 100644 index 9622e3303ff..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist3.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double[] values = { 10.0, 2.88, 2.88, 2.88, 9.0 }; - Double result = 27.64; - Double total = 0; - foreach (var value in values) - total += value; - - if (total.Equals(result)) - Console.WriteLine("The sum of the values equals the total."); - else - Console.WriteLine("The sum of the values ({0}) does not equal the total ({1}).", - total, result); - } -} -// The example displays the following output: -// The sum of the values (36.64) does not equal the total (36.64). -// -// If the index items in the Console.WriteLine statement are changed to {0:R}, -// the example displays the following output: -// The sum of the values (27.639999999999997) does not equal the total (27.64). -// diff --git a/snippets/csharp/System/Double/Overview/precisionlist4.cs b/snippets/csharp/System/Double/Overview/precisionlist4.cs deleted file mode 100644 index b6e51a45d79..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist4.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Doubles.dat"); - Double[] values = { 2.2/1.01, 1.0/3, Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - Double[] restoredValues = new Double[values.Length]; - StreamReader sr = new StreamReader(@".\Doubles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Double.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.17821782178218 <> 2.17821782178218 -// 0.333333333333333 <> 0.333333333333333 -// 3.14159265358979 <> 3.14159265358979 -// diff --git a/snippets/csharp/System/Double/Overview/precisionlist5.cs b/snippets/csharp/System/Double/Overview/precisionlist5.cs deleted file mode 100644 index 7b163065a4b..00000000000 --- a/snippets/csharp/System/Double/Overview/precisionlist5.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Doubles.dat"); - Double[] values = { 2.2/1.01, 1.0/3, Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - sw.Write("{0:G17}{1}", values[ctr], ctr < values.Length - 1 ? "|" : "" ); - - sw.Close(); - - Double[] restoredValues = new Double[values.Length]; - StreamReader sr = new StreamReader(@".\Doubles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Double.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.17821782178218 = 2.17821782178218 -// 0.333333333333333 = 0.333333333333333 -// 3.14159265358979 = 3.14159265358979 -// diff --git a/snippets/csharp/System/Double/Overview/representation1.cs b/snippets/csharp/System/Double/Overview/representation1.cs deleted file mode 100644 index d82052b7672..00000000000 --- a/snippets/csharp/System/Double/Overview/representation1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value = .1; - Double result1 = value * 10; - Double result2 = 0; - for (int ctr = 1; ctr <= 10; ctr++) - result2 += value; - - Console.WriteLine(".1 * 10: {0:R}", result1); - Console.WriteLine(".1 Added 10 times: {0:R}", result2); - } -} -// The example displays the following output: -// .1 * 10: 1 -// .1 Added 10 times: 0.99999999999999989 -// diff --git a/snippets/csharp/System/Double/Overview/representation2.cs b/snippets/csharp/System/Double/Overview/representation2.cs deleted file mode 100644 index 8d3c74765fd..00000000000 --- a/snippets/csharp/System/Double/Overview/representation2.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value = 123456789012.34567; - Double additional = Double.Epsilon * 1e15; - Console.WriteLine("{0} + {1} = {2}", value, additional, - value + additional); - } -} -// The example displays the following output: -// 123456789012.346 + 4.94065645841247E-309 = 123456789012.346 -// diff --git a/snippets/csharp/System/Enum/Overview/EnumMain.cs b/snippets/csharp/System/Enum/Overview/EnumMain.cs deleted file mode 100644 index 2dcab459ead..00000000000 --- a/snippets/csharp/System/Enum/Overview/EnumMain.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class EnumTest { - enum Days { Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday }; - enum BoilingPoints { Celsius = 100, Fahrenheit = 212 }; - [Flags] - enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 }; - - public static void Main() { - - Type weekdays = typeof(Days); - Type boiling = typeof(BoilingPoints); - - Console.WriteLine("The days of the week, and their corresponding values in the Days Enum are:"); - - foreach ( string s in Enum.GetNames(weekdays) ) - Console.WriteLine( "{0,-11}= {1}", s, Enum.Format( weekdays, Enum.Parse(weekdays, s), "d")); - - Console.WriteLine(); - Console.WriteLine("Enums can also be created which have values that represent some meaningful amount."); - Console.WriteLine("The BoilingPoints Enum defines the following items, and corresponding values:"); - - foreach ( string s in Enum.GetNames(boiling) ) - Console.WriteLine( "{0,-11}= {1}", s, Enum.Format(boiling, Enum.Parse(boiling, s), "d")); - - Colors myColors = Colors.Red | Colors.Blue | Colors.Yellow; - Console.WriteLine(); - Console.WriteLine("myColors holds a combination of colors. Namely: {0}", myColors); - } -} -// diff --git a/snippets/csharp/System/Enum/Overview/Extensions.cs b/snippets/csharp/System/Enum/Overview/Extensions.cs deleted file mode 100644 index fd791c08047..00000000000 --- a/snippets/csharp/System/Enum/Overview/Extensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -using System; - -// Define an enumeration to represent student grades. -public enum Grades { F = 0, D = 1, C = 2, B = 3, A = 4 }; - -// Define an extension method for the Grades enumeration. -public static class Extensions -{ - public static Grades minPassing = Grades.D; - - public static bool Passing(this Grades grade) - { - return grade >= minPassing; - } -} - -class Example -{ - static void Main() - { - Grades g1 = Grades.D; - Grades g2 = Grades.F; - Console.WriteLine("{0} {1} a passing grade.", g1, g1.Passing() ? "is" : "is not"); - Console.WriteLine("{0} {1} a passing grade.", g2, g2.Passing() ? "is" : "is not"); - - Extensions.minPassing = Grades.C; - Console.WriteLine("\nRaising the bar!\n"); - Console.WriteLine("{0} {1} a passing grade.", g1, g1.Passing() ? "is" : "is not"); - Console.WriteLine("{0} {1} a passing grade.", g2, g2.Passing() ? "is" : "is not"); - } -} -// The exmaple displays the following output: -// D is a passing grade. -// F is not a passing grade. -// -// Raising the bar! -// -// D is not a passing grade. -// F is not a passing grade. -// diff --git a/snippets/csharp/System/Enum/Overview/class1.cs b/snippets/csharp/System/Enum/Overview/class1.cs deleted file mode 100644 index a1c20d4f747..00000000000 --- a/snippets/csharp/System/Enum/Overview/class1.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -// -public enum ArrivalStatus { Late=-1, OnTime=0, Early=1 }; -// - -// -public class Example -{ - public static void Main() - { - ArrivalStatus status = ArrivalStatus.OnTime; - Console.WriteLine("Arrival Status: {0} ({0:D})", status); - } -} -// The example displays the following output: -// Arrival Status: OnTime (0) -// diff --git a/snippets/csharp/System/Enum/Overview/class2.cs b/snippets/csharp/System/Enum/Overview/class2.cs deleted file mode 100644 index 68e1a2a0d7a..00000000000 --- a/snippets/csharp/System/Enum/Overview/class2.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -public enum ArrivalStatus { Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - ArrivalStatus status1 = new ArrivalStatus(); - Console.WriteLine("Arrival Status: {0} ({0:D})", status1); - // The example displays the following output: - // Arrival Status: OnTime (0) - // - - // - ArrivalStatus status2 = (ArrivalStatus) 1; - Console.WriteLine("Arrival Status: {0} ({0:D})", status2); - // The example displays the following output: - // Arrival Status: Early (1) - // - - // - int value3 = 2; - ArrivalStatus status3 = (ArrivalStatus) value3; - - int value4 = (int) status3; - // - - // - int number = -1; - ArrivalStatus arrived = (ArrivalStatus) ArrivalStatus.ToObject(typeof(ArrivalStatus), number); - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classbitwise1.cs b/snippets/csharp/System/Enum/Overview/classbitwise1.cs deleted file mode 100644 index 8c0e53712a1..00000000000 --- a/snippets/csharp/System/Enum/Overview/classbitwise1.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; - -// -[Flags] public enum Pets { None=0, Dog=1, Cat=2, Bird=4, Rodent=8, - Reptile=16, Other=32 }; - -// - -public class Example -{ - public static void Main() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - Console.WriteLine("Pets: {0:G} ({0:D})", familyPets); - // The example displays the following output: - // Pets: Dog, Cat (3) - // - - ShowHasFlag(); - ShowIfSet(); - TestForNone(); - } - - private static void ShowHasFlag() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - if (familyPets.HasFlag(Pets.Dog)) - Console.WriteLine("The family has a dog."); - // The example displays the following output: - // The family has a dog. - // - } - - private static void ShowIfSet() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - if ((familyPets & Pets.Dog) == Pets.Dog) - Console.WriteLine("The family has a dog."); - // The example displays the following output: - // The family has a dog. - // - } - - private static void TestForNone() - { - // - Pets familyPets = Pets.Dog | Pets.Cat; - if (familyPets == Pets.None) - Console.WriteLine("The family has no pets."); - else - Console.WriteLine("The family has pets."); - // The example displays the following output: - // The family has pets. - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classconversion1.cs b/snippets/csharp/System/Enum/Overview/classconversion1.cs deleted file mode 100644 index 93b36e689e0..00000000000 --- a/snippets/csharp/System/Enum/Overview/classconversion1.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - int[] values = { -3, -1, 0, 1, 5, Int32.MaxValue }; - foreach (var value in values) - { - ArrivalStatus status; - if (Enum.IsDefined(typeof(ArrivalStatus), value)) - status = (ArrivalStatus) value; - else - status = ArrivalStatus.Unknown; - Console.WriteLine("Converted {0:N0} to {1}", value, status); - } - } -} -// The example displays the following output: -// Converted -3 to Unknown -// Converted -1 to Late -// Converted 0 to OnTime -// Converted 1 to Early -// Converted 5 to Unknown -// Converted 2,147,483,647 to Unknown -// diff --git a/snippets/csharp/System/Enum/Overview/classconversion2.cs b/snippets/csharp/System/Enum/Overview/classconversion2.cs deleted file mode 100644 index c80716a2f68..00000000000 --- a/snippets/csharp/System/Enum/Overview/classconversion2.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - ArrivalStatus status = ArrivalStatus.Early; - var number = Convert.ChangeType(status, Enum.GetUnderlyingType(typeof(ArrivalStatus))); - Console.WriteLine("Converted {0} to {1}", status, number); - // The example displays the following output: - // Converted Early to 1 - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classformat1.cs b/snippets/csharp/System/Enum/Overview/classformat1.cs deleted file mode 100644 index 7ed0f38cd3f..00000000000 --- a/snippets/csharp/System/Enum/Overview/classformat1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - string[] formats= { "G", "F", "D", "X"}; - ArrivalStatus status = ArrivalStatus.Late; - foreach (var fmt in formats) - Console.WriteLine(status.ToString(fmt)); - - // The example displays the following output: - // Late - // Late - // -1 - // FFFFFFFF - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classiterate.cs b/snippets/csharp/System/Enum/Overview/classiterate.cs deleted file mode 100644 index 879059e1fc5..00000000000 --- a/snippets/csharp/System/Enum/Overview/classiterate.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - GetEnumByName(); - Console.WriteLine("-----"); - GetEnumByValue(); - } - - private static void GetEnumByName() - { - // - string[] names = Enum.GetNames(typeof(ArrivalStatus)); - Console.WriteLine("Members of {0}:", typeof(ArrivalStatus).Name); - Array.Sort(names); - foreach (var name in names) { - ArrivalStatus status = (ArrivalStatus) Enum.Parse(typeof(ArrivalStatus), name); - Console.WriteLine(" {0} ({0:D})", status); - } - // The example displays the following output: - // Members of ArrivalStatus: - // Early (1) - // Late (-1) - // OnTime (0) - // Unknown (-3) - // - } - - private static void GetEnumByValue() - { - // - var values = Enum.GetValues(typeof(ArrivalStatus)); - Console.WriteLine("Members of {0}:", typeof(ArrivalStatus).Name); - foreach (ArrivalStatus status in values) { - Console.WriteLine(" {0} ({0:D})", status); - } - // The example displays the following output: - // Members of ArrivalStatus: - // OnTime (0) - // Early (1) - // Unknown (-3) - // Late (-1) - // - } -} diff --git a/snippets/csharp/System/Enum/Overview/classparse1.cs b/snippets/csharp/System/Enum/Overview/classparse1.cs deleted file mode 100644 index 1606b53aa30..00000000000 --- a/snippets/csharp/System/Enum/Overview/classparse1.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -public enum ArrivalStatus { Unknown=-3, Late=-1, OnTime=0, Early=1 }; - -public class Example -{ - public static void Main() - { - // - string number = "-1"; - string name = "Early"; - - try { - ArrivalStatus status1 = (ArrivalStatus) Enum.Parse(typeof(ArrivalStatus), number); - if (!(Enum.IsDefined(typeof(ArrivalStatus), status1))) - status1 = ArrivalStatus.Unknown; - Console.WriteLine("Converted '{0}' to {1}", number, status1); - } - catch (FormatException) { - Console.WriteLine("Unable to convert '{0}' to an ArrivalStatus value.", - number); - } - - ArrivalStatus status2; - if (Enum.TryParse(name, out status2)) { - if (!(Enum.IsDefined(typeof(ArrivalStatus), status2))) - status2 = ArrivalStatus.Unknown; - Console.WriteLine("Converted '{0}' to {1}", name, status2); - } - else { - Console.WriteLine("Unable to convert '{0}' to an ArrivalStatus value.", - number); - } - // The example displays the following output: - // Converted '-1' to Late - // Converted 'Early' to Early - // - } -} diff --git a/snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs b/snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs deleted file mode 100644 index fe362cb59a0..00000000000 --- a/snippets/csharp/System/Environment/GetEnvironmentVariable/setenvironmentvariable1.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - String envName = "AppDomain"; - String envValue = "True"; - - // Determine whether the environment variable exists. - if (Environment.GetEnvironmentVariable(envName) == null) - // If it doesn't exist, create it. - Environment.SetEnvironmentVariable(envName, envValue); - - bool createAppDomain; - Message msg; - if (Boolean.TryParse(Environment.GetEnvironmentVariable(envName), - out createAppDomain) && createAppDomain) { - AppDomain domain = AppDomain.CreateDomain("Domain2"); - msg = (Message) domain.CreateInstanceAndUnwrap(typeof(Example).Assembly.FullName, - "Message"); - msg.Display(); - } - else { - msg = new Message(); - msg.Display(); - } - } -} - -public class Message : MarshalByRefObject -{ - public void Display() - { - Console.WriteLine("Executing in domain {0}", - AppDomain.CurrentDomain.FriendlyName); - } -} -// diff --git a/snippets/csharp/System/FormatException/Overview/FormatExample1.cs b/snippets/csharp/System/FormatException/Overview/FormatExample1.cs deleted file mode 100644 index 5cffb77eff2..00000000000 --- a/snippets/csharp/System/FormatException/Overview/FormatExample1.cs +++ /dev/null @@ -1,108 +0,0 @@ -// -// This code example demonstrates the String.Format() method. -// Formatting for this example uses the "en-US" culture. - -using System; -using System.Globalization; - -class Sample -{ - enum Color {Yellow = 1, Blue, Green}; - static DateTime thisDate = DateTime.Now; - - public static void Main() - { -// Store the output of the String.Format method in a string. - string s = ""; - - Console.Clear(); - -// Format a negative integer or floating-point number in various ways. - Console.WriteLine("Standard Numeric Format Specifiers"); - s = String.Format(CultureInfo.InvariantCulture, - "(C) Currency: . . . . . . . . {0:C}\n" + - "(D) Decimal:. . . . . . . . . {0:D}\n" + - "(E) Scientific: . . . . . . . {1:E}\n" + - "(F) Fixed point:. . . . . . . {1:F}\n" + - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(N) Number: . . . . . . . . . {0:N}\n" + - "(P) Percent:. . . . . . . . . {1:P}\n" + - "(R) Round-trip: . . . . . . . {1:R}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - -123, -123.45f); - Console.WriteLine(s); - -// Format the current date in various ways. - Console.WriteLine("Standard DateTime Format Specifiers"); - s = String.Format(CultureInfo.InvariantCulture.DateTimeFormat, - "(d) Short date: . . . . . . . {0:d}\n" + - "(D) Long date:. . . . . . . . {0:D}\n" + - "(t) Short time: . . . . . . . {0:t}\n" + - "(T) Long time:. . . . . . . . {0:T}\n" + - "(f) Full date/short time: . . {0:f}\n" + - "(F) Full date/long time:. . . {0:F}\n" + - "(g) General date/short time:. {0:g}\n" + - "(G) General date/long time: . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(M) Month:. . . . . . . . . . {0:M}\n" + - "(R) RFC1123:. . . . . . . . . {0:R}\n" + - "(s) Sortable: . . . . . . . . {0:s}\n" + - "(u) Universal sortable: . . . {0:u} (invariant)\n" + - "(U) Universal full: . . . . . {0:U}\n" + - "(Y) Year: . . . . . . . . . . {0:Y}\n", - thisDate); - Console.WriteLine(s); - -// Format a Color enumeration value in various ways. - Console.WriteLine("Standard Enumeration Format Specifiers"); - s = String.Format(CultureInfo.InvariantCulture, - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" + - "(D) Decimal number: . . . . . {0:D}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - Color.Green); - Console.WriteLine(s); - } -} -/* -This example displays the following output to the console: - -Standard Numeric Format Specifiers -(C) Currency: . . . . . . . . (¤123.00) -(D) Decimal:. . . . . . . . . -123 -(E) Scientific: . . . . . . . -1.234500E+002 -(F) Fixed point:. . . . . . . -123.45 -(G) General:. . . . . . . . . -123 - (default):. . . . . . . . -123 (default = 'G') -(N) Number: . . . . . . . . . -123.00 -(P) Percent:. . . . . . . . . -12,345.00 % -(R) Round-trip: . . . . . . . -123.45 -(X) Hexadecimal:. . . . . . . FFFFFF85 - -Standard DateTime Format Specifiers -(d) Short date: . . . . . . . 07/09/2007 -(D) Long date:. . . . . . . . Monday, 09 July 2007 -(t) Short time: . . . . . . . 13:48 -(T) Long time:. . . . . . . . 13:48:05 -(f) Full date/short time: . . Monday, 09 July 2007 13:48 -(F) Full date/long time:. . . Monday, 09 July 2007 13:48:05 -(g) General date/short time:. 07/09/2007 13:48 -(G) General date/long time: . 07/09/2007 13:48:05 - (default):. . . . . . . . 07/09/2007 13:48:05 (default = 'G') -(M) Month:. . . . . . . . . . July 09 -(R) RFC1123:. . . . . . . . . Mon, 09 Jul 2007 13:48:05 GMT -(s) Sortable: . . . . . . . . 2007-07-09T13:48:05 -(u) Universal sortable: . . . 2007-07-09 13:48:05Z (invariant) -(U) Universal full: . . . . . Monday, 09 July 2007 20:48:05 -(Y) Year: . . . . . . . . . . 2007 July - -Standard Enumeration Format Specifiers -(G) General:. . . . . . . . . Green - (default):. . . . . . . . Green (default = 'G') -(F) Flags:. . . . . . . . . . Green (flags or integer) -(D) Decimal number: . . . . . 3 -(X) Hexadecimal:. . . . . . . 00000003 -*/ -// diff --git a/snippets/csharp/System/FormatException/Overview/formatexample3.cs b/snippets/csharp/System/FormatException/Overview/formatexample3.cs deleted file mode 100644 index b5b9f2ce03a..00000000000 --- a/snippets/csharp/System/FormatException/Overview/formatexample3.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -using System; - -public enum Color {Yellow = 1, Blue, Green}; - -class Example -{ - static DateTime thisDate = new DateTime(2009, 6, 30, 19, 14, 0); - - public static void Main() - { - // Store the output of the String.Format method in a string. - string s = ""; - - // Format a negative integer or floating-point number in various ways. - Console.WriteLine("Standard Numeric Format Strings"); - s = String.Format( - "(C) Currency: . . . . . . . . {0:C}\n" + - "(D) Decimal:. . . . . . . . . {0:D}\n" + - "(E) Scientific: . . . . . . . {1:E}\n" + - "(F) Fixed point:. . . . . . . {1:F}\n" + - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(N) Number: . . . . . . . . . {0:N}\n" + - "(P) Percent:. . . . . . . . . {2:P}\n" + - "(R) Round-trip: . . . . . . . {3:R}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - -123, -123.45, -.126, -1.5322980781265591); - Console.WriteLine(s); - - // Format a date in various ways. - Console.WriteLine("Standard Date and Time Format Strings"); - s = String.Format( - "(d) Short date: . . . . . . . {0:d}\n" + - "(D) Long date:. . . . . . . . {0:D}\n" + - "(t) Short time: . . . . . . . {0:t}\n" + - "(T) Long time:. . . . . . . . {0:T}\n" + - "(f) Full date/short time: . . {0:f}\n" + - "(F) Full date/long time:. . . {0:F}\n" + - "(g) General date/short time:. {0:g}\n" + - "(G) General date/long time: . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(M) Month:. . . . . . . . . . {0:M}\n" + - "(R) RFC1123:. . . . . . . . . {0:R}\n" + - "(s) Sortable: . . . . . . . . {0:s}\n" + - "(u) Universal sortable: . . . {0:u} (invariant)\n" + - "(U) Universal full: . . . . . {0:U}\n" + - "(Y) Year: . . . . . . . . . . {0:Y}\n", - thisDate); - Console.WriteLine(s); - - // Format an enumeration value in various ways. - Console.WriteLine("Standard Enumeration Format Specifiers"); - s = String.Format( - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(F) Flags:. . . . . . . . . . {1:F}\n" + - "(D) Decimal number: . . . . . {0:D}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - Color.Green, AttributeTargets.Class | AttributeTargets.Struct); - Console.WriteLine(s); - } -} -// The example displays the following output: -// Standard Numeric Format Specifiers -// (C) Currency: . . . . . . . . (¤123.00) -// (D) Decimal:. . . . . . . . . -123 -// (E) Scientific: . . . . . . . -1.234500E+002 -// (F) Fixed point:. . . . . . . -123.45 -// (G) General:. . . . . . . . . -123 -// (default):. . . . . . . . -123 (default = 'G') -// (N) Number: . . . . . . . . . -123.00 -// (P) Percent:. . . . . . . . . -12,345.00 % -// (R) Round-trip: . . . . . . . -123.45 -// (X) Hexadecimal:. . . . . . . FFFFFF85 -// -// Standard DateTime Format Specifiers -// (d) Short date: . . . . . . . 07/09/2007 -// (D) Long date:. . . . . . . . Monday, 09 July 2007 -// (t) Short time: . . . . . . . 13:48 -// (T) Long time:. . . . . . . . 13:48:05 -// (f) Full date/short time: . . Monday, 09 July 2007 13:48 -// (F) Full date/long time:. . . Monday, 09 July 2007 13:48:05 -// (g) General date/short time:. 07/09/2007 13:48 -// (G) General date/long time: . 07/09/2007 13:48:05 -// (default):. . . . . . . . 07/09/2007 13:48:05 (default = 'G') -// (M) Month:. . . . . . . . . . July 09 -// (R) RFC1123:. . . . . . . . . Mon, 09 Jul 2007 13:48:05 GMT -// (s) Sortable: . . . . . . . . 2007-07-09T13:48:05 -// (u) Universal sortable: . . . 2007-07-09 13:48:05Z (invariant) -// (U) Universal full: . . . . . Monday, 09 July 2007 20:48:05 -// (Y) Year: . . . . . . . . . . 2007 July -// -// Standard Enumeration Format Specifiers -// (G) General:. . . . . . . . . Green -// (default):. . . . . . . . Green (default = 'G') -// (F) Flags:. . . . . . . . . . Green (flags or integer) -// (D) Decimal number: . . . . . 3 -// (X) Hexadecimal:. . . . . . . 00000003 -// diff --git a/snippets/csharp/System/FormattableString/Format/Escaping1.cs b/snippets/csharp/System/FormattableString/Format/Escaping1.cs deleted file mode 100644 index b962b8f4f24..00000000000 --- a/snippets/csharp/System/FormattableString/Format/Escaping1.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -public class Class1 -{ - public static void Main() - { - // - int value = 6324; - string output = string.Format("{0}{1:D}{2}", - "{", value, "}"); - Console.WriteLine(output); - // The example displays the following output: - // {6324} - // - } -} diff --git a/snippets/csharp/System/FormattableString/Format/alignment1.cs b/snippets/csharp/System/FormattableString/Format/alignment1.cs deleted file mode 100644 index 9ecf2abd9e2..00000000000 --- a/snippets/csharp/System/FormattableString/Format/alignment1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string[] names = { "Adam", "Bridgette", "Carla", "Daniel", - "Ebenezer", "Francine", "George" }; - decimal[] hours = { 40, 6.667m, 40.39m, 82, 40.333m, 80, - 16.75m }; - - Console.WriteLine("{0,-20} {1,5}\n", "Name", "Hours"); - for (int ctr = 0; ctr < names.Length; ctr++) - Console.WriteLine("{0,-20} {1,5:N1}", names[ctr], hours[ctr]); - } -} -// The example displays the following output: -// Name Hours -// -// Adam 40.0 -// Bridgette 6.7 -// Carla 40.4 -// Daniel 82.0 -// Ebenezer 40.3 -// Francine 80.0 -// George 16.8 -// diff --git a/snippets/csharp/System/FormattableString/Format/index1.cs b/snippets/csharp/System/FormattableString/Format/index1.cs deleted file mode 100644 index 81c398acfa1..00000000000 --- a/snippets/csharp/System/FormattableString/Format/index1.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - string primes; - primes = String.Format("Prime numbers less than 10: {0}, {1}, {2}, {3}", - 2, 3, 5, 7 ); - Console.WriteLine(primes); - // The example displays the following output: - // Prime numbers less than 10: 2, 3, 5, 7 - // - Console.WriteLine(); - - // - string multiple = String.Format("0x{0:X} {0:E} {0:N}", - Int64.MaxValue); - Console.WriteLine(multiple); - // The example displays the following output: - // 0x7FFFFFFFFFFFFFFF 9.223372E+018 9,223,372,036,854,775,807.00 - // - Console.WriteLine(); - } -} diff --git a/snippets/csharp/System/Guid/Parse/program.cs b/snippets/csharp/System/Guid/Parse/program.cs deleted file mode 100644 index d593707cef5..00000000000 --- a/snippets/csharp/System/Guid/Parse/program.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace guids -{ - class Program - { - // - static void Main(string[] args) - { - Guid GStart = Guid.NewGuid(); - string guidB = GStart.ToString("B"); - - Guid GCurrent = Guid.Parse(guidB); - string guidX = GCurrent.ToString("X"); - - if (Guid.TryParse(guidX, out GCurrent)) - Console.WriteLine(GCurrent.ToString("X")); - else - Console.WriteLine("Last parse operation unsuccessful."); - - if (Guid.TryParseExact(guidX, "X", out GCurrent)) - Console.WriteLine(GCurrent.ToString("X")); - else - Console.WriteLine("Last parse operation unsuccessful."); - } - // - } -} diff --git a/snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs b/snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs deleted file mode 100644 index 82e4dbb60ac..00000000000 --- a/snippets/csharp/System/IAsyncResult/Overview/EndInvoke.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -using System; -using System.Threading; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - public class AsyncMain - { - public static void Main() - { - // The asynchronous method puts the thread id here. - int threadId; - - // Create an instance of the test class. - AsyncDemo ad = new AsyncDemo(); - - // Create the delegate. - AsyncMethodCaller caller = new AsyncMethodCaller(ad.TestMethod); - - // Initiate the asychronous call. - IAsyncResult result = caller.BeginInvoke(3000, - out threadId, null, null); - - Thread.Sleep(0); - Console.WriteLine("Main thread {0} does some work.", - Thread.CurrentThread.ManagedThreadId); - - // Call EndInvoke to wait for the asynchronous call to complete, - // and to retrieve the results. - string returnValue = caller.EndInvoke(out threadId, result); - - Console.WriteLine("The call executed on thread {0}, with return value \"{1}\".", - threadId, returnValue); - } - } -} - -/* This example produces output similar to the following: - -Main thread 1 does some work. -Test method begins. -The call executed on thread 3, with return value "My call time was 3000.". - */ -// diff --git a/snippets/csharp/System/IAsyncResult/Overview/makefile b/snippets/csharp/System/IAsyncResult/Overview/makefile deleted file mode 100644 index 6ebfe1d3c97..00000000000 --- a/snippets/csharp/System/IAsyncResult/Overview/makefile +++ /dev/null @@ -1,21 +0,0 @@ -all: testMethod.dll EndInvoke.exe WaitHandle.exe polling.exe Callback.exe - -testMethod.dll: testmethod.cs - csc /t:library testmethod.cs - - -EndInvoke.exe: endinvoke.cs testMethod.dll - csc /out:endinvoke.exe endinvoke.cs /r:testmethod.dll - - -WaitHandle.exe: waithandle.cs testMethod.dll - csc /out:waithandle.exe waithandle.cs /r:testmethod.dll - -polling.exe: polling.cs testmethod.dll - csc /out:polling.exe polling.cs /r:testmethod.dll - -Callback.exe: Callback.cs testmethod.dll - csc /out:Callback.exe Callback.cs /r:testmethod.dll -clean: - del *.dll - del *.exe \ No newline at end of file diff --git a/snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs b/snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs deleted file mode 100644 index 0ea31faa82d..00000000000 --- a/snippets/csharp/System/IndexOutOfRangeException/Overview/empty1.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string[] maleNames= { "Adam", "Bartholomew", "Charles", "David", - "Earl", "Robert", "Stanley", "Wilberforce" }; - string[] selected= Array.FindAll(maleNames, name => { - string fLetter = name.Substring(0, 1); - return fLetter.CompareTo("F") >= 0 && - fLetter.CompareTo("M") <= 0; - } ); - for (int ctr = 0; ctr < selected.Length; ctr++) - Console.WriteLine(selected[ctr]); - } -} -// The example displays the following output: -// Unhandled Exception: -// System.IndexOutOfRangeException: -// Index was outside the bounds of the array. -// at Example.Main() -// diff --git a/snippets/csharp/System/Int32/Overview/Formatting1.cs b/snippets/csharp/System/Int32/Overview/Formatting1.cs deleted file mode 100644 index 28a3494a1ad..00000000000 --- a/snippets/csharp/System/Int32/Overview/Formatting1.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CallToString(); - Console.WriteLine("-----"); - CallConvert(); - } - - private static void CallToString() - { - // - int[] numbers = { -1403, 0, 169, 1483104 }; - foreach (int number in numbers) { - // Display value using default formatting. - Console.Write("{0,-8} --> ", number.ToString()); - // Display value with 3 digits and leading zeros. - Console.Write("{0,11:D3}", number); - // Display value with 1 decimal digit. - Console.Write("{0,13:N1}", number); - // Display value as hexadecimal. - Console.Write("{0,12:X2}", number); - // Display value with eight hexadecimal digits. - Console.WriteLine("{0,14:X8}", number); - } - // The example displays the following output: - // -1403 --> -1403 -1,403.0 FFFFFA85 FFFFFA85 - // 0 --> 000 0.0 00 00000000 - // 169 --> 169 169.0 A9 000000A9 - // 1483104 --> 1483104 1,483,104.0 16A160 0016A160 - // - } - - private static void CallConvert() - { - // - int[] numbers = { -146, 11043, 2781913 }; - Console.WriteLine("{0,8} {1,32} {2,11} {3,10}", - "Value", "Binary", "Octal", "Hex"); - foreach (int number in numbers) { - Console.WriteLine("{0,8} {1,32} {2,11} {3,10}", - number, Convert.ToString(number, 2), - Convert.ToString(number, 8), - Convert.ToString(number, 16)); - } - // The example displays the following output: - // Value Binary Octal Hex - // -146 11111111111111111111111101101110 37777777556 ffffff6e - // 11043 10101100100011 25443 2b23 - // 2781913 1010100111001011011001 12471331 2a72d9 - // - } -} diff --git a/snippets/csharp/System/Int32/Overview/Instantiate1.cs b/snippets/csharp/System/Int32/Overview/Instantiate1.cs deleted file mode 100644 index ea5f8c1b84b..00000000000 --- a/snippets/csharp/System/Int32/Overview/Instantiate1.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - InstantiateByAssignment(); - Console.WriteLine("----"); - InstantiateByNarrowingConversion(); - Console.WriteLine("----"); - Parse(); - Console.WriteLine("----"); - InstantiateByWideningConversion(); - } - - private static void InstantiateByAssignment() - { - // - int number1 = 64301; - int number2 = 25548612; - // - Console.WriteLine("{0} - {1}", number1, number2); - } - - private static void InstantiateByNarrowingConversion() - { - // - long lNumber = 163245617; - try { - int number1 = (int) lNumber; - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int32.", lNumber); - } - - double dbl2 = 35901.997; - try { - int number2 = (int) dbl2; - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int32.", dbl2); - } - - BigInteger bigNumber = 132451; - try { - int number3 = (int) bigNumber; - Console.WriteLine(number3); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int32.", bigNumber); - } - // The example displays the following output: - // 163245617 - // 35902 - // 132451 - // - } - - private static void Parse() - { - // - string string1 = "244681"; - try { - int number1 = Int32.Parse(string1); - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 32-bit integer.", string1); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string1); - } - - string string2 = "F9A3C"; - try { - int number2 = Int32.Parse(string2, - System.Globalization.NumberStyles.HexNumber); - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 32-bit integer.", string2); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string2); - } - // The example displays the following output: - // 244681 - // 1022524 - // - } - - private static void InstantiateByWideningConversion() - { - // - sbyte value1 = 124; - short value2 = 1618; - - int number1 = value1; - int number2 = value2; - // - } -} diff --git a/snippets/csharp/System/Int32/Parse/parse4.cs b/snippets/csharp/System/Int32/Parse/parse4.cs deleted file mode 100644 index b2cfcbc9235..00000000000 --- a/snippets/csharp/System/Int32/Parse/parse4.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; -using System.Globalization; - -public class ParseInt32 -{ - public static void Main() - { - SnippetA(); - SnippetB(); - SnippetC(); - } - - public static void SnippetA() - { - // - string MyString = "12345"; - int MyInt = int.Parse(MyString); - MyInt++; - Console.WriteLine(MyInt); - // The result is "12346". - // - } - - public static void SnippetB() - { - // - CultureInfo MyCultureInfo = new CultureInfo("en-US"); - string MyString = "123,456"; - int MyInt = int.Parse(MyString, MyCultureInfo); - Console.WriteLine(MyInt); - // Raises System.Format exception. - // - } - - public static void SnippetC() - { - // - CultureInfo MyCultureInfo = new CultureInfo("en-US"); - string MyString = "123,456"; - int MyInt = int.Parse(MyString, NumberStyles.AllowThousands, MyCultureInfo); - Console.WriteLine(MyInt); - // The result is "123456". - // - } -} -// diff --git a/snippets/csharp/System/Int64/Overview/formatting1.cs b/snippets/csharp/System/Int64/Overview/formatting1.cs deleted file mode 100644 index 1228d8856bb..00000000000 --- a/snippets/csharp/System/Int64/Overview/formatting1.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CallToString(); - Console.WriteLine("-----"); - CallConvert(); - } - - private static void CallToString() - { - // - long[] numbers = { -1403, 0, 169, 1483104 }; - foreach (var number in numbers) { - // Display value using default formatting. - Console.Write("{0,-8} --> ", number.ToString()); - // Display value with 3 digits and leading zeros. - Console.Write("{0,8:D3}", number); - // Display value with 1 decimal digit. - Console.Write("{0,13:N1}", number); - // Display value as hexadecimal. - Console.Write("{0,18:X2}", number); - // Display value with eight hexadecimal digits. - Console.WriteLine("{0,18:X8}", number); - } - // The example displays the following output: - // -1403 --> -1403 -1,403.0 FFFFFFFFFFFFFA85 FFFFFFFFFFFFFA85 - // 0 --> 000 0.0 00 00000000 - // 169 --> 169 169.0 A9 000000A9 - // 1483104 --> 1483104 1,483,104.0 16A160 0016A160 - // - } - - private static void CallConvert() - { - // - long[] numbers = { -146, 11043, 2781913 }; - foreach (var number in numbers) { - Console.WriteLine("{0} (Base 10):", number); - Console.WriteLine(" Binary: {0}", Convert.ToString(number, 2)); - Console.WriteLine(" Octal: {0}", Convert.ToString(number, 8)); - Console.WriteLine(" Hex: {0}\n", Convert.ToString(number, 16)); - } - // The example displays the following output: - // -146 (Base 10): - // Binary: 1111111111111111111111111111111111111111111111111111111101101110 - // Octal: 1777777777777777777556 - // Hex: ffffffffffffff6e - // - // 11043 (Base 10): - // Binary: 10101100100011 - // Octal: 25443 - // Hex: 2b23 - // - // 2781913 (Base 10): - // Binary: 1010100111001011011001 - // Octal: 12471331 - // Hex: 2a72d9 - // - } -} diff --git a/snippets/csharp/System/Int64/Overview/instantiate1.cs b/snippets/csharp/System/Int64/Overview/instantiate1.cs deleted file mode 100644 index 6f98b515156..00000000000 --- a/snippets/csharp/System/Int64/Overview/instantiate1.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Numerics; - -public class Example -{ - public static void Main() - { - InstantiateByAssignment(); - Console.WriteLine("----"); - InstantiateByNarrowingConversion(); - Console.WriteLine("----"); - Parse(); - Console.WriteLine("----"); - InstantiateByWideningConversion(); - } - - private static void InstantiateByAssignment() - { - // - long number1 = -64301728; - long number2 = 255486129307; - // - Console.WriteLine("{0} - {1}", number1, number2); - } - - private static void InstantiateByNarrowingConversion() - { - // - ulong ulNumber = 163245617943825; - try { - long number1 = (long) ulNumber; - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int64.", ulNumber); - } - - double dbl2 = 35901.997; - try { - long number2 = (long) dbl2; - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int64.", dbl2); - } - - BigInteger bigNumber = (BigInteger) 1.63201978555e30; - try { - long number3 = (long) bigNumber; - Console.WriteLine(number3); - } - catch (OverflowException) { - Console.WriteLine("{0} is out of range of an Int64.", bigNumber); - } - // The example displays the following output: - // 163245617943825 - // 35902 - // 1,632,019,785,549,999,969,612,091,883,520 is out of range of an Int64. - // - } - - private static void Parse() - { - // - string string1 = "244681903147"; - try { - long number1 = Int64.Parse(string1); - Console.WriteLine(number1); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 64-bit integer.", string1); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string1); - } - - string string2 = "F9A3CFF0A"; - try { - long number2 = Int64.Parse(string2, - System.Globalization.NumberStyles.HexNumber); - Console.WriteLine(number2); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is out of range of a 64-bit integer.", string2); - } - catch (FormatException) { - Console.WriteLine("The format of '{0}' is invalid.", string2); - } - // The example displays the following output: - // 244681903147 - // 67012198154 - // - } - - private static void InstantiateByWideningConversion() - { - // - sbyte value1 = 124; - short value2 = 1618; - int value3 = Int32.MaxValue; - - long number1 = value1; - long number2 = value2; - long number3 = value3; - // - } -} diff --git a/snippets/csharp/System/IntPtr/Add/makefile b/snippets/csharp/System/IntPtr/Add/makefile deleted file mode 100644 index ce25ec64d61..00000000000 --- a/snippets/csharp/System/IntPtr/Add/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: Add1.exe - -Add1.exe: Add1.cs - csc /unsafe Add1.cs diff --git a/snippets/csharp/System/IntPtr/Subtract/makefile b/snippets/csharp/System/IntPtr/Subtract/makefile deleted file mode 100644 index d61faa2e849..00000000000 --- a/snippets/csharp/System/IntPtr/Subtract/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: Add1.exe - -Subtract1.exe: Subtract1.cs - csc /unsafe Subtract1.cs diff --git a/snippets/csharp/System/IntPtr/op_Addition/makefile b/snippets/csharp/System/IntPtr/op_Addition/makefile deleted file mode 100644 index 7cff7967e8a..00000000000 --- a/snippets/csharp/System/IntPtr/op_Addition/makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: Addition1.exe op_Subtraction1.exe - -Addition1.exe: Addition1.cs - csc /unsafe Addition1.cs - -op_Subtraction1.exe: op_Subtraction1.cs - csc /unsafe op_Subtraction1.cs - diff --git a/snippets/csharp/System/InvalidCastException/Overview/Interface1.cs b/snippets/csharp/System/InvalidCastException/Overview/Interface1.cs deleted file mode 100644 index 614b8a40d42..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/Interface1.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - var culture = CultureInfo.InvariantCulture; - IFormatProvider provider = culture; - - DateTimeFormatInfo dt = (DateTimeFormatInfo) provider; - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidCastException: -// Unable to cast object of type //System.Globalization.CultureInfo// to -// type //System.Globalization.DateTimeFormatInfo//. -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/ToString1.cs b/snippets/csharp/System/InvalidCastException/Overview/ToString1.cs deleted file mode 100644 index 6b248a2cb82..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/ToString1.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - object value = 12; - // Cast throws an InvalidCastException exception. - string s = (string) value; - } -} -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/ToString2.cs b/snippets/csharp/System/InvalidCastException/Overview/ToString2.cs deleted file mode 100644 index 210a54af176..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/ToString2.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - object value = 12; - string s = value.ToString(); - Console.WriteLine(s); - } -} -// The example displays the following output: -// 12 -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs b/snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs deleted file mode 100644 index ff589249a2c..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/basetoderived1.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -using System; - -public class Person -{ - String _name; - - public String Name - { - get { return _name; } - set { _name = value; } - } -} - -public class PersonWithId : Person -{ - String _id; - - public string Id - { - get { return _id; } - set { _id = value; } - } -} - -public class Example -{ - public static void Main() - { - Person p = new Person(); - p.Name = "John"; - try { - PersonWithId pid = (PersonWithId) p; - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Conversion failed."); - } - - PersonWithId pid1 = new PersonWithId(); - pid1.Name = "John"; - pid1.Id = "246"; - Person p1 = pid1; - try { - PersonWithId pid1a = (PersonWithId) p1; - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Conversion failed."); - } - - Person p2 = null; - try { - PersonWithId pid2 = (PersonWithId) p2; - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Conversion failed."); - } - } -} -// The example displays the following output: -// Conversion failed. -// Conversion succeeded. -// Conversion succeeded. -// diff --git a/snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs b/snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs deleted file mode 100644 index 0ab111e2b83..00000000000 --- a/snippets/csharp/System/InvalidCastException/Overview/iconvertible1.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - bool flag = true; - try { - IConvertible conv = flag; - Char ch = conv.ToChar(null); - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Cannot convert a Boolean to a Char."); - } - - try { - Char ch = Convert.ToChar(flag); - Console.WriteLine("Conversion succeeded."); - } - catch (InvalidCastException) { - Console.WriteLine("Cannot convert a Boolean to a Char."); - } - } -} -// The example displays the following output: -// Cannot convert a Boolean to a Char. -// Cannot convert a Boolean to a Char. -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs deleted file mode 100644 index c642bbfa5b2..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable1.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] data = { 1, 2, 3, 4 }; - var average = data.Where(num => num > 4).Average(); - Console.Write("The average of numbers greater than 4 is {0}", - average); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: Sequence contains no elements -// at System.Linq.Enumerable.Average(IEnumerable`1 source) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs deleted file mode 100644 index b6a349a344d..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable2.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - var moreThan4 = dbQueryResults.Where(num => num > 4); - - if(moreThan4.Any()) - Console.WriteLine("Average value of numbers greater than 4: {0}:", - moreThan4.Average()); - else - // handle empty collection - Console.WriteLine("The dataset has no values greater than 4."); - } -} -// The example displays the following output: -// The dataset has no values greater than 4. -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs deleted file mode 100644 index 404c72634ab..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable3.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var firstNum = dbQueryResults.First(n => n > 4); - - Console.WriteLine("The first value greater than 4 is {0}", - firstNum); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: -// Sequence contains no matching element -// at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs deleted file mode 100644 index 961d3d9224b..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable4.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var firstNum = dbQueryResults.FirstOrDefault(n => n > 4); - - if (firstNum == 0) - Console.WriteLine("No value is greater than 4."); - else - Console.WriteLine("The first value greater than 4 is {0}", - firstNum); - } -} -// The example displays the following output: -// No value is greater than 4. -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs deleted file mode 100644 index 1a84c9ebabe..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable5.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var singleObject = dbQueryResults.Single(value => value > 4); - - // Display results. - Console.WriteLine("{0} is the only value greater than 4", singleObject); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: -// Sequence contains no matching element -// at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs b/snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs deleted file mode 100644 index a00ff0fe7e1..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Enumerable6.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - int[] dbQueryResults = { 1, 2, 3, 4 }; - - var singleObject = dbQueryResults.SingleOrDefault(value => value > 2); - - if (singleObject != 0) - Console.WriteLine("{0} is the only value greater than 2", - singleObject); - else - // Handle an empty collection. - Console.WriteLine("No value is greater than 2"); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: -// Sequence contains more than one matching element -// at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs b/snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs deleted file mode 100644 index 643a1c1ce7e..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Iterating1.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Example -{ - public static void Main() - { - var numbers = new List() { 1, 2, 3, 4, 5 }; - foreach (var number in numbers) { - int square = (int) Math.Pow(number, 2); - Console.WriteLine("{0}^{1}", number, square); - Console.WriteLine("Adding {0} to the collection...\n", square); - numbers.Add(square); - } - } -} -// The example displays the following output: -// 1^1 -// Adding 1 to the collection... -// -// -// Unhandled Exception: System.InvalidOperationException: Collection was modified; -// enumeration operation may not execute. -// at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) -// at System.Collections.Generic.List`1.Enumerator.MoveNextRare() -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs b/snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs deleted file mode 100644 index 965803fc717..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Iterating2.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Example -{ - public static void Main() - { - var numbers = new List() { 1, 2, 3, 4, 5 }; - - int upperBound = numbers.Count - 1; - for (int ctr = 0; ctr <= upperBound; ctr++) { - int square = (int) Math.Pow(numbers[ctr], 2); - Console.WriteLine("{0}^{1}", numbers[ctr], square); - Console.WriteLine("Adding {0} to the collection...\n", square); - numbers.Add(square); - } - - Console.WriteLine("Elements now in the collection: "); - foreach (var number in numbers) - Console.Write("{0} ", number); - } -} -// The example displays the following output: -// 1^1 -// Adding 1 to the collection... -// -// 2^4 -// Adding 4 to the collection... -// -// 3^9 -// Adding 9 to the collection... -// -// 4^16 -// Adding 16 to the collection... -// -// 5^25 -// Adding 25 to the collection... -// -// Elements now in the collection: -// 1 2 3 4 5 1 4 9 16 25 -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs b/snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs deleted file mode 100644 index 9283746cbf4..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Iterating3.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Example -{ - public static void Main() - { - var numbers = new List() { 1, 2, 3, 4, 5 }; - var temp = new List(); - - // Square each number and store it in a temporary collection. - foreach (var number in numbers) { - int square = (int) Math.Pow(number, 2); - temp.Add(square); - } - - // Combine the numbers into a single array. - int[] combined = new int[numbers.Count + temp.Count]; - Array.Copy(numbers.ToArray(), 0, combined, 0, numbers.Count); - Array.Copy(temp.ToArray(), 0, combined, numbers.Count, temp.Count); - - // Iterate the array. - foreach (var value in combined) - Console.Write("{0} ", value); - } -} -// The example displays the following output: -// 1 2 3 4 5 1 4 9 16 25 -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs deleted file mode 100644 index dd25bd14336..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort1.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } -} -// The example displays the following output: -// Unhandled Exception: System.InvalidOperationException: Failed to compare two elements in the array. ---> -// System.ArgumentException: At least one object must implement IComparable. -// at System.Collections.Comparer.Compare(Object a, Object b) -// at System.Collections.Generic.ArraySortHelper`1.SwapIfGreater(T[] keys, IComparer`1 comparer, Int32 a, Int32 b) -// at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit) -// at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer) -// --- End of inner exception stack trace --- -// at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer) -// at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer) -// at System.Collections.Generic.List`1.Sort(Int32 index, Int32 count, IComparer`1 comparer) -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs deleted file mode 100644 index 24f61b3d9df..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort2.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person : IComparable -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } - - public int CompareTo(Person other) - { - return String.Format("{0} {1}", LastName, FirstName). - CompareTo(String.Format("{0} {1}", other.LastName, other.FirstName)); - } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } -} -// The example displays the following output: -// Jane Doe -// John Doe -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs deleted file mode 100644 index 453f5d5d4b2..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort3.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } -} - -public class PersonComparer : IComparer -{ - public int Compare(Person x, Person y) - { - return String.Format("{0} {1}", x.LastName, x.FirstName). - CompareTo(String.Format("{0} {1}", y.LastName, y.FirstName)); - } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(new PersonComparer()); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } -} -// The example displays the following output: -// Jane Doe -// John Doe -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs b/snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs deleted file mode 100644 index 220928e4a0b..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/List_Sort4.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Collections.Generic; - -public class Person -{ - public Person(String fName, String lName) - { - FirstName = fName; - LastName = lName; - } - - public String FirstName { get; set; } - public String LastName { get; set; } -} - -public class Example -{ - public static void Main() - { - var people = new List(); - - people.Add(new Person("John", "Doe")); - people.Add(new Person("Jane", "Doe")); - people.Sort(PersonComparison); - foreach (var person in people) - Console.WriteLine("{0} {1}", person.FirstName, person.LastName); - } - - public static int PersonComparison(Person x, Person y) - { - return String.Format("{0} {1}", x.LastName, x.FirstName). - CompareTo(String.Format("{0} {1}", y.LastName, y.FirstName)); - } -} -// The example displays the following output: -// Jane Doe -// John Doe -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs b/snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs deleted file mode 100644 index f9965bcf108..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Nullable1.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - var queryResult = new int?[] { 1, 2, null, 4 }; - var map = queryResult.Select(nullableInt => (int)nullableInt); - - // Display list. - foreach (var num in map) - Console.Write("{0} ", num); - Console.WriteLine(); - } -} -// The example displays the following output: -// 1 2 -// Unhandled Exception: System.InvalidOperationException: Nullable object must have a value. -// at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) -// at Example.
b__0(Nullable`1 nullableInt) -// at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() -// at Example.Main() -// diff --git a/snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs b/snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs deleted file mode 100644 index 56506c0979c..00000000000 --- a/snippets/csharp/System/InvalidOperationException/Overview/Nullable2.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; -using System.Linq; - -public class Example -{ - public static void Main() - { - var queryResult = new int?[] { 1, 2, null, 4 }; - var numbers = queryResult.Select(nullableInt => (int)nullableInt.GetValueOrDefault()); - - // Display list using Nullable.HasValue. - foreach (var number in numbers) - Console.Write("{0} ", number); - Console.WriteLine(); - - numbers = queryResult.Select(nullableInt => (int) (nullableInt.HasValue ? nullableInt : -1)); - // Display list using Nullable.GetValueOrDefault. - foreach (var number in numbers) - Console.Write("{0} ", number); - Console.WriteLine(); - } -} -// The example displays the following output: -// 1 2 0 4 -// 1 2 -1 4 -// diff --git a/snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs b/snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs deleted file mode 100644 index 1a1e13873e5..00000000000 --- a/snippets/csharp/System/NotImplementedException/Overview/Consumer1.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System; -using Utilities; - -class Example -{ - public static void Main() - { - string eol = ""; - if (StringLibrary.Version.Major >= 2) - eol = StringLibrary.GetendOfLineCharacter(); - else - eol = "\n"; - - Console.Write("The first line." + eol); - Console.Write("The second line." + eol); - } -} -// diff --git a/snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs b/snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs deleted file mode 100644 index 90889cbd520..00000000000 --- a/snippets/csharp/System/NotImplementedException/Overview/LibraryV1.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -namespace Utilities -{ - public class StringLibrary - { - public static Version Version { get; } = new Version("1.0"); - - public static String GetEndOfLineCharacter() - { - throw new NotSupportedException("This functionality will be provided in a later version."); - } - } -} -// diff --git a/snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs b/snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs deleted file mode 100644 index 992fcdbfa2b..00000000000 --- a/snippets/csharp/System/NotImplementedException/Overview/LibraryV2.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -namespace Utilities -{ - public class StringLibrary - { - public static Version Version { get; } = new Version("2.0"); - - public static String GetEndOfLineCharacter() - { - return Environment.Newline; - } - } -} -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/BadState1.cs b/snippets/csharp/System/NotSupportedException/Overview/BadState1.cs deleted file mode 100644 index 431ad2b35c5..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/BadState1.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -using System; -using System.IO; -using System.Text; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - Encoding enc = Encoding.Unicode; - String value = "This is a string to persist."; - Byte[] bytes = enc.GetBytes(value); - - FileStream fs = new FileStream(@".\TestFile.dat", - FileMode.Open, - FileAccess.Read); - Task t = fs.WriteAsync(enc.GetPreamble(), 0, enc.GetPreamble().Length); - Task t2 = t.ContinueWith( (a) => fs.WriteAsync(bytes, 0, bytes.Length) ); - await t2; - fs.Close(); - } -} -// The example displays the following output: -// Unhandled Exception: System.NotSupportedException: Stream does not support writing. -// at System.IO.Stream.BeginWriteInternal(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state -// , Boolean serializeAsynchronously) -// at System.IO.FileStream.BeginWrite(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback userCallback, Object sta -// teObject) -// at System.IO.Stream.<>c.b__53_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, -// Object state) -// at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func`5 beginMet -// hod, Func`3 endMethod) -// at System.IO.Stream.BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count) -// at System.IO.FileStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) -// at System.IO.Stream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count) -// at Example.Main() -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/BadState2.cs b/snippets/csharp/System/NotSupportedException/Overview/BadState2.cs deleted file mode 100644 index 094060f5f23..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/BadState2.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; -using System.IO; -using System.Text; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - Encoding enc = Encoding.Unicode; - String value = "This is a string to persist."; - Byte[] bytes = enc.GetBytes(value); - - FileStream fs = new FileStream(@".\TestFile.dat", - FileMode.Create, - FileAccess.Write); - Task t = fs.WriteAsync(enc.GetPreamble(), 0, enc.GetPreamble().Length); - Task t2 = t.ContinueWith( (a) => fs.WriteAsync(bytes, 0, bytes.Length) ); - await t2; - fs.Close(); - } -} -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs b/snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs deleted file mode 100644 index 68abcea9a04..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -using System; -using System.IO; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - String name = @".\TestFile.dat"; - var fs = new FileStream(name, - FileMode.Create, - FileAccess.Write); - Console.WriteLine("Filename: {0}, Encoding: {1}", - name, await FileUtilities.GetEncodingType(fs)); - } -} - -public class FileUtilities -{ - public enum EncodingType - { None = 0, Unknown = -1, Utf8 = 1, Utf16 = 2, Utf32 = 3 } - - public async static Task GetEncodingType(FileStream fs) - { - Byte[] bytes = new Byte[4]; - int bytesRead = await fs.ReadAsync(bytes, 0, 4); - if (bytesRead < 2) - return EncodingType.None; - - if (bytesRead >= 3 & (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)) - return EncodingType.Utf8; - - if (bytesRead == 4) { - var value = BitConverter.ToUInt32(bytes, 0); - if (value == 0x0000FEFF | value == 0xFEFF0000) - return EncodingType.Utf32; - } - - var value16 = BitConverter.ToUInt16(bytes, 0); - if (value16 == (ushort)0xFEFF | value16 == (ushort)0xFFFE) - return EncodingType.Utf16; - - return EncodingType.Unknown; - } -} -// The example displays the following output: -// Unhandled Exception: System.NotSupportedException: Stream does not support reading. -// at System.IO.FileStream.BeginRead(Byte[] array, Int32 offset, Int32 numBytes, AsyncCallback callback, Object state) -// at System.IO.Stream.<>c.b__46_0(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state) -// at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance, TArgs](TInstance thisRef, TArgs args, Func`5 beginMethod, Func`3 endMethod) -// at System.IO.Stream.BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count) -// at System.IO.FileStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) -// at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count) -// at FileUtilities.GetEncodingType(FileStream fs) in C:\Work\docs\program.cs:line 26 -// at Example.Main() in C:\Work\docs\program.cs:line 13 -// at Example.
() -// diff --git a/snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs b/snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs deleted file mode 100644 index 5b65caace07..00000000000 --- a/snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.IO; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - String name = @".\TestFile.dat"; - var fs = new FileStream(name, - FileMode.Create, - FileAccess.Write); - Console.WriteLine("Filename: {0}, Encoding: {1}", - name, await FileUtilities.GetEncodingType(fs)); - } -} - -public class FileUtilities -{ - public enum EncodingType - { None = 0, Unknown = -1, Utf8 = 1, Utf16 = 2, Utf32 = 3 } - - // - public static async Task GetEncodingType(FileStream fs) - { - if (!fs.CanRead) - return EncodingType.Unknown; - - Byte[] bytes = new Byte[4]; - int bytesRead = await fs.ReadAsync(bytes, 0, 4); - if (bytesRead < 2) - return EncodingType.None; - - if (bytesRead >= 3 & (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)) - return EncodingType.Utf8; - - if (bytesRead == 4) { - var value = BitConverter.ToUInt32(bytes, 0); - if (value == 0x0000FEFF | value == 0xFEFF0000) - return EncodingType.Utf32; - } - - var value16 = BitConverter.ToUInt16(bytes, 0); - if (value16 == (ushort)0xFEFF | value16 == (ushort)0xFFFE) - return EncodingType.Utf16; - - return EncodingType.Unknown; - } -} -// The example displays the following output: -// Filename: .\TestFile.dat, Encoding: Unknown -// diff --git a/snippets/csharp/System/PredicateT/Overview/source.cs b/snippets/csharp/System/PredicateT/Overview/source.cs deleted file mode 100644 index 02b663f607c..00000000000 --- a/snippets/csharp/System/PredicateT/Overview/source.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; -using System.Drawing; - -public class Example -{ - public static void Main() - { - // Create an array of five Point structures. - Point[] points = { new Point(100, 200), - new Point(150, 250), new Point(250, 375), - new Point(275, 395), new Point(295, 450) }; - - // To find the first Point structure for which X times Y - // is greater than 100000, pass the array and a delegate - // that represents the ProductGT10 method to the static - // Find method of the Array class. - Point first = Array.Find(points, ProductGT10); - - // Note that you do not need to create the delegate - // explicitly, or to specify the type parameter of the - // generic method, because the C# compiler has enough - // context to determine that information for you. - - // Display the first structure found. - Console.WriteLine("Found: X = {0}, Y = {1}", first.X, first.Y); - } - - // This method implements the test condition for the Find - // method. - private static bool ProductGT10(Point p) - { - if (p.X * p.Y > 100000) - { - return true; - } - else - { - return false; - } - } -} - -/* This code example produces the following output: - -Found: X = 275, Y = 395 - */ -// diff --git a/snippets/csharp/System/SByte/Parse/parse.cs b/snippets/csharp/System/SByte/Parse/parse.cs deleted file mode 100644 index eaf195c37cf..00000000000 --- a/snippets/csharp/System/SByte/Parse/parse.cs +++ /dev/null @@ -1,149 +0,0 @@ -// -// Example of the SByte.Parse( ) methods. -using System; -using System.Globalization; - -class SByteParseDemo -{ - static void SByteParse( NumberStyles styles, - IFormatProvider provider ) - { - string[ ] sbyteFormats = { - " 99 ", " +123 ", " (123) ", - " -123 ", " 1_2_3", " 7E " }; - - // Parse each string in the sbyteFormats array, using - // NumberStyles and IFormatProvider, if specified. - foreach( string sbyteString in sbyteFormats ) - { - SByte sbyteNumber; - - // Display the first part of the output line. - Console.Write( " Parse of {0,-12}", - String.Format( "\"{0}\"", sbyteString ) ); - - try - { - // Use the appropriate SByte.Parse overload, based - // on the parameters that are specified. - if( provider == null ) - if( styles < 0 ) - sbyteNumber = SByte.Parse( sbyteString ); - else - sbyteNumber = - SByte.Parse( sbyteString, styles ); - else if( styles < 0 ) - sbyteNumber = - SByte.Parse( sbyteString, provider ); - else - sbyteNumber = SByte.Parse( - sbyteString, styles, provider ); - - // Display the resulting value if Parse succeeded. - Console.WriteLine( "succeeded: {0}", - sbyteNumber ); - } - catch( Exception ex ) - { - // Display the exception message if Parse failed. - Console.WriteLine( "failed: {0}", ex.Message ); - } - } - } - - static void RunParseDemo( ) - { - // Do not use IFormatProvider or NumberStyles. - Console.WriteLine( - "\nNumberStyles and IFormatProvider are not used:" ); - SByteParse( (NumberStyles)(-1), null ); - - // Use NumberStyles.HexNumber; do not use IFormatProvider. - Console.WriteLine( "\nNumberStyles.HexNumber " + - "is used; IFormatProvider is not used:" ); - SByteParse( NumberStyles.HexNumber, null ); - - // Get the NumberFormatInfo object from the invariant - // culture, and enable parentheses to indicate negative. - CultureInfo culture = new CultureInfo( "" ); - NumberFormatInfo numFormat = culture.NumberFormat; - numFormat.NumberNegativePattern = 0; - - // Change the digit group separator to '_' and the digit - // group size to 1. - numFormat.NumberGroupSeparator = "_"; - numFormat.NumberGroupSizes = new int[ ] { 1 }; - - // Use the NumberFormatInfo object as the IFormatProvider. - Console.WriteLine( "\nA NumberStyles value is not used, " + - "but the IFormatProvider sets the group \nseparator = " + - "'_', group size = 1, and negative pattern = ( ):" ); - SByteParse( (NumberStyles)(-1), numFormat ); - - // Use NumberStyles.Number and NumberStyles.AllowParentheses. - Console.WriteLine( - "\nNumberStyles.Number, NumberStyles.AllowParentheses, " + - "and the same \nIFormatProvider are used:" ); - SByteParse( NumberStyles.Number | - NumberStyles.AllowParentheses, numFormat ); - } - - static void Main( ) - { - Console.WriteLine( "This example of\n" + - " SByte.Parse( String ),\n" + - " SByte.Parse( String, NumberStyles ),\n" + - " SByte.Parse( String, IFormatProvider ), and\n" + - " SByte.Parse( String, NumberStyles, IFormatProvider )" + - "\ngenerates the following output when parsing " + - "string representations\nof SByte values with each " + - "of these forms of SByte.Parse( )." ); - - RunParseDemo( ); - } -} - -/* -This example of - SByte.Parse( String ), - SByte.Parse( String, NumberStyles ), - SByte.Parse( String, IFormatProvider ), and - SByte.Parse( String, NumberStyles, IFormatProvider ) -generates the following output when parsing string representations -of SByte values with each of these forms of SByte.Parse( ). - -NumberStyles and IFormatProvider are not used: - Parse of " 99 " succeeded: 99 - Parse of " +123 " succeeded: 123 - Parse of " (123) " failed: Input string was not in a correct format. - Parse of " -123 " succeeded: -123 - Parse of " 1_2_3" failed: Input string was not in a correct format. - Parse of " 7E " failed: Input string was not in a correct format. - -NumberStyles.HexNumber is used; IFormatProvider is not used: - Parse of " 99 " succeeded: -103 - Parse of " +123 " failed: Input string was not in a correct format. - Parse of " (123) " failed: Input string was not in a correct format. - Parse of " -123 " failed: Input string was not in a correct format. - Parse of " 1_2_3" failed: Input string was not in a correct format. - Parse of " 7E " succeeded: 126 - -A NumberStyles value is not used, but the IFormatProvider sets the group -separator = '_', group size = 1, and negative pattern = ( ): - Parse of " 99 " succeeded: 99 - Parse of " +123 " succeeded: 123 - Parse of " (123) " failed: Input string was not in a correct format. - Parse of " -123 " succeeded: -123 - Parse of " 1_2_3" failed: Input string was not in a correct format. - Parse of " 7E " failed: Input string was not in a correct format. - -NumberStyles.Number, NumberStyles.AllowParentheses, and the same -IFormatProvider are used: - Parse of " 99 " succeeded: 99 - Parse of " +123 " succeeded: 123 - Parse of " (123) " succeeded: -123 - Parse of " -123 " succeeded: -123 - Parse of " 1_2_3" succeeded: 123 - Parse of " 7E " failed: Input string was not in a correct format. -*/ -// diff --git a/snippets/csharp/System/SByte/Parse/parseex4.cs b/snippets/csharp/System/SByte/Parse/parseex4.cs deleted file mode 100644 index 69f2a38dc24..00000000000 --- a/snippets/csharp/System/SByte/Parse/parseex4.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -using System; -using System.Globalization; - -public class Example -{ - public static void Main() - { - string[] cultureNames = { "en-US", "fr-FR" }; - NumberStyles[] styles= { NumberStyles.Integer, - NumberStyles.Integer | NumberStyles.AllowDecimalPoint }; - string[] values = { "-17", "-17.0", "-17,0", "+103.00", "+103,00" }; - - // Parse strings using each culture - foreach (string cultureName in cultureNames) - { - CultureInfo ci = new CultureInfo(cultureName); - Console.WriteLine("Parsing strings using the {0} culture", - ci.DisplayName); - // Use each style. - foreach (NumberStyles style in styles) - { - Console.WriteLine(" Style: {0}", style.ToString()); - // Parse each numeric string. - foreach (string value in values) - { - try { - Console.WriteLine(" Converted '{0}' to {1}.", value, - SByte.Parse(value, style, ci)); - } - catch (FormatException) { - Console.WriteLine(" Unable to parse '{0}'.", value); - } - catch (OverflowException) { - Console.WriteLine(" '{0}' is out of range of the SByte type.", - value); - } - } - } - } - } -} -// The example displays the following output: -// Parsing strings using the English (United States) culture -// Style: Integer -// Converted '-17' to -17. -// Unable to parse '-17.0'. -// Unable to parse '-17,0'. -// Unable to parse '+103.00'. -// Unable to parse '+103,00'. -// Style: Integer, AllowDecimalPoint -// Converted '-17' to -17. -// Converted '-17.0' to -17. -// Unable to parse '-17,0'. -// Converted '+103.00' to 103. -// Unable to parse '+103,00'. -// Parsing strings using the French (France) culture -// Style: Integer -// Converted '-17' to -17. -// Unable to parse '-17.0'. -// Unable to parse '-17,0'. -// Unable to parse '+103.00'. -// Unable to parse '+103,00'. -// Style: Integer, AllowDecimalPoint -// Converted '-17' to -17. -// Unable to parse '-17.0'. -// Converted '-17,0' to -17. -// Unable to parse '+103.00'. -// Converted '+103,00' to 103. -// diff --git a/snippets/csharp/System/SByte/ToString/tostring.cs b/snippets/csharp/System/SByte/ToString/tostring.cs deleted file mode 100644 index 8c934302856..00000000000 --- a/snippets/csharp/System/SByte/ToString/tostring.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -// Example for the SByte.ToString( ) methods. -using System; -using System.Globalization; - -public class SByteToStringDemo -{ - static void RunToStringDemo( ) - { - SByte smallValue = -99; - SByte largeValue = 123; - - // Format the SByte values without and with format strings. - Console.WriteLine( "\nIFormatProvider is not used:" ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "No format string:", smallValue.ToString( ), - largeValue.ToString( ) ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "'X2' format string:", smallValue.ToString( "X2" ), - largeValue.ToString( "X2" ) ); - - // Get the NumberFormatInfo object from the - // invariant culture. - CultureInfo culture = new CultureInfo( "" ); - NumberFormatInfo numInfo = culture.NumberFormat; - - // Set decimal digits to 0. Set the negative pattern to ( ). - numInfo.NumberDecimalDigits = 0; - numInfo.NumberNegativePattern = 0; - - // Use the NumberFormatInfo object for an IFormatProvider. - Console.WriteLine( "\nA NumberFormatInfo " + - "object with negative pattern = ( ) and \nno " + - "decimal digits is used for the IFormatProvider:" ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "No format string:", smallValue.ToString( numInfo ), - largeValue.ToString( numInfo ) ); - Console.WriteLine( " {0,-20}{1,10}{2,10}", - "'N' format string:", - smallValue.ToString( "N", numInfo ), - largeValue.ToString( "N", numInfo ) ); - } - - static void Main( ) - { - Console.WriteLine( - "This example of\n SByte.ToString( ),\n" + - " SByte.ToString( string ),\n" + - " SByte.ToString( IFormatProvider ), and\n" + - " SByte.ToString( string, IFormatProvider )\n" + - "generates the following output when formatting " + - "SByte values \nwith combinations of format " + - "strings and IFormatProvider." ); - - RunToStringDemo( ); - } -} - -/* -This example of - SByte.ToString( ), - SByte.ToString( string ), - SByte.ToString( IFormatProvider ), and - SByte.ToString( string, IFormatProvider ) -generates the following output when formatting SByte values -with combinations of format strings and IFormatProvider. - -IFormatProvider is not used: - No format string: -99 123 - 'X2' format string: 9D 7B - -A NumberFormatInfo object with negative pattern = ( ) and -no decimal digits is used for the IFormatProvider: - No format string: -99 123 - 'N' format string: (99) 123 -*/ -// diff --git a/snippets/csharp/System/Single/Overview/PrecisionList5a.cs b/snippets/csharp/System/Single/Overview/PrecisionList5a.cs deleted file mode 100644 index d4d1300def6..00000000000 --- a/snippets/csharp/System/Single/Overview/PrecisionList5a.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - sw.Write("{0:G9}{1}", values[ctr], ctr < values.Length - 1 ? "|" : "" ); - - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 = 2.882883 -// 0.3333333 = 0.3333333 -// 3.141593 = 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/comparison1.cs b/snippets/csharp/System/Single/Overview/comparison1.cs deleted file mode 100644 index d7ba9b768c6..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison1.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = .3333333f; - float value2 = 1.0f/3; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.3333333 = 0.333333343: False -// diff --git a/snippets/csharp/System/Single/Overview/comparison2.cs b/snippets/csharp/System/Single/Overview/comparison2.cs deleted file mode 100644 index ea7269c7d7f..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison2.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = 10.201438f; - value1 = (float) Math.Sqrt((float) Math.Pow(value1, 2)); - float value2 = (float) Math.Pow((float) value1 * 3.51f, 2); - value2 = ((float) Math.Sqrt(value2)) / 3.51f; - Console.WriteLine("{0} = {1}: {2}\n", - value1, value2, value1.Equals(value2)); - Console.WriteLine("{0:G9} = {1:G9}", value1, value2); - } -} -// The example displays the following output: -// 10.20144 = 10.20144: False -// -// 10.201438 = 10.2014389 -// diff --git a/snippets/csharp/System/Single/Overview/comparison3.cs b/snippets/csharp/System/Single/Overview/comparison3.cs deleted file mode 100644 index d520a83a65a..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison3.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = .3333333f; - float value2 = 1.0f/3; - int precision = 7; - value1 = (float) Math.Round(value1, precision); - value2 = (float) Math.Round(value2, precision); - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.3333333 = 0.3333333: True -// diff --git a/snippets/csharp/System/Single/Overview/comparison4.cs b/snippets/csharp/System/Single/Overview/comparison4.cs deleted file mode 100644 index a4fb50ea529..00000000000 --- a/snippets/csharp/System/Single/Overview/comparison4.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float one1 = .1f * 10; - float one2 = 0f; - for (int ctr = 1; ctr <= 10; ctr++) - one2 += .1f; - - Console.WriteLine("{0:R} = {1:R}: {2}", one1, one2, one1.Equals(one2)); - Console.WriteLine("{0:R} is approximately equal to {1:R}: {2}", - one1, one2, - IsApproximatelyEqual(one1, one2, .000001f)); - } - - static bool IsApproximatelyEqual(float value1, float value2, float epsilon) - { - // If they are equal anyway, just return True. - if (value1.Equals(value2)) - return true; - - // Handle NaN, Infinity. - if (Double.IsInfinity(value1) | Double.IsNaN(value1)) - return value1.Equals(value2); - else if (Double.IsInfinity(value2) | Double.IsNaN(value2)) - return value1.Equals(value2); - - // Handle zero to avoid division by zero - double divisor = Math.Max(value1, value2); - if (divisor.Equals(0)) - divisor = Math.Min(value1, value2); - - return Math.Abs(value1 - value2)/divisor <= epsilon; - } -} -// The example displays the following output: -// 1 = 1.00000012: False -// 1 is approximately equal to 1.00000012: True -// diff --git a/snippets/csharp/System/Single/Overview/convert1.cs b/snippets/csharp/System/Single/Overview/convert1.cs deleted file mode 100644 index 1feb509fe08..00000000000 --- a/snippets/csharp/System/Single/Overview/convert1.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - dynamic[] values = { Byte.MinValue, Byte.MaxValue, Decimal.MinValue, - Decimal.MaxValue, Double.MinValue, Double.MaxValue, - Int16.MinValue, Int16.MaxValue, Int32.MinValue, - Int32.MaxValue, Int64.MinValue, Int64.MaxValue, - SByte.MinValue, SByte.MaxValue, UInt16.MinValue, - UInt16.MaxValue, UInt32.MinValue, UInt32.MaxValue, - UInt64.MinValue, UInt64.MaxValue }; - float sngValue; - foreach (var value in values) { - if (value.GetType() == typeof(Decimal) || - value.GetType() == typeof(Double)) - sngValue = (float) value; - else - sngValue = value; - Console.WriteLine("{0} ({1}) --> {2:R} ({3})", - value, value.GetType().Name, - sngValue, sngValue.GetType().Name); - } - } -} -// The example displays the following output: -// 0 (Byte) --> 0 (Single) -// 255 (Byte) --> 255 (Single) -// -79228162514264337593543950335 (Decimal) --> -7.92281625E+28 (Single) -// 79228162514264337593543950335 (Decimal) --> 7.92281625E+28 (Single) -// -1.79769313486232E+308 (Double) --> -Infinity (Single) -// 1.79769313486232E+308 (Double) --> Infinity (Single) -// -32768 (Int16) --> -32768 (Single) -// 32767 (Int16) --> 32767 (Single) -// -2147483648 (Int32) --> -2.14748365E+09 (Single) -// 2147483647 (Int32) --> 2.14748365E+09 (Single) -// -9223372036854775808 (Int64) --> -9.223372E+18 (Single) -// 9223372036854775807 (Int64) --> 9.223372E+18 (Single) -// -128 (SByte) --> -128 (Single) -// 127 (SByte) --> 127 (Single) -// 0 (UInt16) --> 0 (Single) -// 65535 (UInt16) --> 65535 (Single) -// 0 (UInt32) --> 0 (Single) -// 4294967295 (UInt32) --> 4.2949673E+09 (Single) -// 0 (UInt64) --> 0 (Single) -// 18446744073709551615 (UInt64) --> 1.84467441E+19 (Single) -// diff --git a/snippets/csharp/System/Single/Overview/convert2.cs b/snippets/csharp/System/Single/Overview/convert2.cs deleted file mode 100644 index 491165a52d4..00000000000 --- a/snippets/csharp/System/Single/Overview/convert2.cs +++ /dev/null @@ -1,143 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float[] values = { Single.MinValue, -67890.1234f, -12345.6789f, - 12345.6789f, 67890.1234f, Single.MaxValue, - Single.NaN, Single.PositiveInfinity, - Single.NegativeInfinity }; - checked { - foreach (var value in values) { - try { - Int64 lValue = (long) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - lValue, lValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Int64.", value); - } - try { - UInt64 ulValue = (ulong) value; - Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})", - value, value.GetType().Name, - ulValue, ulValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to UInt64.", value); - } - try { - Decimal dValue = (decimal) value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - dValue, dValue.GetType().Name); - } - catch (OverflowException) { - Console.WriteLine("Unable to convert {0} to Decimal.", value); - } - - Double dblValue = value; - Console.WriteLine("{0} ({1}) --> {2} ({3})", - value, value.GetType().Name, - dblValue, dblValue.GetType().Name); - Console.WriteLine(); - } - } - } -} -// The example displays the following output for conversions performed -// in a checked context: -// Unable to convert -3.402823E+38 to Int64. -// Unable to convert -3.402823E+38 to UInt64. -// Unable to convert -3.402823E+38 to Decimal. -// -3.402823E+38 (Single) --> -3.40282346638529E+38 (Double) -// -// -67890.13 (Single) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// Unable to convert -67890.13 to UInt64. -// -67890.13 (Single) --> -67890.12 (Decimal) -// -67890.13 (Single) --> -67890.125 (Double) -// -// -12345.68 (Single) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// Unable to convert -12345.68 to UInt64. -// -12345.68 (Single) --> -12345.68 (Decimal) -// -12345.68 (Single) --> -12345.6787109375 (Double) -// -// 12345.68 (Single) --> 12345 (0x0000000000003039) (Int64) -// 12345.68 (Single) --> 12345 (0x0000000000003039) (UInt64) -// 12345.68 (Single) --> 12345.68 (Decimal) -// 12345.68 (Single) --> 12345.6787109375 (Double) -// -// 67890.13 (Single) --> 67890 (0x0000000000010932) (Int64) -// 67890.13 (Single) --> 67890 (0x0000000000010932) (UInt64) -// 67890.13 (Single) --> 67890.12 (Decimal) -// 67890.13 (Single) --> 67890.125 (Double) -// -// Unable to convert 3.402823E+38 to Int64. -// Unable to convert 3.402823E+38 to UInt64. -// Unable to convert 3.402823E+38 to Decimal. -// 3.402823E+38 (Single) --> 3.40282346638529E+38 (Double) -// -// Unable to convert NaN to Int64. -// Unable to convert NaN to UInt64. -// Unable to convert NaN to Decimal. -// NaN (Single) --> NaN (Double) -// -// Unable to convert Infinity to Int64. -// Unable to convert Infinity to UInt64. -// Unable to convert Infinity to Decimal. -// Infinity (Single) --> Infinity (Double) -// -// Unable to convert -Infinity to Int64. -// Unable to convert -Infinity to UInt64. -// Unable to convert -Infinity to Decimal. -// -Infinity (Single) --> -Infinity (Double) -// The example displays the following output for conversions performed -// in an unchecked context: -// -3.402823E+38 (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -3.402823E+38 (Single) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -3.402823E+38 to Decimal. -// -3.402823E+38 (Single) --> -3.40282346638529E+38 (Double) -// -// -67890.13 (Single) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64) -// -67890.13 (Single) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64) -// -67890.13 (Single) --> -67890.12 (Decimal) -// -67890.13 (Single) --> -67890.125 (Double) -// -// -12345.68 (Single) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64) -// -12345.68 (Single) --> 18446744073709539271 (0xFFFFFFFFFFFFCFC7) (UInt64) -// -12345.68 (Single) --> -12345.68 (Decimal) -// -12345.68 (Single) --> -12345.6787109375 (Double) -// -// 12345.68 (Single) --> 12345 (0x0000000000003039) (Int64) -// 12345.68 (Single) --> 12345 (0x0000000000003039) (UInt64) -// 12345.68 (Single) --> 12345.68 (Decimal) -// 12345.68 (Single) --> 12345.6787109375 (Double) -// -// 67890.13 (Single) --> 67890 (0x0000000000010932) (Int64) -// 67890.13 (Single) --> 67890 (0x0000000000010932) (UInt64) -// 67890.13 (Single) --> 67890.12 (Decimal) -// 67890.13 (Single) --> 67890.125 (Double) -// -// 3.402823E+38 (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// 3.402823E+38 (Single) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert 3.402823E+38 to Decimal. -// 3.402823E+38 (Single) --> 3.40282346638529E+38 (Double) -// -// NaN (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// NaN (Single) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert NaN to Decimal. -// NaN (Single) --> NaN (Double) -// -// Infinity (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// Infinity (Single) --> 0 (0x0000000000000000) (UInt64) -// Unable to convert Infinity to Decimal. -// Infinity (Single) --> Infinity (Double) -// -// -Infinity (Single) --> -9223372036854775808 (0x8000000000000000) (Int64) -// -Infinity (Single) --> 9223372036854775808 (0x8000000000000000) (UInt64) -// Unable to convert -Infinity to Decimal. -// -Infinity (Single) --> -Infinity (Double) -// diff --git a/snippets/csharp/System/Single/Overview/exceptional1.cs b/snippets/csharp/System/Single/Overview/exceptional1.cs deleted file mode 100644 index 1bdda06c237..00000000000 --- a/snippets/csharp/System/Single/Overview/exceptional1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = 1.163287e-36f; - float value2 = 9.164234e-25f; - float result = value1 * value2; - Console.WriteLine("{0} * {1} = {2}", value1, value2, result); - Console.WriteLine("{0} = 0: {1}", result, result.Equals(0.0f)); - } -} -// The example displays the following output: -// 1.163287E-36 * 9.164234E-25 = 0 -// 0 = 0: True -// diff --git a/snippets/csharp/System/Single/Overview/exceptional2.cs b/snippets/csharp/System/Single/Overview/exceptional2.cs deleted file mode 100644 index 9b6f111f9c2..00000000000 --- a/snippets/csharp/System/Single/Overview/exceptional2.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - float value1 = 3.065e35f; - float value2 = 6.9375e32f; - float result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Single.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}\n", - Single.IsNegativeInfinity(result)); - - value1 = -value1; - result = value1 * value2; - Console.WriteLine("PositiveInfinity: {0}", - Single.IsPositiveInfinity(result)); - Console.WriteLine("NegativeInfinity: {0}", - Single.IsNegativeInfinity(result)); - } -} - -// The example displays the following output: -// PositiveInfinity: True -// NegativeInfinity: False -// -// PositiveInfinity: False -// NegativeInfinity: True -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist1.cs b/snippets/csharp/System/Single/Overview/precisionlist1.cs deleted file mode 100644 index 013abcb6980..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist1.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Double value1 = 1/3.0; - Single sValue2 = 1/3.0f; - Double value2 = (Double) sValue2; - Console.WriteLine("{0:R} = {1:R}: {2}", value1, value2, - value1.Equals(value2)); - } -} -// The example displays the following output: -// 0.33333333333333331 = 0.3333333432674408: False -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist3.cs b/snippets/csharp/System/Single/Overview/precisionlist3.cs deleted file mode 100644 index 916bbc9bfe3..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist3.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Single[] values = { 10.01f, 2.88f, 2.88f, 2.88f, 9.0f }; - Single result = 27.65f; - Single total = 0f; - foreach (var value in values) - total += value; - - if (total.Equals(result)) - Console.WriteLine("The sum of the values equals the total."); - else - Console.WriteLine("The sum of the values ({0}) does not equal the total ({1}).", - total, result); - } -} -// The example displays the following output: -// The sum of the values (27.65) does not equal the total (27.65). -// -// If the index items in the Console.WriteLine statement are changed to {0:R}, -// the example displays the following output: -// The sum of the values (27.6500015) does not equal the total (27.65). -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist4.cs b/snippets/csharp/System/Single/Overview/precisionlist4.cs deleted file mode 100644 index 8b5076f17c3..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist4.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 <> 2.882883 -// 0.3333333 <> 0.3333333 -// 3.141593 <> 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist4a.cs b/snippets/csharp/System/Single/Overview/precisionlist4a.cs deleted file mode 100644 index 377c3d644c9..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist4a.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) { - sw.Write(values[ctr].ToString()); - if (ctr != values.Length - 1) - sw.Write("|"); - } - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 <> 2.882883 -// 0.3333333 <> 0.3333333 -// 3.141593 <> 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/precisionlist5.cs b/snippets/csharp/System/Single/Overview/precisionlist5.cs deleted file mode 100644 index 714592c5e12..00000000000 --- a/snippets/csharp/System/Single/Overview/precisionlist5.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.IO; - -public class Example -{ - public static void Main() - { - StreamWriter sw = new StreamWriter(@".\Singles.dat"); - Single[] values = { 3.2f/1.11f, 1.0f/3f, (float) Math.PI }; - for (int ctr = 0; ctr < values.Length; ctr++) - sw.Write("{0:R}{1}", values[ctr], ctr < values.Length - 1 ? "|" : "" ); - - sw.Close(); - - Single[] restoredValues = new Single[values.Length]; - StreamReader sr = new StreamReader(@".\Singles.dat"); - string temp = sr.ReadToEnd(); - string[] tempStrings = temp.Split('|'); - for (int ctr = 0; ctr < tempStrings.Length; ctr++) - restoredValues[ctr] = Single.Parse(tempStrings[ctr]); - - for (int ctr = 0; ctr < values.Length; ctr++) - Console.WriteLine("{0} {2} {1}", values[ctr], - restoredValues[ctr], - values[ctr].Equals(restoredValues[ctr]) ? "=" : "<>"); - } -} -// The example displays the following output: -// 2.882883 = 2.882883 -// 0.3333333 = 0.3333333 -// 3.141593 = 3.141593 -// diff --git a/snippets/csharp/System/Single/Overview/representation1.cs b/snippets/csharp/System/Single/Overview/representation1.cs deleted file mode 100644 index c661ce90c7e..00000000000 --- a/snippets/csharp/System/Single/Overview/representation1.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Single value = .2f; - Single result1 = value * 10f; - Single result2 = 0f; - for (int ctr = 1; ctr <= 10; ctr++) - result2 += value; - - Console.WriteLine(".2 * 10: {0:R}", result1); - Console.WriteLine(".2 Added 10 times: {0:R}", result2); - } -} -// The example displays the following output: -// .2 * 10: 2 -// .2 Added 10 times: 2.00000024 -// diff --git a/snippets/csharp/System/Single/Overview/representation2.cs b/snippets/csharp/System/Single/Overview/representation2.cs deleted file mode 100644 index 94a4ad65cf8..00000000000 --- a/snippets/csharp/System/Single/Overview/representation2.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Single value = 123.456f; - Single additional = Single.Epsilon * 1e15f; - Console.WriteLine($"{value} + {additional} = {value + additional}"); - } -} -// The example displays the following output: -// 123.456 + 1.401298E-30 = 123.456 -// diff --git a/snippets/csharp/System/Single/Parse/parse.cs b/snippets/csharp/System/Single/Parse/parse.cs deleted file mode 100644 index b919ed8fde4..00000000000 --- a/snippets/csharp/System/Single/Parse/parse.cs +++ /dev/null @@ -1,156 +0,0 @@ -// -// Example of the Single.Parse( ) methods. -using System; -using System.Globalization; - -class SingleParseDemo -{ - // Get the exception type name; remove the namespace prefix. - static string GetExceptionType( Exception ex ) - { - string exceptionType = ex.GetType( ).ToString( ); - return exceptionType.Substring( - exceptionType.LastIndexOf( '.' )+1 ); - } - - // Parse each string in the singleFormats array, using - // NumberStyles and IFormatProvider, if specified. - static void SingleParse( NumberStyles styles, - IFormatProvider provider ) - { - string[ ] singleFormats = { - " 987.654E-2", " 987,654E-2", "(98765,43210)", - "9,876,543.210", "9.876.543,210", "98_76_54_32,19" }; - - foreach( string singleString in singleFormats ) - { - float singleNumber; - - // Display the first part of the output line. - Console.Write( " Parse of {0,-20}", - String.Format( "\"{0}\"", singleString ) ); - - try - { - // Use the appropriate Single.Parse overload, based - // on the parameters that are specified. - if( provider == null ) - { - if( styles < 0 ) - singleNumber = Single.Parse( singleString ); - else - singleNumber = - Single.Parse( singleString, styles ); - } - else if( styles < 0 ) - singleNumber = - Single.Parse( singleString, provider ); - else - singleNumber = - Single.Parse( singleString, styles, provider ); - - // Display the resulting value if Parse succeeded. - Console.WriteLine( "success: {0}", singleNumber ); - } - catch( Exception ex ) - { - // Display the exception type if Parse failed. - Console.WriteLine( "failed: {0}", - GetExceptionType( ex ) ); - } - } - } - - public static void Main( ) - { - Console.WriteLine( "This example of\n" + - " Single.Parse( String ),\n" + - " Single.Parse( String, NumberStyles ),\n" + - " Single.Parse( String, IFormatProvider ), and\n" + - " Single.Parse( String, NumberStyles, " + - "IFormatProvider )\ngenerates the " + - "following output when run in the [{0}] culture.", - CultureInfo.CurrentCulture.Name ); - Console.WriteLine( "Several string representations " + - "of Single values are parsed." ); - - // Do not use IFormatProvider or NumberStyles. - Console.WriteLine( "\nNumberStyles and IFormatProvider " + - "are not used; current culture is [{0}]:", - CultureInfo.CurrentCulture.Name ); - SingleParse( ( (NumberStyles)( -1 ) ), null ); - - // Use the NumberStyle for Currency. - Console.WriteLine( "\nNumberStyles.Currency " + - "is used; IFormatProvider is not used:" ); - SingleParse( NumberStyles.Currency, null ); - - // Create a CultureInfo object for another culture. Use - // [Dutch - The Netherlands] unless the current culture - // is Dutch language. In that case use [English - U.S.]. - string cultureName = - CultureInfo.CurrentCulture.Name.Substring( 0, 2 ) == "nl" ? - "en-US" : "nl-NL"; - CultureInfo culture = new CultureInfo( cultureName ); - - Console.WriteLine( "\nNumberStyles is not used; " + - "[{0}] culture IFormatProvider is used:", - culture.Name ); - SingleParse( ( (NumberStyles)( -1 ) ), culture ); - - // Get the NumberFormatInfo object from CultureInfo, and - // then change the digit group size to 2 and the digit - // separator to '_'. - NumberFormatInfo numInfo = culture.NumberFormat; - numInfo.NumberGroupSizes = new int[ ] { 2 }; - numInfo.NumberGroupSeparator = "_"; - - // Use the NumberFormatInfo object as the IFormatProvider. - Console.WriteLine( "\nNumberStyles.Currency is used, " + - "group size = 2, separator = \"_\":" ); - SingleParse( NumberStyles.Currency, numInfo ); - } -} - -/* -This example of - Single.Parse( String ), - Single.Parse( String, NumberStyles ), - Single.Parse( String, IFormatProvider ), and - Single.Parse( String, NumberStyles, IFormatProvider ) -generates the following output when run in the [en-US] culture. -Several string representations of Single values are parsed. - -NumberStyles and IFormatProvider are not used; current culture is [en-US]: - Parse of " 987.654E-2" success: 9.87654 - Parse of " 987,654E-2" success: 9876.54 - Parse of "(98765,43210)" failed: FormatException - Parse of "9,876,543.210" success: 9876543 - Parse of "9.876.543,210" failed: FormatException - Parse of "98_76_54_32,19" failed: FormatException - -NumberStyles.Currency is used; IFormatProvider is not used: - Parse of " 987.654E-2" failed: FormatException - Parse of " 987,654E-2" failed: FormatException - Parse of "(98765,43210)" success: -9.876543E+09 - Parse of "9,876,543.210" success: 9876543 - Parse of "9.876.543,210" failed: FormatException - Parse of "98_76_54_32,19" failed: FormatException - -NumberStyles is not used; [nl-NL] culture IFormatProvider is used: - Parse of " 987.654E-2" success: 9876.54 - Parse of " 987,654E-2" success: 9.87654 - Parse of "(98765,43210)" failed: FormatException - Parse of "9,876,543.210" failed: FormatException - Parse of "9.876.543,210" success: 9876543 - Parse of "98_76_54_32,19" failed: FormatException - -NumberStyles.Currency is used, group size = 2, separator = "_": - Parse of " 987.654E-2" failed: FormatException - Parse of " 987,654E-2" failed: FormatException - Parse of "(98765,43210)" success: -98765.43 - Parse of "9,876,543.210" failed: FormatException - Parse of "9.876.543,210" success: 9876543 - Parse of "98_76_54_32,19" success: 9.876543E+07 -*/ -// diff --git a/snippets/csharp/System/String/.ctor/makefile b/snippets/csharp/System/String/.ctor/makefile deleted file mode 100644 index f19149e6a0d..00000000000 --- a/snippets/csharp/System/String/.ctor/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all : source.dll - -source.dll : source.cs - csc /t:library /unsafe source.cs \ No newline at end of file diff --git a/snippets/csharp/System/String/IndexOf/ignorable1.cs b/snippets/csharp/System/String/IndexOf/ignorable1.cs deleted file mode 100644 index 44549f12460..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable1.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD")); - Console.WriteLine(s2.IndexOf("\u00AD")); - - // Find the index of the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn")); - Console.WriteLine(s2.IndexOf("\u00ADn")); - - // Find the index of the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm")); - Console.WriteLine(s2.IndexOf("\u00ADm")); - } -} -// The example displays the following output if run under -// .NET 4 or later: -// 0 -// 0 -// 1 -// 1 -// 4 -// 3 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable10.cs b/snippets/csharp/System/String/IndexOf/ignorable10.cs deleted file mode 100644 index a0f7341c51b..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable10.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, s1.Length - position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, s1.Length - position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, s2.Length - position)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, s1.Length - position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, s2.Length - position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable12.cs b/snippets/csharp/System/String/IndexOf/ignorable12.cs deleted file mode 100644 index 1a69627a260..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable12.cs +++ /dev/null @@ -1,124 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, - s1.Length - position, StringComparison.CurrentCulture)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, - s2.Length - position, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, - s1.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, - s2.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, - s1.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, - s2.Length - position, StringComparison.CurrentCultureIgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, - s1.Length - position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, - s2.Length - position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, - s1.Length - position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, - s2.Length - position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, - s1.Length - position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, - s2.Length - position, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable5.cs b/snippets/csharp/System/String/IndexOf/ignorable5.cs deleted file mode 100644 index 7cd507e85d4..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable5.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - Console.WriteLine("Culture-sensitive comparison:"); - // Use culture-sensitive comparison to find the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.CurrentCulture)); - Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.CurrentCulture)); - - Console.WriteLine("Ordinal comparison:"); - // Use ordinal comparison to find the soft hyphen. - Console.WriteLine(s1.IndexOf("\u00AD", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00AD", StringComparison.Ordinal)); - - // Use ordinal comparison to find the soft hyphen followed by "n". - Console.WriteLine(s1.IndexOf("\u00ADn", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00ADn", StringComparison.Ordinal)); - - // Use ordinal comparison to find the soft hyphen followed by "m". - Console.WriteLine(s1.IndexOf("\u00ADm", StringComparison.Ordinal)); - Console.WriteLine(s2.IndexOf("\u00ADm", StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparison: -// 0 -// 0 -// 1 -// 1 -// 4 -// 3 -// Ordinal comparison: -// 3 -// -1 -// -1 -// -1 -// 3 -// -1 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable6.cs b/snippets/csharp/System/String/IndexOf/ignorable6.cs deleted file mode 100644 index 2f96426aa85..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable6.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position)); - } -} -// The example displays the following output: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// diff --git a/snippets/csharp/System/String/IndexOf/ignorable9.cs b/snippets/csharp/System/String/IndexOf/ignorable9.cs deleted file mode 100644 index 33ce8550f14..00000000000 --- a/snippets/csharp/System/String/IndexOf/ignorable9.cs +++ /dev/null @@ -1,113 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00AD", position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00AD", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADn", position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADn", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.IndexOf("\u00ADm", position, StringComparison.Ordinal)); - - position = s2.IndexOf("n"); - Console.WriteLine("'n' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.IndexOf("\u00ADm", position, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 1 -// 'n' at position 1 -// 4 -// 'n' at position 1 -// 3 -// -// Ordinal comparisons: -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// -1 -// 'n' at position 1 -// 3 -// 'n' at position 1 -// -1 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable1.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable1.cs deleted file mode 100644 index 036f569571a..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable1.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the last soft hyphen. - Console.WriteLine(s1.LastIndexOf("\u00AD")); - Console.WriteLine(s2.LastIndexOf("\u00AD")); - - // Find the index of the last soft hyphen followed by "n". - Console.WriteLine(s1.LastIndexOf("\u00ADn")); - Console.WriteLine(s2.LastIndexOf("\u00ADn")); - - // Find the index of the last soft hyphen followed by "m". - Console.WriteLine(s1.LastIndexOf("\u00ADm")); - Console.WriteLine(s2.LastIndexOf("\u00ADm")); - } -} -// The example displays the following output: -// 6 -// 5 -// 1 -// 1 -// 4 -// 3 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable10.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable10.cs deleted file mode 100644 index 41431515a47..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable10.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, position + 1)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, position + 1)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, position + 1)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, position + 1)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, position + 1)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, position + 1)); - } -} -// The example displays the following output: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable12.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable12.cs deleted file mode 100644 index f2ba187d07b..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable12.cs +++ /dev/null @@ -1,124 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // All the following comparisons are culture-sensitive. - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, - position + 1, StringComparison.CurrentCulture)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, - position + 1, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.CurrentCultureIgnoreCase)); - - // All the following comparisons are ordinal. - Console.WriteLine("\nOrdinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, - position + 1, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, - position + 1, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, - position + 1, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, - position + 1, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 1 -// 'm' at position 1 -// 4 -// 'm' at position 1 -// 3 -// -// Ordinal comparisons: -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// -1 -// 'm' at position 1 -// 3 -// 'm' at position 1 -// -1 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable5.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable5.cs deleted file mode 100644 index cbbfc8b7ae6..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable5.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - Console.WriteLine("Culture-sensitive comparison:"); - // Use culture-sensitive comparison to find the last soft hyphen. - Console.WriteLine(s1.LastIndexOf("\u00AD", StringComparison.CurrentCulture)); - Console.WriteLine(s2.LastIndexOf("\u00AD", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the last soft hyphen followed by "n". - Console.WriteLine(s1.LastIndexOf("\u00ADn", StringComparison.CurrentCulture)); - Console.WriteLine(s2.LastIndexOf("\u00ADn", StringComparison.CurrentCulture)); - - // Use culture-sensitive comparison to find the last soft hyphen followed by "m". - Console.WriteLine(s1.LastIndexOf("\u00ADm", StringComparison.CurrentCulture)); - Console.WriteLine(s2.LastIndexOf("\u00ADm", StringComparison.CurrentCulture)); - - Console.WriteLine("Ordinal comparison:"); - // Use ordinal comparison to find the last soft hyphen. - Console.WriteLine(s1.LastIndexOf("\u00AD", StringComparison.Ordinal)); - Console.WriteLine(s2.LastIndexOf("\u00AD", StringComparison.Ordinal)); - - // Use ordinal comparison to find the last soft hyphen followed by "n". - Console.WriteLine(s1.LastIndexOf("\u00ADn", StringComparison.Ordinal)); - Console.WriteLine(s2.LastIndexOf("\u00ADn", StringComparison.Ordinal)); - - // Use ordinal comparison to find the last soft hyphen followed by "m". - Console.WriteLine(s1.LastIndexOf("\u00ADm", StringComparison.Ordinal)); - Console.WriteLine(s2.LastIndexOf("\u00ADm", StringComparison.Ordinal)); - } -} -// The example displays the following output: -// 6 -// 5 -// 1 -// 1 -// 4 -// 3 -// Ordinal comparison: -// 3 -// -1 -// -1 -// -1 -// 3 -// -1 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable6.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable6.cs deleted file mode 100644 index 782797e58b0..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable6.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position)); - } -} -// The example displays the following output: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// diff --git a/snippets/csharp/System/String/LastIndexOf/lastignorable9.cs b/snippets/csharp/System/String/LastIndexOf/lastignorable9.cs deleted file mode 100644 index 9d973f97023..00000000000 --- a/snippets/csharp/System/String/LastIndexOf/lastignorable9.cs +++ /dev/null @@ -1,113 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - int position = 0; - - string s1 = "ani\u00ADmal"; - string s2 = "animal"; - - // Use culture-sensitive comparison for the following searches: - Console.WriteLine("Culture-sensitive comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, StringComparison.CurrentCulture)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, StringComparison.CurrentCultureIgnoreCase)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, StringComparison.CurrentCultureIgnoreCase)); - - Console.WriteLine(); - // Use ordinal comparison for the following searches: - Console.WriteLine("Ordinal comparisons:"); - // Find the index of the soft hyphen. - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00AD", position, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00AD", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "n". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADn", position, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADn", position, StringComparison.Ordinal)); - - // Find the index of the soft hyphen followed by "m". - position = s1.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s1.LastIndexOf("\u00ADm", position, StringComparison.Ordinal)); - - position = s2.LastIndexOf("m"); - Console.WriteLine("'m' at position {0}", position); - if (position >= 0) - Console.WriteLine(s2.LastIndexOf("\u00ADm", position, StringComparison.Ordinal)); - } -} -// The example displays the following output: -// Culture-sensitive comparisons: -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// 'm' at position 4 -// 1 -// 'm' at position 3 -// 1 -// 'm' at position 4 -// 4 -// 'm' at position 3 -// 3 -// -// Ordinal comparisons: -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// -1 -// 'm' at position 3 -// -1 -// 'm' at position 4 -// 3 -// 'm' at position 3 -// -1 -// diff --git a/snippets/csharp/System/TimeSpan/Overview/instantiate1.cs b/snippets/csharp/System/TimeSpan/Overview/instantiate1.cs deleted file mode 100644 index a2b58defd48..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/instantiate1.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - Implicit(); - Console.WriteLine(); - Explicit(); - Console.WriteLine(); - TimeSpanOperation(); - Console.WriteLine(); - Parse(); - Console.WriteLine(); - } - - private static void Implicit() - { - // - TimeSpan interval = new TimeSpan(); - Console.WriteLine(interval.Equals(TimeSpan.Zero)); // Displays "True". - // - } - - private static void Explicit() - { - // - TimeSpan interval = new TimeSpan(2, 14, 18); - Console.WriteLine(interval.ToString()); - - // Displays "02:14:18". - // - } - - private static void TimeSpanOperation() - { - // - DateTime departure = new DateTime(2010, 6, 12, 18, 32, 0); - DateTime arrival = new DateTime(2010, 6, 13, 22, 47, 0); - TimeSpan travelTime = arrival - departure; - Console.WriteLine("{0} - {1} = {2}", arrival, departure, travelTime); - - // The example displays the following output: - // 6/13/2010 10:47:00 PM - 6/12/2010 6:32:00 PM = 1.04:15:00 - // - } - - private static void Parse() - { - // - string[] values = { "12", "31.", "5.8:32:16", "12:12:15.95", ".12"}; - foreach (string value in values) - { - try { - TimeSpan ts = TimeSpan.Parse(value); - Console.WriteLine("'{0}' --> {1}", value, ts); - } - catch (FormatException) { - Console.WriteLine("Unable to parse '{0}'", value); - } - catch (OverflowException) { - Console.WriteLine("'{0}' is outside the range of a TimeSpan.", value); - } - } - - // The example displays the following output: - // '12' --> 12.00:00:00 - // Unable to parse '31.' - // '5.8:32:16' --> 5.08:32:16 - // '12:12:15.95' --> 12:12:15.9500000 - // Unable to parse '.12' - // - } -} diff --git a/snippets/csharp/System/TimeSpan/Overview/legacycode1.cs b/snippets/csharp/System/TimeSpan/Overview/legacycode1.cs deleted file mode 100644 index f41ded0b18b..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/legacycode1.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - ShowFormattingCode(); - // Output from .NET Framework 3.5 and earlier versions: - // 12:30:45 - // Output from .NET Framework 4: - // Invalid Format - - Console.WriteLine("---"); - - ShowParsingCode(); - // Output: - // 000000006 --> 6.00:00:00 - - void ShowFormattingCode() - { - TimeSpan interval = new TimeSpan(12, 30, 45); - string output; - try { - output = String.Format("{0:r}", interval); - } - catch (FormatException) { - output = "Invalid Format"; - } - Console.WriteLine(output); - } - - void ShowParsingCode() - { - string value = "000000006"; - try { - TimeSpan interval = TimeSpan.Parse(value); - Console.WriteLine("{0} --> {1}", value, interval); - } - catch (FormatException) { - Console.WriteLine("{0}: Bad Format", value); - } - catch (OverflowException) { - Console.WriteLine("{0}: Overflow", value); - } - } - // - } -} diff --git a/snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs b/snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs deleted file mode 100644 index 70c6359fe96..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/perappdomain1.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - AppDomainSetup appSetup = new AppDomainSetup(); - appSetup.SetCompatibilitySwitches( new string[] { "NetFx40_TimeSpanLegacyFormatMode" } ); - AppDomain legacyDomain = AppDomain.CreateDomain("legacyDomain", - null, appSetup); - legacyDomain.ExecuteAssembly("ShowTimeSpan.exe"); - } -} -// \ No newline at end of file diff --git a/snippets/csharp/System/TimeSpan/Overview/showtimespan.cs b/snippets/csharp/System/TimeSpan/Overview/showtimespan.cs deleted file mode 100644 index f134c4f0573..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/showtimespan.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - TimeSpan interval = DateTime.Now - DateTime.Now.Date; - string msg = String.Format("Elapsed Time Today: {0:d} hours.", - interval); - Console.WriteLine(msg); - } -} -// The example displays the following output: -// Elapsed Time Today: 01:40:52.2524662 hours. -// \ No newline at end of file diff --git a/snippets/csharp/System/TimeSpan/Overview/zero1.cs b/snippets/csharp/System/TimeSpan/Overview/zero1.cs deleted file mode 100644 index 02e32a707bb..00000000000 --- a/snippets/csharp/System/TimeSpan/Overview/zero1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - Random rnd = new Random(); - - TimeSpan timeSpent = TimeSpan.Zero; - - timeSpent += GetTimeBeforeLunch(); - timeSpent += GetTimeAfterLunch(); - - Console.WriteLine("Total time: {0}", timeSpent); - - TimeSpan GetTimeBeforeLunch() - { - return new TimeSpan(rnd.Next(3, 6), 0, 0); - } - - TimeSpan GetTimeAfterLunch() - { - return new TimeSpan(rnd.Next(3, 6), 0, 0); - } - - // The example displays output like the following: - // Total time: 08:00:00 - // - } -} diff --git a/snippets/csharp/System/TimeSpan/ToString/ToString2.cs b/snippets/csharp/System/TimeSpan/ToString/ToString2.cs deleted file mode 100644 index 8df19c7df4d..00000000000 --- a/snippets/csharp/System/TimeSpan/ToString/ToString2.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -using System; - -public class ToString -{ - public static void Main() - { - TimeSpan span; - - // Initialize a time span to zero. - span = TimeSpan.Zero; - Console.WriteLine(FormatTimeSpan(span, true)); - - // Initialize a time span to 14 days. - span = new TimeSpan(-14, 0, 0, 0, 0); - Console.WriteLine(FormatTimeSpan(span, true)); - - // Initialize a time span to 1:02:03. - span = new TimeSpan(1, 2, 3); - Console.WriteLine(FormatTimeSpan(span, false)); - - // Initialize a time span to 250 milliseconds. - span = new TimeSpan(0, 0, 0, 0, 250); - Console.WriteLine(FormatTimeSpan(span, true)); - - // Initialize a time span to 99 days, 23 hours, 59 minutes, and 59.9999999 seconds. - span = new TimeSpan(99, 23, 59, 59, 999); - Console.WriteLine(FormatTimeSpan(span, false)); - - // Initialize a timespan to 25 milliseconds. - span = new TimeSpan(0, 0, 0, 0, 25); - Console.WriteLine(FormatTimeSpan(span, false)); - } - - private static string FormatTimeSpan(TimeSpan span, bool showSign) - { - string sign = String.Empty; - if (showSign && (span > TimeSpan.Zero)) - sign = "+"; - - return sign + span.Days.ToString("00") + "." + - span.Hours.ToString("00") + ":" + - span.Minutes.ToString("00") + ":" + - span.Seconds.ToString("00") + "." + - span.Milliseconds.ToString("000"); - } -} -// This example displays the following output: -// 00.00:00:00.000 -// -14.00:00:00.000 -// 00.01:02:03.000 -// +00.00:00:00.250 -// 99.23:59:59.999 -// 00.00:00:00.025 -// diff --git a/snippets/csharp/System/Type/FullName/remarks.cs b/snippets/csharp/System/Type/FullName/remarks.cs deleted file mode 100644 index 30aaf98c27b..00000000000 --- a/snippets/csharp/System/Type/FullName/remarks.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -// -public class Base { } -public class Derived : Base { } -// - -class ProgStubClass -{ - public static void Main() {} -} \ No newline at end of file diff --git a/snippets/csharp/System/Type/GetType/yourassembly.cs b/snippets/csharp/System/Type/GetType/yourassembly.cs deleted file mode 100644 index d0eeb5002d9..00000000000 --- a/snippets/csharp/System/Type/GetType/yourassembly.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; -using System.Reflection; -[assembly:AssemblyVersion("1.0.0.0")] -namespace YourNamespace -{ - public class YourType {} -} \ No newline at end of file diff --git a/snippets/csharp/System/Type/HasElementType/makefile b/snippets/csharp/System/Type/HasElementType/makefile deleted file mode 100644 index 62fd8db0d22..00000000000 --- a/snippets/csharp/System/Type/HasElementType/makefile +++ /dev/null @@ -1,2 +0,0 @@ -type_haselementtype.exe: - csc /unsafe type_haselementtype.cs \ No newline at end of file diff --git a/snippets/csharp/System/Type/Overview/Equals1.cs b/snippets/csharp/System/Type/Overview/Equals1.cs deleted file mode 100644 index 9a6219c45a9..00000000000 --- a/snippets/csharp/System/Type/Overview/Equals1.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - long number1 = 1635429; - int number2 = 16203; - double number3 = 1639.41; - long number4 = 193685412; - - // Get the type of number1. - Type t = number1.GetType(); - - // Compare types of all objects with number1. - Console.WriteLine("Type of number1 and number2 are equal: {0}", - Object.ReferenceEquals(t, number2.GetType())); - Console.WriteLine("Type of number1 and number3 are equal: {0}", - Object.ReferenceEquals(t, number3.GetType())); - Console.WriteLine("Type of number1 and number4 are equal: {0}", - Object.ReferenceEquals(t, number4.GetType())); - - // The example displays the following output: - // Type of number1 and number2 are equal: False - // Type of number1 and number3 are equal: False - // Type of number1 and number4 are equal: True - // - } -} diff --git a/snippets/csharp/System/Type/Overview/GetType1.cs b/snippets/csharp/System/Type/Overview/GetType1.cs deleted file mode 100644 index 54feeda6386..00000000000 --- a/snippets/csharp/System/Type/Overview/GetType1.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - object[] values = { "word", true, 120, 136.34, 'a' }; - foreach (var value in values) - Console.WriteLine("{0} - type {1}", value, - value.GetType().Name); - - // The example displays the following output: - // word - type String - // True - type Boolean - // 120 - type Int32 - // 136.34 - type Double - // a - type Char - // - } -} diff --git a/snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs b/snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs deleted file mode 100644 index b2c1d09a6fb..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/Missing1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -using System; - -public class Example -{ - public static void Main() - { - Person p = new Person("John", "Doe"); - Console.WriteLine(p); - } -} - -public class Person -{ - static InfoModule infoModule; - - String fName; - String mName; - String lName; - - static Person() - { - infoModule = new InfoModule(DateTime.UtcNow); - } - - public Person(String fName, String lName) - { - this.fName = fName; - this.lName = lName; - infoModule.Increment(); - } - - public override String ToString() - { - return String.Format("{0} {1}", fName, lName); - } -} -// The example displays the following output if missing1a.dll is renamed or removed: -// Unhandled Exception: System.TypeInitializationException: -// The type initializer for 'Person' threw an exception. ---> -// System.IO.FileNotFoundException: Could not load file or assembly -// 'Missing1a, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' -// or one of its dependencies. The system cannot find the file specified. -// at Person..cctor() -// --- End of inner exception stack trace --- -// at Person..ctor(String fName, String lName) -// at Example.Main() -// diff --git a/snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs b/snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs deleted file mode 100644 index 56903779fba..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/Missing1a.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -using System; - -public class InfoModule -{ - private DateTime firstUse; - private int ctr = 0; - - public InfoModule(DateTime dat) - { - firstUse = dat; - } - - public int Increment() - { - return ++ctr; - } - - public DateTime GetInitializationTime() - { - return firstUse; - } -} -// diff --git a/snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs b/snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs deleted file mode 100644 index ce73d8fa914..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/Regex1.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class Example -{ - public static void Main() - { - AppDomain domain = AppDomain.CurrentDomain; - // Set a timeout interval of -2 seconds. - domain.SetData("REGEX_DEFAULT_MATCH_TIMEOUT", TimeSpan.FromSeconds(-2)); - - Regex rgx = new Regex("[aeiouy]"); - Console.WriteLine("Regular expression pattern: {0}", rgx.ToString()); - Console.WriteLine("Timeout interval for this regex: {0} seconds", - rgx.MatchTimeout.TotalSeconds); - } -} -// The example displays the following output: -// Unhandled Exception: System.TypeInitializationException: -// The type initializer for 'System.Text.RegularExpressions.Regex' threw an exception. ---> -// System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. -// Parameter name: AppDomain data 'REGEX_DEFAULT_MATCH_TIMEOUT' contains an invalid value or -// object for specifying a default matching timeout for System.Text.RegularExpressions.Regex. -// at System.Text.RegularExpressions.Regex.InitDefaultMatchTimeout() -// at System.Text.RegularExpressions.Regex..cctor() -// --- End of inner exception stack trace --- -// at System.Text.RegularExpressions.Regex..ctor(String pattern) -// at Example.Main() -// diff --git a/snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs b/snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs deleted file mode 100644 index f8b8e1b478a..00000000000 --- a/snippets/csharp/System/TypeInitializationException/Overview/ctorException1.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; - -public class Example -{ - private static TestClass test = new TestClass(3); - - public static void Main() - { - Example ex = new Example(); - Console.WriteLine(test.Value); - } -} - -public class TestClass -{ - public readonly int Value; - - public TestClass(int value) - { - if (value < 0 || value > 1) throw new ArgumentOutOfRangeException(); - Value = value; - } -} -// The example displays the following output: -// Unhandled Exception: System.TypeInitializationException: -// The type initializer for 'Example' threw an exception. ---> -// System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. -// at TestClass..ctor(Int32 value) -// at Example..cctor() -// --- End of inner exception stack trace --- -// at Example.Main() -// diff --git a/snippets/csharp/System/UInt16/Parse/parseex1.cs b/snippets/csharp/System/UInt16/Parse/parseex1.cs deleted file mode 100644 index a18bb39d180..00000000000 --- a/snippets/csharp/System/UInt16/Parse/parseex1.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -using System; - -public class Temperature -{ - internal ushort n_value; - internal string s_value; - - // Parses a string in the form [ws][sign]digits['F|'C][ws] - public static Temperature Parse(string s) - { - Temperature temp = new Temperature(); - - if (s == null) - throw new ArgumentNullException("s"); - - s = s.TrimEnd(); - temp.s_value = s; - if (s.EndsWith("'F") | s.EndsWith("'C")) - { - temp.Value = UInt16.Parse(s.Remove(s.LastIndexOf("'"), 2) ); - } - else - { - try { - temp.Value = UInt16.Parse(s); - } - catch (FormatException e) { - throw new FormatException(String.Format("{0} is an invalid temperature.", s), e); - } - catch (OverflowException e) { - throw new OverflowException(String.Format("{0} is out of range.", s), e); - } - } - - return temp; - } - - public ushort Value - { - get { return n_value; } - set { this.n_value = value; } - } -} -// - -// -public class Example -{ - public static void Main() - { - string[] values = { "32'F", "32'C", "16", "-0", "-12", "", null }; - foreach (string value in values) - { - try { - Temperature tmp = Temperature.Parse(value); - Console.WriteLine(tmp.Value); - } - catch (FormatException) { - Console.WriteLine("'{0}': Invalid Format", value.Trim()); - } - catch (OverflowException) { - Console.WriteLine("{0}: Overflow", value.Trim()); - } - catch (ArgumentNullException e) { - Console.WriteLine("The {0} parameter is null.", e.ParamName); - } - } - } -} -// The example displays the following output: -// 32 -// 32 -// 16 -// 0 -// -12: Overflow -// '': Invalid Format -// The s parameter is null. -// diff --git a/snippets/csharp/System/UInt16/TryParse/tryparse1.cs b/snippets/csharp/System/UInt16/TryParse/tryparse1.cs deleted file mode 100644 index f8110f998c2..00000000000 --- a/snippets/csharp/System/UInt16/TryParse/tryparse1.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - // - string[] numericStrings = { "1293.8", "+1671.7", "28347.", - " 33113 ", "(0)", "-0", "+12936", - "18-", "9870", "31,024", " 3127 ", - "70000" }; - ushort number; - foreach (string numericString in numericStrings) - { - if (UInt16.TryParse(numericString, out number)) - Console.WriteLine("Converted '{0}' to {1}.", numericString, number); - else - Console.WriteLine("Cannot convert '{0}' to a UInt16.", numericString); - } - // The example displays the following output: - // Cannot convert '1293.8' to a UInt16. - // Cannot convert '+1671.7' to a UInt16. - // Cannot convert '28347.' to a UInt16. - // Converted ' 33113 ' to 33113. - // Cannot convert '(0)' to a UInt16. - // Converted '-0' to 0. - // Converted '+12936' to 12936. - // Cannot convert '18-' to a UInt16. - // Converted '9870' to 9870. - // Cannot convert '31,024' to a UInt16. - // Converted ' 3127 ' to 3127. - // Cannot convert '70000' to a UInt16. - // - } -} diff --git a/snippets/csharp/System/Version/Overview/GettingVersions1.cs b/snippets/csharp/System/Version/Overview/GettingVersions1.cs deleted file mode 100644 index c9cdee4c9b3..00000000000 --- a/snippets/csharp/System/Version/Overview/GettingVersions1.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Reflection; - -[assembly: CLSCompliant(true)] -public class Class1 -{ - public static void Main() - { - Example1 ex1 = new Example1(); - - GetOsVersion(); - Console.WriteLine(); - GetClrVersion(); - Console.WriteLine(); - GetSpecificAssemblyVersion(); - Console.WriteLine(); - ex1.GetExecutingAssemblyVersion(); - Console.WriteLine(); - GetApplicationVersion(); - } - - private static void GetOsVersion() - { - // - // Get the operating system version. - OperatingSystem os = Environment.OSVersion; - Version ver = os.Version; - Console.WriteLine("Operating System: {0} ({1})", os.VersionString, ver.ToString()); - // - } - - private static void GetClrVersion() - { - // - // Get the common language runtime version. - Version ver = Environment.Version; - Console.WriteLine("CLR Version {0}", ver.ToString()); - // - } - - private static void GetSpecificAssemblyVersion() - { - // Get the version of a specific assembly. - string filename = @".\StringLibrary.dll"; - Assembly assem = Assembly.ReflectionOnlyLoadFrom(filename); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } - - private static void GetApplicationVersion() - { - // Get the version of the executing assembly (that is, this assembly). - Assembly assem = Assembly.GetEntryAssembly(); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("Application {0}, Version {1}", assemName.Name, ver.ToString()); - } -} - -public class Example1 -{ - public static void GetExecutingAssemblyVersion() - { - // Get the version of the current application. - Assembly assem = typeof(Example1).Assembly; - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } -} \ No newline at end of file diff --git a/snippets/csharp/System/Version/Overview/clickonce.cs b/snippets/csharp/System/Version/Overview/clickonce.cs deleted file mode 100644 index e05774aa507..00000000000 --- a/snippets/csharp/System/Version/Overview/clickonce.cs +++ /dev/null @@ -1,13 +0,0 @@ -// -using System; -using System.Deployment.Application; - -public class Example -{ - public static void Main() - { - Version ver = ApplicationDeployment.CurrentDeployment.CurrentVersion; - Console.WriteLine("ClickOnce Publish Version: {0}", ver); - } -} -// diff --git a/snippets/csharp/System/Version/Overview/comparisons1.cs b/snippets/csharp/System/Version/Overview/comparisons1.cs deleted file mode 100644 index 40c0aab873e..00000000000 --- a/snippets/csharp/System/Version/Overview/comparisons1.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -public class Example -{ - public static void Main() - { - CompareSimple(); - } - - private static void CompareSimple() - { - // - Version v1 = new Version(2, 0); - Version v2 = new Version("2.1"); - Console.Write("Version {0} is ", v1); - switch(v1.CompareTo(v2)) - { - case 0: - Console.Write("the same as"); - break; - case 1: - Console.Write("later than"); - break; - case -1: - Console.Write("earlier than"); - break; - } - Console.WriteLine(" Version {0}.", v2); - // The example displays the following output: - // Version 2.0 is earlier than Version 2.1. - // - } -} diff --git a/snippets/csharp/System/Version/Overview/comparisons2.cs b/snippets/csharp/System/Version/Overview/comparisons2.cs deleted file mode 100644 index 15310b9ca95..00000000000 --- a/snippets/csharp/System/Version/Overview/comparisons2.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -enum VersionTime {Earlier = -1, Same = 0, Later = 1 }; - -public class Example -{ - public static void Main() - { - Version v1 = new Version(1, 1); - Version v1a = new Version("1.1.0"); - ShowRelationship(v1, v1a); - - Version v1b = new Version(1, 1, 0, 0); - ShowRelationship(v1b, v1a); - } - - private static void ShowRelationship(Version v1, Version v2) - { - Console.WriteLine("Relationship of {0} to {1}: {2}", - v1, v2, (VersionTime) v1.CompareTo(v2)); - } -} -// The example displays the following output: -// Relationship of 1.1 to 1.1.0: Earlier -// Relationship of 1.1.0.0 to 1.1.0: Later -// diff --git a/snippets/csharp/System/Version/Overview/currentapp.cs b/snippets/csharp/System/Version/Overview/currentapp.cs deleted file mode 100644 index 58fc2f22360..00000000000 --- a/snippets/csharp/System/Version/Overview/currentapp.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; -using System.Reflection; - -public class Example -{ - public static void Main() - { - // Get the version of the executing assembly (that is, this assembly). - Assembly assem = Assembly.GetEntryAssembly(); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("Application {0}, Version {1}", assemName.Name, ver.ToString()); - } -} -// diff --git a/snippets/csharp/System/Version/Overview/currentassem.cs b/snippets/csharp/System/Version/Overview/currentassem.cs deleted file mode 100644 index e6e5968ebb0..00000000000 --- a/snippets/csharp/System/Version/Overview/currentassem.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -using System; -using System.Reflection; - -public class Example -{ - public static void Main() - { - // Get the version of the current assembly. - Assembly assem = typeof(Example).Assembly; - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } -} -// diff --git a/snippets/csharp/System/Version/Overview/specificassem.cs b/snippets/csharp/System/Version/Overview/specificassem.cs deleted file mode 100644 index 9a9ac7b8491..00000000000 --- a/snippets/csharp/System/Version/Overview/specificassem.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -using System; -using System.Reflection; - -public class Example -{ - public static void Main() - { - // Get the version of a specific assembly. - string filename = @".\StringLibrary.dll"; - Assembly assem = Assembly.ReflectionOnlyLoadFrom(filename); - AssemblyName assemName = assem.GetName(); - Version ver = assemName.Version; - Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString()); - } -} -// diff --git a/snippets/visualbasic/System.DateTime/Calendar.vb b/snippets/visualbasic/System.DateTime/Calendar.vb deleted file mode 100644 index 23346c6863c..00000000000 --- a/snippets/visualbasic/System.DateTime/Calendar.vb +++ /dev/null @@ -1,110 +0,0 @@ -Imports System.Globalization - -Module CalendarSamples - Public Sub Snippets() - ThaiBuddhistEra() - ThaiBuddhistEraParse() - InstantiateCalendar() - CalendarFields() - CalculateWeeks() - End Sub - - Private Sub ThaiBuddhistEra() - ' - Dim thTH As New CultureInfo("th-TH") - Dim value As New DateTime(2016, 5, 28) - - Console.WriteLine(value.ToString(thTH)) - - thTH.DateTimeFormat.Calendar = New GregorianCalendar() - Console.WriteLine(value.ToString(thTH)) - ' The example displays the following output: - ' 28/5/2559 0:00:00 - ' 28/5/2016 0:00:00 - ' - End Sub - - ' - Private Sub ThaiBuddhistEraParse() - Dim thTH As New CultureInfo("th-TH") - Dim value As DateTime = DateTime.Parse("28/5/2559", thTH) - Console.WriteLine(value.ToString(thTH)) - - thTH.DateTimeFormat.Calendar = New GregorianCalendar() - Console.WriteLine(value.ToString(thTH)) - ' The example displays the following output: - ' 28/5/2559 0:00:00 - ' 28/5/2016 0:00:00 - End Sub - ' - - Private Sub InstantiateCalendar() - ' - Dim thTH As New CultureInfo("th-TH") - Dim dat As New DateTime(2559, 5, 28, thTH.DateTimeFormat.Calendar) - Console.WriteLine($"Thai Buddhist Era date: {dat.ToString("d", thTH)}") - Console.WriteLine($"Gregorian date: {dat:d}") - ' The example displays the following output: - ' Thai Buddhist Era Date: 28/5/2559 - ' Gregorian Date: 28/05/2016 - ' - End Sub - - Private Sub CalendarFields() - ' - Dim thTH As New CultureInfo("th-TH") - Dim cal As Calendar = thTH.DateTimeFormat.Calendar - Dim dat As New DateTime(2559, 5, 28, cal) - Console.WriteLine("Using the Thai Buddhist Era calendar:") - Console.WriteLine($"Date: {dat.ToString("d", thTH)}") - Console.WriteLine($"Year: {cal.GetYear(dat)}") - Console.WriteLine($"Leap year: {cal.IsLeapYear(cal.GetYear(dat))}") - Console.WriteLine() - - Console.WriteLine("Using the Gregorian calendar:") - Console.WriteLine($"Date: {dat:d}") - Console.WriteLine($"Year: {dat.Year}") - Console.WriteLine($"Leap year: {DateTime.IsLeapYear(dat.Year)}") - ' The example displays the following output: - ' Using the Thai Buddhist Era calendar - ' Date : 28/5/2559 - ' Year: 2559 - ' Leap year : True - ' - ' Using the Gregorian calendar - ' Date : 28/05/2016 - ' Year: 2016 - ' Leap year : True - ' - End Sub - - Private Sub CalculateWeeks() - ' - Dim thTH As New CultureInfo("th-TH") - Dim thCalendar As Calendar = thTH.DateTimeFormat.Calendar - Dim dat As New DateTime(1395, 8, 18, thCalendar) - Console.WriteLine("Using the Thai Buddhist Era calendar:") - Console.WriteLine($"Date: {dat.ToString("d", thTH)}") - Console.WriteLine($"Day of Week: {thCalendar.GetDayOfWeek(dat)}") - Console.WriteLine($"Week of year: {thCalendar.GetWeekOfYear(dat, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)}") - Console.WriteLine() - - Dim greg As Calendar = New GregorianCalendar() - Console.WriteLine("Using the Gregorian calendar:") - Console.WriteLine($"Date: {dat:d}") - Console.WriteLine($"Day of Week: {dat.DayOfWeek}") - Console.WriteLine($"Week of year: {greg.GetWeekOfYear(dat, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)}") - ' The example displays the following output: - ' Using the Thai Buddhist Era calendar - ' Date : 18/8/1395 - ' Day of Week: Sunday - ' Week of year: 34 - ' - ' Using the Gregorian calendar - ' Date : 18/08/0852 - ' Day of Week: Sunday - ' Week of year: 34 - ' - End Sub -End Module - diff --git a/snippets/visualbasic/System.DateTime/DateTimeComparisons.vb b/snippets/visualbasic/System.DateTime/DateTimeComparisons.vb deleted file mode 100644 index aee488bf948..00000000000 --- a/snippets/visualbasic/System.DateTime/DateTimeComparisons.vb +++ /dev/null @@ -1,58 +0,0 @@ -Class DateTimeComparisons - Public Shared Sub Snippets() - TestRoughlyEquals() - End Sub - - ' - Public Shared Function RoughlyEquals(time As DateTime, timeWithWindow As DateTime, - windowInSeconds As Integer, - frequencyInSeconds As Integer) As Boolean - Dim delta As Long = (timeWithWindow.Subtract(time)).TotalSeconds _ - Mod frequencyInSeconds - - If delta > windowInSeconds Then - delta = frequencyInSeconds - delta - End If - - Return Math.Abs(delta) < windowInSeconds - End Function - - Public Shared Sub TestRoughlyEquals() - Dim window As Integer = 10 - Dim freq As Integer = 60 * 60 * 2 ' 2 hours; - Dim d1 As DateTime = DateTime.Now - - Dim d2 As DateTime = d1.AddSeconds(2 * window) - Dim d3 As DateTime = d1.AddSeconds(-2 * window) - Dim d4 As DateTime = d1.AddSeconds(window / 2) - Dim d5 As DateTime = d1.AddSeconds(-window / 2) - - Dim d6 As DateTime = d1.AddHours(2).AddSeconds(2 * window) - Dim d7 As DateTime = d1.AddHours(2).AddSeconds(-2 * window) - Dim d8 As DateTime = d1.AddHours(2).AddSeconds(window / 2) - Dim d9 As DateTime = d1.AddHours(2).AddSeconds(-window / 2) - - Console.WriteLine($"d1 ({d1}) ~= d1 ({d1}): {RoughlyEquals(d1, d1, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d2 ({d2}): {RoughlyEquals(d1, d2, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d3 ({d3}): {RoughlyEquals(d1, d3, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d4 ({d4}): {RoughlyEquals(d1, d4, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d5 ({d5}): {RoughlyEquals(d1, d5, window, freq)}") - - Console.WriteLine($"d1 ({d1}) ~= d6 ({d6}): {RoughlyEquals(d1, d6, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d7 ({d7}): {RoughlyEquals(d1, d7, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d8 ({d8}): {RoughlyEquals(d1, d8, window, freq)}") - Console.WriteLine($"d1 ({d1}) ~= d9 ({d9}): {RoughlyEquals(d1, d9, window, freq)}") - End Sub - ' The example displays output similar to the following: - ' d1 (1/28/2010 9:01:26 PM) ~= d1 (1/28/2010 9:01:26 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d2 (1/28/2010 9:01:46 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d3 (1/28/2010 9:01:06 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d4 (1/28/2010 9:01:31 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d5 (1/28/2010 9:01:21 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d6 (1/28/2010 11:01:46 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d7 (1/28/2010 11:01:06 PM): False - ' d1 (1/28/2010 9:01:26 PM) ~= d8 (1/28/2010 11:01:31 PM): True - ' d1 (1/28/2010 9:01:26 PM) ~= d9 (1/28/2010 11:01:21 PM): True - ' - -End Class diff --git a/snippets/visualbasic/System.DateTime/DateWithTimeZone.vb b/snippets/visualbasic/System.DateTime/DateWithTimeZone.vb deleted file mode 100644 index 8c38aaaced5..00000000000 --- a/snippets/visualbasic/System.DateTime/DateWithTimeZone.vb +++ /dev/null @@ -1,32 +0,0 @@ -' -Namespace DateTimeExtensions - Public Structure DateWithTimeZone - Private tz As TimeZoneInfo - Private dt As DateTime - - Public Sub New(dateValue As DateTime, timeZone As TimeZoneInfo) - dt = dateValue - tz = If(timeZone, TimeZoneInfo.Local) - End Sub - - Public Property TimeZone As TimeZoneInfo - Get - Return tz - End Get - Set - tz = Value - End Set - End Property - - Public Property DateTime As Date - Get - Return dt - End Get - Set - dt = Value - End Set - End Property - End Structure -End Namespace -' - diff --git a/snippets/visualbasic/System.DateTime/Instantiation.vb b/snippets/visualbasic/System.DateTime/Instantiation.vb deleted file mode 100644 index b4612342cd9..00000000000 --- a/snippets/visualbasic/System.DateTime/Instantiation.vb +++ /dev/null @@ -1,61 +0,0 @@ -Module Instantiation - - Public Sub Snippets() - InstantiateWithConstructor() - InstantiateWithCompilerSyntax() - InstantiateWithReturnValue() - InstantiateFromString() - InstantiateUsingDftCtor() - End Sub - - Private Sub InstantiateWithConstructor() - ' - Dim date1 As New Date(2008, 5, 1, 8, 30, 52) - ' - End Sub - - Private Sub InstantiateWithCompilerSyntax() - ' - Dim date1 As Date = #5/1/2008 8:30:52AM# - ' - End Sub - - Private Sub InstantiateWithReturnValue() - ' - Dim date1 As Date = Date.Now - Dim date2 As Date = Date.UtcNow - Dim date3 As Date = Date.Today - ' - End Sub - - Private Sub InstantiateFromString() - ' - Dim dateString As String = "5/1/2008 8:30:52 AM" - Dim date1 As Date = Date.Parse(dateString, - System.Globalization.CultureInfo.InvariantCulture) - Dim iso8601String As String = "20080501T08:30:52Z" - Dim dateISO8602 As Date = DateTime.ParseExact(iso8601String, "yyyyMMddTHH:mm:ssZ", - System.Globalization.CultureInfo.InvariantCulture) - Console.WriteLine(dateISO8602) - - ' - Console.WriteLine(date1) - End Sub - - Private Sub InstantiateUsingDftCtor() - ' - Dim dat1 As DateTime - ' The following method call displays 1/1/0001 12:00:00 AM. - Console.WriteLine(dat1.ToString(System.Globalization.CultureInfo.InvariantCulture)) - ' The following method call displays True. - Console.WriteLine(dat1.Equals(Date.MinValue)) - - Dim dat2 As New DateTime() - ' The following method call displays 1/1/0001 12:00:00 AM. - Console.WriteLine(dat2.ToString(System.Globalization.CultureInfo.InvariantCulture)) - ' The following method call displays True. - Console.WriteLine(dat2.Equals(Date.MinValue)) - ' - End Sub - -End Module diff --git a/snippets/visualbasic/System.DateTime/Parsing.vb b/snippets/visualbasic/System.DateTime/Parsing.vb deleted file mode 100644 index 4cfe6eecb6c..00000000000 --- a/snippets/visualbasic/System.DateTime/Parsing.vb +++ /dev/null @@ -1,166 +0,0 @@ -Imports System.Globalization -Imports System.Threading - -Module Parsing - Public Sub Snippets() - ParseStandardFormats() - End Sub - - Private Sub ParseStandardFormats() - ' - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - - Dim date1 As New DateTime(2013, 6, 1, 12, 32, 30) - Dim badFormats As New List(Of String) - - Console.WriteLine($"{"Date String",-37} {"Date",-19}") - Console.WriteLine() - For Each dateString As String In date1.GetDateTimeFormats() - Dim parsedDate As DateTime - If DateTime.TryParse(dateString, parsedDate) Then - Console.WriteLine($"{dateString,-37} {DateTime.Parse(dateString),-19:g}") - Else - badFormats.Add(dateString) - End If - Next - - ' Display strings that could not be parsed. - If badFormats.Count > 0 Then - Console.WriteLine() - Console.WriteLine("Strings that could not be parsed: ") - For Each badFormat In badFormats - Console.WriteLine($" {badFormat}") - Next - End If - ' The example displays the following output: - ' Date String Date - ' - ' 01/06/2013 01/06/2013 00:00:00 - ' 01/06/13 01/06/2013 00:00:00 - ' 1/6/13 01/06/2013 00:00:00 - ' 1.6.13 01/06/2013 00:00:00 - ' 2013-06-01 01/06/2013 00:00:00 - ' 01 June 2013 01/06/2013 00:00:00 - ' 1 June 2013 01/06/2013 00:00:00 - ' 01 June 2013 12:32 01/06/2013 12:32:00 - ' 01 June 2013 12:32 01/06/2013 12:32:00 - ' 01 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 01 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 1 June 2013 12:32 01/06/2013 12:32:00 - ' 1 June 2013 12:32 01/06/2013 12:32:00 - ' 1 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 1 June 2013 12:32 PM 01/06/2013 12:32:00 - ' 01 June 2013 12:32:30 01/06/2013 12:32:30 - ' 01 June 2013 12:32:30 01/06/2013 12:32:30 - ' 01 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 1 June 2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/2013 12:32 01/06/2013 12:32:00 - ' 01/06/2013 12:32 01/06/2013 12:32:00 - ' 01/06/2013 12:32 PM 01/06/2013 12:32:00 - ' 01/06/2013 12:32 PM 01/06/2013 12:32:00 - ' 01/06/13 12:32 01/06/2013 12:32:00 - ' 01/06/13 12:32 01/06/2013 12:32:00 - ' 01/06/13 12:32 PM 01/06/2013 12:32:00 - ' 01/06/13 12:32 PM 01/06/2013 12:32:00 - ' 1/6/13 12:32 01/06/2013 12:32:00 - ' 1/6/13 12:32 01/06/2013 12:32:00 - ' 1/6/13 12:32 PM 01/06/2013 12:32:00 - ' 1/6/13 12:32 PM 01/06/2013 12:32:00 - ' 1.6.13 12:32 01/06/2013 12:32:00 - ' 1.6.13 12:32 01/06/2013 12:32:00 - ' 1.6.13 12:32 PM 01/06/2013 12:32:00 - ' 1.6.13 12:32 PM 01/06/2013 12:32:00 - ' 2013-06-01 12:32 01/06/2013 12:32:00 - ' 2013-06-01 12:32 01/06/2013 12:32:00 - ' 2013-06-01 12:32 PM 01/06/2013 12:32:00 - ' 2013-06-01 12:32 PM 01/06/2013 12:32:00 - ' 01/06/2013 12:32:30 01/06/2013 12:32:30 - ' 01/06/2013 12:32:30 01/06/2013 12:32:30 - ' 01/06/2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/2013 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 PM 01/06/2013 12:32:30 - ' 01/06/13 12:32:30 PM 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 PM 01/06/2013 12:32:30 - ' 1/6/13 12:32:30 PM 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 PM 01/06/2013 12:32:30 - ' 1.6.13 12:32:30 PM 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 PM 01/06/2013 12:32:30 - ' 2013-06-01 12:32:30 PM 01/06/2013 12:32:30 - ' 01 June 01/06/2013 00:00:00 - ' 01 June 01/06/2013 00:00:00 - ' 2013-06-01T12:32:30.0000000 01/06/2013 12:32:30 - ' 2013-06-01T12:32:30.0000000 01/06/2013 12:32:30 - ' Sat, 01 Jun 2013 12:32:30 GMT 01/06/2013 05:32:30 - ' Sat, 01 Jun 2013 12:32:30 GMT 01/06/2013 05:32:30 - ' 2013-06-01T12:32:30 01/06/2013 12:32:30 - ' 12:32 22/04/2013 12:32:00 - ' 12:32 22/04/2013 12:32:00 - ' 12:32 PM 22/04/2013 12:32:00 - ' 12:32 PM 22/04/2013 12:32:00 - ' 12:32:30 22/04/2013 12:32:30 - ' 12:32:30 22/04/2013 12:32:30 - ' 12:32:30 PM 22/04/2013 12:32:30 - ' 12:32:30 PM 22/04/2013 12:32:30 - ' 2013-06-01 12:32:30Z 01/06/2013 05:32:30 - ' 01 June 2013 19:32:30 01/06/2013 19:32:30 - ' 01 June 2013 19:32:30 01/06/2013 19:32:30 - ' 01 June 2013 07:32:30 PM 01/06/2013 19:32:30 - ' 01 June 2013 7:32:30 PM 01/06/2013 19:32:30 - ' 1 June 2013 19:32:30 01/06/2013 19:32:30 - ' 1 June 2013 19:32:30 01/06/2013 19:32:30 - ' 1 June 2013 07:32:30 PM 01/06/2013 19:32:30 - ' 1 June 2013 7:32:30 PM 01/06/2013 19:32:30 - ' June 2013 01/06/2013 00:00:00 - ' June 2013 01/06/2013 00:00:00 - ' - End Sub - - Private Sub ParseCustomFormats() - ' - Dim formats() As String = {"yyyyMMdd", "HHmmss"} - Dim dateStrings() As String = {"20130816", "20131608", - " 20130816 ", "115216", - "521116", " 115216 "} - Dim parsedDate As DateTime - - For Each dateString As String In dateStrings - If DateTime.TryParseExact(dateString, formats, Nothing, - DateTimeStyles.AllowWhiteSpaces Or - DateTimeStyles.AdjustToUniversal, - parsedDate) Then - Console.WriteLine($"{dateString} --> {parsedDate:g}") - Else - Console.WriteLine($"Cannot convert {dateString}") - End If - Next - ' The example displays the following output: - ' 20130816 --> 8/16/2013 12:00 AM - ' Cannot convert 20131608 - ' 20130816 --> 8/16/2013 12:00 AM - ' 115216 --> 4/22/2013 11:52 AM - ' Cannot convert 521116 - ' 115216 --> 4/22/2013 11:52 AM - ' - End Sub - - Private Sub ParseISO8601() - ' - Dim iso8601String As String = "20080501T08:30:52Z" - Dim dateISO8602 As DateTime = DateTime.ParseExact(iso8601String, "yyyyMMddTHH:mm:ssZ", CultureInfo.InvariantCulture) - Console.WriteLine($"{iso8601String} --> {dateISO8602:g}") - ' - - End Sub -End Module diff --git a/snippets/visualbasic/System.DateTime/Persistence.vb b/snippets/visualbasic/System.DateTime/Persistence.vb deleted file mode 100644 index 02ea45a9a25..00000000000 --- a/snippets/visualbasic/System.DateTime/Persistence.vb +++ /dev/null @@ -1,296 +0,0 @@ -Imports System.Globalization -Imports System.IO -Imports System.Runtime.Serialization -Imports System.Runtime.Serialization.Formatters.Binary -Imports System.Threading -Imports System.Xml.Serialization -Imports SystemDateTimeReference.DateTimeExtensions - -Module Persistence - Private Const filenameTxt As String = ".\BadDates.txt" - Sub Snippets() - File.Delete(filenameTxt) - PersistAsLocalStrings() - File.Delete(filenameTxt) - PersistAsInvariantStrings() - File.Delete(filenameTxt) - File.Delete(filenameInts) - PersistAsIntegers() - File.Delete(filenameInts) - - File.Delete(filenameXml) - PersistAsXml() - File.Delete(filenameXml) - - File.Delete(filenameBin) - End Sub - - ' - Public Sub PersistAsLocalStrings() - SaveDatesAsStrings() - RestoreDatesAsStrings() - End Sub - - Private Sub SaveDatesAsStrings() - Dim dates As Date() = {#6/14/2014 6:32AM#, #7/10/2014 11:49PM#, - #1/10/2015 1:16AM#, #12/20/2014 9:45PM#, - #6/2/2014 3:14PM#} - Dim output As String = Nothing - - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For ctr As Integer = 0 To dates.Length - 1 - Console.WriteLine(dates(ctr).ToString("f")) - output += dates(ctr).ToString() + If(ctr <> dates.Length - 1, "|", "") - Next - Dim sw As New StreamWriter(filenameTxt) - sw.Write(output) - sw.Close() - Console.WriteLine("Saved dates...") - End Sub - - Private Sub RestoreDatesAsStrings() - TimeZoneInfo.ClearCachedData() - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - Dim sr As New StreamReader(filenameTxt) - Dim inputValues As String() = sr.ReadToEnd().Split({"|"c}, StringSplitOptions.RemoveEmptyEntries) - sr.Close() - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For Each inputValue In inputValues - Dim dateValue As Date - If DateTime.TryParse(inputValue, dateValue) Then - Console.WriteLine($"'{inputValue}' --> {dateValue:f}") - Else - Console.WriteLine($"Cannot parse '{inputValue}'") - End If - Next - Console.WriteLine("Restored dates...") - End Sub - ' When saved on an en-US system, the example displays the following output: - ' Current Time Zone: (UTC-08:00) Pacific Time (US & Canada) - ' The dates on an en-US system: - ' Saturday, June 14, 2014 6:32 AM - ' Thursday, July 10, 2014 11:49 PM - ' Saturday, January 10, 2015 1:16 AM - ' Saturday, December 20, 2014 9:45 PM - ' Monday, June 02, 2014 3:14 PM - ' Saved dates... - ' - ' When restored on an en-GB system, the example displays the following output: - ' Current Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London - ' The dates on an en-GB system: - ' Cannot parse '6/14/2014 6:32:00 AM' - ' '7/10/2014 11:49:00 PM' --> 07 October 2014 23:49 - ' '1/10/2015 1:16:00 AM' --> 01 October 2015 01:16 - ' Cannot parse '12/20/2014 9:45:00 PM' - ' '6/2/2014 3:14:00 PM' --> 06 February 2014 15:14 - ' Restored dates... - ' - - ' - Public Sub PersistAsInvariantStrings() - SaveDatesAsInvariantStrings() - RestoreDatesAsInvariantStrings() - End Sub - - Private Sub SaveDatesAsInvariantStrings() - Dim dates As Date() = {#6/14/2014 6:32AM#, #7/10/2014 11:49PM#, - #1/10/2015 1:16AM#, #12/20/2014 9:45PM#, - #6/2/2014 3:14PM#} - Dim output As String = Nothing - - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For ctr As Integer = 0 To dates.Length - 1 - Console.WriteLine(dates(ctr).ToString("f")) - output += dates(ctr).ToUniversalTime().ToString("O", CultureInfo.InvariantCulture) + - If(ctr <> dates.Length - 1, "|", "") - Next - Dim sw As New StreamWriter(filenameTxt) - sw.Write(output) - sw.Close() - Console.WriteLine("Saved dates...") - End Sub - - Private Sub RestoreDatesAsInvariantStrings() - TimeZoneInfo.ClearCachedData() - Console.WriteLine("Current Time Zone: {0}", - TimeZoneInfo.Local.DisplayName) - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - Dim sr As New StreamReader(filenameTxt) - Dim inputValues As String() = sr.ReadToEnd().Split({"|"c}, StringSplitOptions.RemoveEmptyEntries) - sr.Close() - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For Each inputValue In inputValues - Dim dateValue As Date - If DateTime.TryParseExact(inputValue, "O", CultureInfo.InvariantCulture, - DateTimeStyles.RoundtripKind, dateValue) Then - Console.WriteLine($"'{inputValue}' --> {dateValue.ToLocalTime():f}") - Else - Console.WriteLine($"Cannot parse '{inputValue}'") - End If - Next - Console.WriteLine("Restored dates...") - End Sub - ' When saved on an en-US system, the example displays the following output: - ' Current Time Zone: (UTC-08:00) Pacific Time (US & Canada) - ' The dates on an en-US system: - ' Saturday, June 14, 2014 6:32 AM - ' Thursday, July 10, 2014 11:49 PM - ' Saturday, January 10, 2015 1:16 AM - ' Saturday, December 20, 2014 9:45 PM - ' Monday, June 02, 2014 3:14 PM - ' Saved dates... - ' - ' When restored on an en-GB system, the example displays the following output: - ' Current Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London - ' The dates on an en-GB system: - ' '2014-06-14T13:32:00.0000000Z' --> 14 June 2014 14:32 - ' '2014-07-11T06:49:00.0000000Z' --> 11 July 2014 07:49 - ' '2015-01-10T09:16:00.0000000Z' --> 10 January 2015 09:16 - ' '2014-12-21T05:45:00.0000000Z' --> 21 December 2014 05:45 - ' '2014-06-02T22:14:00.0000000Z' --> 02 June 2014 23:14 - ' Restored dates... - ' - - Private Const filenameInts As String = ".\IntDates.bin" - - ' - Public Sub PersistAsIntegers() - SaveDatesAsIntegers() - RestoreDatesAsIntegers() - End Sub - - Private Sub SaveDatesAsIntegers() - Dim dates As Date() = {#6/14/2014 6:32AM#, #7/10/2014 11:49PM#, - #1/10/2015 1:16AM#, #12/20/2014 9:45PM#, - #6/2/2014 3:14PM#} - - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - Dim ticks(dates.Length - 1) As Long - For ctr As Integer = 0 To dates.Length - 1 - Console.WriteLine(dates(ctr).ToString("f")) - ticks(ctr) = dates(ctr).ToUniversalTime().Ticks - Next - Dim fs As New FileStream(filenameInts, FileMode.Create) - Dim bw As New BinaryWriter(fs) - bw.Write(ticks.Length) - For Each tick In ticks - bw.Write(tick) - Next - bw.Close() - Console.WriteLine("Saved dates...") - End Sub - - Private Sub RestoreDatesAsIntegers() - TimeZoneInfo.ClearCachedData() - Console.WriteLine($"Current Time Zone: {TimeZoneInfo.Local.DisplayName}") - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB") - Dim fs As New FileStream(filenameInts, FileMode.Open) - Dim br As New BinaryReader(fs) - Dim items As Integer - Dim dates As DateTime() - - Try - items = br.ReadInt32() - ReDim dates(items - 1) - - For ctr As Integer = 0 To items - 1 - Dim ticks As Long = br.ReadInt64() - dates(ctr) = New DateTime(ticks).ToLocalTime() - Next - Catch e As EndOfStreamException - Console.WriteLine("File corruption detected. Unable to restore data...") - Exit Sub - Catch e As IOException - Console.WriteLine("Unspecified I/O error. Unable to restore data...") - Exit Sub - Catch e As OutOfMemoryException 'Thrown in array initialization. - Console.WriteLine("File corruption detected. Unable to restore data...") - Exit Sub - Finally - br.Close() - End Try - - Console.WriteLine($"The dates on an {Thread.CurrentThread.CurrentCulture.Name} system:") - For Each value In dates - Console.WriteLine(value.ToString("f")) - Next - Console.WriteLine("Restored dates...") - End Sub - ' When saved on an en-US system, the example displays the following output: - ' Current Time Zone: (UTC-08:00) Pacific Time (US & Canada) - ' The dates on an en-US system: - ' Saturday, June 14, 2014 6:32 AM - ' Thursday, July 10, 2014 11:49 PM - ' Saturday, January 10, 2015 1:16 AM - ' Saturday, December 20, 2014 9:45 PM - ' Monday, June 02, 2014 3:14 PM - ' Saved dates... - ' - ' When restored on an en-GB system, the example displays the following output: - ' Current Time Zone: (UTC) Dublin, Edinburgh, Lisbon, London - ' The dates on an en-GB system: - ' 14 June 2014 14:32 - ' 11 July 2014 07:49 - ' 10 January 2015 09:16 - ' 21 December 2014 05:45 - ' 02 June 2014 23:14 - ' Restored dates... - ' - - Private Const filenameXml As String = ".\LeapYears.xml" - - ' - Public Sub PersistAsXml() - ' Serialize the data. - Dim leapYears As New List(Of DateTime)() - For year As Integer = 2000 To 2100 Step 4 - If Date.IsLeapYear(year) Then - leapYears.Add(New Date(year, 2, 29)) - End If - Next - Dim dateArray As DateTime() = leapYears.ToArray() - - Dim serializer As New XmlSerializer(dateArray.GetType()) - Dim sw As TextWriter = New StreamWriter(filenameXml) - - Try - serializer.Serialize(sw, dateArray) - Catch e As InvalidOperationException - Console.WriteLine(e.InnerException.Message) - Finally - If sw IsNot Nothing Then sw.Close() - End Try - - ' Deserialize the data. - Dim deserializedDates As Date() - Using fs As New FileStream(filenameXml, FileMode.Open) - deserializedDates = CType(serializer.Deserialize(fs), Date()) - End Using - - ' Display the dates. - Console.WriteLine($"Leap year days from 2000-2100 on an {Thread.CurrentThread.CurrentCulture.Name} system:") - Dim nItems As Integer - For Each dat In deserializedDates - Console.Write($" {dat:d} ") - nItems += 1 - If nItems Mod 5 = 0 Then Console.WriteLine() - Next - End Sub - ' The example displays the following output: - ' Leap year days from 2000-2100 on an en-GB system: - ' 29/02/2000 29/02/2004 29/02/2008 29/02/2012 29/02/2016 - ' 29/02/2020 29/02/2024 29/02/2028 29/02/2032 29/02/2036 - ' 29/02/2040 29/02/2044 29/02/2048 29/02/2052 29/02/2056 - ' 29/02/2060 29/02/2064 29/02/2068 29/02/2072 29/02/2076 - ' 29/02/2080 29/02/2084 29/02/2088 29/02/2092 29/02/2096 - ' - - Private Const filenameBin As String = ".\Dates.bin" - - Private Const filename As String = ".\Schedule.bin" - -End Module diff --git a/snippets/visualbasic/System.DateTime/Program.vb b/snippets/visualbasic/System.DateTime/Program.vb deleted file mode 100644 index 33cd33cade6..00000000000 --- a/snippets/visualbasic/System.DateTime/Program.vb +++ /dev/null @@ -1,11 +0,0 @@ -Module Program - Sub Main(args As String()) - Instantiation.Snippets() - StringFormat.Snippets() - Parsing.Snippets() - Resolution.Snippets() - CalendarSamples.Snippets() - Persistence.Snippets() - DateTimeComparisons.Snippets() - End Sub -End Module diff --git a/snippets/visualbasic/System.DateTime/Resolution.vb b/snippets/visualbasic/System.DateTime/Resolution.vb deleted file mode 100644 index a317d56fe09..00000000000 --- a/snippets/visualbasic/System.DateTime/Resolution.vb +++ /dev/null @@ -1,50 +0,0 @@ -Imports System.Threading - -Module Resolution - - Public Sub Snippets() - DemonstrateResolution() - End Sub - - Private Sub DemonstrateResolution() - ' - Dim output As String = "" - For ctr As Integer = 0 To 20 - output += Date.Now.Millisecond.ToString() + vbCrLf - ' Introduce a delay loop. - For delay As Integer = 0 To 1000 - Next - - If ctr = 10 Then - output += "Thread.Sleep called..." + vbCrLf - Thread.Sleep(5) - End If - Next - Console.WriteLine(output) - ' The example displays output like the following: - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' 111 - ' Thread.Sleep called... - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' 143 - ' - - End Sub -End Module diff --git a/snippets/visualbasic/System.DateTime/StringFormat.vb b/snippets/visualbasic/System.DateTime/StringFormat.vb deleted file mode 100644 index 9d488e4f41f..00000000000 --- a/snippets/visualbasic/System.DateTime/StringFormat.vb +++ /dev/null @@ -1,50 +0,0 @@ -Module StringFormat - Public Sub Snippets() - ShowDefaultToString() - ShowCultureSpecificToString() - ShowDefaultFullDateAndTime() - ShowCultureSpecificFullDateAndTime() - ShowIsoDateTime() - End Sub - - Private Sub ShowDefaultToString() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString()) - ' For en-US culture, displays 3/1/2008 7:00:00 AM - ' - End Sub - - Private Sub ShowCultureSpecificToString() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString(System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR"))) - ' Displays 01/03/2008 07:00:00 - ' - End Sub - - Private Sub ShowDefaultFullDateAndTime() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString("F")) - ' Displays Saturday, March 01, 2008 7:00:00 AM - ' - End Sub - - Private Sub ShowCultureSpecificFullDateAndTime() - ' - Dim date1 As Date = #3/1/2008 7:00AM# - Console.WriteLine(date1.ToString("F", New System.Globalization.CultureInfo("fr-FR"))) - ' Displays samedi 1 mars 2008 07:00:00 - ' - End Sub - - Private Sub ShowIsoDateTime() - ' - Dim date1 As DateTime = New DateTime(2008, 3, 1, 7, 0, 0, DateTimeKind.Utc) - Console.WriteLine(date1.ToString("yyyy-MM-ddTHH:mm:sszzz", System.Globalization.CultureInfo.InvariantCulture)) - ' Displays 2008-03-01T07:00:00+00:00 - ' - End Sub - -End Module diff --git a/snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj b/snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj deleted file mode 100644 index 41f1d5ad4b2..00000000000 --- a/snippets/visualbasic/System.DateTime/SystemDateTimeReference.vbproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - net6.0 - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program1.vb b/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program1.vb similarity index 100% rename from snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program1.vb rename to snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program1.vb diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program2.vb b/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program2.vb similarity index 100% rename from snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program2.vb rename to snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program2.vb diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb b/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program3.vb similarity index 100% rename from snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program3.vb rename to snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program3.vb diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb deleted file mode 100644 index c0c899a403c..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Cancel/VB/source.vb +++ /dev/null @@ -1,23 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleCommand _ - (ByVal queryString As String, ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - command.Connection.Open() - command.ExecuteReader() - command.Cancel() - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb deleted file mode 100644 index 71cc4a0603e..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandText/VB/source.vb +++ /dev/null @@ -1,19 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim command As New OracleCommand() - command.CommandText = "SELECT * FROM Emp ORDER BY EmpNo" - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb deleted file mode 100644 index 71cc4a0603e..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.CommandType/VB/source.vb +++ /dev/null @@ -1,19 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim command As New OracleCommand() - command.CommandText = "SELECT * FROM Emp ORDER BY EmpNo" - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb deleted file mode 100644 index 52d1f71324a..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Connection/VB/source.vb +++ /dev/null @@ -1,20 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim queryString As String = _ - "SELECT * FROM Emp ORDER BY EmpNo" - Dim command As New OracleCommand(queryString) - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb deleted file mode 100644 index 316fc9d1c5d..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteNonQuery/VB/source.vb +++ /dev/null @@ -1,22 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleCommand(ByVal myExecuteQuery As String, _ - ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(myExecuteQuery, connection) - command.Connection.Open() - command.ExecuteNonQuery() - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb deleted file mode 100644 index cdc86049b48..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader1/VB/source.vb +++ /dev/null @@ -1,29 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateMyOracleDataReader(ByVal queryString As String, _ - ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - connection.Open() - Dim reader As OracleDataReader = command.ExecuteReader() - Try - While reader.Read() - Console.WriteLine(reader.GetValue(0)) - End While - Finally - reader.Close() - End Try - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb deleted file mode 100644 index 8cdcd768f67..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteReader2/VB/mysample.vb +++ /dev/null @@ -1,30 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateMyOracleDataReader(ByVal queryString As String, _ - ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - connection.Open() - - 'Implicitly closes the connection because - ' CommandBehavior.CloseConnectionwas specified. - Dim reader As OracleDataReader = _ - command.ExecuteReader(CommandBehavior.CloseConnection) - While reader.Read() - Console.WriteLine(reader.GetValue(0)) - End While - reader.Close() - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb deleted file mode 100644 index ce391bc5c65..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.ExecuteScalar/VB/mysample.vb +++ /dev/null @@ -1,19 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid -' -Public Sub CreateOracleCommand(myScalarQuery As String, connection As OracleConnection) - Dim command As New OracleCommand(myScalarQuery, connection) - command.Connection.Open() - command.ExecuteScalar() - connection.Close() -End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb deleted file mode 100644 index 747d8c46c74..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand/VB/source.vb +++ /dev/null @@ -1,18 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim command As New OracleCommand() - command.CommandType = CommandType.Text - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb deleted file mode 100644 index 1cfa929c2c4..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand2/VB/source.vb +++ /dev/null @@ -1,21 +0,0 @@ -Imports System.Xml -Imports System.Data -Imports System.Data.OracleClient -Imports System.Data.Common -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected DataSet1 As DataSet - Protected dataGrid1 As DataGrid - -' - Public Sub CreateOracleCommand() - Dim connection As New OracleConnection _ - ("Data Source=Oracle8i;Integrated Security=yes") - Dim queryString As String = _ - "SELECT * FROM Emp ORDER BY EmpNo" - Dim command As New OracleCommand(queryString, connection) - End Sub -' -End Class diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb deleted file mode 100644 index 9974a10dae6..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.OracleCommand3/VB/mysample.vb +++ /dev/null @@ -1,24 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleCommand(ByVal connectionString As String) - Using connection As New OracleConnection(connectionString) - connection.Open() - Dim transaction As OracleTransaction = connection.BeginTransaction() - Dim queryString As String = _ - "SELECT * FROM Emp ORDER BY EmpNo" - Dim command As New OracleCommand(queryString, connection, transaction) - command.CommandType = CommandType.Text - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb deleted file mode 100644 index 6e0598529f5..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand.Parameters/VB/source.vb +++ /dev/null @@ -1,40 +0,0 @@ -Imports System.Data -Imports System.Data.OracleClient - -Module Module1 - - Sub Main() - ' Need to create actual connection code here. - 'Call CreateOracleCommand() - End Sub - - ' - Public Sub CreateOracleCommand(ByVal connection As OracleConnection, _ - ByVal queryString As String, ByVal prmArray() As OracleParameter) - - Dim command As New OracleCommand(queryString, connection) - command.CommandText = _ - "SELECT * FROM Emp WHERE Job = :pJob AND Sal = :pSal" - - Dim j As Integer - For j = 0 To prmArray.Length - 1 - command.Parameters.Add(prmArray(j)) - Next j - - Dim message As String = "" - Dim i As Integer - For i = 0 To command.Parameters.Count - 1 - message += command.Parameters(i).ToString() + ControlChars.Cr - Next i - - Console.WriteLine(message) - - Dim reader As OracleDataReader = command.ExecuteReader - While reader.Read - Console.WriteLine(reader.GetValue(0)) - End While - - End Sub - ' - -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb deleted file mode 100644 index 0571a03b985..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleCommand/VB/source.vb +++ /dev/null @@ -1,31 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub ReadMyData(ByVal connectionString As String) - Dim queryString As String = "SELECT EmpNo, DeptNo FROM Scott.Emp" - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString, connection) - connection.Open() - Dim reader As OracleDataReader = command.ExecuteReader() - Try - While reader.Read() - Console.WriteLine(reader.GetInt32(0) & ", " _ - & reader.GetInt32(1)) - End While - Finally - ' always call Close when done reading. - reader.Close() - End Try - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb deleted file mode 100644 index 255df495a87..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.DataSource/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleConnection() - Dim connectionString As String = _ - "Data Source=Oracle8i;Integrated Security=yes" - - Using connection As New OracleConnection(connectionString) - connection.Open() - Console.WriteLine("ServerVersion: " + connection.ServerVersion _ - + ControlChars.NewLine + "DataSource: " + connection.DataSource) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb deleted file mode 100644 index 255df495a87..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.OracleConnection1/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleConnection() - Dim connectionString As String = _ - "Data Source=Oracle8i;Integrated Security=yes" - - Using connection As New OracleConnection(connectionString) - connection.Open() - Console.WriteLine("ServerVersion: " + connection.ServerVersion _ - + ControlChars.NewLine + "DataSource: " + connection.DataSource) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb deleted file mode 100644 index b2a04f57aa6..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.ServerVersion/VB/source.vb +++ /dev/null @@ -1,22 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub CreateOracleConnection() - Dim connectionString As String = "Data Source=Oracle8i;Integrated Security=yes" - Using connection As New OracleConnection(connectionString) - connection.Open() - Console.WriteLine("ServerVersion: " & connection.ServerVersion _ - + ControlChars.NewLine + "State: " & connection.State) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb deleted file mode 100644 index 26b50c79bf3..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection.State/VB/source.vb +++ /dev/null @@ -1,22 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Oracleclient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub createOracleConnection() - Using connection As New OracleConnection() - connection.ConnectionString = _ - "Data Source=Oracle8i;Integrated Security=yes" - connection.Open() - Console.WriteLine("Connection State: " & connection.State) - End Using - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb deleted file mode 100644 index e76dcabc966..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OracleConnection/VB/source.vb +++ /dev/null @@ -1,27 +0,0 @@ -Imports System.Data -Imports System.Data.OracleClient - -Module Module1 - - Sub Main() - End Sub - - ' - Public Sub InsertRow(ByVal connectionString As String) - Dim queryString As String = _ - "INSERT INTO Dept (DeptNo, Dname, Loc) values (50, 'TECHNOLOGY', 'DENVER')" - - Using connection As New OracleConnection(connectionString) - Dim command As New OracleCommand(queryString) - command.Connection = connection - Try - connection.Open() - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - End Using - End Sub - ' - -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb deleted file mode 100644 index 9124fc7d8cf..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb +++ /dev/null @@ -1,20 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Common -Module Module1 - ' - Sub Main() - Dim builder As New DbConnectionStringBuilder - builder.ConnectionString = _ - "Provider=MSDataShape.1;Persist Security Info=False;" & _ - "Data Provider=MSDAORA;Data Source=orac;" & _ - "user id=username;password=*******" - - For Each value As String In builder.Values - Console.WriteLine(value) - Next - End Sub - ' -End Module diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb deleted file mode 100644 index 98351880d86..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb +++ /dev/null @@ -1,28 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before running this example. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder - builder.DataSource = "OracleSample" - builder.IntegratedSecurity = True - Console.WriteLine("Initial connection string: " & builder.ConnectionString) - - Console.WriteLine("Before call to Clear, count = " & builder.Count) - builder.Clear() - Console.WriteLine("After call to Clear, count = " & builder.Count) - Console.WriteLine("Cleared connection string: " & builder.ConnectionString) - Console.WriteLine() - - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj deleted file mode 100644 index 1564968cb6e..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/Project.vbproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Library - net4.8 - - - - - - - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb deleted file mode 100644 index 78dcf2592bf..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb +++ /dev/null @@ -1,33 +0,0 @@ -Option Explicit -Option Strict On - -Imports System.Data.OracleClient - -Module Module1 - ' - Sub Main() - Dim builder As _ - New OracleConnectionStringBuilder(GetConnectionString()) - Console.WriteLine("Connection string = " & builder.ConnectionString) - - ' Keys you have provided return true. - Console.WriteLine(builder.ContainsKey("Integrated Security")) - - ' Keys that are valid but have not been set return true. - Console.WriteLine(builder.ContainsKey("Unicode")) - - ' Keys that don't exist return false. - Console.WriteLine(builder.ContainsKey("MyKey")) - - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub - - Private Function GetConnectionString() As String - ' To avoid storing the connection string in your code, - ' you can retrieve it from a configuration file. - Return "Server=OracleDemo;Integrated Security=True" - End Function - ' -End Module - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb deleted file mode 100644 index 478604effee..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb +++ /dev/null @@ -1,31 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before running this example. -Imports System.Data.OracleClient - -Module Module1 - - Sub Main() - Dim builder As _ - New OracleConnectionStringBuilder( _ - "Server=OracleDemo;Integrated Security=True") - - ' Display the connection string, which should now - ' contains the "Data Source" key, as opposed to the - ' supplied "Server". - Console.WriteLine(builder.ConnectionString) - - ' Retrieve the DataSource property. - Console.WriteLine("DataSource = " & builder.DataSource) - - Console.WriteLine("Press any key to continue.") - Console.ReadLine() - End Sub - -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb deleted file mode 100644 index e16b9d4b909..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb +++ /dev/null @@ -1,29 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before you can run this sample. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder - builder.Item("Data Source") = "OracleDemo" - ' Item is the default property, so - ' you need not include it in the reference. - builder("integrated security") = True - builder.Item("Unicode") = True - - ' Overwrite the existing value for the Data Source value. - builder.Item("Data Source") = "NewOracleDemo" - - Console.WriteLine(builder.ConnectionString) - Console.WriteLine() - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb deleted file mode 100644 index 52c1b448dab..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb +++ /dev/null @@ -1,28 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may have to set a reference to the System.Data.OracleClient -' assembly before running this example. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder - builder.DataSource = "OracleSample" - builder.IntegratedSecurity = True - - ' Loop through the collection of keys, displaying - ' the key and value for each item. - For Each key As String In builder.Keys - Console.WriteLine("{0}={1}", key, builder(key)) - Next - - Console.WriteLine() - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb deleted file mode 100644 index 4f5fd578b4b..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb +++ /dev/null @@ -1,54 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly before you can run this sample. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As New OracleConnectionStringBuilder() - builder.ConnectionString = GetConnectionString() - - ' Call TryGetValue method for multiple - ' key names. Note that these keys are converted - ' to well-known synonynms for data retrieval. - DisplayValue(builder, "Data Source") - DisplayValue(builder, "trusted_connection") - DisplayValue(builder, "InvalidKey") - DisplayValue(builder, Nothing) - - Console.WriteLine("Press any key to continue.") - Console.ReadLine() - End Sub - - Private Sub DisplayValue( _ - ByVal builder As OracleConnectionStringBuilder, ByVal key As String) - Dim value As Object = Nothing - - ' Although TryGetValue handles missing keys just fine, - ' it doesn't handle passing in a null (Nothing in Visual Basic) - ' key. This example traps for that particular error, but - ' bubbles any other unknown exceptions back out to the - ' caller. - Try - If builder.TryGetValue(key, value) Then - Console.WriteLine("{0}='{1}' ", key, value) - Else - Console.WriteLine("Unable to retrieve value for '{0}'", key) - End If - Catch ex As ArgumentNullException - Console.WriteLine("Unable to retrieve value for null key.") - End Try - End Sub - - Private Function GetConnectionString() As String - ' To avoid storing the connection string in your code, - ' you can retrieve it from a configuration file. - Return "Server=OracleDemo;Integrated Security=True" - End Function -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb deleted file mode 100644 index efa9915363f..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -' You may need to set a reference to the System.Data.OracleClient -' assembly in order to run this example. -Imports System.Data.OracleClient - -Module Module1 - Sub Main() - Dim builder As _ - New OracleConnectionStringBuilder(GetConnectionString()) - - ' Loop through each of the values, displaying the contents. - For Each value As Object In builder.Values - Console.WriteLine(value) - Next - - Console.WriteLine("Press any key to continue.") - Console.ReadLine() - End Sub - - Private Function GetConnectionString() As String - ' To avoid storing the connection string in your code, - ' you can retrieve it from a configuration file. - Return "Data Source=OracleSample;Integrated Security=true;" & _ - "Persist Security Info=True; Max Pool Size=100; Min Pool Size=1" - End Function -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb b/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb deleted file mode 100644 index 758485d89d2..00000000000 --- a/snippets/visualbasic/VS_Snippets_Atlas/System.Web.Script.Serialization.TypeResolver/VB/App_Code/TypeResolver.vb +++ /dev/null @@ -1,38 +0,0 @@ -Imports System.Collections.Generic -Imports System.Security.Permissions -Imports System.Text -Imports System.Web - -Namespace System.Web.Script.Serialization.TypeResolver.VB - - ' - Public Class CustomTypeResolver - Inherits JavaScriptTypeResolver - - Public Overrides Function ResolveType(ByVal id As String) As Type - Return Type.GetType(id) - End Function - - Public Overrides Function ResolveTypeId(ByVal type As Type) As String - If type Is Nothing Then - Throw New ArgumentNullException("type") - End If - - Return type.Name - End Function - End Class - ' - - Public Class ColorType - Public rgb() As String = {"00", "00", "FF"} - Public defaultColor As FavoriteColors = FavoriteColors.Blue - End Class - - Public Enum FavoriteColors - Black - White - Blue - Red - End Enum - -End Namespace \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb b/snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb deleted file mode 100644 index 2c031943135..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/ImprovedInteropSnippets/VB/codefile1.vb +++ /dev/null @@ -1,17 +0,0 @@ -'System.Runtime.InteropServices.IDispatchImplAttribute -'System.Runtime.InteropServices.IDispatchImplType -' -Imports System.Runtime.InteropServices -' by default all classes in this assembly will use COM implementaion - - -Module MyNamespace - ' But this class will use runtime implementaion - _ - Public Class c - ' - End Class - -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb b/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb deleted file mode 100644 index d1590e56adb..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb +++ /dev/null @@ -1,58 +0,0 @@ -'Types:System.Security.Permissions.IsolatedStorageContainment (enum) -'Types:System.Security.Permissions.IsolatedStoragePermissionAttribute -'Types:System.Security.Permissions.SecurityAction -' -Option Strict On -Imports System.Security.Permissions -Imports System.IO.IsolatedStorage -Imports System.IO - - -' Notify the CLR to only grant IsolatedStorageFilePermission to called methods. -' This restricts the called methods to working only with storage files that are isolated -' by user and assembly. - _ -Public NotInheritable Class App - - Shared Sub Main() - WriteIsolatedStorage() - End Sub - Shared Sub WriteIsolatedStorage() - ' Attempt to create a storage file that is isolated by user and assembly. - ' IsolatedStorageFilePermission granted to the attribute at the top of this file - ' allows CLR to load this assembly and execution of this statement. - Dim s As New IsolatedStorageFileStream("AssemblyData", FileMode.Create, IsolatedStorageFile.GetUserStoreForAssembly()) - Try - - ' Write some data out to the isolated file. - Dim sw As New StreamWriter(s) - Try - sw.Write("This is some test data.") - Finally - sw.Dispose() - End Try - Finally - s.Dispose() - End Try - - ' Attempt to open the file that was previously created. - Dim t As New IsolatedStorageFileStream("AssemblyData", FileMode.Open, IsolatedStorageFile.GetUserStoreForAssembly()) - Try - ' Read the data from the file and display it. - Dim sr As New StreamReader(t) - Try - Console.WriteLine(sr.ReadLine()) - Finally - sr.Dispose() - End Try - Finally - t.Dispose() - End Try - - End Sub -End Class - -' This code produces the following output. -' -' Some test data. -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb b/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb deleted file mode 100644 index 0da0a8f2800..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb +++ /dev/null @@ -1,129 +0,0 @@ -' -Imports System.Security.Permissions -Imports System.Collections - - Public Class MailslotPermission - Inherits ResourcePermissionBase - - Private innerCollection As ArrayList - - - Public Sub New() - SetNames() - End Sub - - - Public Sub New(ByVal state As PermissionState) - MyBase.New(state) - SetNames() - End Sub - - - ' - Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String) - SetNames() - Me.AddPermissionAccess(New MailslotPermissionEntry(permissionAccess, name, machineName1)) - End Sub - - - Public Sub New(ByVal permissionAccessEntries() As MailslotPermissionEntry) - SetNames() - If permissionAccessEntries Is Nothing Then - Throw New ArgumentNullException("permissionAccessEntries") - End If - Dim index As Integer - - While index < permissionAccessEntries.Length - Me.AddPermissionAccess(permissionAccessEntries(index)) - End While - End Sub - ' - - Public ReadOnly Property PermissionEntries() As ArrayList - Get - If Me.innerCollection Is Nothing Then - Me.innerCollection = New ArrayList() - End If - Me.innerCollection.InsertRange(0, MyBase.GetPermissionEntries()) - - Return Me.innerCollection - End Get - End Property - - - Friend Overloads Sub AddPermissionAccess(ByVal entry As MailslotPermissionEntry) - MyBase.AddPermissionAccess(entry.GetBaseEntry()) - End Sub - - - Friend Shadows Sub Clear() - MyBase.Clear() - End Sub - - - Friend Overloads Sub RemovePermissionAccess(ByVal entry As MailslotPermissionEntry) - MyBase.RemovePermissionAccess(entry.GetBaseEntry()) - End Sub - - - Private Sub SetNames() - Me.PermissionAccessType = GetType(MailslotPermissionAccess) - Me.TagNames = New String() {"Name", "Machine"} - End Sub -End Class - - Public Enum MailslotPermissionAccess - None = 0 - Send = 2 - Receive = 4 Or Send -End Enum 'MailslotPermissionAccess - - Public Class MailslotPermissionEntry - Private nameVar As String - Private machineNameVar As String - Private permissionAccessVar As MailslotPermissionAccess - - - Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String) - Me.permissionAccessVar = permissionAccess - Me.nameVar = name - Me.machineNameVar = machineName1 - End Sub - - - Friend Sub New(ByVal baseEntry As ResourcePermissionBaseEntry) - Me.permissionAccessVar = CType(baseEntry.PermissionAccess, MailslotPermissionAccess) - Me.nameVar = baseEntry.PermissionAccessPath(0) - Me.machineNameVar = baseEntry.PermissionAccessPath(1) - End Sub - - - Public ReadOnly Property Name() As String - Get - Return Me.nameVar - End Get - End Property - - - Public ReadOnly Property MachineName() As String - Get - Return Me.machineNameVar - End Get - End Property - - - Public ReadOnly Property PermissionAccess() As MailslotPermissionAccess - Get - Return Me.permissionAccessVar - End Get - End Property - - - Friend Function GetBaseEntry() As ResourcePermissionBaseEntry - Dim baseEntry As New ResourcePermissionBaseEntry(CInt(Me.PermissionAccess), New String() {Me.Name, Me.MachineName}) - Return baseEntry - End Function 'GetBaseEntry - - -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb b/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb deleted file mode 100644 index 17320d0faa6..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb +++ /dev/null @@ -1,35 +0,0 @@ - ' -Imports System.Collections -Imports System.Diagnostics -Imports System.Security -Imports System.Security.Permissions -Imports System.Security.Policy -Imports System.Reflection -Imports System.IO - - - -Class Program - - Shared Sub Main(ByVal args() As String) - ' Create the permission set to grant to other assemblies. - ' In this case we are granting the permissions found in the LocalIntranet zone. - Dim e As New Evidence() - e.AddHostEvidence(New Zone(SecurityZone.Intranet)) - Dim pset As PermissionSet = SecurityManager.GetStandardSandbox(e) - - Dim ads As New AppDomainSetup() - ' Identify the folder to use for the sandbox. - ads.ApplicationBase = "C:\Sandbox" - ' Copy the application to be executed to the sandbox. - Directory.CreateDirectory("C:\Sandbox") - File.Copy("..\..\..\HelloWorld\bin\debug\HelloWorld.exe", "C:\sandbox\HelloWorld.exe", True) - - ' Create the sandboxed domain. - Dim sandbox As AppDomain = AppDomain.CreateDomain("Sandboxed Domain", e, ads, pset, Nothing) - sandbox.ExecuteAssemblyByName("HelloWorld") - - End Sub -End Class - -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb b/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb deleted file mode 100644 index 482c300503a..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR/UnmanagedMarshalObsolete/vb/source.vb +++ /dev/null @@ -1,66 +0,0 @@ -' -Imports System.Reflection -Imports System.Reflection.Emit -Imports System.Runtime.InteropServices - -Public Class Example - - Public Shared Sub Main() - - Dim myDomain As AppDomain = AppDomain.CurrentDomain - Dim myAsmName As New AssemblyName("EmitMarshalAs") - - Dim myAssembly As AssemblyBuilder = _ - myDomain.DefineDynamicAssembly(myAsmName, _ - AssemblyBuilderAccess.RunAndSave) - - Dim myModule As ModuleBuilder = _ - myAssembly.DefineDynamicModule(myAsmName.Name, _ - myAsmName.Name & ".dll") - - Dim myType As TypeBuilder = _ - myModule.DefineType("Sample", TypeAttributes.Public) - - Dim myMethod As MethodBuilder = _ - myType.DefineMethod("Test", MethodAttributes.Public, _ - Nothing, new Type() { GetType(String) }) - - - ' Get a parameter builder for the parameter that needs the - ' attribute, using the HasFieldMarshal attribute. In this - ' example, the parameter is at position 0 and has the name - ' "arg". - Dim pb As ParameterBuilder = _ - myMethod.DefineParameter(0, _ - ParameterAttributes.HasFieldMarshal, "arg") - - ' Get the MarshalAsAttribute constructor that takes an - ' argument of type UnmanagedType. - ' - Dim ciParameters() As Type = { GetType(UnmanagedType) } - Dim ci As ConstructorInfo = _ - GetType(MarshalAsAttribute).GetConstructor(ciParameters) - - ' Create a CustomAttributeBuilder representing the attribute, - ' specifying the necessary unmanaged type. In this case, - ' UnmanagedType.BStr is specified. - ' - Dim ciArguments() As Object = { UnmanagedType.BStr } - Dim cabuilder As New CustomAttributeBuilder(ci, ciArguments) - - ' Apply the attribute to the parameter. - ' - pb.SetCustomAttribute(cabuilder) - - - ' Emit a dummy method body. - Dim il As ILGenerator = myMethod.GetILGenerator() - il.Emit(OpCodes.Ret) - - myType.CreateType() - myAssembly.Save(myAsmName.Name & ".dll") - - End Sub - -End Class -' diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb deleted file mode 100644 index 79a4422d272..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Delegate Example/VB/source.vb +++ /dev/null @@ -1,59 +0,0 @@ -' -Public Class SamplesDelegate - - ' Declares a delegate for a method that takes in an int and returns a String. - Delegate Function myMethodDelegate(myInt As Integer) As [String] - - ' Defines some methods to which the delegate can point. - Public Class mySampleClass - - ' Defines an instance method. - Public Function myStringMethod(myInt As Integer) As [String] - If myInt > 0 Then - Return "positive" - End If - If myInt < 0 Then - Return "negative" - End If - Return "zero" - End Function 'myStringMethod - - ' Defines a static method. - Public Shared Function mySignMethod(myInt As Integer) As [String] - If myInt > 0 Then - Return "+" - End If - If myInt < 0 Then - Return "-" - End If - Return "" - End Function 'mySignMethod - End Class - - Public Shared Sub Main() - - ' Creates one delegate for each method. For the instance method, an - ' instance (mySC) must be supplied. For the Shared method, the - ' method name is qualified by the class name. - Dim mySC As New mySampleClass() - Dim myD1 As New myMethodDelegate(AddressOf mySC.myStringMethod) - Dim myD2 As New myMethodDelegate(AddressOf mySampleClass.mySignMethod) - - ' Invokes the delegates. - Console.WriteLine("{0} is {1}; use the sign ""{2}"".", 5, myD1(5), myD2(5)) - Console.WriteLine("{0} is {1}; use the sign ""{2}"".", - 3, myD1(- 3), myD2(- 3)) - Console.WriteLine("{0} is {1}; use the sign ""{2}"".", 0, myD1(0), myD2(0)) - - End Sub - -End Class - - -'This code produces the following output: -' -'5 is positive; use the sign "+". -'-3 is negative; use the sign "-". -'0 is zero; use the sign "". - - -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb deleted file mode 100644 index 9c1e98fe574..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -Imports System.Security.Permissions - -' - -'In Visual Basic, you must specify that you are using the assembly scope when making a request. -' - -Namespace Snippet2 - -' - Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace - -Namespace Snippet3 - -' -' -Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb deleted file mode 100644 index 3f31e11761a..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb +++ /dev/null @@ -1,42 +0,0 @@ - -Imports System.Security -Imports System.Security.Permissions - - - -Class Program - - Shared Sub Main(ByVal args() As String) - ' - Dim f As New FileIOPermission(PermissionState.None) - f.AllLocalFiles = FileIOPermissionAccess.Read - Try - f.Demand() - Catch s As SecurityException - Console.WriteLine(s.Message) - End Try - - ' - ' - Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, "C:\test_r") - f2.AddPathList(FileIOPermissionAccess.Write Or FileIOPermissionAccess.Read, "C:\example\out.txt") - Try - f2.Demand() - Catch s As SecurityException - Console.WriteLine(s.Message) - End Try - ' - Console.Read() - - ' - Dim f3 As New FileIOPermission(PermissionState.None) - f3.AllFiles = FileIOPermissionAccess.Read - Try - f3.Demand() - Catch s As SecurityException - Console.WriteLine(s.Message) - End Try - ' - - End Sub -End Class \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb deleted file mode 100644 index 594bbf45ce1..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System.Security.Permissions - -Namespace Snippet1 - -' - Public Class SampleClass -' - End Class -End Namespace - -Namespace Snippet2 - -' - Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace - -Namespace Snippet3 - -' -' - Public Class SampleClass -' - ' Insert class members here - End Class - - -End Namespace diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb deleted file mode 100644 index a4157e37046..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb +++ /dev/null @@ -1,19 +0,0 @@ -' -Imports System.Threading -Imports System.Security.Permissions -Imports System.Security.Principal - - - -Class SecurityPrincipalDemo - - - Public Shared Sub Main() - AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) - Dim principalPerm As New PrincipalPermission(Nothing, "Administrators") - principalPerm.Demand() - Console.WriteLine("Demand succeeded.") - - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb deleted file mode 100644 index d0247922b9c..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb +++ /dev/null @@ -1,24 +0,0 @@ -Imports System.Security -Imports System.Security.Policy -Imports System.Security.Permissions -Imports System.Windows.Forms - -Public Class Form1 - Inherits Form - Protected textBox1 As TextBox - - Public Sub Method() -' - 'Define users and roles. - Dim ppBob As New PrincipalPermission("Bob", "Manager") - Dim ppLouise As New PrincipalPermission("Louise", "Supervisor") - Dim ppGreg As New PrincipalPermission("Greg", "Employee") - - 'Define groups of users. - Dim pp1 As PrincipalPermission = _ - CType(ppBob.Union(ppLouise), PrincipalPermission) - Dim pp2 As PrincipalPermission = _ - CType(ppGreg.Union(pp1), PrincipalPermission) -' - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb deleted file mode 100644 index 47c4beb16a6..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb +++ /dev/null @@ -1,32 +0,0 @@ -' -Imports System.Threading -Imports System.Security.Permissions -Imports System.Security.Principal - - - -Class SecurityPrincipalDemo - - Public Shared Sub Main() - Try - ' PrincipalPolicy must be set to WindowsPrincipal to check roles. - AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) - ' Check using the PrincipalPermissionAttribute - CheckAdministrator() - ' Check using PrincipalPermission class. - Dim principalPerm As New PrincipalPermission(Nothing, "Administrators") - principalPerm.Demand() - Console.WriteLine("Demand succeeded.") - Catch e As Exception - Console.WriteLine(e.Message) - End Try - - End Sub - - _ - Shared Sub CheckAdministrator() - Console.WriteLine("User is an administrator") - - End Sub -End Class -' \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb deleted file mode 100644 index cc71c398bca..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/fileinfomembers.vb +++ /dev/null @@ -1,260 +0,0 @@ -' -Imports System.IO -Imports System.Runtime.Serialization.Formatters.Binary - -' - -Public Class FileInfoSnippets - Public Sub Attributes() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - Console.WriteLine("{0} has attributes of {1}", fileName, fileInfo.Attributes) - ' Toggle the archive flag of the file. - Dim archiveFlag As Boolean = CBool(fileInfo.Attributes And FileAttributes.Archive) - If archiveFlag Then - fileInfo.Attributes = fileInfo.Attributes And Not FileAttributes.Archive - Else - fileInfo.Attributes = fileInfo.Attributes Or FileAttributes.Archive - End If - Console.WriteLine("{0} has attributes of {1}", fileName, fileInfo.Attributes) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat has attributes of Normal - ' C:\autoexec.bat has attributes of Archive - ' - Console.WriteLine() - End Sub - Public Sub CreationTime() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} was created at {1}", fileName, fileInfo.CreationTime) - - ' Add two hours to the creation time. - fileInfo.CreationTime.Add(TimeSpan.FromHours(2.0)) - - Console.WriteLine("{0} is now created at {1}", fileName, fileInfo.CreationTime) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat was created at 8/17/2004 5:30:13 PM - ' C:\autoexec.bat is now created at 8/17/2004 7:30:13 PM - ' - Console.WriteLine() - End Sub - - Public Sub DirectoryName() - ' - Dim fileName As String = "C:\TMP\log.txt" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} has a directoryName of {1}", fileName, fileInfo.DirectoryName) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\TMP\log.txt has a directory name of C:\TMP - ' - Console.WriteLine() - End Sub - - - Public Sub Directory() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - Dim dirInfo As DirectoryInfo = fileInfo.Directory - - Console.WriteLine("{0} is in a directory of {1} files.", fileName, dirInfo.GetFiles().Length) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat is in a directory of 24 files. - ' - Console.WriteLine() - End Sub - - Public Sub ExtensionAndName() - ' - Dim dirName As String = "C:\" - Dim dirInfo As New DirectoryInfo(dirName) - - Console.WriteLine("{0} contains the following system files:", dirName) - Dim fileInfo As FileInfo - For Each fileInfo In dirInfo.GetFiles() - If fileInfo.Extension.ToLower().Equals(".sys") Then - Console.WriteLine(fileInfo.Name) - End If - Next fileInfo - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\ contains the following system files: - ' CONFIG.SYS - ' IO.SYS - ' MSDOS.SYS - ' pagefile.sys - ' - Console.WriteLine() - End Sub - - Public Sub LastAccessTime() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} was last accessed at {1}", fileName, fileInfo.LastAccessTime) - - ' Set the access time back two hours. - fileInfo.LastAccessTime.Subtract(TimeSpan.FromHours(2.0)) - - Console.WriteLine("{0} now was last accessed at {1}", fileName, fileInfo.LastAccessTime) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat was last accessed at 8/17/2004 1:30:13 PM - ' C:\autoexec.bat now was last accessed at 8/17/2004 11:30:13 AM - ' - Console.WriteLine() - End Sub - - Public Sub LastWriteTime() - ' - Dim fileName As String = "C:\autoexec.bat" - Dim fileInfo As New FileInfo(fileName) - If Not fileInfo.Exists Then - Return - End If - - Console.WriteLine("{0} was last written to at {1}", fileName, fileInfo.LastWriteTime) - - ' Set the last write time back two hours. - fileInfo.LastWriteTime.Subtract(TimeSpan.FromHours(2.0)) - - Console.WriteLine("{0} now was last written to at {1}", fileName, fileInfo.LastWriteTime) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\autoexec.bat was last written to at 8/17/2004 1:30:13 PM - ' C:\autoexec.bat now was last written to at 8/17/2004 11:30:13 AM - ' - Console.WriteLine() - End Sub - - Public Sub Length() - ' - Dim dirName As String = "C:\" - Dim dirInfo As New DirectoryInfo(dirName) - - Console.WriteLine("{0} contains the following files:", dirName) - Console.WriteLine("Size Filename") - Dim fileInfo As FileInfo - For Each fileInfo In dirInfo.GetFiles() - Try - Console.WriteLine("{0}" + ChrW(9) + " {1}", fileInfo.Length, fileInfo.Name) - Catch e As IOException - Console.WriteLine(ChrW(9) + " {0}: {1}", fileInfo.Name, e.Message) - End Try - Next fileInfo - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' C:\ contains the following files: - ' Size Filename - ' 0 AUTOEXEC.BAT - ' 211 boot.ini - ' 0 CONFIG.SYS - ' 885 InoSetRTThread.log - ' 0 IO.SYS - ' 0 MSDOS.SYS - ' 47564 NTDETECT.COM - ' 250032 ntldr - ' 1610612736 pagefile.sys - ' 1479 PatchInfo.txt - ' 102 Platform.ini - ' 548 RISGX280.log - ' 196568 UpdatePatch.log - ' - Console.WriteLine() - End Sub - - Public Sub AppendTextAndOpenText() - ' - Dim fileName As String = Path.GetTempFileName() - Dim fileInfo As New FileInfo(fileName) - Console.WriteLine("File '{0}' created of size {1} bytes", fileName, fileInfo.Length) - - ' Append some text to the file. - Dim s As StreamWriter = fileInfo.AppendText() - s.WriteLine("The text in the file") - s.Close() - - fileInfo.Refresh() - Console.WriteLine("File '{0}' now has size {1} bytes", fileName, fileInfo.Length) - - ' Read the text file. - Dim r As StreamReader = fileInfo.OpenText() - Dim textLine As String = r.ReadLine() - Console.WriteLine(textLine) - r.Close() - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' File 'C:\DOCUME~1\cliffc\LOCALS~1\Temp\tmp12C.tmp' created of size 0 bytes - ' File 'C:\DOCUME~1\cliffc\LOCALS~1\Temp\tmp12C.tmp' now has size 22 bytes - ' The text in the file - ' - Console.WriteLine() - End Sub - - Public Sub CreateText() - ' - Dim fileInfo As New FileInfo("myFile") - - ' Create the file and output some text to it. - Dim s As StreamWriter = fileInfo.CreateText() - s.WriteLine("Output to the file") - s.Close() - - fileInfo.Refresh() - Console.WriteLine("File '{0}' now has size {1} bytes", fileInfo.Name, fileInfo.Length) - ' This code produces output similar to the following, - ' though actual results may vary by machine: - ' - ' File 'myFile' now has size 20 bytes - ' - Console.WriteLine() - End Sub - - Public Shared Sub Main() - Console.WriteLine() - Dim fileInfoSnippets As New FileInfoSnippets() - fileInfoSnippets.Attributes() - fileInfoSnippets.CreationTime() - fileInfoSnippets.DirectoryName() - fileInfoSnippets.Directory() - fileInfoSnippets.ExtensionAndName() - fileInfoSnippets.LastAccessTime() - fileInfoSnippets.LastWriteTime() - fileInfoSnippets.Length() - fileInfoSnippets.AppendTextAndOpenText() - fileInfoSnippets.CreateText() - End Sub -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj b/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj deleted file mode 100644 index 4b1cf7e4bb1..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileInfo members/VB/project.vbproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - exe - net7.0 - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb deleted file mode 100644 index 7fa5f7c2430..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.Designer.vb +++ /dev/null @@ -1,38 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - 'NOTE: This file is auto-generated; do not modify it directly. To make changes, - ' or if you encounter build errors in this file, go to the Project Designer - ' (go to Project Properties or double-click the My Project node in - ' Solution Explorer), and make changes on the Application tab. - ' - Partial Friend Class MyApplication - - _ - Public Sub New() - MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - Me.IsSingleInstance = false - Me.EnableVisualStyles = true - Me.SaveMySettingsOnExit = true - Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses - End Sub - - _ - Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.WFCrossThreadVB.Form1 - End Sub - End Class -End Namespace diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp deleted file mode 100644 index 1243847fd9b..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Application.myapp +++ /dev/null @@ -1,11 +0,0 @@ - - - true - Form1 - false - 0 - true - 0 - 0 - true - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb deleted file mode 100644 index 6f270bef899..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ - _ -Partial Class Form1 - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - _ - Private Sub InitializeComponent() - Me.threadExampleBtn = New System.Windows.Forms.Button() - Me.textBox1 = New System.Windows.Forms.TextBox() - Me.SuspendLayout() - ' - 'threadExampleBtn - ' - Me.threadExampleBtn.Location = New System.Drawing.Point(101, 184) - Me.threadExampleBtn.Name = "threadExampleBtn" - Me.threadExampleBtn.Size = New System.Drawing.Size(75, 23) - Me.threadExampleBtn.TabIndex = 0 - Me.threadExampleBtn.Text = "Button1" - Me.threadExampleBtn.UseVisualStyleBackColor = True - ' - 'textBox1 - ' - Me.textBox1.Location = New System.Drawing.Point(12, 36) - Me.textBox1.Multiline = True - Me.textBox1.Name = "textBox1" - Me.textBox1.Size = New System.Drawing.Size(260, 113) - Me.textBox1.TabIndex = 1 - ' - 'Form1 - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(284, 261) - Me.Controls.Add(Me.textBox1) - Me.Controls.Add(Me.threadExampleBtn) - Me.Name = "Form1" - Me.Text = "Form1" - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - - Friend WithEvents threadExampleBtn As Button - Friend WithEvents textBox1 As TextBox -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx deleted file mode 100644 index 1af7de150c9..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb deleted file mode 100644 index 48508e05c31..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/Form1.vb +++ /dev/null @@ -1,31 +0,0 @@ -Imports System.Threading - -Public Class Form1 - ' - Dim lines As New List(Of String)() - Private Async Sub threadExampleBtn_Click(sender As Object, e As EventArgs) Handles threadExampleBtn.Click - textBox1.Text = String.Empty - lines.Clear() - - lines.Add("Simulating work on UI thread.") - textBox1.Lines = lines.ToArray() - DoSomeWork(20) - - lines.Add("Simulating work on non-UI thread.") - textBox1.Lines = lines.ToArray() - Await Task.Run(Sub() DoSomeWork(1000)) - - lines.Add("ThreadsExampleBtn_Click completes. ") - textBox1.Lines = lines.ToArray() - End Sub - - Private Async Sub DoSomeWork(milliseconds As Integer) - ' Simulate work. - Await Task.Delay(milliseconds) - - ' Report completion. - lines.Add(String.Format("Some work completed in {0} ms on UI thread.", milliseconds)) - textBox1.Lines = lines.ToArray() - End Sub - ' -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj deleted file mode 100644 index bcfd20b0c58..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/WFCrossThreadVB.vbproj +++ /dev/null @@ -1,140 +0,0 @@ - - - - - Debug - AnyCPU - {0B7BE8EF-B57B-4945-862B-D341854CBF58} - WinExe - WFCrossThreadVB.My.MyApplication - WFCrossThreadVB - WFCrossThreadVB - 512 - WindowsForms - v4.8 - true - - - - AnyCPU - true - full - true - true - bin\Debug\ - WFCrossThreadVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - WFCrossThreadVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form - - - Form1.vb - Form - - - - True - Application.myapp - - - - - - Form1.vb - - - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config deleted file mode 100644 index b5cb6d50fc4..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/app.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json deleted file mode 100644 index da9ebf8da2f..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf/vb/snippets.5000.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "host": "visualstudio" -} diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb deleted file mode 100644 index 20deef8b370..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ - _ -Partial Class Form1 - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - _ - Private Sub InitializeComponent() - Me.theadExampleBtn = New System.Windows.Forms.Button() - Me.textBox1 = New System.Windows.Forms.TextBox() - Me.SuspendLayout() - ' - 'theadExampleBtn - ' - Me.theadExampleBtn.Location = New System.Drawing.Point(106, 210) - Me.theadExampleBtn.Name = "theadExampleBtn" - Me.theadExampleBtn.Size = New System.Drawing.Size(75, 23) - Me.theadExampleBtn.TabIndex = 0 - Me.theadExampleBtn.Text = "Button1" - Me.theadExampleBtn.UseVisualStyleBackColor = True - ' - 'textBox1 - ' - Me.textBox1.Location = New System.Drawing.Point(31, 45) - Me.textBox1.Multiline = True - Me.textBox1.Name = "textBox1" - Me.textBox1.Size = New System.Drawing.Size(221, 139) - Me.textBox1.TabIndex = 1 - ' - 'Form1 - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(284, 261) - Me.Controls.Add(Me.textBox1) - Me.Controls.Add(Me.theadExampleBtn) - Me.Name = "Form1" - Me.Text = "Form1" - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - - Friend WithEvents theadExampleBtn As Button - Friend WithEvents textBox1 As TextBox -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx deleted file mode 100644 index 1af7de150c9..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb deleted file mode 100644 index dd001ceb45f..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/Form1.vb +++ /dev/null @@ -1,42 +0,0 @@ -Imports System.Collections.Generic -Imports System.Threading.Tasks - -Public Class Form1 - - Dim lines As New List(Of String)() - - Private Async Sub theadExampleBtn_Click(sender As Object, e As EventArgs) Handles theadExampleBtn.Click - textBox1.Text = String.Empty - lines.Clear() - - lines.Add("Simulating work on UI thread.") - textBox1.Lines = lines.ToArray() - DoSomeWork(20) - - lines.Add("Simulating work on non-UI thread.") - textBox1.Lines = lines.ToArray() - Await Task.Run(Sub() DoSomeWork(1000)) - - lines.Add("ThreadsExampleBtn_Click completes. ") - textBox1.Lines = lines.ToArray() - End Sub - - ' - Private Async Sub DoSomeWork(milliseconds As Integer) - ' Simulate work. - Await Task.Delay(milliseconds) - - ' Report completion. - Dim uiMarshal As Boolean = textBox1.InvokeRequired - Dim msg As String = String.Format("Some work completed in {0} ms. on {1}UI thread" + vbCrLf, - milliseconds, If(uiMarshal, String.Empty, "non-")) - lines.Add(msg) - - If uiMarshal Then - textBox1.Invoke(New Action(Sub() textBox1.Lines = lines.ToArray())) - Else - textBox1.Lines = lines.ToArray() - End If - End Sub - ' -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj deleted file mode 100644 index ee9a99e687b..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/WFCrossThreadSolutionVB.vbproj +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Debug - AnyCPU - {11E8460E-5231-4932-92A2-443AA943A4E4} - WinExe - WFCrossThreadSolutionVB.My.MyApplication - WFCrossThreadSolutionVB - WFCrossThreadSolutionVB - 512 - WindowsForms - v4.8 - true - - - - AnyCPU - true - full - true - true - bin\Debug\ - WFCrossThreadSolutionVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - WFCrossThreadSolutionVB.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form - - - Form1.vb - Form - - - - - - Form1.vb - - - - - - - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config deleted file mode 100644 index b5cb6d50fc4..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/app.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json deleted file mode 100644 index da9ebf8da2f..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wf2/vb/snippets.5000.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "host": "visualstudio" -} diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml deleted file mode 100644 index ecb56e719b6..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb deleted file mode 100644 index 084cbe917ec..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/Application.xaml.vb +++ /dev/null @@ -1,6 +0,0 @@ -Class Application - - ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException - ' can be handled in this file. - -End Class diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml b/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml deleted file mode 100644 index 008112be3f0..00000000000 --- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Invalidoperationexception.threading.wpf1/vb/MainWindow.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - -